OSDN Git Service

Add dialog for Chrome OS users
authorBraden Farmer <farmerbb@gmail.com>
Sun, 25 Jun 2017 18:28:17 +0000 (12:28 -0600)
committerBraden Farmer <farmerbb@gmail.com>
Sun, 25 Jun 2017 18:28:17 +0000 (12:28 -0600)
app/src/main/java/com/farmerbb/taskbar/MainActivity.java
app/src/main/res/values-de/strings.xml
app/src/main/res/values-ja/strings.xml
app/src/main/res/values-ru/strings.xml
app/src/main/res/values/strings.xml

index 3d2fc53..1d877ec 100644 (file)
@@ -166,32 +166,17 @@ public class MainActivity extends AppCompatActivity {
                         startTaskbarService();
 
                         if(firstRun && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !U.isSystemApp(this)) {
-                            ApplicationInfo applicationInfo = null;
-                            try {
-                                applicationInfo = getPackageManager().getApplicationInfo(BuildConfig.APPLICATION_ID, 0);
-                            } catch (PackageManager.NameNotFoundException e) { /* Gracefully fail */ }
-
-                            if(applicationInfo != null) {
-                                AppOpsManager appOpsManager = (AppOpsManager) getSystemService(Context.APP_OPS_SERVICE);
-                                int mode = appOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_GET_USAGE_STATS, applicationInfo.uid, applicationInfo.packageName);
-
-                                if(mode != AppOpsManager.MODE_ALLOWED) {
-                                    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
-                                    builder.setTitle(R.string.pref_header_recent_apps)
-                                            .setMessage(R.string.enable_recent_apps)
-                                            .setPositiveButton(R.string.action_ok, (dialog, which) -> {
-                                                try {
-                                                    startActivity(new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS));
-                                                    U.showToastLong(MainActivity.this, R.string.usage_stats_message);
-                                                } catch (ActivityNotFoundException e) {
-                                                    U.showErrorDialog(MainActivity.this, "GET_USAGE_STATS");
-                                                }
-                                            }).setNegativeButton(R.string.action_cancel, null);
-
-                                    AlertDialog dialog = builder.create();
-                                    dialog.show();
-                                }
-                            }
+                            if(U.isChromeOs(this)) {
+                                AlertDialog.Builder builder = new AlertDialog.Builder(this);
+                                builder.setTitle(R.string.chromebook_dialog_title)
+                                        .setMessage(R.string.chromebook_dialog_message)
+                                        .setPositiveButton(R.string.action_ok, (dialogInterface, i) -> showRecentAppsDialog());
+
+                                AlertDialog dialog = builder.create();
+                                dialog.show();
+                                dialog.setCancelable(false);
+                            } else
+                                showRecentAppsDialog();
                         }
                     } else {
                         U.showPermissionDialog(MainActivity.this);
@@ -277,6 +262,36 @@ public class MainActivity extends AppCompatActivity {
         }
     }
 
+    private void showRecentAppsDialog() {
+        ApplicationInfo applicationInfo = null;
+        try {
+            applicationInfo = getPackageManager().getApplicationInfo(BuildConfig.APPLICATION_ID, 0);
+        } catch (PackageManager.NameNotFoundException e) { /* Gracefully fail */ }
+
+        if(applicationInfo != null) {
+            AppOpsManager appOpsManager = (AppOpsManager) getSystemService(Context.APP_OPS_SERVICE);
+            int mode = appOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_GET_USAGE_STATS, applicationInfo.uid, applicationInfo.packageName);
+
+            if(mode != AppOpsManager.MODE_ALLOWED) {
+                AlertDialog.Builder builder = new AlertDialog.Builder(this);
+                builder.setTitle(R.string.pref_header_recent_apps)
+                        .setMessage(R.string.enable_recent_apps)
+                        .setPositiveButton(R.string.action_ok, (dialog, which) -> {
+                            try {
+                                startActivity(new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS));
+                                U.showToastLong(this, R.string.usage_stats_message);
+                            } catch (ActivityNotFoundException e) {
+                                U.showErrorDialog(this, "GET_USAGE_STATS");
+                            }
+                        }).setNegativeButton(R.string.action_cancel, null);
+
+                AlertDialog dialog = builder.create();
+                dialog.show();
+                dialog.setCancelable(false);
+            }
+        }
+    }
+
     @Override
     protected void onResume() {
         super.onResume();
index 08b7824..006aaa7 100644 (file)
     <string name="color_picker_green">Green</string>
     <string name="color_picker_blue">Blue</string>
 
+    <string name="chromebook_dialog_title">@string/samsung_freeform_title</string>
+    <string name="chromebook_dialog_message">On Chromebooks, Taskbar may be hidden or overlapped by the Chrome OS shelf.\n\nIf this is the case, either right-click the shelf and select \"Autohide shelf\", or swipe away the shelf as needed using the touchscreen in order to access Taskbar.</string>
+
 </resources>
index bf561e4..a1c3b6d 100644 (file)
     <string name="color_picker_green">Green</string>
     <string name="color_picker_blue">Blue</string>
 
+    <string name="chromebook_dialog_title">@string/samsung_freeform_title</string>
+    <string name="chromebook_dialog_message">On Chromebooks, Taskbar may be hidden or overlapped by the Chrome OS shelf.\n\nIf this is the case, either right-click the shelf and select \"Autohide shelf\", or swipe away the shelf as needed using the touchscreen in order to access Taskbar.</string>
+
 </resources>
index a1cb299..c8b20bd 100644 (file)
     <string name="color_picker_green">Green</string>
     <string name="color_picker_blue">Blue</string>
 
+    <string name="chromebook_dialog_title">@string/samsung_freeform_title</string>
+    <string name="chromebook_dialog_message">On Chromebooks, Taskbar may be hidden or overlapped by the Chrome OS shelf.\n\nIf this is the case, either right-click the shelf and select \"Autohide shelf\", or swipe away the shelf as needed using the touchscreen in order to access Taskbar.</string>
+
 </resources>
index 0b6a113..af6ccce 100644 (file)
     <string name="color_picker_green">Green</string>
     <string name="color_picker_blue">Blue</string>
 
+    <string name="chromebook_dialog_title">@string/samsung_freeform_title</string>
+    <string name="chromebook_dialog_message">On Chromebooks, Taskbar may be hidden or overlapped by the Chrome OS shelf.\n\nIf this is the case, either right-click the shelf and select \"Autohide shelf\", or swipe away the shelf as needed using the touchscreen in order to access Taskbar.</string>
+
 </resources>