-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated Gradle and Kotlin deps, minor cleanup, made the commands text selectable to allow copy/paste * Added feature to view licenses * Added feature to rate the app * Added feature to request a feature * Added Timber * New features list implementation, Circle CI setup * Added build status badge * Added help menu item, bumped version numbers
- Loading branch information
1 parent
36f0eee
commit e0282a4
Showing
24 changed files
with
300 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
working_directory: ~/code | ||
docker: | ||
- image: circleci/android:api-26-alpha | ||
environment: | ||
JVM_OPTS: -Xmx3200m | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} | ||
- run: | ||
name: Download Dependencies | ||
command: ./gradlew androidDependencies | ||
- save_cache: | ||
paths: | ||
- ~/.gradle | ||
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} | ||
- run: | ||
name: Compile & Run Tests | ||
command: ./gradlew assemble test | ||
- store_artifacts: | ||
path: app/build/reports | ||
destination: reports | ||
- store_test_results: | ||
path: app/build/test-results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
app/src/main/kotlin/xyz/mustafaali/devqstiles/DevQSApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package xyz.mustafaali.devqstiles | ||
|
||
import android.app.Application | ||
import timber.log.Timber | ||
|
||
class DevQSApplication : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
if (BuildConfig.DEBUG) { | ||
Timber.plant(Timber.DebugTree()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
package xyz.mustafaali.devqstiles; | ||
|
||
import android.content.ActivityNotFoundException | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.support.v7.app.AppCompatActivity | ||
import android.text.Html | ||
import android.support.v7.widget.LinearLayoutManager | ||
import android.view.Menu | ||
import android.view.MenuItem | ||
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity | ||
import kotlinx.android.synthetic.main.activity_main.* | ||
import timber.log.Timber | ||
import xyz.mustafaali.devqstiles.model.Feature | ||
import xyz.mustafaali.devqstiles.ui.FeaturesAdapter | ||
|
||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
|
@@ -22,18 +29,58 @@ class MainActivity : AppCompatActivity() { | |
} | ||
|
||
override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||
when (item.itemId) { | ||
return when (item.itemId) { | ||
R.id.menu_help -> { | ||
openHelpVideo() | ||
true | ||
} | ||
R.id.menu_share_app -> { | ||
shareApp() | ||
return true | ||
true | ||
} | ||
R.id.menu_rate_app -> { | ||
openStoreListing() | ||
true | ||
} | ||
R.id.menu_request_feature -> { | ||
openEmailClient() | ||
true | ||
} | ||
else -> return super.onOptionsItemSelected(item) | ||
R.id.menu_oss_licenses -> { | ||
startActivity(Intent(this, OssLicensesMenuActivity::class.java)) | ||
true | ||
} | ||
else -> super.onOptionsItemSelected(item) | ||
} | ||
} | ||
|
||
private fun openStoreListing() { | ||
val intent = Intent(Intent.ACTION_VIEW) | ||
intent.data = Uri.parse("market://details?id=xyz.mustafaali.devqstiles") | ||
try { | ||
startActivity(intent) | ||
} catch(e: ActivityNotFoundException) { | ||
Timber.e("Couldn't launch activity, maybe PlayStore is not installed") | ||
} | ||
} | ||
|
||
fun initUi() { | ||
private fun openHelpVideo() { | ||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://www.youtube.com/watch?v=tdSAobQq1nQ"))) | ||
} | ||
|
||
private fun openEmailClient() { | ||
val intent = Intent(Intent.ACTION_SEND) | ||
intent.type = "message/rfc822" | ||
intent.putExtra(android.content.Intent.EXTRA_EMAIL, arrayOf("[email protected]")) | ||
intent.putExtra(Intent.EXTRA_SUBJECT, "[DevTiles] Feature Request") | ||
startActivity(intent) | ||
} | ||
|
||
private fun initUi() { | ||
copyButton.setOnClickListener({ sharePermissionsCommand() }) | ||
featuresDescriptionTextView.text = Html.fromHtml(getString(R.string.features_description), Html.FROM_HTML_MODE_COMPACT) | ||
featuresRecyclerView.layoutManager = LinearLayoutManager(this) | ||
featuresRecyclerView.setHasFixedSize(true) | ||
featuresRecyclerView.adapter = FeaturesAdapter(getFeaturesList()) {} | ||
} | ||
|
||
private fun shareApp() { | ||
|
@@ -51,4 +98,14 @@ class MainActivity : AppCompatActivity() { | |
sendIntent.type = "text/plain" | ||
startActivity(sendIntent) | ||
} | ||
|
||
private fun getFeaturesList(): List<Feature> { | ||
return listOf( | ||
Feature("Toggle USB Debugging", "Enable/disable USB debugging from your notification drawer", R.drawable.ic_toggle_usb_debugging), | ||
Feature("Keep Screen On", "Keep screen on when connected via USB, but turn it off when connected to a charger", R.drawable.ic_toggle_keep_screen_on), | ||
Feature("Show Touches", "Show touch points when you touch the screen, ideal for demos", R.drawable.ic_toggle_show_taps), | ||
Feature("Demo Mode", "Cleans up the status bar for those perfect screenshots", R.drawable.ic_toggle_demo_mode), | ||
Feature("Change Animator Duration", "Change the default animator duration to easily debug animations", R.drawable.ic_animator_duration) | ||
) | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
app/src/main/kotlin/xyz/mustafaali/devqstiles/model/Feature.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package xyz.mustafaali.devqstiles.model | ||
|
||
data class Feature (val title: String, val description: String, val drawableId: Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 8 additions & 12 deletions
20
app/src/main/kotlin/xyz/mustafaali/devqstiles/service/ToggleShowTapsService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,30 @@ | ||
package xyz.mustafaali.devqstiles.service | ||
|
||
import android.provider.Settings | ||
import android.util.Log | ||
import android.widget.Toast | ||
|
||
import xyz.mustafaali.devqstiles.R | ||
import timber.log.Timber | ||
|
||
class ToggleShowTapsService : BaseTileService() { | ||
val TAG = this.javaClass.simpleName | ||
val SHOW_TOUCHES = "show_touches" | ||
private val SHOW_TOUCHES = "show_touches" | ||
|
||
override fun onClick() { | ||
val newValue = if (isFeatureEnabled()) 0 else 1 | ||
|
||
try { | ||
Settings.System.putInt(contentResolver, SHOW_TOUCHES, newValue) | ||
} catch (se: SecurityException) { | ||
} catch (e: Exception) { | ||
showPermissionError() | ||
Log.e(TAG, se.message) | ||
Timber.e(e, e.message) | ||
} | ||
|
||
updateTile() | ||
} | ||
|
||
override fun isFeatureEnabled(): Boolean { | ||
try { | ||
return Settings.System.getInt(contentResolver, SHOW_TOUCHES) == 1 | ||
return try { | ||
Settings.System.getInt(contentResolver, SHOW_TOUCHES) == 1 | ||
} catch (e: Settings.SettingNotFoundException) { | ||
e.printStackTrace() | ||
return false | ||
Timber.e(e, e.message) | ||
false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/src/main/kotlin/xyz/mustafaali/devqstiles/ui/FeaturesAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package xyz.mustafaali.devqstiles.ui | ||
|
||
import android.support.v7.widget.RecyclerView | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import kotlinx.android.synthetic.main.feature_item_layout.view.* | ||
import xyz.mustafaali.devqstiles.R | ||
import xyz.mustafaali.devqstiles.model.Feature | ||
import xyz.mustafaali.devqstiles.util.inflate | ||
|
||
class FeaturesAdapter(val features: List<Feature>, val listener: (Feature) -> Unit) : RecyclerView.Adapter<FeaturesAdapter.ViewHolder>() { | ||
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
fun bind(feature: Feature, listener: (Feature) -> Unit) = with(itemView) { | ||
featureImageView.setImageResource(feature.drawableId) | ||
featureTitle.text = feature.title | ||
featureDescription.text = feature.description | ||
setOnClickListener { listener(feature) } | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder = ViewHolder(parent.inflate(R.layout.feature_item_layout)) | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) = holder.bind(features[position], listener) | ||
|
||
override fun getItemCount(): Int = features.size | ||
|
||
} |
Oops, something went wrong.