-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'Show taps' tile; update README and graphic resources
- Loading branch information
Showing
30 changed files
with
319 additions
and
60 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 |
---|---|---|
@@ -1,2 +1,39 @@ | ||
# Dev-QuickSettings | ||
Android Quick Settings Tiles for Android developers | ||
## What is this? | ||
Android Quick Settings Tiles for Android developers, written in [Kotlin](https://kotlinlang.org/). | ||
|
||
 | ||
|
||
The app is based on the work of [Nick Butcher](https://github.com/nickbutcher) and his [Animator Duration Quick Settings Tile](https://github.com/nickbutcher/AnimatorDurationTile) which I borrowed for the animation duration tile. | ||
|
||
## Current features | ||
The app provides a few Quick Settings tiles that act as shortcut to Development Options in the Android device: | ||
* USB Debugging | ||
* Demo mode | ||
* Keep screen on | ||
* Animator duration scale | ||
* Show taps on screen | ||
* Destroy activities | ||
|
||
## Where can I get it? | ||
You can get it from [Google Play](https://play.google.com/store/apps/details?id=com.adriangl.devquicksettings) or from the [Releases](https://github.com/adriangl/Android-Dev-QuickSettings/releases) page :) | ||
|
||
[](https://play.google.com/store/apps/details?id=com.adriangl.devquicksettings) | ||
|
||
|
||
## License | ||
``` | ||
Copyright (C) 2017 Adrián García | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
``` |
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
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
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
69 changes: 69 additions & 0 deletions
69
app/src/main/kotlin/com/adriangl/devquicktiles/tiles/show_taps/ShowTapsTileService.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,69 @@ | ||
/* | ||
* Copyright (C) 2017 Adrián García | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.adriangl.devquicktiles.tiles.show_taps | ||
|
||
import android.graphics.drawable.Icon | ||
import com.adriangl.devquicktiles.R | ||
import com.adriangl.devquicktiles.tiles.DevelopmentTileService | ||
import com.adriangl.devquicktiles.utils.SettingsUtils | ||
|
||
|
||
class ShowTapsTileService : DevelopmentTileService<Int>() { | ||
companion object { | ||
val SETTING = "show_touches" // This is hidden for developers, so we use the string resource | ||
} | ||
|
||
override fun isActive(value: Int): Boolean { | ||
return value != 0 | ||
} | ||
|
||
override fun queryValue(): Int { | ||
var value = SettingsUtils.getIntFromSystemSettings(contentResolver, SETTING) | ||
if (value > 1) value = 1 | ||
return value | ||
} | ||
|
||
override fun saveValue(value: Int): Boolean { | ||
/* | ||
* The proper way to do this would be to check Settings.System.canWrite(). | ||
* If we can write there then write the setting and if we can't, then launch an Intent to | ||
* Settings.ACTION_MANAGE_WRITE_SETTINGS to enable the app to write system settings. | ||
* | ||
* The problem is that from API 23+ we can't do that with the "show_touches" setting | ||
* (and others I suppose) as it throws an IllegalArgumentException: | ||
* You cannot change private secure settings. | ||
* | ||
* So we have to fall back to use a targetSdkVersion of 22 so we can write the setting. | ||
* Kinda hacky, but it works ¯\_(ツ)_/¯. | ||
*/ | ||
|
||
return SettingsUtils.setIntToSystemSettings(contentResolver, SETTING, value) | ||
} | ||
|
||
override fun getValueList(): List<Int> { | ||
return listOf(0, 1) | ||
} | ||
|
||
override fun getIcon(value: Int): Icon? { | ||
return Icon.createWithResource(applicationContext, | ||
if (value != 0) R.drawable.ic_qs_show_taps_enabled else R.drawable.ic_qs_show_taps_disabled) | ||
} | ||
|
||
override fun getLabel(value: Int): CharSequence? { | ||
return getString(R.string.qs_show_taps) | ||
} | ||
} |
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
Oops, something went wrong.