mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 22:25:08 +00:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
5225d0b200 | ||
|
54e5224f20 | ||
|
6ab846cbbd | ||
|
ea66605ef0 | ||
|
c903c5d3fd |
@@ -2,8 +2,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="org.kde.kdeconnect_tp"
|
||||
android:versionCode="12000"
|
||||
android:versionName="1.20">
|
||||
android:versionCode="12002"
|
||||
android:versionName="1.20.2">
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
|
@@ -168,7 +168,7 @@ dependencies {
|
||||
|
||||
implementation 'com.klinkerapps:android-smsmms:5.2.6' //For SMS and MMS purposes
|
||||
|
||||
implementation 'commons-io:commons-io:2.11.0'
|
||||
implementation 'commons-io:commons-io:2.8.0' // newer versions don't work on Android 7: https://stackoverflow.com/questions/73604534/no-static-method-threadlocal-withinitial-commons-io-dependency
|
||||
implementation 'org.apache.commons:commons-collections4:4.4'
|
||||
implementation 'org.apache.commons:commons-lang3:3.11'
|
||||
|
||||
|
@@ -161,6 +161,9 @@ public class BackgroundService extends Service {
|
||||
}
|
||||
|
||||
public Device getDevice(String id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return devices.get(id);
|
||||
}
|
||||
|
||||
@@ -370,21 +373,24 @@ public class BackgroundService extends Service {
|
||||
}
|
||||
|
||||
if (connectedDeviceIds.size() == 1) {
|
||||
// Adding two action buttons only when there is a single device connected.
|
||||
// Setting up Send File Intent.
|
||||
Intent sendFile = new Intent(this, SendFileActivity.class);
|
||||
sendFile.putExtra("deviceId", connectedDeviceIds.get(0));
|
||||
PendingIntent sendPendingFile = PendingIntent.getActivity(this, 1, sendFile, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
|
||||
notification.addAction(0, getString(R.string.send_files), sendPendingFile);
|
||||
String deviceId = connectedDeviceIds.get(0);
|
||||
Device device = getDevice(deviceId);
|
||||
if (device != null) {
|
||||
// Adding two action buttons only when there is a single device connected.
|
||||
// Setting up Send File Intent.
|
||||
Intent sendFile = new Intent(this, SendFileActivity.class);
|
||||
sendFile.putExtra("deviceId", deviceId);
|
||||
PendingIntent sendPendingFile = PendingIntent.getActivity(this, 1, sendFile, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
|
||||
notification.addAction(0, getString(R.string.send_files), sendPendingFile);
|
||||
|
||||
// Checking if there are registered commands and adding the button.
|
||||
Device device = getDevice(connectedDeviceIds.get(0));
|
||||
RunCommandPlugin plugin = (RunCommandPlugin) device.getPlugin("RunCommandPlugin");
|
||||
if (plugin != null && !plugin.getCommandList().isEmpty()) {
|
||||
Intent runCommand = new Intent(this, RunCommandActivity.class);
|
||||
runCommand.putExtra("deviceId", connectedDeviceIds.get(0));
|
||||
PendingIntent runPendingCommand = PendingIntent.getActivity(this, 2, runCommand, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
|
||||
notification.addAction(0, getString(R.string.pref_plugin_runcommand), runPendingCommand);
|
||||
// Checking if there are registered commands and adding the button.
|
||||
RunCommandPlugin plugin = (RunCommandPlugin) device.getPlugin("RunCommandPlugin");
|
||||
if (plugin != null && !plugin.getCommandList().isEmpty()) {
|
||||
Intent runCommand = new Intent(this, RunCommandActivity.class);
|
||||
runCommand.putExtra("deviceId", connectedDeviceIds.get(0));
|
||||
PendingIntent runPendingCommand = PendingIntent.getActivity(this, 2, runCommand, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
|
||||
notification.addAction(0, getString(R.string.pref_plugin_runcommand), runPendingCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -211,6 +211,6 @@ public class FindMyPhonePlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public PluginSettingsFragment getSettingsFragment(Activity activity) {
|
||||
return FindMyPhoneSettingsFragment.newInstance(getPluginKey());
|
||||
return FindMyPhoneSettingsFragment.newInstance(getPluginKey(), R.xml.findmyphoneplugin_preferences);
|
||||
}
|
||||
}
|
||||
|
@@ -28,9 +28,9 @@ public class FindMyPhoneSettingsFragment extends PluginSettingsFragment {
|
||||
private SharedPreferences sharedPreferences;
|
||||
private Preference ringtonePreference;
|
||||
|
||||
public static FindMyPhoneSettingsFragment newInstance(@NonNull String pluginKey) {
|
||||
public static FindMyPhoneSettingsFragment newInstance(@NonNull String pluginKey, int layout) {
|
||||
FindMyPhoneSettingsFragment fragment = new FindMyPhoneSettingsFragment();
|
||||
fragment.setArguments(pluginKey);
|
||||
fragment.setArguments(pluginKey, layout);
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ import android.graphics.drawable.Drawable;
|
||||
import org.kde.kdeconnect.NetworkPacket;
|
||||
import org.kde.kdeconnect.Plugins.Plugin;
|
||||
import org.kde.kdeconnect.Plugins.PluginFactory;
|
||||
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
@@ -54,6 +55,11 @@ public class MousePadPlugin extends Plugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginSettingsFragment getSettingsFragment(Activity activity) {
|
||||
return PluginSettingsFragment.newInstance(getPluginKey(), R.xml.mousepadplugin_preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMainActivity() {
|
||||
return true;
|
||||
|
@@ -19,6 +19,7 @@ import androidx.core.content.ContextCompat;
|
||||
import org.kde.kdeconnect.NetworkPacket;
|
||||
import org.kde.kdeconnect.Plugins.Plugin;
|
||||
import org.kde.kdeconnect.Plugins.PluginFactory;
|
||||
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
@@ -254,6 +255,11 @@ public class MprisPlugin extends Plugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginSettingsFragment getSettingsFragment(Activity activity) {
|
||||
return PluginSettingsFragment.newInstance(getPluginKey(), R.xml.mprisplugin_preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
MprisMediaSession.getInstance().onCreate(context.getApplicationContext(), this, device.getDeviceId());
|
||||
|
@@ -166,7 +166,8 @@ public abstract class Plugin {
|
||||
* @return The PluginSettingsFragment used to display this plugins settings
|
||||
*/
|
||||
public PluginSettingsFragment getSettingsFragment(Activity activity) {
|
||||
return PluginSettingsFragment.newInstance(getPluginKey());
|
||||
throw new RuntimeException("Plugin doesn't reimplement getSettingsFragment: " + getPluginKey());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
package org.kde.kdeconnect.Plugins.RemoteKeyboardPlugin;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.SystemClock;
|
||||
@@ -24,6 +25,7 @@ import org.kde.kdeconnect.Plugins.Plugin;
|
||||
import org.kde.kdeconnect.Plugins.PluginFactory;
|
||||
import org.kde.kdeconnect.UserInterface.MainActivity;
|
||||
import org.kde.kdeconnect.UserInterface.StartActivityAlertDialogFragment;
|
||||
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -159,6 +161,11 @@ public class RemoteKeyboardPlugin extends Plugin implements SharedPreferences.On
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginSettingsFragment getSettingsFragment(Activity activity) {
|
||||
return PluginSettingsFragment.newInstance(getPluginKey(), R.xml.remotekeyboardplugin_preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMainActivity() {
|
||||
return false;
|
||||
|
@@ -8,6 +8,7 @@
|
||||
|
||||
package org.kde.kdeconnect.Plugins.SMSPlugin;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -36,6 +37,7 @@ import org.kde.kdeconnect.NetworkPacket;
|
||||
import org.kde.kdeconnect.Plugins.Plugin;
|
||||
import org.kde.kdeconnect.Plugins.PluginFactory;
|
||||
import org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin;
|
||||
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
|
||||
import org.kde.kdeconnect_tp.BuildConfig;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
|
||||
@@ -557,6 +559,11 @@ public class SMSPlugin extends Plugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginSettingsFragment getSettingsFragment(Activity activity) {
|
||||
return PluginSettingsFragment.newInstance(getPluginKey(), R.xml.smsplugin_preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedPacketTypes() {
|
||||
return new String[]{
|
||||
|
@@ -263,7 +263,7 @@ public class SftpPlugin extends Plugin implements SharedPreferences.OnSharedPref
|
||||
|
||||
@Override
|
||||
public PluginSettingsFragment getSettingsFragment(Activity activity) {
|
||||
return SftpSettingsFragment.newInstance(getPluginKey());
|
||||
return SftpSettingsFragment.newInstance(getPluginKey(), R.xml.sftpplugin_preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -64,9 +64,9 @@ public class SftpSettingsFragment
|
||||
private ActionMode actionMode;
|
||||
private JSONObject savedActionModeState;
|
||||
|
||||
public static SftpSettingsFragment newInstance(@NonNull String pluginKey) {
|
||||
public static SftpSettingsFragment newInstance(@NonNull String pluginKey, int layout) {
|
||||
SftpSettingsFragment fragment = new SftpSettingsFragment();
|
||||
fragment.setArguments(pluginKey);
|
||||
fragment.setArguments(pluginKey, layout);
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
@@ -197,7 +197,7 @@ public class SharePlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public PluginSettingsFragment getSettingsFragment(Activity activity) {
|
||||
return ShareSettingsFragment.newInstance(getPluginKey());
|
||||
return ShareSettingsFragment.newInstance(getPluginKey(), R.xml.shareplugin_preferences);
|
||||
}
|
||||
|
||||
void sendUriList(final ArrayList<Uri> uriList) {
|
||||
|
@@ -37,9 +37,9 @@ public class ShareSettingsFragment extends PluginSettingsFragment {
|
||||
|
||||
private Preference filePicker;
|
||||
|
||||
public static ShareSettingsFragment newInstance(@NonNull String pluginKey) {
|
||||
public static ShareSettingsFragment newInstance(@NonNull String pluginKey, int layout) {
|
||||
ShareSettingsFragment fragment = new ShareSettingsFragment();
|
||||
fragment.setArguments(pluginKey);
|
||||
fragment.setArguments(pluginKey, layout);
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
package org.kde.kdeconnect.Plugins.TelephonyPlugin;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.Manifest;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -26,6 +27,7 @@ import org.kde.kdeconnect.Helpers.ContactsHelper;
|
||||
import org.kde.kdeconnect.NetworkPacket;
|
||||
import org.kde.kdeconnect.Plugins.Plugin;
|
||||
import org.kde.kdeconnect.Plugins.PluginFactory;
|
||||
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -318,4 +320,9 @@ public class TelephonyPlugin extends Plugin {
|
||||
public boolean hasSettings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginSettingsFragment getSettingsFragment(Activity activity) {
|
||||
return PluginSettingsFragment.newInstance(getPluginKey(), R.xml.telephonyplugin_preferences);
|
||||
}
|
||||
}
|
||||
|
@@ -18,28 +18,33 @@ import org.kde.kdeconnect.Device;
|
||||
import org.kde.kdeconnect.Plugins.Plugin;
|
||||
import org.kde.kdeconnect.Plugins.PluginFactory;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class PluginSettingsFragment extends PreferenceFragmentCompat {
|
||||
private static final String ARG_PLUGIN_KEY = "plugin_key";
|
||||
private static final String ARG_LAYOUT = "layout";
|
||||
|
||||
private String pluginKey;
|
||||
private int layout;
|
||||
protected Device device;
|
||||
protected Plugin plugin;
|
||||
|
||||
public static PluginSettingsFragment newInstance(@NonNull String pluginKey) {
|
||||
public static PluginSettingsFragment newInstance(@NonNull String pluginKey, int settingsLayout) {
|
||||
PluginSettingsFragment fragment = new PluginSettingsFragment();
|
||||
fragment.setArguments(pluginKey);
|
||||
fragment.setArguments(pluginKey, settingsLayout);
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public PluginSettingsFragment() {}
|
||||
|
||||
protected Bundle setArguments(@NonNull String pluginKey) {
|
||||
protected Bundle setArguments(@NonNull String pluginKey, int settingsLayout) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PLUGIN_KEY, pluginKey);
|
||||
args.putInt(ARG_LAYOUT, settingsLayout);
|
||||
|
||||
|
||||
setArguments(args);
|
||||
|
||||
@@ -52,7 +57,8 @@ public class PluginSettingsFragment extends PreferenceFragmentCompat {
|
||||
throw new RuntimeException("You must provide a pluginKey by calling setArguments(@NonNull String pluginKey)");
|
||||
}
|
||||
|
||||
pluginKey = getArguments().getString(ARG_PLUGIN_KEY);
|
||||
this.pluginKey = getArguments().getString(ARG_PLUGIN_KEY);
|
||||
this.layout = getArguments().getInt(ARG_LAYOUT);
|
||||
this.device = getDeviceOrThrow(getDeviceId());
|
||||
this.plugin = device.getPlugin(pluginKey);
|
||||
|
||||
@@ -67,9 +73,7 @@ public class PluginSettingsFragment extends PreferenceFragmentCompat {
|
||||
prefsManager.setSharedPreferencesMode(Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
int resFile = getResources().getIdentifier(pluginKey.toLowerCase(Locale.ENGLISH) + "_preferences", "xml",
|
||||
requireContext().getPackageName());
|
||||
addPreferencesFromResource(resFile);
|
||||
addPreferencesFromResource(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user