Commit 495e7998 authored by Adnan's avatar Adnan Committed by Adnan Begovic

Settings: Point to per-sim ringtone options if on Msim device.

Change-Id: I56244242cece2c0ab732a2edb8d8c57e9d2c29b3
(cherry picked from commit 9be2bd4e)
parent 87b13833
......@@ -1439,4 +1439,6 @@ two in order to insert additional control points. \'Remove\' deletes the selecte
<string name="profile_setup_setup_triggers_description">Please select triggers which will activate this profile</string>
<string name="profile_setup_actions_description">Now configure what happens when the profile is activated</string>
<string name="sound_ringtone_multisim_options">Change default ringtones</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 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.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/sound_settings"
android:key="sound_settings"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
<PreferenceCategory
android:key="category_calls_and_notification"
android:title="@string/sound_category_call_ringtone_vibrate_title"/>
<!-- Do not nest these, or removals in code will break -->
<Preference
android:key="ringtone"
android:title="@string/sound_ringtone_multisim_options"
android:persistent="false" />
<com.android.settings.cyanogenmod.IncreasingRingPreference
android:key="increasing_ring"
android:title="@string/increasing_ring_title"
android:dialogTitle="@string/increasing_ring_title"
android:persistent="false"
android:streamType="ring" />
</PreferenceScreen>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 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.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/sound_settings"
android:key="sound_settings"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
<PreferenceCategory
android:key="category_calls_and_notification"
android:title="@string/sound_category_call_ringtone_vibrate_title"/>
<!-- Do not nest these, or removals in code will break -->
<com.android.settings.DefaultRingtonePreference
android:key="ringtone"
android:title="@string/ringtone_title"
android:dialogTitle="@string/ringtone_title"
android:persistent="false"
android:ringtoneType="ringtone" />
<com.android.settings.cyanogenmod.SystemSettingCheckBoxPreference
android:key="vibrate_when_ringing"
android:title="@string/vibrate_when_ringing_title" />
<com.android.settings.cyanogenmod.IncreasingRingPreference
android:key="increasing_ring"
android:title="@string/increasing_ring_title"
android:dialogTitle="@string/increasing_ring_title"
android:persistent="false"
android:streamType="ring" />
</PreferenceScreen>
......@@ -63,29 +63,6 @@
android:summary="@string/headset_connect_player_summary"
android:defaultValue="false" />
<PreferenceCategory
android:key="category_calls_and_notification"
android:title="@string/sound_category_call_ringtone_vibrate_title"/>
<!-- Do not nest these, or removals in code will break -->
<com.android.settings.DefaultRingtonePreference
android:key="ringtone"
android:title="@string/ringtone_title"
android:dialogTitle="@string/ringtone_title"
android:persistent="false"
android:ringtoneType="ringtone" />
<com.android.settings.cyanogenmod.SystemSettingCheckBoxPreference
android:key="vibrate_when_ringing"
android:title="@string/vibrate_when_ringing_title" />
<com.android.settings.cyanogenmod.IncreasingRingPreference
android:key="increasing_ring"
android:title="@string/increasing_ring_title"
android:dialogTitle="@string/increasing_ring_title"
android:persistent="false"
android:streamType="ring" />
<PreferenceCategory
android:title="@string/volume_notification_description"/>
......
......@@ -16,6 +16,8 @@
package com.android.settings;
import android.content.ComponentName;
import android.telephony.MSimTelephonyManager;
import com.android.settings.bluetooth.DockEventReceiver;
import com.android.settings.hardware.VibratorIntensity;
......@@ -58,7 +60,7 @@ import java.util.Calendar;
import java.util.List;
public class SoundSettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener {
Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener {
private static final String TAG = "SoundSettings";
private static final int DIALOG_NOT_DOCKED = 1;
......@@ -134,6 +136,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements
private CheckBoxPreference mPowerSounds;
private CheckBoxPreference mPowerSoundsVibrate;
private MSimTelephonyManager mSimTelephonyManager;
private Preference mPowerSoundsRingtone;
private Handler mHandler = new Handler() {
......@@ -169,6 +172,14 @@ public class SoundSettings extends SettingsPreferenceFragment implements
int activePhoneType = TelephonyManager.getDefault().getCurrentPhoneType();
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mSimTelephonyManager =
(MSimTelephonyManager) getSystemService(Context.MSIM_TELEPHONY_SERVICE);
if (mSimTelephonyManager.isMultiSimEnabled()) {
addPreferencesFromResource(R.xml.msim_ringtone_settings);
} else {
addPreferencesFromResource(R.xml.ringtone_settings);
}
addPreferencesFromResource(R.xml.sound_settings);
......@@ -252,9 +263,14 @@ public class SoundSettings extends SettingsPreferenceFragment implements
mRingtonePreference = null;
}
// Set a new onclick listener if our preference is inherited from msim_ringtone_settings
if (mRingtonePreference != null && mSimTelephonyManager.isMultiSimEnabled()) {
mRingtonePreference.setOnPreferenceClickListener(this);
}
mRingtoneLookupRunnable = new Runnable() {
public void run() {
if (mRingtonePreference != null) {
if (!mSimTelephonyManager.isMultiSimEnabled() && mRingtonePreference != null) {
updateRingtoneName(RingtoneManager.TYPE_RINGTONE, mRingtonePreference,
MSG_UPDATE_RINGTONE_SUMMARY);
}
......@@ -641,5 +657,22 @@ public class SoundSettings extends SettingsPreferenceFragment implements
ab.setPositiveButton(android.R.string.ok, null);
return ab.create();
}
@Override
public boolean onPreferenceClick(Preference preference) {
if (preference == mRingtonePreference && mSimTelephonyManager.isMultiSimEnabled()) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.putExtra("PACKAGE", "com.android.phone");
intent.putExtra("TARGET_CLASS",
"com.android.phone.MSimCallFeaturesSubSetting");
intent.setComponent(new ComponentName("com.android.phone",
"com.android.phone.SelectSubscription"));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
return true;
}
return false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment