diff --git a/mobile/android/base/AndroidManifest.xml.in b/mobile/android/base/AndroidManifest.xml.in index bd5f65961b9b..6030334d98cc 100644 --- a/mobile/android/base/AndroidManifest.xml.in +++ b/mobile/android/base/AndroidManifest.xml.in @@ -149,6 +149,11 @@ + + + + + diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index 37f59e8d0989..22b24b662d9a 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -185,7 +185,7 @@ public class BrowserApp extends GeckoApp } // The types of guest mdoe dialogs we show - private static enum GuestModeDialog { + public static enum GuestModeDialog { ENTERING, LEAVING } @@ -536,11 +536,15 @@ public class BrowserApp extends GeckoApp mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar); mProgressView = (ToolbarProgressView) findViewById(R.id.progress); mBrowserToolbar.setProgressBar(mProgressView); - if (Intent.ACTION_VIEW.equals(intent.getAction())) { + + final String action = intent.getAction(); + if (Intent.ACTION_VIEW.equals(action)) { // Show the target URL immediately in the toolbar. mBrowserToolbar.setTitle(intent.getDataString()); Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.INTENT); + } else if (GuestSession.NOTIFICATION_INTENT.equals(action)) { + GuestSession.handleIntent(this, intent); } if (NewTabletUI.isEnabled(this)) { @@ -660,6 +664,13 @@ 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 registerOnboardingReceiver(Context context) { @@ -1033,6 +1044,8 @@ public class BrowserApp extends GeckoApp mBrowserHealthReporter = null; } + GuestSession.onDestroy(this); + EventDispatcher.getInstance().unregisterGeckoThreadListener((GeckoEventListener)this, "Menu:Update", "Reader:Added", @@ -2831,7 +2844,7 @@ public class BrowserApp extends GeckoApp return super.onOptionsItemSelected(item); } - private void showGuestModeDialog(final GuestModeDialog type) { + public void showGuestModeDialog(final GuestModeDialog type) { final Prompt ps = new Prompt(this, new Prompt.PromptCallback() { @Override public void onPromptFinished(String result) { @@ -2923,6 +2936,8 @@ public class BrowserApp extends GeckoApp // Only solicit feedback when the app has been launched from the icon shortcut. if (!Intent.ACTION_MAIN.equals(action)) { return; + } else if (GuestSession.NOTIFICATION_INTENT.equals(action)) { + GuestSession.handleIntent(this, intent); } // Check to see how many times the app has been launched. diff --git a/mobile/android/base/GeckoProfile.java b/mobile/android/base/GeckoProfile.java index 2a77a97f86b0..133548113eb7 100644 --- a/mobile/android/base/GeckoProfile.java +++ b/mobile/android/base/GeckoProfile.java @@ -331,7 +331,7 @@ public final class GeckoProfile { // If this dir doesn't exist getDir will create it for us final File lockFile = new File(getDir(), LOCK_FILE_NAME); final boolean result = lockFile.createNewFile(); - if (result) { + if (lockFile.exists()) { mLocked = LockState.LOCKED; } else { mLocked = LockState.UNLOCKED; diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index 86e21edba1ca..6dccc357a6b8 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -505,6 +505,8 @@ just addresses the organization to follow, e.g. "This site is run by " --> + + diff --git a/mobile/android/base/moz.build b/mobile/android/base/moz.build index 4f18a8703bf9..d9be4cb2cf56 100644 --- a/mobile/android/base/moz.build +++ b/mobile/android/base/moz.build @@ -251,6 +251,7 @@ gbjar.sources += [ 'gfx/ViewTransform.java', 'gfx/VirtualLayer.java', 'GlobalHistory.java', + 'GuestSession.java', 'health/BrowserHealthRecorder.java', 'health/BrowserHealthReporter.java', 'health/HealthRecorder.java', diff --git a/mobile/android/base/prompts/Prompt.java b/mobile/android/base/prompts/Prompt.java index 41b5ec27eb40..68b8125c4caf 100644 --- a/mobile/android/base/prompts/Prompt.java +++ b/mobile/android/base/prompts/Prompt.java @@ -11,6 +11,7 @@ import org.json.JSONObject; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoEvent; import org.mozilla.gecko.R; +import org.mozilla.gecko.gfx.LayerView; import org.mozilla.gecko.util.ThreadUtils; import org.mozilla.gecko.Tab; import org.mozilla.gecko.Tabs; @@ -162,7 +163,10 @@ public class Prompt implements OnClickListener, OnCancelListener, OnItemClickLis private void create(String title, String text, PromptListItem[] listItems, int choiceMode) throws IllegalStateException { - GeckoAppShell.getLayerView().abortPanning(); + final LayerView view = GeckoAppShell.getLayerView(); + if (view != null) { + view.abortPanning(); + } AlertDialog.Builder builder = new AlertDialog.Builder(mContext); if (!TextUtils.isEmpty(title)) { diff --git a/mobile/android/base/resources/drawable-hdpi-v11/alert_guest.png b/mobile/android/base/resources/drawable-hdpi-v11/alert_guest.png new file mode 100644 index 000000000000..55d569730182 Binary files /dev/null and b/mobile/android/base/resources/drawable-hdpi-v11/alert_guest.png differ diff --git a/mobile/android/base/resources/drawable-hdpi/alert_guest.png b/mobile/android/base/resources/drawable-hdpi/alert_guest.png new file mode 100644 index 000000000000..b812a703f538 Binary files /dev/null and b/mobile/android/base/resources/drawable-hdpi/alert_guest.png differ diff --git a/mobile/android/base/resources/drawable-mdpi-v11/alert_guest.png b/mobile/android/base/resources/drawable-mdpi-v11/alert_guest.png new file mode 100644 index 000000000000..051b13f8b8e2 Binary files /dev/null and b/mobile/android/base/resources/drawable-mdpi-v11/alert_guest.png differ diff --git a/mobile/android/base/resources/drawable-mdpi/alert_guest.png b/mobile/android/base/resources/drawable-mdpi/alert_guest.png new file mode 100644 index 000000000000..40e5ccac9ef9 Binary files /dev/null and b/mobile/android/base/resources/drawable-mdpi/alert_guest.png differ diff --git a/mobile/android/base/resources/drawable-xhdpi-v11/alert_guest.png b/mobile/android/base/resources/drawable-xhdpi-v11/alert_guest.png new file mode 100644 index 000000000000..5bb71d4c77f2 Binary files /dev/null and b/mobile/android/base/resources/drawable-xhdpi-v11/alert_guest.png differ diff --git a/mobile/android/base/resources/drawable-xhdpi/alert_guest.png b/mobile/android/base/resources/drawable-xhdpi/alert_guest.png new file mode 100644 index 000000000000..4ca6d8451023 Binary files /dev/null and b/mobile/android/base/resources/drawable-xhdpi/alert_guest.png differ diff --git a/mobile/android/base/resources/values/ids.xml b/mobile/android/base/resources/values/ids.xml new file mode 100644 index 000000000000..4e25fe2c5c4d --- /dev/null +++ b/mobile/android/base/resources/values/ids.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index 7e9f91b6204d..f7f0fa447bcd 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -454,6 +454,8 @@ &guest_session_dialog_cancel; &new_guest_session_title; &new_guest_session_text; + &guest_browsing_notification_title; + &guest_browsing_notification_text; &exit_guest_session_title; &exit_guest_session_text;