Bug 1074343 - Dismiss guest mode notification on browser close. r=bnicholson

This commit is contained in:
Richard Newman 2014-10-08 11:21:02 -07:00
parent 4f80f3e08e
commit 7ebb7ddc42
3 changed files with 38 additions and 34 deletions

View File

@ -191,7 +191,7 @@ public class BrowserApp extends GeckoApp
public boolean added; // So we can re-add after a locale change.
}
// The types of guest mdoe dialogs we show
// The types of guest mode dialogs we show.
public static enum GuestModeDialog {
ENTERING,
LEAVING
@ -673,13 +673,6 @@ public class BrowserApp extends GeckoApp
Log.e(LOGTAG, "Error initializing media manager", ex);
}
}
if (getProfile().inGuestMode()) {
GuestSession.showNotification(this);
} else {
// If we're restarting, we won't destroy the activity. Make sure we remove any guest notifications that might have been shown.
GuestSession.hideNotification(this);
}
}
private void setupSystemUITinting() {
@ -790,6 +783,35 @@ public class BrowserApp extends GeckoApp
lbm.unregisterReceiver(mOnboardingReceiver);
}
@Override
public void onStart() {
super.onStart();
// Queue this work so that the first launch of the activity doesn't
// trigger profile init too early.
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
public void run() {
if (getProfile().inGuestMode()) {
GuestSession.showNotification(BrowserApp.this);
} else {
// If we're restarting, we won't destroy the activity.
// Make sure we remove any guest notifications that might
// have been shown.
GuestSession.hideNotification(BrowserApp.this);
}
}
});
}
@Override
public void onStop() {
super.onStop();
// We only show the guest mode notification when our activity is in the foreground.
GuestSession.hideNotification(this);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
@ -1087,8 +1109,6 @@ public class BrowserApp extends GeckoApp
mBrowserHealthReporter = null;
}
GuestSession.onDestroy(this);
EventDispatcher.getInstance().unregisterGeckoThreadListener((GeckoEventListener)this,
"Menu:Update",
"Reader:Added",
@ -2939,6 +2959,9 @@ public class BrowserApp extends GeckoApp
args = GUEST_BROWSING_ARG;
} else {
GeckoProfile.leaveGuestSession(BrowserApp.this);
// Now's a good time to make sure we're not displaying the Guest Browsing notification.
GuestSession.hideNotification(BrowserApp.this);
}
if (!GuestSession.isSecureKeyguardLocked(BrowserApp.this)) {

View File

@ -9,7 +9,6 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@ -45,7 +44,6 @@ import org.mozilla.gecko.mozglue.GeckoLoader;
import org.mozilla.gecko.preferences.ClearOnShutdownPref;
import org.mozilla.gecko.preferences.GeckoPreferences;
import org.mozilla.gecko.prompts.PromptService;
import org.mozilla.gecko.SmsManager;
import org.mozilla.gecko.updater.UpdateService;
import org.mozilla.gecko.updater.UpdateServiceHelper;
import org.mozilla.gecko.util.ActivityResultHandler;
@ -443,6 +441,9 @@ public abstract class GeckoApp
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.quit) {
// Make sure the Guest Browsing notification goes away when we quit.
GuestSession.hideNotification(this);
if (GeckoThread.checkAndSetLaunchState(GeckoThread.LaunchState.GeckoRunning, GeckoThread.LaunchState.GeckoExiting)) {
final SharedPreferences prefs = GeckoSharedPrefs.forProfile(this);
final Set<String> clearSet = PrefUtils.getStringSet(prefs, ClearOnShutdownPref.PREF, new HashSet<String>());

View File

@ -4,29 +4,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko;
import android.app.NotificationManager;
import android.app.KeyguardManager;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.util.Log;
import android.support.v4.app.NotificationCompat;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ListView;
import android.support.v4.app.NotificationCompat;
import org.mozilla.gecko.prompts.Prompt;
import org.mozilla.gecko.util.EventCallback;
import org.mozilla.gecko.util.NativeEventListener;
import org.mozilla.gecko.util.NativeJSObject;
import org.mozilla.gecko.util.ThreadUtils;
import java.io.File;
import org.json.JSONException;
import org.json.JSONObject;
// Utility methods for entering/exiting guest mode.
public class GuestSession {
@ -105,12 +91,6 @@ public class GuestSession {
manager.cancel(R.id.guestNotification);
}
public static void onDestroy(Context context) {
if (GeckoProfile.get(context).inGuestMode()) {
hideNotification(context);
}
}
public static void handleIntent(BrowserApp context, Intent intent) {
context.showGuestModeDialog(BrowserApp.GuestModeDialog.LEAVING);
}