Differential D10332 Diff 27746 src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhoneActivity.java
Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhoneActivity.java
1 | /* Copyright 2018 Nicolas Fella <nicolas.fella@gmx.de> | ||||
---|---|---|---|---|---|
2 | * Copyright 2015 David Edmundson <david@davidedmundson.co.uk> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
1 | package org.kde.kdeconnect.Plugins.FindMyPhonePlugin; | 20 | package org.kde.kdeconnect.Plugins.FindMyPhonePlugin; | ||
2 | 21 | | |||
3 | import android.app.Activity; | 22 | import android.app.Activity; | ||
4 | import android.content.Context; | 23 | import android.content.Context; | ||
5 | import android.content.Intent; | 24 | import android.content.Intent; | ||
25 | import android.content.SharedPreferences; | ||||
6 | import android.media.AudioManager; | 26 | import android.media.AudioManager; | ||
7 | import android.media.MediaPlayer; | 27 | import android.media.MediaPlayer; | ||
8 | import android.media.RingtoneManager; | 28 | import android.media.RingtoneManager; | ||
9 | import android.net.Uri; | 29 | import android.net.Uri; | ||
10 | import android.os.Bundle; | 30 | import android.os.Bundle; | ||
31 | import android.preference.PreferenceManager; | ||||
11 | import android.util.Log; | 32 | import android.util.Log; | ||
12 | import android.view.View; | 33 | import android.view.View; | ||
13 | import android.view.Window; | 34 | import android.view.Window; | ||
14 | import android.view.WindowManager; | 35 | import android.view.WindowManager; | ||
15 | 36 | | |||
16 | import org.kde.kdeconnect_tp.R; | 37 | import org.kde.kdeconnect_tp.R; | ||
17 | 38 | | |||
18 | public class FindMyPhoneActivity extends Activity { | 39 | public class FindMyPhoneActivity extends Activity { | ||
Show All 37 Lines | |||||
56 | protected void onStart() { | 77 | protected void onStart() { | ||
57 | super.onStart(); | 78 | super.onStart(); | ||
58 | 79 | | |||
59 | try { | 80 | try { | ||
60 | // Make sure we are heard even when the phone is silent, restore original volume later | 81 | // Make sure we are heard even when the phone is silent, restore original volume later | ||
61 | previousVolume = audioManager.getStreamVolume(AudioManager.STREAM_ALARM); | 82 | previousVolume = audioManager.getStreamVolume(AudioManager.STREAM_ALARM); | ||
62 | audioManager.setStreamVolume(AudioManager.STREAM_ALARM, audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM), 0); | 83 | audioManager.setStreamVolume(AudioManager.STREAM_ALARM, audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM), 0); | ||
63 | 84 | | |||
64 | Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); | 85 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); | ||
65 | if (alert == null) { | 86 | String ringtone = prefs.getString("select_ringtone", ""); | ||
66 | alert = RingtoneManager.getValidRingtoneUri(getApplicationContext()); | | |||
67 | } | | |||
68 | 87 | | |||
69 | mediaPlayer = new MediaPlayer(); | 88 | mediaPlayer = new MediaPlayer(); | ||
70 | mediaPlayer.setDataSource(this, alert); | 89 | mediaPlayer.setDataSource(this, Uri.parse(ringtone)); | ||
apol: It's not defaulting to RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE), right? | |||||
nicolasfella: It should use the same default like before | |||||
71 | mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); | 90 | mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); | ||
72 | mediaPlayer.setLooping(true); | 91 | mediaPlayer.setLooping(true); | ||
73 | mediaPlayer.prepare(); | 92 | mediaPlayer.prepare(); | ||
74 | mediaPlayer.start(); | 93 | mediaPlayer.start(); | ||
75 | 94 | | |||
76 | } catch (Exception e) { | 95 | } catch (Exception e) { | ||
77 | Log.e("FindMyPhoneActivity", "Exception", e); | 96 | Log.e("FindMyPhoneActivity", "Exception", e); | ||
78 | } | 97 | } | ||
Show All 14 Lines |
It's not defaulting to RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE), right?