From 184ae3fa4f69da6f7e539e9670f987daf43325c5 Mon Sep 17 00:00:00 2001 From: Chenxia Liu Date: Mon, 27 Oct 2014 16:05:49 -0700 Subject: [PATCH 01/10] Bug 1072831 - Firefox becomes unresponsive at start-up with "Don't keep activities" enabled due to first run experience. r=lucasr --- mobile/android/base/BrowserApp.java | 8 ++- mobile/android/base/StartPane.java | 70 +++++++++---------- .../resources/layout/onboard_start_pane.xml | 27 +++---- .../resources/values-large-v11/styles.xml | 5 -- .../android/base/resources/values/styles.xml | 4 -- 5 files changed, 53 insertions(+), 61 deletions(-) diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index 2da84a9df711..eff02e679b3e 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -103,6 +103,7 @@ import android.nfc.NfcEvent; import android.os.Build; import android.os.Bundle; import android.os.StrictMode; +import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentManager; import android.support.v4.content.LocalBroadcastManager; import android.text.TextUtils; @@ -152,6 +153,7 @@ public class BrowserApp extends GeckoApp private static final String STATE_ABOUT_HOME_TOP_PADDING = "abouthome_top_padding"; private static final String BROWSER_SEARCH_TAG = "browser_search"; + private static final String ONBOARD_STARTPANE_TAG = "startpane_dialog"; // Request ID for startActivityForResult. private static final int ACTIVITY_REQUEST_PREFERENCES = 1001; @@ -628,8 +630,8 @@ public class BrowserApp extends GeckoApp if (prefs.getBoolean(PREF_STARTPANE_ENABLED, false)) { if (!Intent.ACTION_VIEW.equals(intentAction)) { - final Intent startIntent = new Intent(this, StartPane.class); - context.startActivity(startIntent); + final DialogFragment dialog = new StartPane(); + dialog.show(getSupportFragmentManager(), ONBOARD_STARTPANE_TAG); } // Don't bother trying again to show the v1 minimal first run. prefs.edit().putBoolean(PREF_STARTPANE_ENABLED, false).apply(); @@ -637,7 +639,7 @@ public class BrowserApp extends GeckoApp } finally { StrictMode.setThreadPolicy(savedPolicy); } - } + } private Class getMediaPlayerManager() { if (AppConstants.MOZ_MEDIA_PLAYER) { diff --git a/mobile/android/base/StartPane.java b/mobile/android/base/StartPane.java index 8d444474532f..803b5bf8c72c 100644 --- a/mobile/android/base/StartPane.java +++ b/mobile/android/base/StartPane.java @@ -1,73 +1,71 @@ package org.mozilla.gecko; import org.mozilla.gecko.fxa.activities.FxAccountGetStartedActivity; -import org.mozilla.gecko.util.HardwareUtils; -import android.app.Activity; import android.content.Intent; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.view.GestureDetector; +import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnTouchListener; +import android.view.ViewGroup; import android.widget.Button; -public class StartPane extends Activity { +public class StartPane extends DialogFragment { @Override - public void onCreate(Bundle bundle) { - super.onCreate(bundle); - setContentView(R.layout.onboard_start_pane); + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setStyle(DialogFragment.STYLE_NO_TITLE, 0); + } - final Button accountButton = (Button) findViewById(R.id.button_account); - accountButton.setOnClickListener(new OnClickListener() { - - @Override - public void onClick(View v) { - Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-sync"); - showAccountSetup(); - } - }); - - final Button browserButton = (Button) findViewById(R.id.button_browser); + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { + final View view = inflater.inflate(R.layout.onboard_start_pane, container, false); + final Button browserButton = (Button) view.findViewById(R.id.button_browser); browserButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-browser"); - showBrowser(); + Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-sync"); + + // StartPane is on the stack above the browser, so just dismiss this Fragment. + StartPane.this.dismiss(); } }); - if (!HardwareUtils.isTablet() && !HardwareUtils.isTelevision()) { - addDismissHandler(); - } - } + final Button accountButton = (Button) view.findViewById(R.id.button_account); + accountButton.setOnClickListener(new OnClickListener() { - private void showBrowser() { - // StartPane is on the stack above the browser, so just kill this activity. - finish(); - } + @Override + public void onClick(View v) { + Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-browser"); - private void showAccountSetup() { - final Intent intent = new Intent(this, FxAccountGetStartedActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - finish(); + final Intent intent = new Intent(getActivity(), FxAccountGetStartedActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + StartPane.this.dismiss(); + } + }); + + addDismissHandler(view); + return view; } // Add handler for dismissing the StartPane on a single click. - private void addDismissHandler() { - final GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { + private void addDismissHandler(View view) { + final GestureDetector gestureDetector = new GestureDetector(getActivity(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { - StartPane.this.finish(); + StartPane.this.dismiss(); return true; } }); - findViewById(R.id.onboard_content).setOnTouchListener(new OnTouchListener() { + view.findViewById(R.id.onboard_content).setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return gestureDetector.onTouchEvent(event); diff --git a/mobile/android/base/resources/layout/onboard_start_pane.xml b/mobile/android/base/resources/layout/onboard_start_pane.xml index 51a8e48847ed..9aa122a5fb4a 100644 --- a/mobile/android/base/resources/layout/onboard_start_pane.xml +++ b/mobile/android/base/resources/layout/onboard_start_pane.xml @@ -5,10 +5,10 @@ + android:background="@color/onboard_start"> - - + \ No newline at end of file diff --git a/mobile/android/base/resources/values-large-v11/styles.xml b/mobile/android/base/resources/values-large-v11/styles.xml index 28e3bef8ede7..077058c48afb 100644 --- a/mobile/android/base/resources/values-large-v11/styles.xml +++ b/mobile/android/base/resources/values-large-v11/styles.xml @@ -168,11 +168,6 @@ center - - diff --git a/mobile/android/base/resources/values/styles.xml b/mobile/android/base/resources/values/styles.xml index 1579a0827baa..f9dd73e8f829 100644 --- a/mobile/android/base/resources/values/styles.xml +++ b/mobile/android/base/resources/values/styles.xml @@ -835,10 +835,6 @@ true true -