♻️ refactor(launcher, dialogs): close global settings dialog before showing other dialogs and popups, improve dismiss behavior of global settings dialog
This commit is contained in:
3 files changed
+41
-15
No files matched your search
@@ -650,6 +650,8 @@ public class LauncherActivity extends Activity implements View.OnClickListener,
|
||||
dialogs = null;
|
||||
}
|
||||
|
||||
closeGlobalSettingsDialog();
|
||||
|
||||
if (mSearchTask!=null) {
|
||||
mSearchTask.cancel(true);
|
||||
mSearchTask=null;
|
||||
@@ -664,13 +666,18 @@ public class LauncherActivity extends Activity implements View.OnClickListener,
|
||||
showPopup((String) view.getTag(), (AppTextView) view);
|
||||
} else if (view instanceof FlowLayout) {
|
||||
// show launcher setting for FlowLayout (this handles long press on FlowLayout itself)
|
||||
dialogs = new GlobalSettingsDialog(this, this);
|
||||
dialogs.show();
|
||||
if (globalSettingsDialog == null || !globalSettingsDialog.isShowing()) {
|
||||
globalSettingsDialog = new GlobalSettingsDialog(this, this);
|
||||
globalSettingsDialog.setOnDismissListener(d -> globalSettingsDialog = null);
|
||||
globalSettingsDialog.show();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showPopup(String activityName, AppTextView view) {
|
||||
// Close global settings dialog if it's open when showing app settings
|
||||
closeGlobalSettingsDialog();
|
||||
// show app settings dialog instead of popup menu
|
||||
AppSettingsPopup popup = new AppSettingsPopup(this, activityName, view, this);
|
||||
popup.show();
|
||||
@@ -926,6 +933,8 @@ public class LauncherActivity extends Activity implements View.OnClickListener,
|
||||
dialogs = null;
|
||||
}
|
||||
|
||||
closeGlobalSettingsDialog();
|
||||
|
||||
if (mSearchTask!=null) {
|
||||
mSearchTask.cancel(true);
|
||||
mSearchTask=null;
|
||||
@@ -1339,6 +1348,9 @@ public class LauncherActivity extends Activity implements View.OnClickListener,
|
||||
}
|
||||
|
||||
private void showDialog(Dialog dialog, boolean setWindow) {
|
||||
// Close global settings dialog if it's open when showing other dialogs
|
||||
closeGlobalSettingsDialog();
|
||||
|
||||
if (setWindow) {
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
@@ -1351,4 +1363,14 @@ public class LauncherActivity extends Activity implements View.OnClickListener,
|
||||
this.dialogs = dialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the global settings dialog if it's currently open
|
||||
*/
|
||||
public void closeGlobalSettingsDialog() {
|
||||
if (globalSettingsDialog != null && globalSettingsDialog.isShowing()) {
|
||||
globalSettingsDialog.dismiss();
|
||||
globalSettingsDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -157,8 +157,8 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
} else if (id == R.id.settings_alignment) {
|
||||
setFlowLayoutAlignment(view);
|
||||
} else if (id == R.id.settings_padding) {
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
launcherActivity.setPadding();
|
||||
cancel();
|
||||
} else if (id == R.id.settings_restart_launcher) {
|
||||
launcherActivity.recreate();
|
||||
} else if (id == R.id.settings_double_tap_lock) {
|
||||
@@ -179,6 +179,7 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
popupMenu.getMenuInflater().inflate(R.menu.sort_apps_popups, popupMenu.getMenu());
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(menuItem -> {
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
int id = menuItem.getItemId();
|
||||
if (id == R.id.menu_sort_by_name) {
|
||||
launcherActivity.sortApps(Constants.SORT_BY_NAME);
|
||||
@@ -199,8 +200,8 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
}
|
||||
|
||||
private void showColorAndSizeDialog() {
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
launcherActivity.setColorsAndSize();
|
||||
cancel();
|
||||
}
|
||||
|
||||
private void setFlowLayoutAlignment(View view) {
|
||||
@@ -214,6 +215,7 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
popupMenu.getMenuInflater().inflate(R.menu.alignment_popup, popupMenu.getMenu());
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(menuItem -> {
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
int id = menuItem.getItemId();
|
||||
if (id == R.id.menu_center) {
|
||||
launcherActivity.setFlowLayoutAlignment(Gravity.CENTER | Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
|
||||
@@ -230,7 +232,7 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
private void randomColor() {
|
||||
boolean rColor = !DbUtils.isRandomColor();
|
||||
DbUtils.randomColor(rColor);
|
||||
cancel();
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
if (rColor) {
|
||||
int color;
|
||||
for (Apps app : launcherActivity.mAppsList) {
|
||||
@@ -246,7 +248,7 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
}
|
||||
|
||||
private void showColorSnifferDialog() {
|
||||
cancel();
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
Intent intent = context.getPackageManager().getLaunchIntentForPackage("ryey.colorsniffer");
|
||||
|
||||
// if color snifer app is not installed then send user to install it
|
||||
@@ -273,22 +275,23 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
}
|
||||
|
||||
private void frozenApps() {
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
launcherActivity.showFrozenApps();
|
||||
cancel();
|
||||
}
|
||||
|
||||
//show hidden apps
|
||||
private void hiddenApps() {
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
launcherActivity.showHiddenApps();
|
||||
cancel();
|
||||
}
|
||||
|
||||
private void showThemeDialog() {
|
||||
cancel();
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
new ThemeSelectorDialog(getContext(), launcherActivity).show();
|
||||
}
|
||||
|
||||
private void defaultSettings() {
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
DbUtils.clearDB();
|
||||
launcherActivity.recreate();
|
||||
}
|
||||
@@ -302,6 +305,7 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
updateDoubleTapLockButtonText();
|
||||
} else {
|
||||
// If currently disabled, show the detailed dialog to explain and enable the feature
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
DoubleTapLockDialog doubleTapDialog = new DoubleTapLockDialog(context, launcherActivity);
|
||||
doubleTapDialog.show();
|
||||
|
||||
@@ -336,7 +340,7 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
}
|
||||
|
||||
private void backup() {
|
||||
cancel();
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
Intent intentBackupFiles;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
|
||||
intentBackupFiles = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||
@@ -359,7 +363,7 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
}
|
||||
|
||||
private void restore() {
|
||||
cancel();
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
Intent intentRestoreFiles;
|
||||
intentRestoreFiles = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intentRestoreFiles.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
@@ -369,7 +373,7 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
}
|
||||
|
||||
private void setFonts() {
|
||||
cancel();
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
Intent intentSetFonts = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
|
||||
intentSetFonts.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
@@ -397,10 +401,10 @@ public class GlobalSettingsDialog extends Dialog implements View.OnClickListener
|
||||
setFonts();
|
||||
} else if (id == R.id.menu_default_font) {
|
||||
if (DbUtils.isFontExists()) {
|
||||
launcherActivity.closeGlobalSettingsDialog();
|
||||
DbUtils.removeFont();
|
||||
launcherActivity.setFont();
|
||||
launcherActivity.loadApps();
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
<solid android:color="@android:color/black" />
|
||||
|
||||
<!-- Border/stroke around the popup -->
|
||||
<stroke
|
||||
<!-- <stroke
|
||||
android:width="1dp"
|
||||
android:color="#DEDEDE" />
|
||||
android:color="#DEDEDE" /> -->
|
||||
|
||||
<!-- Rounded corners for better appearance -->
|
||||
<corners android:radius="4dp" />
|
||||
|
||||
Reference in new issue
Block a user