diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index bd649760..629a7ada 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -81,7 +81,7 @@
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index be25f6a1..e38817a5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -29,21 +29,25 @@
Open remote control
Open touchpad control
Move a finger on the screen to move the mouse cursor
+ Set two finger tap action
+ Set three finger tap action
mousepad_double_tap_key
mousepad_triple_tap_key
- right
- middle
- Set Two Finger Tap Action
- @string/mousepad_right_value
- @string/mousepad_middle_value
- Set Three Finger Tap Action
- Right click
- Middle click
+
+ - Right click
+ - Middle click
+
+ right
+ middle
+
+ - right
+ - middle
+
Connected devices
Available devices
Remembered devices
Plugins failed to load (tap for more info):
- Select plugins
+ Plugin settings
Unpair
Paired device not reachable
Unknown device
@@ -83,17 +87,30 @@
Next
Volume
Multimedia Settings
- Interval Time
- Adjust the time to fast forward or rewind a multimedia file.
+ Forward/rewind buttons
+ Adjust the time to fast forward/rewind when pressed.
mpris_interval_time
+
+ - 10 seconds
+ - 20 seconds
+ - 30 seconds
+ - 1 minute
+ - 2 minutes
+
10000000
+
+ - 10000000
+ - 20000000
+ - 30000000
+ - 60000000
+ - 120000000
+
Share To...
This device uses an old protocol version
This device uses a newer protocol version
General Settings
Settings
%s settings
- _preferences
Device name
%s
Invalid device name
@@ -103,7 +120,7 @@
Noisy notifications
Vibrate and play a sound when receiving a file
Notification filter
- Notifications will be synchronized for selected applications
+ Notifications will be synchronized for the selected apps.
Internal storage
All files
SD card %d
@@ -115,29 +132,4 @@
Use this option only if your device is not automatically detected. Enter IP address or hostname below and touch the button to add it to the list. Touch an existing item to remove it from the list.
%1$s on %2$s
-
- - 10 seconds
- - 20 seconds
- - 30 seconds
- - 1 minute
- - 2 minutes
-
-
- - 10000000
- - 20000000
- - 30000000
- - 60000000
- - 120000000
-
-
-
- - @string/mousepad_right_click
- - @string/mousepad_middle_click
-
-
-
- - @string/mousepad_right_value
- - @string/mousepad_middle_value
-
-
diff --git a/src/org/kde/kdeconnect/Device.java b/src/org/kde/kdeconnect/Device.java
index 4aac6419..b9a876b5 100644
--- a/src/org/kde/kdeconnect/Device.java
+++ b/src/org/kde/kdeconnect/Device.java
@@ -558,7 +558,15 @@ public class Device implements BaseLink.PackageReceiver {
//
public Plugin getPlugin(String name) {
- return plugins.get(name);
+ return getPlugin(name, false);
+ }
+
+ public Plugin getPlugin(String name, boolean includeFailed) {
+ Plugin plugin = plugins.get(name);
+ if (includeFailed && plugin == null) {
+ plugin = failedPlugins.get(name);
+ }
+ return plugin;
}
private synchronized void addPlugin(final String name) {
diff --git a/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationsPlugin.java b/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationsPlugin.java
index ab6383fd..e4f08e58 100644
--- a/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationsPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/NotificationsPlugin/NotificationsPlugin.java
@@ -38,6 +38,7 @@ import org.kde.kdeconnect.Helpers.AppsHelper;
import org.kde.kdeconnect.NetworkPackage;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.UserInterface.DeviceActivity;
+import org.kde.kdeconnect.UserInterface.SettingsActivity;
import org.kde.kdeconnect_tp.R;
public class NotificationsPlugin extends Plugin implements NotificationReceiver.NotificationListener {
@@ -67,13 +68,42 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
return true;
}
+ @Override
+ public void startPreferencesActivity(final SettingsActivity parentActivity) {
+ if (hasPermission()) {
+ Intent intent = new Intent(parentActivity, NotificationFilterActivity.class);
+ parentActivity.startActivity(intent);
+ } else {
+ new AlertDialog.Builder(parentActivity)
+ .setTitle(R.string.pref_plugin_notifications)
+ .setMessage(R.string.no_permissions)
+ .setPositiveButton(R.string.open_settings, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ Intent intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
+ parentActivity.startActivityForResult(intent, DeviceActivity.RESULT_NEEDS_RELOAD);
+ }
+ })
+ .setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ //Do nothing
+ }
+ })
+ .create().show();
+
+ }
+ }
+
@Override
public boolean isEnabledByDefault() {
return true;
}
-
-
+ private boolean hasPermission() {
+ String notificationListenerList = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners");
+ return (notificationListenerList != null && notificationListenerList.contains(context.getPackageName()));
+ }
static class NotificationId {
String packageName;
@@ -136,9 +166,7 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
return false;
}
- //Check for permissions
- String notificationListenerList = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners");
- if (notificationListenerList != null && notificationListenerList.contains(context.getPackageName())) {
+ if (hasPermission()) {
NotificationReceiver.RunCommand(context, new NotificationReceiver.InstanceCallback() {
@Override
public void onServiceStart(NotificationReceiver service) {
diff --git a/src/org/kde/kdeconnect/Plugins/Plugin.java b/src/org/kde/kdeconnect/Plugins/Plugin.java
index aca3b8d6..818b05e4 100644
--- a/src/org/kde/kdeconnect/Plugins/Plugin.java
+++ b/src/org/kde/kdeconnect/Plugins/Plugin.java
@@ -23,18 +23,22 @@ package org.kde.kdeconnect.Plugins;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
+import android.content.Intent;
import android.graphics.drawable.Drawable;
+import android.preference.PreferenceActivity;
import android.widget.Button;
import org.kde.kdeconnect.Device;
import org.kde.kdeconnect.NetworkPackage;
+import org.kde.kdeconnect.UserInterface.PluginSettingsActivity;
+import org.kde.kdeconnect.UserInterface.SettingsActivity;
public abstract class Plugin {
protected Device device;
protected Context context;
- public void setContext(Context context, Device device) {
+ public final void setContext(Context context, Device device) {
this.device = device;
this.context = context;
}
@@ -71,12 +75,24 @@ public abstract class Plugin {
*/
public abstract boolean isEnabledByDefault();
-
/**
* Return true if this plugin needs an specific UI settings.
*/
public abstract boolean hasSettings();
+ /**
+ * If hasSettings returns true, this will be called when the user
+ * wants to access this plugin preferences and should launch some
+ * kind of interface. The default implementation will launch a
+ * SettingsActivity with content from "yourplugin"_preferences.xml.
+ */
+ public void startPreferencesActivity(SettingsActivity parentActivity) {
+ Intent intent = new Intent(parentActivity, PluginSettingsActivity.class);
+ intent.putExtra("plugin_display_name", getDisplayName());
+ intent.putExtra("plugin_name", getPluginName());
+ parentActivity.startActivity(intent);
+ }
+
/**
* Initialize the listeners and structures in your plugin.
* Should return true if initialization was successful.
diff --git a/src/org/kde/kdeconnect/UserInterface/PluginSettingsActivity.java b/src/org/kde/kdeconnect/UserInterface/PluginSettingsActivity.java
index 240c16c6..f359056f 100644
--- a/src/org/kde/kdeconnect/UserInterface/PluginSettingsActivity.java
+++ b/src/org/kde/kdeconnect/UserInterface/PluginSettingsActivity.java
@@ -20,12 +20,10 @@
package org.kde.kdeconnect.UserInterface;
-import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
-import android.util.Log;
-import org.kde.kdeconnect.Plugins.NotificationsPlugin.NotificationFilterActivity;
+import org.kde.kdeconnect_tp.R;
public class PluginSettingsActivity extends PreferenceActivity {
@@ -33,14 +31,12 @@ public class PluginSettingsActivity extends PreferenceActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- String resource_name = getIntent().getStringExtra(Intent.EXTRA_INTENT);
- if (resource_name.equals("plugin_notifications_preferences")){
- Intent intent = new Intent(PluginSettingsActivity.this,NotificationFilterActivity.class);
- startActivity(intent);
- finish();
- }else {
- int resource_file = getResources().getIdentifier(resource_name, "xml", getPackageName());
- addPreferencesFromResource(resource_file);
- }
+ String pluginDisplayName = getIntent().getStringExtra("plugin_display_name");
+ setTitle(getString(R.string.plugin_settings_with_name, pluginDisplayName));
+
+ String pluginName = getIntent().getStringExtra("plugin_name");
+ int resFile = getResources().getIdentifier(pluginName + "_preferences", "xml", getPackageName());
+ addPreferencesFromResource(resFile);
}
+
}
diff --git a/src/org/kde/kdeconnect/UserInterface/SettingsActivity.java b/src/org/kde/kdeconnect/UserInterface/SettingsActivity.java
index 3950d09f..e6bdae71 100644
--- a/src/org/kde/kdeconnect/UserInterface/SettingsActivity.java
+++ b/src/org/kde/kdeconnect/UserInterface/SettingsActivity.java
@@ -26,11 +26,13 @@ import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
+import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import org.kde.kdeconnect.BackgroundService;
import org.kde.kdeconnect.Device;
+import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect_tp.R;
@@ -72,7 +74,7 @@ public class SettingsActivity extends PreferenceActivity {
if (info.hasSettings()) {
final Preference pluginPreference = new Preference(getBaseContext());
- pluginPreference.setKey(pluginName + getString(R.string.plugin_settings_key));
+ pluginPreference.setKey(pluginName + "_preferences");
pluginPreference.setSummary(getString(R.string.plugin_settings_with_name, info.getDisplayName()));
preferences.add(pluginPreference);
preferenceScreen.addPreference(pluginPreference);
@@ -84,16 +86,16 @@ public class SettingsActivity extends PreferenceActivity {
@Override
public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
Preference pref = preferences.get(i);
- if (pref.getDependency() == null) { //Is a plugin check
+ if (pref.getDependency() == null) { //Is a check to enable/disable a plugin
CheckBoxPreference check = (CheckBoxPreference)pref;
boolean enabled = device.isPluginEnabled(pref.getKey());
device.setPluginEnabled(pref.getKey(), !enabled);
check.setChecked(!enabled);
} else { //Is a plugin suboption
if (pref.isEnabled()) {
- Intent intent = new Intent(SettingsActivity.this, PluginSettingsActivity.class);
- intent.putExtra(Intent.EXTRA_INTENT, pref.getKey());
- startActivity(intent);
+ String pluginName = pref.getDependency(); //The parent pref will be named like the plugin
+ Plugin plugin = device.getPlugin(pluginName, true);
+ plugin.startPreferencesActivity(SettingsActivity.this);
}
}
}
@@ -102,6 +104,5 @@ public class SettingsActivity extends PreferenceActivity {
});
-
}
}