diff options
author | Yvonne Wong <ywong@cyngn.com> | 2015-11-30 15:32:16 -0800 |
---|---|---|
committer | Yvonne Wong <ywong@cyngn.com> | 2015-11-30 15:32:16 -0800 |
commit | fe70926e116fca0d84b3642aae3fe6c68d6c7264 (patch) | |
tree | ff7d77fd2fa683807b85f580a45f231d6f6c2433 /src/com/android/launcher3/Launcher.java | |
parent | b3de38c976eeb5a8c4b5c1b0d68d9c84253d3187 (diff) | |
download | android_packages_apps_Trebuchet-fe70926e116fca0d84b3642aae3fe6c68d6c7264.tar.gz android_packages_apps_Trebuchet-fe70926e116fca0d84b3642aae3fe6c68d6c7264.tar.bz2 android_packages_apps_Trebuchet-fe70926e116fca0d84b3642aae3fe6c68d6c7264.zip |
Reimplement CM Settings Overview Panel in the new Launcher Part 2
- Enables hiding the search bar from the workspace
- Adds a reload launcher flag to reload only during onResume or newIntent if needed
Change-Id: I0feb279f9003b268b5a129cef40d3665787ee451
Diffstat (limited to 'src/com/android/launcher3/Launcher.java')
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 759ca041b..454d77614 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -358,6 +358,8 @@ public class Launcher extends Activity // the press state and keep this reference to reset the press state when we return to launcher. private BubbleTextView mWaitingForResume; + private boolean mReloadLauncher; + // Preferences private boolean mHideIconLabels; @@ -1090,6 +1092,8 @@ public class Launcher extends Activity if (mLauncherCallbacks != null) { mLauncherCallbacks.onResume(); } + + reloadLauncherIfNeeded(); } @Override @@ -1695,6 +1699,10 @@ public class Launcher extends Activity } }; + /** + * Initializes the device profile based off of the launcher app state and screen orientation + * @param app The launcher app state + */ public void initializeDeviceProfile(LauncherAppState app) { // Load configuration-specific DeviceProfile mDeviceProfile = getResources().getConfiguration().orientation @@ -1702,16 +1710,45 @@ public class Launcher extends Activity app.getInvariantDeviceProfile().landscapeProfile : app.getInvariantDeviceProfile().portraitProfile; - mModel = app.setLauncher(this); - mIconCache = app.getIconCache(); - mHideIconLabels = SettingsProvider.getBoolean(this, SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, R.bool.preferences_interface_homescreen_hide_icon_labels_default); + + mModel = app.setLauncher(this); + mIconCache = app.getIconCache(); + mIconCache.flushInvalidIcons(mDeviceProfile); + } + + /** + * Sets the reload launcher flag to true, which will reload the launcher at the next appropriate + * time. + */ + public void setReloadLauncher() { + mReloadLauncher = true; } - public void reloadLauncher() + /** + * If the reload launcher flag is set to true, the launcher will be reloaded. + * @return Whether the launcher was actually reloaded. + */ + public boolean reloadLauncherIfNeeded() { + if (mReloadLauncher) { + reloadLauncher(mWorkspace.getCurrentPage()); + mReloadLauncher = false; + return true; + } + + return false; + } + + /** + * Reloads the launcher by re-initializing the device profile and layout + * @param page + */ + public void reloadLauncher(int page) { + mSearchDropTargetBar.setupQsb(this); + // Re-initialize device profile LauncherAppState app = LauncherAppState.getInstance(); app.initInvariantDeviceProfile(); @@ -1721,7 +1758,7 @@ public class Launcher extends Activity // Reload mModel.resetLoadedState(true, true); - mModel.startLoader(mWorkspace.getRestorePage(), LauncherModel.LOADER_FLAG_NONE); + mModel.startLoader(page, LauncherModel.LOADER_FLAG_NONE); mWorkspace.updateCustomContentVisibility(); mAppsView.reset(); @@ -1959,6 +1996,8 @@ public class Launcher extends Activity } super.onNewIntent(intent); + reloadLauncherIfNeeded(); + // Close the menu Folder openFolder = mWorkspace.getOpenFolder(); boolean alreadyOnHome = mHasFocus && ((intent.getFlags() & |