Bug 1072831 - Firefox becomes unresponsive at start-up with "Don't keep activities" enabled due to first run experience. r=lucasr

This commit is contained in:
Chenxia Liu 2014-10-27 16:05:49 -07:00
parent 7b557e6569
commit ab57baae85
5 changed files with 53 additions and 61 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -5,10 +5,10 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/OnboardStartLayout"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:orientation="vertical"
android:background="@color/onboard_start"
android:windowIsFloating="true">
android:background="@color/onboard_start">
<ScrollView android:id="@+id/onboard_content"
android:layout_width="match_parent"
@ -25,8 +25,8 @@
android:layout_height="0dp"
android:layout_weight="1"/>
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingTop="15dp">
<ImageView android:id="@+id/image_shield"
@ -59,34 +59,35 @@
<ImageView android:id="@+id/image_sync"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/image_shield"
android:layout_toLeftOf="@id/image_logo"
android:layout_marginRight="30dp"
android:paddingRight="200dp"
android:src="@drawable/onboard_start_sync"
android:contentDescription="@string/onboard_empty_contentDescription"/>
<ImageView android:id="@+id/image_addon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/image_private"
android:layout_toRightOf="@id/image_logo"
android:layout_marginLeft="30dp"
android:layout_centerHorizontal="true"
android:layout_below="@id/image_shield"
android:paddingLeft="200dp"
android:src="@drawable/onboard_start_addon"
android:contentDescription="@string/onboard_empty_contentDescription"/>
<TextView android:id="@+id/text_message"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/image_logo"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:gravity="center"
android:padding="10sp"
android:text="@string/onboard_start_message"
android:textAppearance="@style/OnboardStartTextAppearance"
android:textSize="23sp" />
<TextView android:layout_width="295dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:layout_below="@id/text_message"
@ -124,4 +125,4 @@
android:text="@string/onboard_start_button_browser"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@ -168,11 +168,6 @@
<item name="android:layout_gravity">center</item>
</style>
<style name="OnboardStartLayout">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">400dp</item>
</style>
<style name="TextAppearance.UrlBar.Title" parent="TextAppearance.Medium">
<item name="android:textSize">16sp</item>
</style>

View File

@ -835,10 +835,6 @@
<item name="android:windowIsTranslucent">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
<style name="OnboardStartLayout">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
</style>
<style name="OnboardStartTextAppearance">
<item name="android:textColor">#5F636B</item>