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
This commit is contained in:
parent
ff0c2e26ec
commit
2ca0ae7d7c
|
@ -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" />
|
||||
|
|
|
@ -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,22 +821,10 @@ public final class Launcher extends Activity
|
|||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
||||
// Close the menu
|
||||
if (Intent.ACTION_MAIN.equals(intent.getAction())) {
|
||||
void closeSystemDialogs() {
|
||||
closeAllApps(false);
|
||||
getWindow().closeAllPanels();
|
||||
|
||||
// Whatever we were doing is hereby canceled.
|
||||
mWaitingForResult = false;
|
||||
|
||||
// Set this flag so that onResume knows to close the search dialog if it's open,
|
||||
// because this was a new intent (thus a press of 'home' or some such) rather than
|
||||
// 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
|
||||
|
@ -843,6 +838,23 @@ public final class Launcher extends Activity
|
|||
} 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())) {
|
||||
closeSystemDialogs();
|
||||
|
||||
// Whatever we were doing is hereby canceled.
|
||||
mWaitingForResult = false;
|
||||
|
||||
// Set this flag so that onResume knows to close the search dialog if it's open,
|
||||
// because this was a new intent (thus a press of 'home' or some such) rather than
|
||||
// for example onResume being called when the user pressed the 'back' button.
|
||||
mIsNewIntent = true;
|
||||
|
||||
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,
|
||||
|
@ -1953,6 +1971,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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue