├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── values-night
│ │ │ └── themes.xml
│ │ ├── values
│ │ │ ├── ic_launcher_background.xml
│ │ │ ├── themes.xml
│ │ │ └── strings.xml
│ │ ├── mipmap-anydpi-v26
│ │ │ └── ic_launcher.xml
│ │ ├── drawable
│ │ │ ├── ic_do_not_disturb.xml
│ │ │ ├── ic_check_20px.xml
│ │ │ ├── ic_launcher_foreground.xml
│ │ │ ├── ic_do_not_disturb_on_fill1_24px.xml
│ │ │ └── ic_do_not_disturb_on_24px.xml
│ │ ├── mipmap-anydpi
│ │ │ └── ic_launcher_round.xml
│ │ └── layout
│ │ │ └── main_activity.xml
│ │ ├── java
│ │ └── me
│ │ │ └── grishka
│ │ │ └── dndtoggle
│ │ │ ├── SettingsRedirectActivity.java
│ │ │ ├── InterruptionFilterChangeReceiver.java
│ │ │ ├── DNDTileService.java
│ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── proguard-rules.pro
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── libs.versions.toml
├── .gitignore
├── README.md
├── settings.gradle
├── UNLICENSE
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /release
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/grishka/Android-DND-Toggle/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | .cxx
10 | local.properties
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Mar 15 14:45:58 MSK 2025
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_do_not_disturb.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## DND Toggle
2 |
3 | This app was made [out of frustration](https://mastodon.social/@grishka/114159868754483988) with Google's new "Modes" feature introduced in Android 15 QPR2. Because adding new functionality without breaking people's existing use cases is impossible for the modern IT industry, apparently.
4 |
5 | Just install it, give it the permission it asks for, and add the quick settings tile.
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_check_20px.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google {
4 | content {
5 | includeGroupByRegex("com\\.android.*")
6 | includeGroupByRegex("com\\.google.*")
7 | includeGroupByRegex("androidx.*")
8 | }
9 | }
10 | mavenCentral()
11 | gradlePluginPortal()
12 | }
13 | }
14 | dependencyResolutionManagement {
15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | rootProject.name = "DNDToggle"
23 | include ':app'
24 |
--------------------------------------------------------------------------------
/app/src/main/java/me/grishka/dndtoggle/SettingsRedirectActivity.java:
--------------------------------------------------------------------------------
1 | package me.grishka.dndtoggle;
2 |
3 | import android.app.Activity;
4 | import android.app.NotificationManager;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.provider.Settings;
8 |
9 | public class SettingsRedirectActivity extends Activity{
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState){
12 | super.onCreate(savedInstanceState);
13 | startActivity(new Intent(Settings.ACTION_ZEN_MODE_PRIORITY_SETTINGS));
14 | finish();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_do_not_disturb_on_fill1_24px.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/me/grishka/dndtoggle/InterruptionFilterChangeReceiver.java:
--------------------------------------------------------------------------------
1 | package me.grishka.dndtoggle;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.ComponentName;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.service.quicksettings.TileService;
8 |
9 | public class InterruptionFilterChangeReceiver extends BroadcastReceiver{
10 | @Override
11 | public void onReceive(Context context, Intent intent){
12 | if(DNDTileService.current!=null)
13 | DNDTileService.current.updateTile();
14 | else
15 | TileService.requestListeningState(context, new ComponentName(context, DNDTileService.class));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.android.application)
3 | }
4 |
5 | android {
6 | namespace 'me.grishka.dndtoggle'
7 | compileSdk 35
8 |
9 | defaultConfig {
10 | applicationId "me.grishka.dndtoggle"
11 | minSdk 34
12 | targetSdk 34
13 | versionCode 2
14 | versionName "1.1"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_11
27 | targetCompatibility JavaVersion.VERSION_11
28 | }
29 | }
30 |
31 | dependencies {
32 | }
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.9.0"
3 | junit = "4.13.2"
4 | junitVersion = "1.2.1"
5 | espressoCore = "3.6.1"
6 | appcompat = "1.6.1"
7 | material = "1.10.0"
8 |
9 | [libraries]
10 | junit = { group = "junit", name = "junit", version.ref = "junit" }
11 | ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
12 | espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
13 | appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
14 | material = { group = "com.google.android.material", name = "material", version.ref = "material" }
15 |
16 | [plugins]
17 | android-application = { id = "com.android.application", version.ref = "agp" }
18 |
19 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | DND Toggle
3 | This tiny app adds a quick settings tile to allow you to toggle the \"Do not disturb\" mode with just one tap, just like you were able to for more than a decade before Google decided to do the stupid thing in Android 15 QPR2 with its \"Modes\" feature.
4 | 1. Grant the app the permission to manage your notifications policy:
5 | Open settings
6 | Permission granted
7 | 2. Add the tile to your quick settings:
8 | Add tile
9 | Tile added
10 | Do not disturb
11 | No permission
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_do_not_disturb_on_24px.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/UNLICENSE:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. For more details, visit
12 | # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Enables namespacing of each library's R class so that its R class includes only the
19 | # resources declared in the library itself and none from the library's dependencies,
20 | # thereby reducing the size of the R class for that library
21 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/java/me/grishka/dndtoggle/DNDTileService.java:
--------------------------------------------------------------------------------
1 | package me.grishka.dndtoggle;
2 |
3 | import android.app.NotificationManager;
4 | import android.content.Context;
5 | import android.content.SharedPreferences;
6 | import android.graphics.drawable.Icon;
7 | import android.service.quicksettings.Tile;
8 | import android.service.quicksettings.TileService;
9 |
10 | public class DNDTileService extends TileService{
11 | private static final String TAG="DNDTileService";
12 | public static DNDTileService current;
13 |
14 | @Override
15 | public void onStartListening(){
16 | current=this;
17 | super.onStartListening();
18 | updateTile();
19 | }
20 |
21 | @Override
22 | public void onStopListening(){
23 | current=null;
24 | super.onStopListening();
25 | }
26 |
27 | @Override
28 | public void onClick(){
29 | super.onClick();
30 | NotificationManager nm=getSystemService(NotificationManager.class);
31 | boolean isDND=nm.getCurrentInterruptionFilter()==NotificationManager.INTERRUPTION_FILTER_PRIORITY;
32 | nm.setInterruptionFilter(isDND ? NotificationManager.INTERRUPTION_FILTER_ALL : NotificationManager.INTERRUPTION_FILTER_PRIORITY);
33 | updateTile();
34 | }
35 |
36 | @Override
37 | public void onTileAdded(){
38 | super.onTileAdded();
39 | getSharedPrefs(this).edit().putBoolean("added", true).apply();
40 | MainActivity.updateFromService();
41 | }
42 |
43 | @Override
44 | public void onTileRemoved(){
45 | super.onTileRemoved();
46 | getSharedPrefs(this).edit().remove("added").apply();
47 | MainActivity.updateFromService();
48 | }
49 |
50 | public void updateTile(){
51 | NotificationManager nm=getSystemService(NotificationManager.class);
52 | Tile tile=getQsTile();
53 | if(!nm.isNotificationPolicyAccessGranted()){
54 | tile.setState(Tile.STATE_UNAVAILABLE);
55 | tile.setSubtitle(getString(R.string.tile_no_permission));
56 | tile.setIcon(Icon.createWithResource(this, R.drawable.ic_do_not_disturb));
57 | }else{
58 | boolean isDND=nm.getCurrentInterruptionFilter()==NotificationManager.INTERRUPTION_FILTER_PRIORITY;
59 | tile.setSubtitle(null);
60 | tile.setState(isDND ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
61 | tile.setIcon(Icon.createWithResource(this, isDND ? R.drawable.ic_do_not_disturb_on_fill1_24px : R.drawable.ic_do_not_disturb_on_24px));
62 | }
63 | tile.updateTile();
64 | }
65 |
66 | private static SharedPreferences getSharedPrefs(Context context){
67 | return context.getSharedPreferences("tile", MODE_PRIVATE);
68 | }
69 |
70 | public static boolean isTileAdded(Context context){
71 | return getSharedPrefs(context).getBoolean("added", false);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/main_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
15 |
16 |
23 |
24 |
33 |
34 |
37 |
43 |
44 |
55 |
56 |
57 |
66 |
67 |
70 |
76 |
77 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/app/src/main/java/me/grishka/dndtoggle/MainActivity.java:
--------------------------------------------------------------------------------
1 | package me.grishka.dndtoggle;
2 |
3 | import android.app.Activity;
4 | import android.app.NotificationManager;
5 | import android.app.StatusBarManager;
6 | import android.content.BroadcastReceiver;
7 | import android.content.ComponentName;
8 | import android.content.Context;
9 | import android.content.Intent;
10 | import android.content.IntentFilter;
11 | import android.graphics.drawable.Icon;
12 | import android.os.Bundle;
13 | import android.provider.Settings;
14 | import android.view.View;
15 | import android.widget.Button;
16 | import android.widget.TextView;
17 |
18 | public class MainActivity extends Activity{
19 | private Button openSettingsBtn, addTileBtn;
20 | private TextView permissionGrantedText, tileAddedText;
21 | private static MainActivity current;
22 |
23 | private final BroadcastReceiver permissionChangeReceiver=new BroadcastReceiver(){
24 | @Override
25 | public void onReceive(Context context, Intent intent){
26 | if(NotificationManager.ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED.equals(intent.getAction())){
27 | updateButtons();
28 | }
29 | }
30 | };
31 |
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState){
34 | current=this;
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.main_activity);
37 |
38 | openSettingsBtn=findViewById(R.id.settings_btn);
39 | addTileBtn=findViewById(R.id.add_tile_btn);
40 | permissionGrantedText=findViewById(R.id.permission_granted);
41 | tileAddedText=findViewById(R.id.tile_added);
42 |
43 | openSettingsBtn.setOnClickListener(v->startActivity(new Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS)));
44 | addTileBtn.setOnClickListener(v->{
45 | StatusBarManager sbm=getSystemService(StatusBarManager.class);
46 | sbm.requestAddTileService(new ComponentName(this, DNDTileService.class), getString(R.string.do_not_disturb), Icon.createWithResource(this, R.drawable.ic_do_not_disturb), getMainExecutor(), result->updateButtons());
47 | });
48 |
49 | registerReceiver(permissionChangeReceiver, new IntentFilter(NotificationManager.ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED), RECEIVER_EXPORTED);
50 | updateButtons();
51 | }
52 |
53 | @Override
54 | protected void onDestroy(){
55 | current=null;
56 | unregisterReceiver(permissionChangeReceiver);
57 | super.onDestroy();
58 | }
59 |
60 | public static void updateFromService(){
61 | if(current!=null){
62 | current.runOnUiThread(current::updateButtons);
63 | }
64 | }
65 |
66 | private void updateButtons(){
67 | NotificationManager nm=getSystemService(NotificationManager.class);
68 | if(nm.isNotificationPolicyAccessGranted()){
69 | openSettingsBtn.setVisibility(View.INVISIBLE);
70 | permissionGrantedText.setVisibility(View.VISIBLE);
71 | if(DNDTileService.isTileAdded(this)){
72 | addTileBtn.setVisibility(View.INVISIBLE);
73 | tileAddedText.setVisibility(View.VISIBLE);
74 | }else{
75 | addTileBtn.setVisibility(View.VISIBLE);
76 | addTileBtn.setEnabled(true);
77 | tileAddedText.setVisibility(View.INVISIBLE);
78 | }
79 | }else{
80 | permissionGrantedText.setVisibility(View.INVISIBLE);
81 | tileAddedText.setVisibility(View.INVISIBLE);
82 | addTileBtn.setVisibility(View.VISIBLE);
83 | addTileBtn.setEnabled(false);
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------