Settings: enable SIM card ringtone only if slot not empty [1/2]
same as in SIM card settings page Change-Id: I3d0478080fdb838e0b730fdf7900dfa2f2e2ffe0 Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com> Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
This commit is contained in:
@@ -8417,12 +8417,6 @@ Data usage charges may apply.</string>
|
||||
<!-- Sound: Title for the option defining the phone ringtone. [CHAR LIMIT=30] -->
|
||||
<string name="ringtone_title">Phone ringtone</string>
|
||||
|
||||
<!-- Sound: Title for the option defining the phone ringtone for slot1 on Muilti SIM device. [CHAR LIMIT=50] -->
|
||||
<string name="ringtone1_title">Phone ringtone - SIM 1</string>
|
||||
|
||||
<!-- Sound: Title for the option defining the phone ringtone for slot2 on Muilti SIM device. [CHAR LIMIT=50] -->
|
||||
<string name="ringtone2_title">Phone ringtone - SIM 2</string>
|
||||
|
||||
<!-- Sound: Title for the option defining the default notification sound. [CHAR LIMIT=30] -->
|
||||
<string name="notification_ringtone_title">Default notification sound</string>
|
||||
|
||||
@@ -14413,4 +14407,9 @@ Data usage charges may apply.</string>
|
||||
<!-- Title for supervision PIN verification screen [CHAR LIMIT=60] -->
|
||||
<string name="supervision_full_screen_pin_verification_title">Enter supervision PIN</string>
|
||||
<string name="accessibility_illustration_content_description"><xliff:g id="feature" example="Select to Speak">%1$s</xliff:g> animation</string>
|
||||
|
||||
<!-- Sound: Title for the option defining the phone ringtone for slot1 on Muilti SIM device. [CHAR LIMIT=50] -->
|
||||
<string name="ringtone1_title">Phone ringtone - SIM 1</string>
|
||||
<!-- Sound: Title for the option defining the phone ringtone for slot2 on Muilti SIM device. [CHAR LIMIT=50] -->
|
||||
<string name="ringtone2_title">Phone ringtone - SIM 2</string>
|
||||
</resources>
|
||||
|
||||
@@ -41,6 +41,7 @@ public class PhoneRingtone2PreferenceController extends RingtonePreferenceContro
|
||||
DefaultRingtonePreference ringtonePreference =
|
||||
(DefaultRingtonePreference) screen.findPreference(KEY_PHONE_RINGTONE2);
|
||||
ringtonePreference.setSlotId(SLOT_ID);
|
||||
ringtonePreference.setEnabled(hasCard());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,4 +60,10 @@ public class PhoneRingtone2PreferenceController extends RingtonePreferenceContro
|
||||
public int getRingtoneType() {
|
||||
return RingtoneManager.TYPE_RINGTONE;
|
||||
}
|
||||
|
||||
private boolean hasCard() {
|
||||
TelephonyManager telephonyManager =
|
||||
(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
return telephonyManager.hasIccCard(SLOT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.android.settings.Utils;
|
||||
|
||||
public class PhoneRingtonePreferenceController extends RingtonePreferenceControllerBase {
|
||||
|
||||
private static final int SLOT_ID = 0;
|
||||
private static final String KEY_PHONE_RINGTONE = "phone_ringtone";
|
||||
|
||||
public PhoneRingtonePreferenceController(Context context) {
|
||||
@@ -48,6 +49,7 @@ public class PhoneRingtonePreferenceController extends RingtonePreferenceControl
|
||||
DefaultRingtonePreference ringtonePreference =
|
||||
(DefaultRingtonePreference) screen.findPreference(KEY_PHONE_RINGTONE);
|
||||
ringtonePreference.setTitle(mContext.getString(R.string.ringtone1_title));
|
||||
ringtonePreference.setEnabled(hasCard());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,4 +75,10 @@ public class PhoneRingtonePreferenceController extends RingtonePreferenceControl
|
||||
return Flags.enableRingtoneHapticsCustomization() && mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_ringtoneVibrationSettingsSupported);
|
||||
}
|
||||
|
||||
private boolean hasCard() {
|
||||
TelephonyManager telephonyManager =
|
||||
(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
return telephonyManager.hasIccCard(SLOT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user