mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 05:37:43 +00:00
Added preference to disable incoming file notification sound.
This commit is contained in:
parent
400b35216d
commit
8e0daa69cc
@ -8,10 +8,12 @@ import android.app.PendingIntent;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
import android.util.Log;
|
||||
@ -33,7 +35,7 @@ public class SharePlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "share_ping";
|
||||
return "plugin_share";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,7 +55,7 @@ public class SharePlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public boolean hasSettings() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,6 +112,7 @@ public class SharePlugin extends Plugin {
|
||||
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setAutoCancel(true)
|
||||
.build();
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(notificationId, noti);
|
||||
|
||||
@ -155,15 +158,23 @@ public class SharePlugin extends Plugin {
|
||||
);
|
||||
|
||||
Resources res = context.getResources();
|
||||
Notification noti = new NotificationCompat.Builder(context)
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
|
||||
.setContentTitle(res.getString(R.string.received_file_title, device.getName()))
|
||||
.setContentText(res.getString(R.string.received_file_text, filename))
|
||||
.setContentIntent(resultPendingIntent)
|
||||
.setTicker(res.getString(R.string.received_file_title, device.getName()))
|
||||
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setAutoCancel(true)
|
||||
.setDefaults(Notification.DEFAULT_SOUND)
|
||||
.build();
|
||||
.setAutoCancel(true);
|
||||
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (prefs.getBoolean("share_notification_preference", true)) {
|
||||
builder.setDefaults(Notification.DEFAULT_ALL);
|
||||
}
|
||||
|
||||
Notification noti = builder.build();
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(notificationId, noti);
|
||||
|
||||
@ -214,7 +225,7 @@ public class SharePlugin extends Plugin {
|
||||
.setTicker(res.getString(R.string.received_url_title, device.getName()))
|
||||
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setAutoCancel(true)
|
||||
.setDefaults(Notification.DEFAULT_SOUND)
|
||||
.setDefaults(Notification.DEFAULT_ALL)
|
||||
.build();
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
@ -87,4 +87,7 @@
|
||||
<string name="device_name_preference_summary">%s</string>
|
||||
<string name="invalid_device_name">Invalid device name</string>
|
||||
<string name="shareplugin_text_saved">Received text, saved to clipboard</string>
|
||||
<string name="share_notification_preference">Noisy notifications</string>
|
||||
<string name="share_notification_preference_summary">Vibrate and play a sound when receiving a file</string>
|
||||
|
||||
</resources>
|
||||
|
13
src/main/res/xml/plugin_share_preferences.xml
Normal file
13
src/main/res/xml/plugin_share_preferences.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?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">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:id="@+id/share_notification_preference"
|
||||
android:key="share_notification_preference"
|
||||
android:title="@string/share_notification_preference"
|
||||
android:summary="@string/share_notification_preference_summary"
|
||||
android:defaultValue="true" />
|
||||
|
||||
</PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user