Merge "Add padding for the animation in the gestures settings." into nyc-mr1-dev
diff --git a/res/layout/gesture_preference.xml b/res/layout/gesture_preference.xml
index 2ad625c..2f593fe 100644
--- a/res/layout/gesture_preference.xml
+++ b/res/layout/gesture_preference.xml
@@ -57,7 +57,7 @@
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:orientation="horizontal">
- <FrameLayout
+ <com.android.settings.widget.AspectRatioFrameLayout
android:id="@+id/gesture_animation_frame"
android:layout_width="0dp"
android:layout_height="match_parent"
@@ -74,7 +74,7 @@
android:id="@+id/gesture_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="gone"/>
+ android:background="@color/gestures_setting_background_color"/>
<ImageView
android:id="@+id/gesture_play_button"
@@ -82,10 +82,9 @@
android:layout_height="@dimen/gestures_play_button_size"
android:src="@drawable/ic_gesture_play_button"
android:gravity="center"
- android:layout_gravity="center"
- android:visibility="gone"/>
+ android:layout_gravity="center"/>
- </FrameLayout>
+ </com.android.settings.widget.AspectRatioFrameLayout>
<TextView
android:id="@android:id/summary"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 8fb61dd..218d7f2 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -141,4 +141,9 @@
<attr name="animation" format="reference" />
</declare-styleable>
+ <!-- For AspectRatioFrameLayout -->
+ <declare-styleable name="AspectRatioFrameLayout">
+ <attr name="aspectRatio" format="float" />
+ </declare-styleable>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5073893..369210f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7516,7 +7516,10 @@
<string name="support_escalation_24_7_summary">Our support team is available all day, every day</string>
<!-- Summary text when customer support is closed. [CHAR LIMIT=NONE]-->
- <string name="support_escalation_closed_summary">Phone support hours (local time)<br><b><xliff:g id="operation_hours">%s</xliff:g></b></string>
+ <string name="support_escalation_closed_summary">Search help or come back during support hours (local time):<br><b><xliff:g id="operation_hours">%s</xliff:g></b></string>
+
+ <!-- Summary text to call customer support when there is no internet. [CHAR LIMIT=NONE]-->
+ <string name="support_escalation_no_internet_summary">Phone support hours (local time)<br><b><xliff:g id="operation_hours">%s</xliff:g></b></string>
<!-- Summary text when customer support is unavailable in the region. [CHAR LIMIT=NONE]-->
<string name="support_escalation_unavailable_summary">Search help or explore tips & tricks</string>
@@ -7538,7 +7541,7 @@
</string>
<!-- Title text for a list of international support phone numbers. [CHAR LIMIT=60]-->
- <string name="support_international_phone_title">Traveling aboard?</string>
+ <string name="support_international_phone_title">Traveling abroad?</string>
<!-- Description text warning international phone charge may apply when dialing support numbers. [CHAR LIMIT=NONE]-->
<string name="support_international_phone_summary">International charges may apply</string>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index cb1fac5..b540c8f 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -77,7 +77,7 @@
android:title="@string/doze_title"
android:summary="@string/doze_summary"
android:fragment="com.android.settings.gestures.GestureSettings" >
- <extra android:name=":settings:fragment_args_key"
+ <extra android:name="gesture_scroll_to_preference"
android:value="gesture_pick_up_and_nudge" />
</PreferenceScreen>
diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java
index dd8064f..7befbc2 100644
--- a/src/com/android/settings/DeviceInfoSettings.java
+++ b/src/com/android/settings/DeviceInfoSettings.java
@@ -32,6 +32,8 @@
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
import android.telephony.CarrierConfigManager;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
@@ -377,17 +379,39 @@
private final Context mContext;
private final SummaryLoader mSummaryLoader;
+ private final SubscriptionManager mSubscriptionManager;
+ private final SubscriptionChangeListener mSubscriptionChangeListener;
public SummaryProvider(Context context, SummaryLoader summaryLoader) {
mContext = context;
mSummaryLoader = summaryLoader;
+ mSubscriptionManager = SubscriptionManager.from(mContext);
+ mSubscriptionChangeListener = new SubscriptionChangeListener();
}
@Override
public void setListening(boolean listening) {
if (listening) {
- mSummaryLoader.setSummary(this, mContext.getString(R.string.about_summary,
- Build.VERSION.RELEASE));
+ updateSummary();
+ mSubscriptionManager.addOnSubscriptionsChangedListener(mSubscriptionChangeListener);
+ } else {
+ mSubscriptionManager.removeOnSubscriptionsChangedListener(
+ mSubscriptionChangeListener);
+ }
+ }
+
+ private void updateSummary() {
+ final String formattedPhoneNumbers = DeviceInfoUtils.getFormattedPhoneNumbers(
+ mContext, mSubscriptionManager.getActiveSubscriptionInfoList());
+ mSummaryLoader.setSummary(SummaryProvider.this, formattedPhoneNumbers);
+ }
+
+ private final class SubscriptionChangeListener
+ extends SubscriptionManager.OnSubscriptionsChangedListener {
+
+ @Override
+ public void onSubscriptionsChanged() {
+ updateSummary();
}
}
}
diff --git a/src/com/android/settings/dashboard/SupportItemAdapter.java b/src/com/android/settings/dashboard/SupportItemAdapter.java
index 9493f89..4e9153c 100644
--- a/src/com/android/settings/dashboard/SupportItemAdapter.java
+++ b/src/com/android/settings/dashboard/SupportItemAdapter.java
@@ -198,10 +198,11 @@
builder.setTileTitle(R.string.support_escalation_title)
.setTileSummary(R.string.support_escalation_summary);
} else {
- // Support is not temporarily unavailable.
+ // Support is now temporarily unavailable.
builder.setTileTitle(R.string.support_escalation_title)
.setTileSummary(
- mSupportFeatureProvider.getOperationHours(mActivity, PHONE, null));
+ mSupportFeatureProvider.getOperationHours(mActivity, PHONE, null,
+ true /* hasInternet */));
}
if (hasPhoneOperation) {
builder.setText1(R.string.support_escalation_by_phone)
@@ -222,7 +223,7 @@
operatingHours = mActivity.getString(R.string.support_escalation_24_7_summary);
} else {
operatingHours = mSupportFeatureProvider.getOperationHours(mActivity,
- PHONE, mSelectedCountry);
+ PHONE, mSelectedCountry, false /* hasInternet */);
}
mSupportData.add(new OfflineEscalationData.Builder(mActivity)
.setCountries(mSupportFeatureProvider.getPhoneSupportCountries())
diff --git a/src/com/android/settings/deviceinfo/SimStatus.java b/src/com/android/settings/deviceinfo/SimStatus.java
index ba14e13..4569131 100644
--- a/src/com/android/settings/deviceinfo/SimStatus.java
+++ b/src/com/android/settings/deviceinfo/SimStatus.java
@@ -16,9 +16,6 @@
package com.android.settings.deviceinfo;
-import static android.content.Context.CARRIER_CONFIG_SERVICE;
-import static android.content.Context.TELEPHONY_SERVICE;
-
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -32,7 +29,6 @@
import android.support.v7.preference.Preference;
import android.telephony.CarrierConfigManager;
import android.telephony.CellBroadcastMessage;
-import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
@@ -58,9 +54,13 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
+import com.android.settingslib.DeviceInfoUtils;
import java.util.List;
+import static android.content.Context.CARRIER_CONFIG_SERVICE;
+import static android.content.Context.TELEPHONY_SERVICE;
+
/**
* Display the following information
@@ -393,13 +393,10 @@
mShowICCID = carrierConfig.getBoolean(
CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL);
- String rawNumber = mTelephonyManager.getLine1Number(mSir.getSubscriptionId());
- String formattedNumber = null;
- if (!TextUtils.isEmpty(rawNumber)) {
- formattedNumber = PhoneNumberUtils.formatNumber(rawNumber);
- }
+
// If formattedNumber is null or empty, it'll display as "Unknown".
- setSummaryText(KEY_PHONE_NUMBER, formattedNumber);
+ setSummaryText(KEY_PHONE_NUMBER,
+ DeviceInfoUtils.getFormattedPhoneNumber(getContext(), mSir));
setSummaryText(KEY_IMEI, mPhone.getImei());
setSummaryText(KEY_IMEI_SV, mPhone.getDeviceSvn());
diff --git a/src/com/android/settings/gestures/GesturePreference.java b/src/com/android/settings/gestures/GesturePreference.java
index 76ceba4..cad7297 100644
--- a/src/com/android/settings/gestures/GesturePreference.java
+++ b/src/com/android/settings/gestures/GesturePreference.java
@@ -50,7 +50,8 @@
private Uri mVideoPath;
private MediaPlayer mMediaPlayer;
private MediaMetadataRetriever mMediaMetadata;
- private boolean animationAvailable;
+ private boolean mAnimationAvailable;
+ private boolean mPreviewReady;
public GesturePreference(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -68,7 +69,7 @@
.build();
mMediaMetadata = new MediaMetadataRetriever();
mMediaMetadata.setDataSource(mContext, mVideoPath);
- animationAvailable = true;
+ mAnimationAvailable = true;
} catch (Exception e) {
Log.w(TAG, "Animation resource not found. Will not show animation.");
} finally {
@@ -86,20 +87,11 @@
final ImageView playButton = (ImageView) holder.findViewById(R.id.gesture_play_button);
final View animationFrame = holder.findViewById(R.id.gesture_animation_frame);
- if (!animationAvailable) {
+ if (!mAnimationAvailable) {
animationFrame.setVisibility(View.GONE);
return;
}
- Bitmap bitmap = mMediaMetadata.getFrameAtTime(0);
- if (bitmap != null) {
- imageView.setImageDrawable(new BitmapDrawable(bitmap));
- imageView.setColorFilter(mContext.getResources().getColor(
- R.color.gestures_setting_background_color), PorterDuff.Mode.DARKEN);
- }
- imageView.setVisibility(View.VISIBLE);
- playButton.setVisibility(View.VISIBLE);
-
video.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -119,13 +111,22 @@
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width,
int height) {
- animationFrame.setLayoutParams(new LinearLayout.LayoutParams(width, width));
mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
if (mMediaPlayer != null) {
mMediaPlayer.setSurface(new Surface(surfaceTexture));
+ mMediaPlayer.setOnSeekCompleteListener(
+ new MediaPlayer.OnSeekCompleteListener() {
+ @Override
+ public void onSeekComplete(MediaPlayer mp) {
+ mPreviewReady = true;
+ mMediaPlayer.setOnSeekCompleteListener(null);
+ }
+ });
+
mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
+ mediaPlayer.seekTo(0);
mediaPlayer.setLooping(true);
}
});
@@ -150,7 +151,7 @@
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
- if (mMediaPlayer.isPlaying() && imageView.getVisibility() == View.VISIBLE) {
+ if (mPreviewReady && imageView.getVisibility() == View.VISIBLE) {
imageView.setVisibility(View.GONE);
}
}
diff --git a/src/com/android/settings/gestures/GestureSettings.java b/src/com/android/settings/gestures/GestureSettings.java
index cafba68..a24d810 100644
--- a/src/com/android/settings/gestures/GestureSettings.java
+++ b/src/com/android/settings/gestures/GestureSettings.java
@@ -25,8 +25,12 @@
import android.provider.Settings.Global;
import android.provider.Settings.Secure;
import android.support.v7.preference.Preference;
+import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settings.R;
@@ -51,6 +55,9 @@
private static final String PREF_KEY_PICK_UP_AND_NUDGE = "gesture_pick_up_and_nudge";
private static final String PREF_KEY_SWIPE_DOWN_FINGERPRINT = "gesture_swipe_down_fingerprint";
private static final String DEBUG_DOZE_COMPONENT = "debug.doze.component";
+ private static final String ARG_SCROLL_TO_PREFERENCE = "gesture_scroll_to_preference";
+
+ private int mScrollPosition = -1;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -91,6 +98,27 @@
removePreference(PREF_KEY_SWIPE_DOWN_FINGERPRINT);
}
+ if (savedInstanceState == null) {
+ final Bundle args = getArguments();
+ if (args != null && args.containsKey(ARG_SCROLL_TO_PREFERENCE)) {
+ String prefKey = args.getString(ARG_SCROLL_TO_PREFERENCE);
+ GesturePreference pref = (GesturePreference) findPreference(prefKey);
+ if (pref != null) {
+ mScrollPosition = pref.getOrder();
+ }
+ }
+ }
+
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = super.onCreateView(inflater, container, savedInstanceState);
+ if (mScrollPosition >= 0) {
+ getListView().scrollToPosition(mScrollPosition);
+ }
+ return view;
}
@Override
diff --git a/src/com/android/settings/overlay/SupportFeatureProvider.java b/src/com/android/settings/overlay/SupportFeatureProvider.java
index c535622..4d8e3d6 100644
--- a/src/com/android/settings/overlay/SupportFeatureProvider.java
+++ b/src/com/android/settings/overlay/SupportFeatureProvider.java
@@ -71,7 +71,8 @@
* Returns localized string for operation hours in specified country. If country is null, use
* current country to figure out operation hours.
*/
- CharSequence getOperationHours(Context context, @SupportType int type, String countryCode);
+ CharSequence getOperationHours(Context context, @SupportType int type, String countryCode,
+ boolean hasInternet);
/**
* Returns a localized string indicating estimated wait time for a support time.
diff --git a/src/com/android/settings/widget/AspectRatioFrameLayout.java b/src/com/android/settings/widget/AspectRatioFrameLayout.java
new file mode 100644
index 0000000..14d7921
--- /dev/null
+++ b/src/com/android/settings/widget/AspectRatioFrameLayout.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+
+import com.android.settings.R;
+
+/**
+ * A {@link FrameLayout} with customizable aspect ration.
+ * This is used to avoid dynamically calculating the height for the frame. Default aspect
+ * ratio will be 1 if none is set in layout attribute.
+ */
+public final class AspectRatioFrameLayout extends FrameLayout {
+
+ private float mAspectRatio = 1.0f;
+
+ public AspectRatioFrameLayout(Context context) {
+ this(context, null);
+ }
+
+ public AspectRatioFrameLayout(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public AspectRatioFrameLayout(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ if (attrs != null) {
+ TypedArray array =
+ context.obtainStyledAttributes(attrs, R.styleable.AspectRatioFrameLayout);
+ mAspectRatio = array.getFloat(
+ R.styleable.AspectRatioFrameLayout_aspectRatio, 1.0f);
+ array.recycle();
+ }
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, (int) (widthMeasureSpec / mAspectRatio));
+ }
+
+}