mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 06:05:12 +00:00
Added preference to disable incoming file notification sound.
This commit is contained in:
@@ -8,10 +8,12 @@ import android.app.PendingIntent;
|
|||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
import android.support.v4.app.TaskStackBuilder;
|
import android.support.v4.app.TaskStackBuilder;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -33,7 +35,7 @@ public class SharePlugin extends Plugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPluginName() {
|
public String getPluginName() {
|
||||||
return "share_ping";
|
return "plugin_share";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -53,7 +55,7 @@ public class SharePlugin extends Plugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSettings() {
|
public boolean hasSettings() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -110,6 +112,7 @@ public class SharePlugin extends Plugin {
|
|||||||
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
notificationManager.notify(notificationId, noti);
|
notificationManager.notify(notificationId, noti);
|
||||||
|
|
||||||
@@ -155,15 +158,23 @@ public class SharePlugin extends Plugin {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Resources res = context.getResources();
|
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()))
|
.setContentTitle(res.getString(R.string.received_file_title, device.getName()))
|
||||||
.setContentText(res.getString(R.string.received_file_text, filename))
|
.setContentText(res.getString(R.string.received_file_text, filename))
|
||||||
.setContentIntent(resultPendingIntent)
|
.setContentIntent(resultPendingIntent)
|
||||||
.setTicker(res.getString(R.string.received_file_title, device.getName()))
|
.setTicker(res.getString(R.string.received_file_title, device.getName()))
|
||||||
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true);
|
||||||
.setDefaults(Notification.DEFAULT_SOUND)
|
|
||||||
.build();
|
|
||||||
|
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 notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
notificationManager.notify(notificationId, noti);
|
notificationManager.notify(notificationId, noti);
|
||||||
|
|
||||||
@@ -214,7 +225,7 @@ public class SharePlugin extends Plugin {
|
|||||||
.setTicker(res.getString(R.string.received_url_title, device.getName()))
|
.setTicker(res.getString(R.string.received_url_title, device.getName()))
|
||||||
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setDefaults(Notification.DEFAULT_SOUND)
|
.setDefaults(Notification.DEFAULT_ALL)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
@@ -87,4 +87,7 @@
|
|||||||
<string name="device_name_preference_summary">%s</string>
|
<string name="device_name_preference_summary">%s</string>
|
||||||
<string name="invalid_device_name">Invalid device name</string>
|
<string name="invalid_device_name">Invalid device name</string>
|
||||||
<string name="shareplugin_text_saved">Received text, saved to clipboard</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>
|
</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>
|
Reference in New Issue
Block a user