diff options
author | Joe Onorato <joeo@android.com> | 2009-11-10 13:14:13 -0800 |
---|---|---|
committer | Joe Onorato <joeo@android.com> | 2009-11-10 19:56:01 -0800 |
commit | 2ca0ae7d7c4d5f6b24a1b3d987813cad9ee4197f (patch) | |
tree | 0464d636abfd7cd932fbfdb17fbb60ba1ffb7b6e | |
parent | ff0c2e26ecf3e27571743fb6d11128e948dd91f3 (diff) | |
download | android_packages_apps_Trebuchet-2ca0ae7d7c4d5f6b24a1b3d987813cad9ee4197f.tar.gz android_packages_apps_Trebuchet-2ca0ae7d7c4d5f6b24a1b3d987813cad9ee4197f.tar.bz2 android_packages_apps_Trebuchet-2ca0ae7d7c4d5f6b24a1b3d987813cad9ee4197f.zip |
Fix bug 2250432 - all apps should dismiss when you power off or phone locks
Also cherry-picks this from launcher 1
Fix issue #2133206: dialogs/menus should auto-dismiss when screen turns off
Close things out in various ways. This should be done for Launcher2 as well.
Change-Id: Id4f1c78e35180b437144c54ddcbf10069cc09071
Conflicts:
AndroidManifest.xml
src/com/android/launcher2/Launcher.java
-rw-r--r-- | AndroidManifest.xml | 3 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 59 |
2 files changed, 46 insertions, 16 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index bd9a4de02..af666102a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -84,7 +84,8 @@ android:name="WallpaperChooser" android:label="@string/pick_wallpaper" android:icon="@drawable/ic_launcher_wallpaper" - android:screenOrientation="nosensor"> + android:screenOrientation="nosensor" + android:finishOnCloseSystemDialogs="true"> <intent-filter> <action android:name="android.intent.action.SET_WALLPAPER" /> <category android:name="android.intent.category.DEFAULT" /> diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index f718c5b32..6a0978b8c 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -25,12 +25,14 @@ import android.app.StatusBarManager; import android.app.WallpaperInfo; import android.app.WallpaperManager; import android.content.ActivityNotFoundException; +import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.Intent.ShortcutIconResource; +import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.pm.LabeledIntent; import android.content.pm.PackageManager; @@ -159,6 +161,8 @@ public final class Launcher extends Activity private static final Object sLock = new Object(); private static int sScreen = DEFAULT_SCREEN; + private final BroadcastReceiver mCloseSystemDialogsReceiver + = new CloseSystemDialogsIntentReceiver(); private final ContentObserver mWidgetObserver = new AppWidgetResetObserver(); private LayoutInflater mInflater; @@ -211,6 +215,9 @@ public final class Launcher extends Activity mDragController = new DragController(this); mInflater = getLayoutInflater(); + IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); + registerReceiver(mCloseSystemDialogsReceiver, filter); + mAppWidgetManager = AppWidgetManager.getInstance(this); mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID); mAppWidgetHost.startListening(); @@ -814,13 +821,32 @@ public final class Launcher extends Activity return info; } + void closeSystemDialogs() { + closeAllApps(false); + getWindow().closeAllPanels(); + + try { + dismissDialog(DIALOG_CREATE_SHORTCUT); + // Unlock the workspace if the dialog was showing + } catch (Exception e) { + // An exception is thrown if the dialog is not visible, which is fine + } + + try { + dismissDialog(DIALOG_RENAME_FOLDER); + // Unlock the workspace if the dialog was showing + } catch (Exception e) { + // An exception is thrown if the dialog is not visible, which is fine + } + } + @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); // Close the menu if (Intent.ACTION_MAIN.equals(intent.getAction())) { - getWindow().closeAllPanels(); + closeSystemDialogs(); // Whatever we were doing is hereby canceled. mWaitingForResult = false; @@ -830,20 +856,6 @@ public final class Launcher extends Activity // for example onResume being called when the user pressed the 'back' button. mIsNewIntent = true; - try { - dismissDialog(DIALOG_CREATE_SHORTCUT); - // Unlock the workspace if the dialog was showing - } catch (Exception e) { - // An exception is thrown if the dialog is not visible, which is fine - } - - try { - dismissDialog(DIALOG_RENAME_FOLDER); - // Unlock the workspace if the dialog was showing - } catch (Exception e) { - // An exception is thrown if the dialog is not visible, which is fine - } - if ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) { @@ -939,6 +951,8 @@ public final class Launcher extends Activity dismissPreview(mPreviousView); dismissPreview(mNextView); + + unregisterReceiver(mCloseSystemDialogsReceiver); } @Override @@ -1305,6 +1319,10 @@ public final class Launcher extends Activity startActivityForResult(chooser, REQUEST_PICK_WALLPAPER); } + /** + * Registers various content observers. The current implementation registers + * only a favorites observer to keep track of the favorites applications. + */ private void registerContentObservers() { ContentResolver resolver = getContentResolver(); resolver.registerContentObserver(LauncherProvider.CONTENT_APPWIDGET_RESET_URI, @@ -1954,6 +1972,17 @@ public final class Launcher extends Activity } /** + * Receives notifications when applications are added/removed. + */ + private class CloseSystemDialogsIntentReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + Log.d(TAG, "CloseSystemDialogsIntentReceiver.onReceiver intent=" + intent); + closeSystemDialogs(); + } + } + + /** * Receives notifications whenever the appwidgets are reset. */ private class AppWidgetResetObserver extends ContentObserver { |