From af5c05392ba7b9baf3f71b185f166104c14cf8d1 Mon Sep 17 00:00:00 2001 From: Wenting Xiong Date: Wed, 28 Nov 2018 18:22:21 +0900 Subject: [PATCH] Fix issue that the wifi calling text cannot be customized based on sim Some carriers have requirements that the wifi calling text should be customizable. However, the resources for the wifi calling text are not obtained based on sim. So it cannot be customized per sim for multi sim device. To solve this issue, obtain the resources with specified sim. Test: manual - Checked that the wifi calling text could be customized based on sim. Bug: 117257109 Change-Id: I6b3f6b06c9cc984ee6a68a19ae317b5d1d4e48e2 --- res/values/strings.xml | 2 +- .../wifi/calling/WifiCallingSettings.java | 31 +++++++++++++++++++ .../calling/WifiCallingSettingsForSub.java | 6 ++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 039fb13e070..8035d9f8cf4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -2499,7 +2499,7 @@ "1" - When Wi-Fi calling is on, your phone can route calls via Wi-Fi networks or your carrier\u2019s network, depending on your preference and which signal is stronger. Before turning on this feature, check with your carrier regarding fees and other details. + When Wi-Fi calling is on, your phone can route calls via Wi-Fi networks or your carrier\u2019s network, depending on your preference and which signal is stronger. Before turning on this feature, check with your carrier regarding fees and other details.%1$s diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettings.java b/src/com/android/settings/wifi/calling/WifiCallingSettings.java index b02d6c60b4f..bc2441619b0 100644 --- a/src/com/android/settings/wifi/calling/WifiCallingSettings.java +++ b/src/com/android/settings/wifi/calling/WifiCallingSettings.java @@ -30,6 +30,7 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; import com.android.ims.ImsManager; +import com.android.internal.util.CollectionUtils; import com.android.settings.R; import com.android.settings.core.InstrumentedFragment; import com.android.settings.search.actionbar.SearchMenuController; @@ -53,6 +54,24 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes private WifiCallingViewPagerAdapter mPagerAdapter; private SlidingTabLayout mTabLayout; + private final class InternalViewPagerListener implements + RtlCompatibleViewPager.OnPageChangeListener { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + // Do nothing. + } + + @Override + public void onPageSelected(int position) { + updateTitleForCurrentSub(); + } + + @Override + public void onPageScrollStateChanged(int state) { + // Do nothing. + } + } + @Override public int getMetricsCategory() { return SettingsEnums.WIFI_CALLING; @@ -68,6 +87,7 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes mPagerAdapter = new WifiCallingViewPagerAdapter(getChildFragmentManager(), mViewPager); mViewPager.setAdapter(mPagerAdapter); + mViewPager.addOnPageChangeListener(new InternalViewPagerListener()); return view; } @@ -93,6 +113,8 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes } else { mTabLayout.setVisibility(View.GONE); } + + updateTitleForCurrentSub(); } @Override @@ -163,4 +185,13 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes } } } + + private void updateTitleForCurrentSub() { + if (CollectionUtils.size(mSil) > 1) { + final int subId = mSil.get(mViewPager.getCurrentItem()).getSubscriptionId(); + final String title = SubscriptionManager.getResourcesForSubId(getContext(), subId) + .getString(R.string.wifi_calling_settings_title); + getActivity().getActionBar().setTitle(title); + } + } } diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java index 40cc0dcdf7f..96f8a2d3f9f 100644 --- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java +++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java @@ -23,6 +23,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.res.Resources; import android.os.Bundle; import android.os.PersistableBundle; import android.telephony.CarrierConfigManager; @@ -160,8 +161,9 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment mEmptyView = getView().findViewById(android.R.id.empty); setEmptyView(mEmptyView); - String emptyViewText = activity.getString(R.string.wifi_calling_off_explanation) - + activity.getString(R.string.wifi_calling_off_explanation_2); + final Resources res = SubscriptionManager.getResourcesForSubId(getActivity(), mSubId); + String emptyViewText = res.getString(R.string.wifi_calling_off_explanation, + res.getString(R.string.wifi_calling_off_explanation_2)); mEmptyView.setText(emptyViewText); mSwitchBar = getView().findViewById(R.id.switch_bar);