Update preference screen title.

- Add missing title to preference screen xml so that they will be used to
set the activity title when the fragment is launched.
- Also updated some incorrect preference screen titles.
- Overrides getTitle() in preference fragments that do not use the
preference screen xml.

Bug: 64564191
Test: blaze-bin/screenshots/android/i18nscreenshots/i18nscreenshots
Change-Id: Id72d5ddf18f0962bc484de8bbd847a2e55d6371e
This commit is contained in:
Doris Ling
2017-10-18 14:25:01 -07:00
parent 9d85cfe762
commit 03a3b518de
86 changed files with 838 additions and 93 deletions

View File

@@ -16,23 +16,36 @@ package com.android.settings.datausage;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.net.NetworkTemplate;
import android.os.Bundle;
import android.support.v4.content.res.TypedArrayUtils;
import android.support.v7.preference.Preference;
import android.text.format.Formatter;
import android.util.AttributeSet;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settingslib.net.DataUsageController;
public class DataUsagePreference extends Preference implements TemplatePreference {
private NetworkTemplate mTemplate;
private int mSubId;
private int mTitleRes;
public DataUsagePreference(Context context, AttributeSet attrs) {
super(context, attrs);
if (InstrumentedPreferenceFragment.usePreferenceScreenTitle()) {
final TypedArray a = context.obtainStyledAttributes(
attrs, new int[] { com.android.internal.R.attr.title },
TypedArrayUtils.getAttr(
context, android.support.v7.preference.R.attr.preferenceStyle,
android.R.attr.preferenceStyle), 0);
mTitleRes = a.getResourceId(0, 0);
a.recycle();
}
}
@Override
@@ -52,6 +65,11 @@ public class DataUsagePreference extends Preference implements TemplatePreferenc
Bundle args = new Bundle();
args.putParcelable(DataUsageList.EXTRA_NETWORK_TEMPLATE, mTemplate);
args.putInt(DataUsageList.EXTRA_SUB_ID, mSubId);
if (mTitleRes > 0) {
return Utils.onBuildStartFragmentIntent(getContext(), DataUsageList.class.getName(),
args, getContext().getPackageName(), mTitleRes, null, false,
MetricsProto.MetricsEvent.VIEW_UNKNOWN);
}
return Utils.onBuildStartFragmentIntent(getContext(), DataUsageList.class.getName(), args,
getContext().getPackageName(), 0, getTitle(), false,
MetricsProto.MetricsEvent.VIEW_UNKNOWN);