diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e3ab04f9..98377083 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,231 +1,247 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/menu/runcommand_context.xml b/res/menu/runcommand_context.xml
new file mode 100644
index 00000000..a556845f
--- /dev/null
+++ b/res/menu/runcommand_context.xml
@@ -0,0 +1,8 @@
+
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1da2ee74..23f82b72 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,249 +1,255 @@
Telephony notifier
Send notifications for SMS and calls
Battery report
Periodically report battery status
Filesystem expose
Allows to browse this device\'s filesystem remotely
Clipboard sync
Share the clipboard content
Remote input
Use your phone or tablet as a touchpad and keyboard
Receive remote keypresses
Receive keypress events from remote devices
Multimedia controls
Provides a remote control for your media player
Run Command
Trigger remote commands from your phone or tablet
Contacts Synchronizer
Allow synchronizing the device\'s contacts book
Ping
Send and receive pings
Notification sync
Access your notifications from other devices
Receive notifications
Receive notifications from the other device and display them on Android
Share and receive
Share files and URLs between devices
This feature is not available in your Android version
No devices
OK
Cancel
Open settings
You need to grant permission to access notifications
To be able to control your media players you need to grant access to the notifications
Send ping
Multimedia control
remotekeyboard_editing_only
Handle remote keys only when editing
There is no active remote keyboard connection, establish one in kdeconnect
Remote keyboard connection is active
There is more than one remote keyboard connection, select the device to configure
Remote input
Move a finger on the screen to move the mouse cursor. Tap for a click, and use two/three fingers for right and middle buttons. Use 2 fingers to scroll. Use a long press to drag\'n drop.
Set two finger tap action
Set three finger tap action
Set touchpad sensitivity
mousepad_double_tap_key
mousepad_triple_tap_key
mousepad_sensitivity_key
Reverse Scrolling Direction
mousepad_scroll_direction
- Right click
- Middle click
- Nothing
right
middle
default
- right
- middle
- none
- Slowest
- Above Slowest
- Default
- Above Default
- Fastest
- slowest
- aboveSlowest
- default
- aboveDefault
- fastest
Connected devices
Available devices
Remembered devices
Plugins failed to load (tap for more info):
Plugin settings
Unpair
Paired device not reachable
Pair new device
Unknown device
Device not reachable
Pairing already requested
Device already paired
Could not send package
Timed out
Canceled by user
Canceled by other peer
Invalid key received
Encryption Info
The other device doesn\'t use a recent version of KDE Connect, using the legacy encryption method.
SHA1 fingerprint of your device certificate is:
SHA1 fingerprint of remote device certificate is:
Pair requested
Pairing request from %1s
Received link from %1s
Tap to open \'%1s\'
Incoming file from %1s
%1s
Sending file to %1s
Sending files to %1s
- Sent %1$d file
- Sent %1$d out of %2$d files
Received file from %1s
Failed receiving file from %1s
Tap to open \'%1s\'
Sent file to %1s
%1s
Failed to send file to %1s
%1s
Tap to answer
Reconnect
Send Right Click
Send Middle Click
Show Keyboard
Device not paired
Request pairing
Accept
Reject
Device
Pair device
Remote control
KDE Connect Settings
Play
Pause
Previous
Rewind
Fast-forward
Next
Volume
Multimedia Settings
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
Show media control notification
Allows controlling your media players without opening KDE Connect.
mpris_notification_enabled
Share To...
This device uses an old protocol version
This device uses a newer protocol version
General Settings
Settings
%s settings
Device name
%s
Invalid device name
Received text, saved to clipboard
Custom device list
Pair a new device
Unpair %s
Add devices by IP
Noisy notifications
Vibrate and play a sound when receiving a file
Customize destination directory
Received files will appear in Downloads
Files will be stored in the directory below
Destination directory
Share
Share \"%s\"
Notification filter
Notifications will be synchronized for the selected apps.
Internal storage
All files
SD card %d
SD card
(read only)
Camera pictures
Add host/IP
Hostname or IP
No players found
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
Send files
KDE Connect Devices
Other devices running KDE Connect in your same network should appear here.
Device paired
Rename device
Rename
Refresh
This paired device is not reachable. Make sure it is connected to your same network.
It looks like you are on a mobile data connection. KDE Connect only works on local networks.
There are no file browsers installed.
Send SMS
Send text messages from your desktop
This plugin is not supported by the device
Find my phone
Find my tablet
Find my TV
Rings this device so you can find it
Found
Open
Close
You need to grant permissions to access the storage
Some Plugins need permissions to work (tap for more info):
This plugin needs permissions to work
You need to grant extra permissions to enable all functions
Some plugins have features disabled because of lack of permission (tap for more info):
To access your files from your PC the app needs permission to access your phone\'s storage
To share files between your phone and your desktop you need to give access to the phone\'s storage
To read and write SMS from your desktop you need to give permission to SMS
To see phone calls and SMS from the desktop you need to give permission to phone calls and SMS
To see a contact name instead of a phone number you need to give access to the phone\'s contacts
To share your contacts book with the desktop, you need to give contacts permission
Select a ringtone
Blocked numbers
Don\'t show calls and SMS from these numbers. Please specify one number per line
Cover art of current media
Device icon
Settings icon
Add a command
There are no commands registered
You can add new commands in the KDE Connect System Settings
You can add commands on the desktop
Media Player Control
Control your phones media players from another device
Dark theme
Stop the current player
+ Copy URL to clipboard
+ Copied to clipboard
+ Device is not reachable
+ Device is not paired
+ There is no such device
+ This device does not have the Run Command Plugin enabled
diff --git a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandActivity.java b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandActivity.java
index abe881cc..2e286fec 100644
--- a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandActivity.java
+++ b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandActivity.java
@@ -1,167 +1,201 @@
/*
* Copyright 2015 Aleix Pol Gonzalez
* Copyright 2015 Albert Vaca Cintora
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package org.kde.kdeconnect.Plugins.RunCommandPlugin;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.os.Build;
import android.os.Bundle;
+import android.support.annotation.RequiresApi;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
+import android.view.ContextMenu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
+import android.widget.Toast;
import org.json.JSONException;
import org.json.JSONObject;
import org.kde.kdeconnect.BackgroundService;
import org.kde.kdeconnect.Device;
import org.kde.kdeconnect.UserInterface.List.ListAdapter;
import org.kde.kdeconnect.UserInterface.ThemeUtil;
import org.kde.kdeconnect_tp.R;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
public class RunCommandActivity extends AppCompatActivity {
private String deviceId;
private final RunCommandPlugin.CommandsChangedCallback commandsChangedCallback = this::updateView;
+ private ArrayList commandItems;
private void updateView() {
BackgroundService.RunCommand(this, service -> {
final Device device = service.getDevice(deviceId);
final RunCommandPlugin plugin = device.getPlugin(RunCommandPlugin.class);
if (plugin == null) {
Log.e("RunCommandActivity", "device has no runcommand plugin!");
return;
}
runOnUiThread(() -> {
ListView view = (ListView) findViewById(R.id.runcommandslist);
- final ArrayList commandItems = new ArrayList<>();
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
+ registerForContextMenu(view);
+ }
+
+ commandItems = new ArrayList<>();
for (JSONObject obj : plugin.getCommandList()) {
try {
commandItems.add(new CommandEntry(obj.getString("name"),
obj.getString("command"), obj.getString("key")));
} catch (JSONException e) {
e.printStackTrace();
}
}
Collections.sort(commandItems, (lhs, rhs) -> {
String lName = ((CommandEntry) lhs).getName();
String rName = ((CommandEntry) rhs).getName();
return lName.compareTo(rName);
});
ListAdapter adapter = new ListAdapter(RunCommandActivity.this, commandItems);
view.setAdapter(adapter);
view.setOnItemClickListener((adapterView, view1, i, l) -> {
CommandEntry entry = (CommandEntry) commandItems.get(i);
plugin.runCommand(entry.getKey());
});
TextView explanation = (TextView) findViewById(R.id.addcomand_explanation);
String text = getString(R.string.addcommand_explanation);
if (!plugin.canAddCommand()) {
text += "\n" + getString(R.string.addcommand_explanation2);
}
explanation.setText(text);
explanation.setVisibility(commandItems.isEmpty() ? View.VISIBLE : View.GONE);
});
});
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ThemeUtil.setUserPreferredTheme(this);
setContentView(R.layout.activity_runcommand);
deviceId = getIntent().getStringExtra("deviceId");
boolean canAddCommands = BackgroundService.getInstance().getDevice(deviceId).getPlugin(RunCommandPlugin.class).canAddCommand();
FloatingActionButton addCommandButton = (FloatingActionButton) findViewById(R.id.add_command_button);
addCommandButton.setVisibility(canAddCommands ? View.VISIBLE : View.GONE);
addCommandButton.setOnClickListener(view -> BackgroundService.RunCommand(RunCommandActivity.this, service -> {
final Device device = service.getDevice(deviceId);
final RunCommandPlugin plugin = device.getPlugin(RunCommandPlugin.class);
if (plugin == null) {
Log.e("RunCommandActivity", "device has no runcommand plugin!");
return;
}
plugin.sendSetupPacket();
AlertDialog dialog = new AlertDialog.Builder(RunCommandActivity.this)
.setTitle(R.string.add_command)
.setMessage(R.string.add_command_description)
.setPositiveButton(R.string.ok, null)
.create();
dialog.show();
}));
updateView();
}
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
+ super.onCreateContextMenu(menu, v, menuInfo);
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.runcommand_context, menu);
+ }
+
+ @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
+ @Override
+ public boolean onContextItemSelected(MenuItem item) {
+ AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
+ if (item.getItemId() == R.id.copy_url_to_clipboard) {
+ CommandEntry entry = (CommandEntry) commandItems.get(info.position);
+ String url = "kdeconnect://runcommand/" + deviceId + "/" + entry.getKey();
+ ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
+ cm.setText(url);
+ Toast toast = Toast.makeText(this, R.string.clipboard_toast, Toast.LENGTH_SHORT);
+ toast.show();
+ }
+ return false;
+ }
+
@Override
protected void onResume() {
super.onResume();
BackgroundService.RunCommand(this, service -> {
final Device device = service.getDevice(deviceId);
final RunCommandPlugin plugin = device.getPlugin(RunCommandPlugin.class);
if (plugin == null) {
Log.e("RunCommandActivity", "device has no runcommand plugin!");
return;
}
plugin.addCommandsUpdatedCallback(commandsChangedCallback);
});
}
@Override
protected void onPause() {
super.onPause();
BackgroundService.RunCommand(this, service -> {
final Device device = service.getDevice(deviceId);
final RunCommandPlugin plugin = device.getPlugin(RunCommandPlugin.class);
if (plugin == null) {
Log.e("RunCommandActivity", "device has no runcommand plugin!");
return;
}
plugin.removeCommandsUpdatedCallback(commandsChangedCallback);
});
}
}
diff --git a/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandUrlActivity.java b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandUrlActivity.java
new file mode 100644
index 00000000..9fadf00a
--- /dev/null
+++ b/src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandUrlActivity.java
@@ -0,0 +1,74 @@
+package org.kde.kdeconnect.Plugins.RunCommandPlugin;
+
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Vibrator;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.Gravity;
+import android.widget.TextView;
+
+import org.kde.kdeconnect.BackgroundService;
+import org.kde.kdeconnect.Device;
+import org.kde.kdeconnect_tp.R;
+
+public class RunCommandUrlActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (getIntent().getAction() != null) {
+ try {
+ Uri uri = getIntent().getData();
+ String deviceId = uri.getPathSegments().get(0);
+
+ BackgroundService.RunCommand(this, service -> {
+ final Device device = service.getDevice(deviceId);
+
+ if(device == null) {
+ error(R.string.runcommand_nosuchdevice);
+ return;
+ }
+
+ if (!device.isPaired()) {
+ error(R.string.runcommand_notpaired);
+ return;
+ }
+
+ if (!device.isReachable()) {
+ error(R.string.runcommand_notreachable);
+ return;
+ }
+
+ final RunCommandPlugin plugin = device.getPlugin(RunCommandPlugin.class);
+ if (plugin == null) {
+ error(R.string.runcommand_noruncommandplugin);
+ return;
+ }
+
+ plugin.runCommand(uri.getPathSegments().get(1));
+ RunCommandUrlActivity.this.finish();
+
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
+ Vibrator vibrator = RunCommandUrlActivity.this.getSystemService(Vibrator.class);
+ if(vibrator != null && vibrator.hasVibrator()) {
+ vibrator.vibrate(100);
+ }
+ }
+ });
+ } catch (Exception e) {
+ Log.e("RuncommandPlugin", "Exception", e);
+ }
+ }
+ }
+
+ void error(int message) {
+ TextView view = new TextView(this);
+ view.setText(message);
+ view.setGravity(Gravity.CENTER);
+ setContentView(view);
+ }
+
+}