diff --git a/res/values/strings.xml b/res/values/strings.xml --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -216,5 +216,6 @@ To read and write SMS from your desktop you need to give permission to SMS To see phone calls and SMS from the desktop you need to give permission to phone calls and SMS To see a contact name instead of a phone number you need to give access to the phone\'s contacts + Select a ringtone diff --git a/res/xml/findmyphoneplugin_preferences.xml b/res/xml/findmyphoneplugin_preferences.xml new file mode 100644 --- /dev/null +++ b/res/xml/findmyphoneplugin_preferences.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhoneActivity.java b/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhoneActivity.java --- a/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhoneActivity.java +++ b/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhoneActivity.java @@ -1,13 +1,34 @@ +/* Copyright 2018 Nicolas Fella + * Copyright 2015 David Edmundson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ package org.kde.kdeconnect.Plugins.FindMyPhonePlugin; import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.media.AudioManager; import android.media.MediaPlayer; import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; +import android.preference.PreferenceManager; import android.util.Log; import android.view.View; import android.view.Window; @@ -61,13 +82,11 @@ previousVolume = audioManager.getStreamVolume(AudioManager.STREAM_ALARM); audioManager.setStreamVolume(AudioManager.STREAM_ALARM, audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM), 0); - Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); - if (alert == null) { - alert = RingtoneManager.getValidRingtoneUri(getApplicationContext()); - } + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + String ringtone = prefs.getString("select_ringtone", ""); mediaPlayer = new MediaPlayer(); - mediaPlayer.setDataSource(this, alert); + mediaPlayer.setDataSource(this, Uri.parse(ringtone)); mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); mediaPlayer.setLooping(true); mediaPlayer.prepare(); diff --git a/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java b/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java --- a/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java +++ b/src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java @@ -1,3 +1,23 @@ +/* + * Copyright 2015 David Edmundson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + package org.kde.kdeconnect.Plugins.FindMyPhonePlugin; import android.content.Intent; @@ -7,14 +27,8 @@ import org.kde.kdeconnect.Plugins.Plugin; import org.kde.kdeconnect_tp.R; - -/** - * Created by vineet on 1/11/14. - * and David Edmundson 2015 - */ public class FindMyPhonePlugin extends Plugin { - public final static String PACKAGE_TYPE_FINDMYPHONE = "kdeconnect.findmyphone"; public final static String PACKAGE_TYPE_FINDMYPHONE_REQUEST = "kdeconnect.findmyphone.request"; @Override @@ -30,7 +44,7 @@ @Override public boolean onPackageReceived(NetworkPackage np) { - Intent intent = new Intent(context,FindMyPhoneActivity.class); + Intent intent = new Intent(context, FindMyPhoneActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); return true; @@ -46,4 +60,10 @@ public String[] getOutgoingPackageTypes() { return new String[0]; } + + @Override + public boolean hasSettings() { + return true; + } + }