OSDN Git Service

Implement first-run experience for desktop mode
authorBraden Farmer <farmerbb@gmail.com>
Sun, 24 May 2020 18:37:13 +0000 (12:37 -0600)
committerBraden Farmer <farmerbb@gmail.com>
Sun, 24 May 2020 18:37:13 +0000 (12:37 -0600)
12 files changed:
app/src/main/java/com/farmerbb/taskbar/fragment/DesktopModeFragment.java
app/src/main/java/com/farmerbb/taskbar/fragment/FreeformModeFragment.java
app/src/main/res/values-de/strings.xml
app/src/main/res/values-ja/strings.xml
app/src/main/res/values-nl/strings.xml
app/src/main/res/values-pl/strings.xml
app/src/main/res/values-ru/strings.xml
app/src/main/res/values-tr/strings.xml
app/src/main/res/values-zh-rCN/strings.xml
app/src/main/res/values/strings.xml
app/src/main/res/values/styles.xml
app/src/main/res/xml/tb_pref_desktop_mode.xml

index f03e1b5..5908130 100644 (file)
@@ -45,6 +45,7 @@ import static com.farmerbb.taskbar.util.Constants.*;
 public class DesktopModeFragment extends SettingsFragment {
 
     public static boolean isConfiguringHomeApp;
+    private boolean isConfiguringDeveloperOptions;
 
     private boolean updateAdditionalSettings;
 
@@ -107,11 +108,6 @@ public class DesktopModeFragment extends SettingsFragment {
     public void onResume() {
         super.onResume();
 
-        if(showReminderToast) {
-            showReminderToast = false;
-            desktopModeSetupComplete();
-        }
-
         if(updateAdditionalSettings) {
             updateAdditionalSettings = false;
             updateAdditionalSettings();
@@ -119,7 +115,26 @@ public class DesktopModeFragment extends SettingsFragment {
 
         if(isConfiguringHomeApp) {
             isConfiguringHomeApp = false;
-            startStopDesktopMode(true);
+
+            if(showReminderToast) {
+                showReminderToast = false;
+                desktopModeSetupComplete();
+            } else
+                startStopDesktopMode(true);
+        }
+
+        if(isConfiguringDeveloperOptions && !isConfiguringHomeApp) {
+            isConfiguringDeveloperOptions = false;
+
+            boolean desktopModeEnabled = U.isDesktopModePrefEnabled(getActivity());
+            ((CheckBoxPreference) findPreference(PREF_DESKTOP_MODE)).setChecked(desktopModeEnabled);
+
+            handleDesktopModePrefChange(desktopModeEnabled);
+
+            if(desktopModeEnabled) {
+                showReminderToast = true;
+                configureHomeApp();
+            }
         }
 
         Preference primaryLauncherPref = findPreference(PREF_PRIMARY_LAUNCHER);
@@ -167,14 +182,12 @@ public class DesktopModeFragment extends SettingsFragment {
 
                         AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                         builder.setTitle(R.string.tb_desktop_mode_dialog_title)
-                                .setMessage(R.string.tb_freeform_dialog_message)
+                                .setMessage(R.string.tb_desktop_mode_dialog_message)
                                 .setPositiveButton(R.string.tb_action_developer_options, (dialogInterface, i) -> {
-                                    showReminderToast = true;
-
                                     Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
                                     try {
                                         startActivity(intent);
-                                        U.showToastLong(getActivity(), R.string.tb_enable_desktop_mode);
+                                        isConfiguringDeveloperOptions = true;
                                     } catch (ActivityNotFoundException e1) {
                                         intent = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS);
                                         try {
@@ -190,20 +203,10 @@ public class DesktopModeFragment extends SettingsFragment {
                     }
                 }
 
-                U.setComponentEnabled(getActivity(), SecondaryHomeActivity.class, isChecked);
-                U.setComponentEnabled(getActivity(), HSLActivity.class, isChecked);
-                startStopDesktopMode(isChecked);
-                updateAdditionalSettings(isChecked);
-
+                handleDesktopModePrefChange(isChecked);
                 break;
             case PREF_SET_LAUNCHER_DEFAULT:
-                try {
-                    startActivity(new Intent(Settings.ACTION_HOME_SETTINGS));
-                    isConfiguringHomeApp = true;
-                } catch (ActivityNotFoundException e) {
-                    U.showToastLong(getActivity(), R.string.tb_unable_to_set_default_home);
-                }
-
+                configureHomeApp();
                 break;
             case PREF_PRIMARY_LAUNCHER:
                 Intent intent = new Intent(getActivity(), HSLConfigActivity.class);
@@ -293,6 +296,23 @@ public class DesktopModeFragment extends SettingsFragment {
         finishedLoadingPrefs = true;
     }
 
+    private void handleDesktopModePrefChange(boolean isChecked) {
+        U.setComponentEnabled(getActivity(), SecondaryHomeActivity.class, isChecked);
+        U.setComponentEnabled(getActivity(), HSLActivity.class, isChecked);
+        startStopDesktopMode(isChecked);
+        updateAdditionalSettings(isChecked);
+    }
+
+    private void configureHomeApp() {
+        try {
+            startActivity(new Intent(Settings.ACTION_HOME_SETTINGS));
+            isConfiguringHomeApp = true;
+        } catch (ActivityNotFoundException e) {
+            U.showToastLong(getActivity(), R.string.tb_unable_to_set_default_home);
+            showReminderToast = false;
+        }
+    }
+
     private void desktopModeSetupComplete() {
         boolean desktopModeEnabled = U.isDesktopModePrefEnabled(getActivity());
         ((CheckBoxPreference) findPreference(PREF_DESKTOP_MODE)).setChecked(desktopModeEnabled);
index bbebcda..a053abc 100644 (file)
@@ -157,9 +157,7 @@ public class FreeformModeFragment extends SettingsFragment {
                                         .setMessage(R.string.tb_freeform_dialog_message_alt)
                                         .setPositiveButton(R.string.tb_action_continue, (dialogInterface, i) -> freeformSetupComplete());
                             } else {
-                                String settingName = Build.VERSION.SDK_INT > Build.VERSION_CODES.P
-                                        ? getString(R.string.tb_enable_freeform_windows)
-                                        : getString(R.string.tb_force_activities_resizable);
+                                String settingName = getString(R.string.tb_force_activities_resizable);
 
                                 builder.setTitle(R.string.tb_freeform_dialog_title)
                                         .setMessage(getString(R.string.tb_freeform_dialog_message, settingName))
index 92eb672..6a8a1a0 100644 (file)
     <string name="tb_toggle_dashboard">Dashboard umschalten</string>
 
     <string name="tb_force_activities_resizable">Erzwingen, dass Apps in der Größe veränderbar sind.</string>
-    <string name="tb_enable_freeform_windows">Freiform-Fenster aktivieren</string>
 
     <string name="tb_filepicker_select_an_image_file">Wählen Sie bitte eine Bilddatei aus.</string>
     <string name="tb_filepicker_install_file_manager">Bitte installieren Sie einen Dateimanager.</string>
     <string name="tb_pref_notification_count_title">Show notification count in status area</string>
     <string name="tb_pref_notification_count_description">Requires notification access</string>
 
+    <string name="tb_desktop_mode_dialog_title">Enable desktop mode support</string>
+    <string name="tb_desktop_mode_dialog_message">To configure your device for desktop mode, please follow these steps:\n\n&#8226; Go to Developer Options\n\n&#8226; Scroll to the bottom and turn on \"Enable freeform windows\" and \"Force desktop mode\"\n\n&#8226; Set Taskbar as your default home app\n\n&#8226; Reboot your device</string>
+    <string name="tb_reboot_required_alt">Reboot your device to complete desktop mode setup</string>
+    <string name="tb_enable_additional_settings_message">Taskbar can optionally use elevated permissions to improve your desktop mode experience. These permissions are granted by running an adb shell command.\n\nIf you wish to continue, connect your device to a computer with the Android SDK installed, and run the following command (one line):</string>
+    <string name="tb_desktop_mode_pref_description">Use Taskbar to launch windowed apps on an external display, similar to Samsung DeX and other solutions.\n\nRequires either a USB-to-HDMI adapter, or a lapdock, and a device that supports video output.</string>
+    <string name="tb_enable_additional_settings_pref_description">Requires adb shell access &#8211; tap for more info</string>
+
 </resources>
index 43d9c52..67c7a21 100644 (file)
     <string name="tb_toggle_dashboard">Toggle Dashboard</string>
 
     <string name="tb_force_activities_resizable">強制的にアクティビティをリサイズ可能にする</string>
-    <string name="tb_enable_freeform_windows">Enable freeform windows</string>
 
     <string name="tb_filepicker_select_an_image_file">Select an image file</string>
     <string name="tb_filepicker_install_file_manager">Error selecting image</string>
     <string name="tb_pref_notification_count_title">Show notification count in status area</string>
     <string name="tb_pref_notification_count_description">Requires notification access</string>
 
+    <string name="tb_desktop_mode_dialog_title">Enable desktop mode support</string>
+    <string name="tb_desktop_mode_dialog_message">To configure your device for desktop mode, please follow these steps:\n\n&#8226; Go to Developer Options\n\n&#8226; Scroll to the bottom and turn on \"Enable freeform windows\" and \"Force desktop mode\"\n\n&#8226; Set Taskbar as your default home app\n\n&#8226; Reboot your device</string>
+    <string name="tb_reboot_required_alt">Reboot your device to complete desktop mode setup</string>
+    <string name="tb_enable_additional_settings_message">Taskbar can optionally use elevated permissions to improve your desktop mode experience. These permissions are granted by running an adb shell command.\n\nIf you wish to continue, connect your device to a computer with the Android SDK installed, and run the following command (one line):</string>
+    <string name="tb_desktop_mode_pref_description">Use Taskbar to launch windowed apps on an external display, similar to Samsung DeX and other solutions.\n\nRequires either a USB-to-HDMI adapter, or a lapdock, and a device that supports video output.</string>
+    <string name="tb_enable_additional_settings_pref_description">Requires adb shell access &#8211; tap for more info</string>
+
 </resources>
\ No newline at end of file
index 9d76741..1b27bfd 100644 (file)
     <string name="tb_toggle_dashboard">Widgetoverzicht tonen/verbergen</string>
 
     <string name="tb_force_activities_resizable">Formaat activiteiten geforceerd aanpasbaar maken</string>
-    <string name="tb_enable_freeform_windows">Enable freeform windows</string>
 
     <string name="tb_filepicker_select_an_image_file">Select an image file</string>
     <string name="tb_filepicker_install_file_manager">Error selecting image</string>
     <string name="tb_pref_notification_count_title">Show notification count in status area</string>
     <string name="tb_pref_notification_count_description">Requires notification access</string>
 
+    <string name="tb_desktop_mode_dialog_title">Enable desktop mode support</string>
+    <string name="tb_desktop_mode_dialog_message">To configure your device for desktop mode, please follow these steps:\n\n&#8226; Go to Developer Options\n\n&#8226; Scroll to the bottom and turn on \"Enable freeform windows\" and \"Force desktop mode\"\n\n&#8226; Set Taskbar as your default home app\n\n&#8226; Reboot your device</string>
+    <string name="tb_reboot_required_alt">Reboot your device to complete desktop mode setup</string>
+    <string name="tb_enable_additional_settings_message">Taskbar can optionally use elevated permissions to improve your desktop mode experience. These permissions are granted by running an adb shell command.\n\nIf you wish to continue, connect your device to a computer with the Android SDK installed, and run the following command (one line):</string>
+    <string name="tb_desktop_mode_pref_description">Use Taskbar to launch apps in windows on an external display. similar to Samsung DeX and other solutions.\n\nRequires either a USB-to-HDMI adapter, or a lapdock, and a compatible device.</string>
+    <string name="tb_enable_additional_settings_pref_description">Requires adb shell access &#8211; tap for more info</string>
+
 </resources>
index b08920f..6b5d4d0 100644 (file)
@@ -89,7 +89,6 @@ Taskbar jest i zawsze będzie w 100%% darmowy, open source, bez reklam. Jednak w
 <string name="tb_enable_developer_options">Włącz opcje programisty, stukając wersję 7 razy</string>
 <string name="tb_enable_double_tap_to_sleep">Włączyć dwukrotne stuknięcie w  tryb uśpienia?</string>
 <string name="tb_enable_force_activities_resizable">Przewiń do dołu i włącz \"%s\"</string>
-<string name="tb_enable_freeform_windows">Włącz okienka freeform</string>
 <string name="tb_enable_recent_apps">"Na pasku zadań można opcjonalnie wyświetlać ikony ostatnio używanych aplikacji wzdłuż krawędzi ekranu. W tym celu Taskbar wymaga uprawnień dostępu do użytkowania.
 
 "</string>
@@ -487,4 +486,11 @@ W takim przypadku może być konieczne flashowanie niestandardowego ROM-u w celu
     <string name="tb_pref_notification_count_title">Show notification count in status area</string>
     <string name="tb_pref_notification_count_description">Requires notification access</string>
 
+    <string name="tb_desktop_mode_dialog_title">Enable desktop mode support</string>
+    <string name="tb_desktop_mode_dialog_message">To configure your device for desktop mode, please follow these steps:\n\n&#8226; Go to Developer Options\n\n&#8226; Scroll to the bottom and turn on \"Enable freeform windows\" and \"Force desktop mode\"\n\n&#8226; Set Taskbar as your default home app\n\n&#8226; Reboot your device</string>
+    <string name="tb_reboot_required_alt">Reboot your device to complete desktop mode setup</string>
+    <string name="tb_enable_additional_settings_message">Taskbar can optionally use elevated permissions to improve your desktop mode experience. These permissions are granted by running an adb shell command.\n\nIf you wish to continue, connect your device to a computer with the Android SDK installed, and run the following command (one line):</string>
+    <string name="tb_desktop_mode_pref_description">Use Taskbar to launch windowed apps on an external display, similar to Samsung DeX and other solutions.\n\nRequires either a USB-to-HDMI adapter, or a lapdock, and a device that supports video output.</string>
+    <string name="tb_enable_additional_settings_pref_description">Requires adb shell access &#8211; tap for more info</string>
+
 </resources>
index 2071222..9ecc4b1 100644 (file)
     <string name="tb_toggle_dashboard">Toggle Dashboard</string>
 
     <string name="tb_force_activities_resizable">Изменение размера в многооконном режиме</string>
-    <string name="tb_enable_freeform_windows">Enable freeform windows</string>
 
     <string name="tb_filepicker_select_an_image_file">Select an image file</string>
     <string name="tb_filepicker_install_file_manager">Error selecting image</string>
     <string name="tb_pref_notification_count_title">Show notification count in status area</string>
     <string name="tb_pref_notification_count_description">Requires notification access</string>
 
+    <string name="tb_desktop_mode_dialog_title">Enable desktop mode support</string>
+    <string name="tb_desktop_mode_dialog_message">To configure your device for desktop mode, please follow these steps:\n\n&#8226; Go to Developer Options\n\n&#8226; Scroll to the bottom and turn on \"Enable freeform windows\" and \"Force desktop mode\"\n\n&#8226; Set Taskbar as your default home app\n\n&#8226; Reboot your device</string>
+    <string name="tb_reboot_required_alt">Reboot your device to complete desktop mode setup</string>
+    <string name="tb_enable_additional_settings_message">Taskbar can optionally use elevated permissions to improve your desktop mode experience. These permissions are granted by running an adb shell command.\n\nIf you wish to continue, connect your device to a computer with the Android SDK installed, and run the following command (one line):</string>
+    <string name="tb_desktop_mode_pref_description">Use Taskbar to launch windowed apps on an external display, similar to Samsung DeX and other solutions.\n\nRequires either a USB-to-HDMI adapter, or a lapdock, and a device that supports video output.</string>
+    <string name="tb_enable_additional_settings_pref_description">Requires adb shell access &#8211; tap for more info</string>
+
 </resources>
\ No newline at end of file
index 311568a..e97c220 100644 (file)
@@ -361,7 +361,6 @@ Bu durumda, bu cihazdaki serbest biçimli modu kullanmak için özel bir ROM fla
     <string name="tb_toggle_dashboard">Toggle Dashboard</string>
 
     <string name="tb_force_activities_resizable">Yeniden boyutlandırılacak etkinlikleri zorla</string>
-    <string name="tb_enable_freeform_windows">Enable freeform windows</string>
 
     <string name="tb_filepicker_select_an_image_file">Select an image file</string>
     <string name="tb_filepicker_install_file_manager">Error selecting image</string>
@@ -462,4 +461,11 @@ Bu durumda, bu cihazdaki serbest biçimli modu kullanmak için özel bir ROM fla
     <string name="tb_pref_notification_count_title">Show notification count in status area</string>
     <string name="tb_pref_notification_count_description">Requires notification access</string>
 
+    <string name="tb_desktop_mode_dialog_title">Enable desktop mode support</string>
+    <string name="tb_desktop_mode_dialog_message">To configure your device for desktop mode, please follow these steps:\n\n&#8226; Go to Developer Options\n\n&#8226; Scroll to the bottom and turn on \"Enable freeform windows\" and \"Force desktop mode\"\n\n&#8226; Set Taskbar as your default home app\n\n&#8226; Reboot your device</string>
+    <string name="tb_reboot_required_alt">Reboot your device to complete desktop mode setup</string>
+    <string name="tb_enable_additional_settings_message">Taskbar can optionally use elevated permissions to improve your desktop mode experience. These permissions are granted by running an adb shell command.\n\nIf you wish to continue, connect your device to a computer with the Android SDK installed, and run the following command (one line):</string>
+    <string name="tb_desktop_mode_pref_description">Use Taskbar to launch windowed apps on an external display, similar to Samsung DeX and other solutions.\n\nRequires either a USB-to-HDMI adapter, or a lapdock, and a device that supports video output.</string>
+    <string name="tb_enable_additional_settings_pref_description">Requires adb shell access &#8211; tap for more info</string>
+
 </resources>
index ae0704d..57cac10 100644 (file)
     <string name="tb_toggle_dashboard">切换面板</string>
 
     <string name="tb_force_activities_resizable">强制将活动设为可调整大小</string>
-    <string name="tb_enable_freeform_windows">开启自由式窗口</string>
 
     <string name="tb_filepicker_select_an_image_file">选择一张图片</string>
     <string name="tb_filepicker_install_file_manager">请安装一个文件管理器。</string>
     <string name="tb_pref_notification_count_title">Show notification count in status area</string>
     <string name="tb_pref_notification_count_description">Requires notification access</string>
 
+    <string name="tb_desktop_mode_dialog_title">Enable desktop mode support</string>
+    <string name="tb_desktop_mode_dialog_message">To configure your device for desktop mode, please follow these steps:\n\n&#8226; Go to Developer Options\n\n&#8226; Scroll to the bottom and turn on \"Enable freeform windows\" and \"Force desktop mode\"\n\n&#8226; Set Taskbar as your default home app\n\n&#8226; Reboot your device</string>
+    <string name="tb_reboot_required_alt">Reboot your device to complete desktop mode setup</string>
+    <string name="tb_enable_additional_settings_message">Taskbar can optionally use elevated permissions to improve your desktop mode experience. These permissions are granted by running an adb shell command.\n\nIf you wish to continue, connect your device to a computer with the Android SDK installed, and run the following command (one line):</string>
+    <string name="tb_desktop_mode_pref_description">Use Taskbar to launch windowed apps on an external display, similar to Samsung DeX and other solutions.\n\nRequires either a USB-to-HDMI adapter, or a lapdock, and a device that supports video output.</string>
+    <string name="tb_enable_additional_settings_pref_description">Requires adb shell access &#8211; tap for more info</string>
+
 </resources>
\ No newline at end of file
index 6463aaf..2666485 100644 (file)
     <string name="tb_toggle_dashboard">Toggle Dashboard</string>
 
     <string name="tb_force_activities_resizable">Force activities to be resizable</string>
-    <string name="tb_enable_freeform_windows">Enable freeform windows</string>
 
     <string name="tb_filepicker_select_an_image_file">Select an image file</string>
     <string name="tb_filepicker_install_file_manager">Error selecting image</string>
     <string name="tb_pref_notification_count_description">Requires notification access</string>
 
     <string name="tb_desktop_mode_dialog_title">Enable desktop mode support</string>
-    <string name="tb_desktop_mode_dialog_message">In order for Taskbar to support desktop mode, please follow these steps:\n\n&#8226; Go to Developer Options\n\n&#8226; Scroll to the bottom and turn on \"Enable freeform windows\" and \"Force desktop mode\"\n\n&#8226; Reboot your device</string>
-    <string name="tb_enable_desktop_mode">Scroll to the bottom and turn on \"Enable freeform support\" and \"Force desktop mode\"</string>
+    <string name="tb_desktop_mode_dialog_message">To configure your device for desktop mode, please follow these steps:\n\n&#8226; Go to Developer Options\n\n&#8226; Scroll to the bottom and turn on \"Enable freeform windows\" and \"Force desktop mode\"\n\n&#8226; Set Taskbar as your default home app\n\n&#8226; Reboot your device</string>
     <string name="tb_reboot_required_alt">Reboot your device to complete desktop mode setup</string>
     <string name="tb_enable_additional_settings_message">Taskbar can optionally use elevated permissions to improve your desktop mode experience. These permissions are granted by running an adb shell command.\n\nIf you wish to continue, connect your device to a computer with the Android SDK installed, and run the following command (one line):</string>
+    <string name="tb_desktop_mode_pref_description">Use Taskbar to launch windowed apps on an external display, similar to Samsung DeX and other solutions.\n\nRequires either a USB-to-HDMI adapter, or a lapdock, and a device that supports video output.</string>
+    <string name="tb_enable_additional_settings_pref_description">Requires adb shell access &#8211; tap for more info</string>
 
 </resources>
index 646df7b..fffe05f 100644 (file)
         <item name="colorPrimary">@color/tb_colorPrimary</item>
         <item name="colorPrimaryDark">@color/tb_colorPrimaryDark</item>
         <item name="colorAccent">@color/tb_colorAccent</item>
-        <item name="android:textColor">@color/tb_text_color</item>
+        <item name="android:textColor">@android:color/black</item>
         <item name="android:windowMinWidthMajor">95%</item>
         <item name="android:windowMinWidthMinor">95%</item>
     </style>
         <item name="colorPrimary">@color/tb_colorPrimary</item>
         <item name="colorPrimaryDark">@color/tb_colorPrimaryDark</item>
         <item name="colorAccent">@color/tb_colorAccent</item>
-        <item name="android:textColor">@color/tb_text_color_dark</item>
+        <item name="android:textColor">@android:color/white</item>
         <item name="android:windowMinWidthMajor">95%</item>
         <item name="android:windowMinWidthMinor">95%</item>
     </style>
index 8e64d56..eb9f18d 100644 (file)
@@ -19,7 +19,8 @@
     <CheckBoxPreference
         android:defaultValue="false"
         android:key="desktop_mode"
-        android:title="@string/tb_pref_header_desktop_mode"/>
+        android:title="@string/tb_pref_header_desktop_mode"
+        android:summary="@string/tb_desktop_mode_pref_description"/>
 
     <Preference
         android:key="set_launcher_default"
@@ -45,6 +46,7 @@
         <Preference
             android:key="enable_additional_settings"
             android:title="@string/tb_enable_additional_settings"
+            android:summary="@string/tb_enable_additional_settings_pref_description"
             android:dependency="desktop_mode"/>
 
         <ListPreference