blob: 9f9f832b100a67e5f3612c6ccf01b3bc7d5f963d [file] [log] [blame]
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settings;
18
19
20import android.content.Context;
21import android.content.Intent;
22import android.media.RingtoneManager;
23import android.net.Uri;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080024import android.util.AttributeSet;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080025
26public class DefaultRingtonePreference extends RingtonePreference {
27 private static final String TAG = "DefaultRingtonePreference";
Andre Lago3e398c82016-07-25 14:12:28 +010028
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080029 public DefaultRingtonePreference(Context context, AttributeSet attrs) {
30 super(context, attrs);
31 }
32
33 @Override
Jason Monk39b46742015-09-10 15:52:51 -040034 public void onPrepareRingtonePickerIntent(Intent ringtonePickerIntent) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080035 super.onPrepareRingtonePickerIntent(ringtonePickerIntent);
Andre Lago3e398c82016-07-25 14:12:28 +010036
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080037 /*
38 * Since this preference is for choosing the default ringtone, it
39 * doesn't make sense to show a 'Default' item.
40 */
41 ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, false);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080042 }
43
44 @Override
45 protected void onSaveRingtone(Uri ringtoneUri) {
Andre Lago3e398c82016-07-25 14:12:28 +010046 RingtoneManager.setActualDefaultRingtoneUri(mUserContext, getRingtoneType(), ringtoneUri);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080047 }
48
49 @Override
50 protected Uri onRestoreRingtone() {
Andre Lago3e398c82016-07-25 14:12:28 +010051 return RingtoneManager.getActualDefaultRingtoneUri(mUserContext, getRingtoneType());
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080052 }
Andre Lago3e398c82016-07-25 14:12:28 +010053
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080054}