diff --git a/KdeConnect/src/main/AndroidManifest.xml b/KdeConnect/src/main/AndroidManifest.xml
index ff466ac3..a32c6ab8 100644
--- a/KdeConnect/src/main/AndroidManifest.xml
+++ b/KdeConnect/src/main/AndroidManifest.xml
@@ -37,6 +37,11 @@
android:label="MPRIS controls"
/>
+
+
10 && Build.VERSION.SDK_INT != 18) {
+ if (settings.getBoolean("clipboard_interface", true)) {
+ addPackageInterface(ClipboardPackageInterface.class);
+ } else {
+ removePackageInterface(ClipboardPackageInterface.class);
+ }
}
if (settings.getBoolean("mpris_interface", true)) {
diff --git a/KdeConnect/src/main/java/org/kde/connect/CompatSettingsActivity.java b/KdeConnect/src/main/java/org/kde/connect/CompatSettingsActivity.java
new file mode 100644
index 00000000..c3f4ed4c
--- /dev/null
+++ b/KdeConnect/src/main/java/org/kde/connect/CompatSettingsActivity.java
@@ -0,0 +1,60 @@
+package org.kde.connect;
+
+import android.app.Activity;
+import android.content.SharedPreferences;
+import android.os.Build;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
+import android.util.Log;
+
+import org.kde.kdeconnect.R;
+
+public class CompatSettingsActivity extends PreferenceActivity {
+
+ private SharedPreferences.OnSharedPreferenceChangeListener preferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+
+ Log.e("onSharedPreferenceChanged",key+"->"+sharedPreferences.getBoolean(key,true));
+ BackgroundService.RunCommand(getApplicationContext(), new BackgroundService.InstanceCallback() {
+ @Override
+ public void onServiceStart(BackgroundService service) {
+ service.registerPackageInterfacesFromSettings();
+ }
+ });
+
+ }
+ };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.settings);
+ if (Build.VERSION.SDK_INT < 11 || Build.VERSION.SDK_INT == 18) {
+ CheckBoxPreference p = (CheckBoxPreference)findPreference("clipboard_interface");
+ p.setEnabled(false);
+ p.setChecked(false);
+ p.setSelectable(false);
+ p.setSummary(R.string.app_not_available);
+ }
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ getPreferenceManager().getSharedPreferences()
+ .registerOnSharedPreferenceChangeListener(preferenceChangeListener);
+
+ }
+
+ @Override
+ public void onPause() {
+ getPreferenceManager().getSharedPreferences()
+ .unregisterOnSharedPreferenceChangeListener(preferenceChangeListener);
+ super.onPause();
+ }
+
+}
\ No newline at end of file
diff --git a/KdeConnect/src/main/java/org/kde/connect/MainActivity.java b/KdeConnect/src/main/java/org/kde/connect/MainActivity.java
index 865738b6..bf7e48b6 100644
--- a/KdeConnect/src/main/java/org/kde/connect/MainActivity.java
+++ b/KdeConnect/src/main/java/org/kde/connect/MainActivity.java
@@ -2,6 +2,7 @@ package org.kde.connect;
import android.app.Activity;
import android.content.Intent;
+import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
@@ -120,8 +121,13 @@ public class MainActivity extends Activity {
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch(item.getItemId()){
case R.id.action_settings:
- Intent intent = new Intent(this,SettingsActivity.class);
- startActivity(intent);
+ if (Build.VERSION.SDK_INT > 10) {
+ Intent intent = new Intent(this,SettingsActivity.class);
+ startActivity(intent);
+ } else {
+ Intent intent = new Intent(this,CompatSettingsActivity.class);
+ startActivity(intent);
+ }
return true;
default:
return super.onMenuItemSelected(featureId, item);
diff --git a/KdeConnect/src/main/java/org/kde/connect/PackageInterfaces/CompatClipboardPackageInterface.java b/KdeConnect/src/main/java/org/kde/connect/PackageInterfaces/CompatClipboardPackageInterface.java
new file mode 100644
index 00000000..ba3ca0d4
--- /dev/null
+++ b/KdeConnect/src/main/java/org/kde/connect/PackageInterfaces/CompatClipboardPackageInterface.java
@@ -0,0 +1,43 @@
+package org.kde.connect.PackageInterfaces;
+
+import android.text.ClipboardManager;
+import android.content.Context;
+
+import org.kde.connect.Device;
+import org.kde.connect.NetworkPackage;
+
+public class CompatClipboardPackageInterface extends BasePackageInterface {
+
+ private Context context;
+ private ClipboardManager cm;
+
+ @Override
+ public boolean onCreate(Context context) {
+
+ this.context = context;
+
+ cm = (ClipboardManager)context.getSystemService(Context.CLIPBOARD_SERVICE);
+
+ return false;
+
+ }
+
+ @Override
+ public void onDestroy() {
+
+ }
+
+ @Override
+ public boolean onPackageReceived(Device d, NetworkPackage np) {
+ if (np.getType().equals(NetworkPackage.PACKAGE_TYPE_CLIPBOARD)) {
+ cm.setText(np.getString("content"));
+ return true;
+ }
+ return false;
+ }
+
+ public boolean onDeviceConnected(Device d) {
+ return false;
+ }
+
+}
diff --git a/KdeConnect/src/main/java/org/kde/connect/PackageInterfaces/MprisControlPackageInterface.java b/KdeConnect/src/main/java/org/kde/connect/PackageInterfaces/MprisControlPackageInterface.java
index ff089a60..a022927c 100644
--- a/KdeConnect/src/main/java/org/kde/connect/PackageInterfaces/MprisControlPackageInterface.java
+++ b/KdeConnect/src/main/java/org/kde/connect/PackageInterfaces/MprisControlPackageInterface.java
@@ -84,7 +84,7 @@ public class MprisControlPackageInterface extends BasePackageInterface {
public void setNowPlayingUpdatedHandler(Handler h) {
nowPlayingUpdated = h;
- if (!nowPlaying.isEmpty()) h.dispatchMessage(new Message());
+ if (nowPlaying.length() > 0) h.dispatchMessage(new Message());
requestNowPlaying();
}
@@ -94,7 +94,7 @@ public class MprisControlPackageInterface extends BasePackageInterface {
public void setPlayerListUpdatedHandler(Handler h) {
playerListUpdated = h;
- if (!playerList.isEmpty()) h.dispatchMessage(new Message());
+ if (playerList.size() > 0) h.dispatchMessage(new Message());
requestPlayerList();
}
diff --git a/KdeConnect/src/main/java/org/kde/connect/SettingsFragment.java b/KdeConnect/src/main/java/org/kde/connect/SettingsFragment.java
index 4d05a6dd..f7a9a6dc 100644
--- a/KdeConnect/src/main/java/org/kde/connect/SettingsFragment.java
+++ b/KdeConnect/src/main/java/org/kde/connect/SettingsFragment.java
@@ -2,7 +2,10 @@ package org.kde.connect;
import android.app.Activity;
import android.content.SharedPreferences;
+import android.os.Build;
import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.util.Log;
@@ -30,6 +33,13 @@ public class SettingsFragment extends PreferenceFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
+ if (Build.VERSION.SDK_INT < 11 || Build.VERSION.SDK_INT == 18) {
+ CheckBoxPreference p = (CheckBoxPreference)findPreference("clipboard_interface");
+ p.setEnabled(false);
+ p.setChecked(false);
+ p.setSelectable(false);
+ p.setSummary(R.string.app_not_available);
+ }
}
@Override
diff --git a/KdeConnect/src/main/res/values/strings.xml b/KdeConnect/src/main/res/values/strings.xml
index 4aac14f6..ec85b661 100644
--- a/KdeConnect/src/main/res/values/strings.xml
+++ b/KdeConnect/src/main/res/values/strings.xml
@@ -14,6 +14,7 @@
Control audio/video from your phone
Pings
Enable sending and receiving ping notifications
+ This feature is not available in your Android version