Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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

Change-Id: I56244242cece2c0ab732a2edb8d8c57e9d2c29b3
(cherry picked from commit 9be2bd4e)
parent 87b13833
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -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_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="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>
</resources>
+38 −0
Original line number Original line Diff line number Diff line
<?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>
+44 −0
Original line number Original line Diff line number Diff line
<?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>
+0 −23
Original line number Original line Diff line number Diff line
@@ -63,29 +63,6 @@
            android:summary="@string/headset_connect_player_summary"
            android:summary="@string/headset_connect_player_summary"
            android:defaultValue="false" />
            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
    <PreferenceCategory
            android:title="@string/volume_notification_description"/>
            android:title="@string/volume_notification_description"/>


+35 −2
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.settings;
package com.android.settings;


import android.content.ComponentName;
import android.telephony.MSimTelephonyManager;
import com.android.settings.bluetooth.DockEventReceiver;
import com.android.settings.bluetooth.DockEventReceiver;
import com.android.settings.hardware.VibratorIntensity;
import com.android.settings.hardware.VibratorIntensity;


@@ -58,7 +60,7 @@ import java.util.Calendar;
import java.util.List;
import java.util.List;


public class SoundSettings extends SettingsPreferenceFragment implements
public class SoundSettings extends SettingsPreferenceFragment implements
        Preference.OnPreferenceChangeListener {
        Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener {
    private static final String TAG = "SoundSettings";
    private static final String TAG = "SoundSettings";


    private static final int DIALOG_NOT_DOCKED = 1;
    private static final int DIALOG_NOT_DOCKED = 1;
@@ -134,6 +136,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements


    private CheckBoxPreference mPowerSounds;
    private CheckBoxPreference mPowerSounds;
    private CheckBoxPreference mPowerSoundsVibrate;
    private CheckBoxPreference mPowerSoundsVibrate;
    private MSimTelephonyManager mSimTelephonyManager;
    private Preference mPowerSoundsRingtone;
    private Preference mPowerSoundsRingtone;


    private Handler mHandler = new Handler() {
    private Handler mHandler = new Handler() {
@@ -169,6 +172,14 @@ public class SoundSettings extends SettingsPreferenceFragment implements
        int activePhoneType = TelephonyManager.getDefault().getCurrentPhoneType();
        int activePhoneType = TelephonyManager.getDefault().getCurrentPhoneType();


        mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        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);
        addPreferencesFromResource(R.xml.sound_settings);


@@ -252,9 +263,14 @@ public class SoundSettings extends SettingsPreferenceFragment implements
            mRingtonePreference = null;
            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() {
        mRingtoneLookupRunnable = new Runnable() {
            public void run() {
            public void run() {
                if (mRingtonePreference != null) {
                if (!mSimTelephonyManager.isMultiSimEnabled() && mRingtonePreference != null) {
                    updateRingtoneName(RingtoneManager.TYPE_RINGTONE, mRingtonePreference,
                    updateRingtoneName(RingtoneManager.TYPE_RINGTONE, mRingtonePreference,
                            MSG_UPDATE_RINGTONE_SUMMARY);
                            MSG_UPDATE_RINGTONE_SUMMARY);
                }
                }
@@ -641,5 +657,22 @@ public class SoundSettings extends SettingsPreferenceFragment implements
        ab.setPositiveButton(android.R.string.ok, null);
        ab.setPositiveButton(android.R.string.ok, null);
        return ab.create();
        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;
    }
}
}