From f607b7a8105df2087863709e5766ffc46599a863 Mon Sep 17 00:00:00 2001 From: Mustafa Ali Date: Fri, 15 Sep 2017 10:43:51 -0400 Subject: [PATCH 01/12] Updated Gradle and Kotlin deps, minor cleanup, made the commands text selectable to allow copy/paste --- app/build.gradle | 3 ++- .../devqstiles/service/ToggleShowTapsService.kt | 17 +++++++---------- app/src/main/res/layout/activity_main.xml | 1 + build.gradle | 10 +++++----- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d39234d..98cdf4b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 25 + compileSdkVersion 26 buildToolsVersion "25.0.3" defaultConfig { applicationId "xyz.mustafaali.devqstiles" @@ -42,4 +42,5 @@ dependencies { } repositories { mavenCentral() + google() } diff --git a/app/src/main/kotlin/xyz/mustafaali/devqstiles/service/ToggleShowTapsService.kt b/app/src/main/kotlin/xyz/mustafaali/devqstiles/service/ToggleShowTapsService.kt index 051abf5..b95110f 100644 --- a/app/src/main/kotlin/xyz/mustafaali/devqstiles/service/ToggleShowTapsService.kt +++ b/app/src/main/kotlin/xyz/mustafaali/devqstiles/service/ToggleShowTapsService.kt @@ -2,33 +2,30 @@ package xyz.mustafaali.devqstiles.service import android.provider.Settings import android.util.Log -import android.widget.Toast - -import xyz.mustafaali.devqstiles.R class ToggleShowTapsService : BaseTileService() { - val TAG = this.javaClass.simpleName - val SHOW_TOUCHES = "show_touches" + private val TAG = this.javaClass.simpleName + 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) + Log.e(TAG, 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 + false } } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 37145fe..050199a 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -27,6 +27,7 @@ android:layout_marginTop="@dimen/activity_vertical_margin" android:fontFamily="monospace" android:text="@string/permission_command" + android:textIsSelectable="true" android:textStyle="bold" />