Merge "[Settings] Rename title of SIM UI when changed" into tm-dev am: 7bdf717410
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/17983870 Change-Id: I064026298e1dedeb9bdd8cc170c413aa20739deb Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -37,6 +37,7 @@ import androidx.preference.Preference;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Settings.MobileNetworkActivity;
|
import com.android.settings.Settings.MobileNetworkActivity;
|
||||||
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.datausage.BillingCyclePreferenceController;
|
import com.android.settings.datausage.BillingCyclePreferenceController;
|
||||||
import com.android.settings.datausage.DataUsageSummaryPreferenceController;
|
import com.android.settings.datausage.DataUsageSummaryPreferenceController;
|
||||||
import com.android.settings.network.ActiveSubscriptionsListener;
|
import com.android.settings.network.ActiveSubscriptionsListener;
|
||||||
@@ -54,6 +55,7 @@ import com.android.settingslib.utils.ThreadUtils;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||||
public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
|
public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
|
||||||
@@ -275,17 +277,37 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
|
|||||||
Log.d(LOG_TAG, "Callback during onResume()");
|
Log.d(LOG_TAG, "Callback during onResume()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final SubscriptionInfo subInfo = SubscriptionUtil
|
||||||
|
.getSubscriptionOrDefault(getContext(), mSubId);
|
||||||
|
|
||||||
|
if (subInfo != null) {
|
||||||
|
/**
|
||||||
|
* Update the title when SIM stats got changed
|
||||||
|
*/
|
||||||
|
final Consumer<Activity> renameTitle = activity -> {
|
||||||
|
if (activity != null && !activity.isFinishing()) {
|
||||||
|
if (activity instanceof SettingsActivity) {
|
||||||
|
final CharSequence displayName = SubscriptionUtil
|
||||||
|
.getUniqueSubscriptionDisplayName(subInfo, activity);
|
||||||
|
((SettingsActivity)activity).setTitle(displayName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ThreadUtils.postOnMainThread(() -> renameTitle.accept(getActivity()));
|
||||||
|
}
|
||||||
|
|
||||||
mActiveSubscriptionsListenerCount++;
|
mActiveSubscriptionsListenerCount++;
|
||||||
if (mActiveSubscriptionsListenerCount != 1) {
|
if (mActiveSubscriptionsListenerCount != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SubscriptionUtil.getSubscriptionOrDefault(getContext(), mSubId) == null) {
|
|
||||||
finishFragment();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadUtils.postOnMainThread(() -> {
|
ThreadUtils.postOnMainThread(() -> {
|
||||||
|
if (subInfo == null) {
|
||||||
|
finishFragment();
|
||||||
|
return;
|
||||||
|
}
|
||||||
mActiveSubscriptionsListenerCount = 0;
|
mActiveSubscriptionsListenerCount = 0;
|
||||||
redrawPreferenceControllers();
|
redrawPreferenceControllers();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user