Bug 1264138 - Upgrade FxAccountStatusActivity to use AppCompatActivity too r=sebastian
authorAndrzej Hunt <ahunt@mozilla.com>
Thu, 14 Apr 2016 08:35:13 -0700
changeset 331319 52e570214af308e604b413645136f340ad412711
parent 331318 fec92924befbea7a0ee52c4cedd531a67b61f2fb
child 331320 009d7df1ba6d97a5abd2ed417a3464a8e948742c
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1264138
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1264138 - Upgrade FxAccountStatusActivity to use AppCompatActivity too r=sebastian 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
mobile/android/base/java/org/mozilla/gecko/Locales.java
mobile/android/base/moz.build
mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusActivity.java
mobile/android/services/src/main/res/values-v11/fxaccount_styles.xml
mobile/android/services/src/main/res/values/fxaccount_styles.xml
--- a/mobile/android/base/java/org/mozilla/gecko/Locales.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Locales.java
@@ -9,16 +9,17 @@ import java.util.Locale;
 
 import org.mozilla.gecko.LocaleManager;
 
 import android.app.Activity;
 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
  * hitting StrictMode errors or adding boilerplate to common activity
  * subclasses.
  *
  * Either call {@link Locales#initializeLocale(Context)} in your
  * <code>onCreate</code> method, or inherit from
@@ -42,16 +43,24 @@ public class Locales {
         StrictMode.allowThreadDiskWrites();
         try {
             localeManager.getAndApplyPersistedLocale(context);
         } finally {
             StrictMode.setThreadPolicy(savedPolicy);
         }
     }
 
+    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) {
             Locales.initializeLocale(getApplicationContext());
             super.onCreate(savedInstanceState);
         }
     }
 
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -143,16 +143,17 @@ stjar.sources += [ thirdparty_source_dir
 stjar.javac_flags = ['-Xlint:none']
 
 services_jar = add_java_jar('services')
 services_jar.sources += sync_java_files
 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',
     'gecko-thirdparty.jar',
     'gecko-util.jar',
     'sync-thirdparty.jar',
 ]
 services_jar.javac_flags += ['-Xlint:all,-deprecation']
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusActivity.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusActivity.java
@@ -5,43 +5,43 @@
 package org.mozilla.gecko.fxa.activities;
 
 import android.accounts.Account;
 import android.accounts.AccountManager;
 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;
 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;
 import org.mozilla.gecko.fxa.FirefoxAccounts;
 import org.mozilla.gecko.fxa.FxAccountConstants;
 import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
 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;
 
   @Override
   protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
 
@@ -62,20 +62,21 @@ public class FxAccountStatusActivity ext
    * more information.
    */
   @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
   protected void maybeSetHomeButtonEnabled() {
     if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
       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.");
   }
 
   @Override
   public void onResume() {
     super.onResume();
--- a/mobile/android/services/src/main/res/values-v11/fxaccount_styles.xml
+++ b/mobile/android/services/src/main/res/values-v11/fxaccount_styles.xml
@@ -7,17 +7,15 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android">
 
     <!-- FxAccountStatusActivity ActionBar -->
     <style name="ActionBar.FxAccountStatusActivity">
          <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>
 
 </resources>
--- a/mobile/android/services/src/main/res/values/fxaccount_styles.xml
+++ b/mobile/android/services/src/main/res/values/fxaccount_styles.xml
@@ -2,17 +2,17 @@
 <!--
    This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/.
 -->
 
 <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>
     </style>
 
     <style name="FxAccountTextItem" parent="@android:style/TextAppearance.Medium">
         <item name="android:textColor">@color/fxaccount_textColor</item>
         <item name="android:layout_width">fill_parent</item>