Bug 1264138 - Upgrade FxAccountStatusActivity to use AppCompatActivity too r=sebastian a=ritu

Our theming inheritance around Preferences still seems quite messy, however given we'll
need to uplift this I'm planning to tackle this in a separate bug.

We add the LocaleAwareAppCompatActivity in order to avoid affecting other consumers
of LocaleAwareFragementActivity (primarily the SearchActivity). We will investigate
those separately.

MozReview-Commit-ID: KVEZbDdza1s
This commit is contained in:
Andrzej Hunt 2016-04-14 08:35:13 -07:00
parent 99cd8b1747
commit 70429f76c7
5 changed files with 17 additions and 8 deletions

View File

@ -14,6 +14,7 @@ import android.content.Context;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
/**
* This is a helper class to do typical locale switching operations without
@ -47,6 +48,14 @@ public class Locales {
}
}
public static class LocaleAwareAppCompatActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Locales.initializeLocale(getApplicationContext());
super.onCreate(savedInstanceState);
}
}
public static class LocaleAwareFragmentActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {

View File

@ -149,6 +149,7 @@ services_jar.extra_jars = [
CONFIG['ANDROID_SUPPORT_ANNOTATIONS_JAR_LIB'],
CONFIG['ANDROID_SUPPORT_V4_AAR_LIB'],
CONFIG['ANDROID_SUPPORT_V4_AAR_INTERNAL_LIB'],
CONFIG['ANDROID_APPCOMPAT_V7_AAR_LIB'],
'constants.jar',
'gecko-R.jar',
'gecko-mozglue.jar',

View File

@ -10,7 +10,6 @@ import android.accounts.AccountManagerCallback;
import android.accounts.AccountManagerFuture;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@ -18,13 +17,14 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.Locales.LocaleAwareFragmentActivity;
import org.mozilla.gecko.Locales.LocaleAwareAppCompatActivity;
import org.mozilla.gecko.R;
import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.background.fxa.FxAccountUtils;
@ -36,7 +36,7 @@ import org.mozilla.gecko.sync.Utils;
/**
* Activity which displays account status.
*/
public class FxAccountStatusActivity extends LocaleAwareFragmentActivity {
public class FxAccountStatusActivity extends LocaleAwareAppCompatActivity {
private static final String LOG_TAG = FxAccountStatusActivity.class.getSimpleName();
protected FxAccountStatusFragment statusFragment;
@ -67,10 +67,11 @@ public class FxAccountStatusActivity extends LocaleAwareFragmentActivity {
Logger.debug(LOG_TAG, "Not enabling home button; version too low.");
return;
}
final ActionBar actionBar = getActionBar();
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
Logger.debug(LOG_TAG, "Enabling home button.");
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
return;
}
Logger.debug(LOG_TAG, "Not enabling home button.");

View File

@ -12,11 +12,9 @@
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
</style>
<style name="FxAccountTheme" parent="@style/Gecko" />
<style name="FxAccountTheme" parent="Gecko.Preferences" />
<style name="FxAccountTheme.FxAccountStatusActivity" parent="Gecko.Preferences">
<item name="android:windowActionBar">true</item>
<item name="android:windowNoTitle">false</item>
<item name="android:actionBarStyle">@style/ActionBar.FxAccountStatusActivity</item>
</style>

View File

@ -7,7 +7,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="FxAccountTheme" parent="@style/Gecko" />
<style name="FxAccountTheme" parent="Gecko.Preferences" />
<style name="FxAccountTheme.FxAccountStatusActivity" parent="@style/FxAccountTheme">
<item name="android:windowNoTitle">false</item>