mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-29 13:17:43 +00:00
Allow choosing a ringtone for FindMyPhone
Summary: BUG: 379023 Let users choose a ring tone in the settings. Test Plan: Open settings, choose a ringtone, search for device. Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Subscribers: mtijink, andyholmes, albertvaka, apol, #kde_connect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D10332
This commit is contained in:
parent
82db080a51
commit
4d5d744920
@ -216,5 +216,6 @@
|
||||
<string name="telepathy_permission_explanation">To read and write SMS from your desktop you need to give permission to SMS</string>
|
||||
<string name="telephony_permission_explanation">To see phone calls and SMS from the desktop you need to give permission to phone calls and SMS</string>
|
||||
<string name="telephony_optional_permission_explanation">To see a contact name instead of a phone number you need to give access to the phone\'s contacts</string>
|
||||
<string name="select_ringtone">Select a ringtone</string>
|
||||
|
||||
</resources>
|
||||
|
10
res/xml/findmyphoneplugin_preferences.xml
Normal file
10
res/xml/findmyphoneplugin_preferences.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RingtonePreference
|
||||
android:key="select_ringtone"
|
||||
android:showSilent="false"
|
||||
android:title="@string/select_ringtone"></RingtonePreference>
|
||||
</PreferenceScreen>
|
@ -1,13 +1,34 @@
|
||||
/* Copyright 2018 Nicolas Fella <nicolas.fella@gmx.de>
|
||||
* Copyright 2015 David Edmundson <david@davidedmundson.co.uk>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 @@ public class FindMyPhoneActivity extends Activity {
|
||||
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();
|
||||
|
@ -1,3 +1,23 @@
|
||||
/*
|
||||
* Copyright 2015 David Edmundson <david@davidedmundson.co.uk>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.kde.kdeconnect.Plugins.FindMyPhonePlugin;
|
||||
|
||||
import android.content.Intent;
|
||||
@ -7,14 +27,8 @@ import org.kde.kdeconnect.NetworkPackage;
|
||||
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 @@ public class FindMyPhonePlugin extends Plugin {
|
||||
@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 class FindMyPhonePlugin extends Plugin {
|
||||
public String[] getOutgoingPackageTypes() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSettings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user