diff --git a/mobile/android/base/android-services.mozbuild b/mobile/android/base/android-services.mozbuild index 31be309cdeab..84d3361c35f6 100644 --- a/mobile/android/base/android-services.mozbuild +++ b/mobile/android/base/android-services.mozbuild @@ -850,6 +850,7 @@ sync_java_files = [ 'browserid/verifier/BrowserIDVerifierException.java', 'browserid/VerifyingPublicKey.java', 'fxa/AccountLoader.java', + 'fxa/activities/CustomColorPreference.java', 'fxa/activities/FxAccountAbstractActivity.java', 'fxa/activities/FxAccountAbstractSetupActivity.java', 'fxa/activities/FxAccountAbstractUpdateCredentialsActivity.java', diff --git a/mobile/android/base/fxa/activities/CustomColorPreference.java b/mobile/android/base/fxa/activities/CustomColorPreference.java new file mode 100644 index 000000000000..5c4d7f3ccaf8 --- /dev/null +++ b/mobile/android/base/fxa/activities/CustomColorPreference.java @@ -0,0 +1,52 @@ +/* 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/. */ + +package org.mozilla.gecko.fxa.activities; + +import org.mozilla.gecko.R; +import android.content.Context; +import android.content.res.TypedArray; +import android.preference.Preference; +import android.util.AttributeSet; +import android.view.View; +import android.widget.TextView; + + /** + * This preference is used to define custom colors for both title and summary texts. + * Color code #777777 (placeholder_grey) is used as the fallback color for both title and summary. + */ +public class CustomColorPreference extends Preference { + private int mTitleColor; + private int mSummaryColor; + + public CustomColorPreference(Context context) { + super(context); + } + + public CustomColorPreference(Context context, AttributeSet attrs) { + super(context, attrs); + init(context, attrs); + } + + public CustomColorPreference(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + init(context, attrs); + } + + public void init(Context context, AttributeSet attrs) { + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomColorPreference); + mTitleColor = a.getColor(R.styleable.CustomColorPreference_titleColor, R.color.placeholder_grey); + mSummaryColor = a.getColor(R.styleable.CustomColorPreference_summaryColor, R.color.placeholder_grey); + a.recycle(); + } + + @Override + protected void onBindView(View view) { + super.onBindView(view); + final TextView title = (TextView) view.findViewById(android.R.id.title); + final TextView summary = (TextView) view.findViewById(android.R.id.summary); + title.setTextColor(mTitleColor); + summary.setTextColor(mSummaryColor); + } +} diff --git a/mobile/android/base/resources/values/attrs.xml b/mobile/android/base/resources/values/attrs.xml index d11a33d17e4d..a3cc181449f3 100644 --- a/mobile/android/base/resources/values/attrs.xml +++ b/mobile/android/base/resources/values/attrs.xml @@ -168,6 +168,11 @@ + + + + + diff --git a/mobile/android/base/resources/xml/fxaccount_status_prefscreen.xml b/mobile/android/base/resources/xml/fxaccount_status_prefscreen.xml index 88b16e274976..59e447ebee72 100644 --- a/mobile/android/base/resources/xml/fxaccount_status_prefscreen.xml +++ b/mobile/android/base/resources/xml/fxaccount_status_prefscreen.xml @@ -1,6 +1,7 @@ + xmlns:gecko="http://schemas.android.com/apk/res-auto" + android:key="status_screen"> -