mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-01 06:35:09 +00:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a15cad9ec5 | ||
|
e98100f5f0 | ||
|
d19e7d2052 | ||
|
4e02c674f8 | ||
|
6aa49757fc | ||
|
3c10312d15 | ||
|
26e3363b30 | ||
|
4033233ec1 | ||
|
34e53576e1 | ||
|
a15d76c588 | ||
|
1acea73383 | ||
|
6c8fdb0be7 | ||
|
749170a29c | ||
|
81b08cf89f | ||
|
786ea7658f | ||
|
996516ec88 | ||
|
a36e4a0c88 | ||
|
e08de81c73 |
@@ -25,37 +25,37 @@
|
||||
<output url="file://$MODULE_DIR$/build/classes/debug" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/r/debug" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/aidl/debug" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/rs/debug" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/debug" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/res/rs/debug" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/r/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/aidl/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/rs/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/res/rs/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/r/test" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/aidl/test" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/rs/test" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/test" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/res/rs/test" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/res/rs/test" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/res" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/assets" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/res" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/resources" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/resources" type="java-test-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.git" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea" />
|
||||
@@ -67,6 +67,7 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||
</content>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.kde.kdeconnect_tp"
|
||||
android:versionCode="9"
|
||||
android:versionName="0.4">
|
||||
android:versionCode="11"
|
||||
android:versionName="0.4.2">
|
||||
|
||||
<uses-sdk android:minSdkVersion="9"
|
||||
android:targetSdkVersion="18" />
|
||||
@@ -25,6 +25,7 @@
|
||||
<uses-permission android:name="android.permission.BATTERY_STATS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_SMS" android:required="false" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
@@ -58,11 +58,15 @@ public class LanLinkProvider extends BaseLinkProvider {
|
||||
super.messageReceived(session, message);
|
||||
|
||||
//Log.e("LanLinkProvider","Incoming package, address: "+session.getRemoteAddress()).toString());
|
||||
//Log.e("LanLinkProvider","Received:"+message);
|
||||
|
||||
String theMessage = (String) message;
|
||||
NetworkPackage np = NetworkPackage.unserialize(theMessage);
|
||||
if (theMessage.isEmpty()) {
|
||||
Log.e("LanLinkProvider","Empty package received");
|
||||
return;
|
||||
}
|
||||
|
||||
LanLink prevLink = nioSessions.get(session.getId());
|
||||
NetworkPackage np = NetworkPackage.unserialize(theMessage);
|
||||
|
||||
if (np.getType().equals(NetworkPackage.PACKAGE_TYPE_IDENTITY)) {
|
||||
|
||||
@@ -77,6 +81,7 @@ public class LanLinkProvider extends BaseLinkProvider {
|
||||
nioSessions.put(session.getId(),link);
|
||||
addLink(np, link);
|
||||
} else {
|
||||
LanLink prevLink = nioSessions.get(session.getId());
|
||||
if (prevLink == null) {
|
||||
Log.e("LanLinkProvider","2 Expecting an identity package");
|
||||
} else {
|
||||
|
@@ -50,9 +50,11 @@ public class BackgroundService extends Service {
|
||||
};
|
||||
|
||||
private void loadRememberedDevicesFromSettings() {
|
||||
//Log.e("BackgroundService", "Loading remembered trusted devices");
|
||||
SharedPreferences preferences = getSharedPreferences("trusted_devices", Context.MODE_PRIVATE);
|
||||
Set<String> trustedDevices = preferences.getAll().keySet();
|
||||
for(String deviceId : trustedDevices) {
|
||||
//Log.e("BackgroundService", "Loading device "+deviceId);
|
||||
if (preferences.getBoolean(deviceId, false)) {
|
||||
Device device = new Device(this, deviceId);
|
||||
devices.put(deviceId,device);
|
||||
@@ -110,6 +112,7 @@ public class BackgroundService extends Service {
|
||||
if (d != null) {
|
||||
d.removeLink(link);
|
||||
if (!d.isReachable() && !d.isPaired()) {
|
||||
//Log.e("onConnectionLost","Removing connection device because it was not paired");
|
||||
devices.remove(link.getDeviceId());
|
||||
d.removePairingCallback(devicePairingCallback);
|
||||
}
|
||||
|
@@ -175,6 +175,7 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
|
||||
@Override
|
||||
public void sendSuccessful() {
|
||||
if (pairingTimer != null) pairingTimer.cancel();
|
||||
pairingTimer = new Timer();
|
||||
pairingTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
@@ -182,9 +183,10 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
for (PairingCallback cb : pairingCallback) {
|
||||
cb.pairingFailed(context.getString(R.string.error_timed_out));
|
||||
}
|
||||
Log.e("Device","Unpairing (timeout A)");
|
||||
pairStatus = PairStatus.NotPaired;
|
||||
}
|
||||
}, 30*1000);
|
||||
}, 30*1000); //Time to wait for the other to accept
|
||||
pairStatus = PairStatus.Requested;
|
||||
}
|
||||
|
||||
@@ -193,6 +195,7 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
for (PairingCallback cb : pairingCallback) {
|
||||
cb.pairingFailed(context.getString(R.string.error_could_not_send_package));
|
||||
}
|
||||
Log.e("Device","Unpairing (sendFailed A)");
|
||||
pairStatus = PairStatus.NotPaired;
|
||||
}
|
||||
|
||||
@@ -208,6 +211,7 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
|
||||
if (!isPaired()) return;
|
||||
|
||||
//Log.e("Device","Unpairing (unpair)");
|
||||
pairStatus = PairStatus.NotPaired;
|
||||
|
||||
SharedPreferences preferences = context.getSharedPreferences("trusted_devices", Context.MODE_PRIVATE);
|
||||
@@ -225,16 +229,20 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
|
||||
private void pairingDone() {
|
||||
|
||||
//Log.e("Device", "Storing as trusted, deviceId: "+deviceId);
|
||||
|
||||
if (pairingTimer != null) pairingTimer.cancel();
|
||||
|
||||
pairStatus = PairStatus.Paired;
|
||||
|
||||
//Store as trusted device
|
||||
String encodedPublicKey = Base64.encodeToString(publicKey.getEncoded(), 0);
|
||||
SharedPreferences preferences = context.getSharedPreferences("trusted_devices", Context.MODE_PRIVATE);
|
||||
preferences.edit().putBoolean(deviceId,true).commit();
|
||||
|
||||
//Store device information needed to create a Device object in a future
|
||||
SharedPreferences.Editor editor = settings.edit();
|
||||
editor.putString("deviceName", getName());
|
||||
String encodedPublicKey = Base64.encodeToString(publicKey.getEncoded(), 0);
|
||||
editor.putString("publicKey", encodedPublicKey);
|
||||
editor.commit();
|
||||
|
||||
@@ -259,6 +267,7 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
}
|
||||
@Override
|
||||
public void sendFailed() {
|
||||
Log.e("Device","Unpairing (sendFailed B)");
|
||||
pairStatus = PairStatus.NotPaired;
|
||||
for (PairingCallback cb : pairingCallback) {
|
||||
cb.pairingFailed(context.getString(R.string.error_not_reachable));
|
||||
@@ -272,6 +281,7 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
|
||||
Log.i("Device","Rejected pair request started by the other device");
|
||||
|
||||
//Log.e("Device","Unpairing (rejectPairing)");
|
||||
pairStatus = PairStatus.NotPaired;
|
||||
|
||||
NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_PAIR);
|
||||
@@ -347,8 +357,9 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
|
||||
if (wantsPair == isPaired()) {
|
||||
if (pairStatus == PairStatus.Requested) {
|
||||
//Log.e("Device","Unpairing (pair rejected)");
|
||||
pairStatus = PairStatus.NotPaired;
|
||||
pairingTimer.cancel();
|
||||
if (pairingTimer != null) pairingTimer.cancel();
|
||||
for (PairingCallback cb : pairingCallback) {
|
||||
cb.pairingFailed(context.getString(R.string.error_canceled_by_other_peer));
|
||||
}
|
||||
@@ -376,7 +387,7 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
|
||||
Log.i("Pairing","Pair answer");
|
||||
|
||||
pairingTimer.cancel();
|
||||
if (pairingTimer != null) pairingTimer.cancel();
|
||||
|
||||
pairingDone();
|
||||
|
||||
@@ -405,15 +416,17 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
notificationId = (int)System.currentTimeMillis();
|
||||
notificationManager.notify(notificationId, noti);
|
||||
|
||||
if (pairingTimer != null) pairingTimer.cancel();
|
||||
pairingTimer = new Timer();
|
||||
|
||||
pairingTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.e("Device","Unpairing (timeout B)");
|
||||
pairStatus = PairStatus.NotPaired;
|
||||
notificationManager.cancel(notificationId);
|
||||
}
|
||||
}, 25*1000); //Time to show notification
|
||||
|
||||
}, 25*1000); //Time to show notification, waiting for user to accept (peer will timeout in 30 seconds)
|
||||
pairStatus = PairStatus.RequestedByPeer;
|
||||
for (PairingCallback cb : pairingCallback) cb.incomingRequest();
|
||||
|
||||
@@ -432,6 +445,7 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
reloadPluginsFromSettings();
|
||||
}
|
||||
|
||||
//Log.e("Device","Unpairing (unpair request)");
|
||||
pairStatus = PairStatus.NotPaired;
|
||||
for (PairingCallback cb : pairingCallback) cb.unpaired();
|
||||
|
||||
@@ -515,7 +529,7 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
return plugins.get(name);
|
||||
}
|
||||
|
||||
private void addPlugin(final String name) {
|
||||
private synchronized void addPlugin(final String name) {
|
||||
Plugin existing = plugins.get(name);
|
||||
if (existing != null) {
|
||||
Log.w("addPlugin","plugin already present:" + name);
|
||||
@@ -561,7 +575,7 @@ public class Device implements BaseLink.PackageReceiver {
|
||||
|
||||
}
|
||||
|
||||
private boolean removePlugin(String name) {
|
||||
private synchronized boolean removePlugin(String name) {
|
||||
|
||||
Plugin plugin = plugins.remove(name);
|
||||
Plugin failedPlugin = failedPlugins.remove(name);
|
||||
|
@@ -1,10 +1,12 @@
|
||||
package org.kde.kdeconnect;
|
||||
package org.kde.kdeconnect.Helpers;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class HumanDeviceNames {
|
||||
public class DeviceHelper {
|
||||
|
||||
//from https://github.com/meetup/android-device-names
|
||||
//Converted to java using:
|
||||
@@ -167,4 +169,11 @@ public class HumanDeviceNames {
|
||||
|
||||
}
|
||||
|
||||
public static boolean isTablet() {
|
||||
Configuration config = Resources.getSystem().getConfiguration();
|
||||
//This assumes that the values for the screen sizes are consecutive, so XXLARGE > XLARGE > LARGE
|
||||
boolean isLarge = ((config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE);
|
||||
return isLarge;
|
||||
}
|
||||
|
||||
}
|
@@ -10,13 +10,11 @@ import android.util.Log;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.kde.kdeconnect.Helpers.DeviceHelper;
|
||||
import org.kde.kdeconnect.UserInterface.MainSettingsActivity;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
@@ -28,6 +26,7 @@ public class NetworkPackage {
|
||||
|
||||
public final static int ProtocolVersion = 5;
|
||||
|
||||
//TODO: Move these to their respective plugins
|
||||
public final static String PACKAGE_TYPE_IDENTITY = "kdeconnect.identity";
|
||||
public final static String PACKAGE_TYPE_PAIR = "kdeconnect.pair";
|
||||
public final static String PACKAGE_TYPE_ENCRYPTED = "kdeconnect.encrypted";
|
||||
@@ -222,15 +221,19 @@ public class NetworkPackage {
|
||||
np.mBody.put("deviceName",
|
||||
PreferenceManager.getDefaultSharedPreferences(context).getString(
|
||||
MainSettingsActivity.KEY_DEVICE_NAME_PREFERENCE,
|
||||
HumanDeviceNames.getDeviceName()));
|
||||
DeviceHelper.getDeviceName()));
|
||||
np.mBody.put("protocolVersion", NetworkPackage.ProtocolVersion);
|
||||
} catch (JSONException e) {
|
||||
np.mBody.put("deviceType", DeviceHelper.isTablet()? "tablet" : "phone");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("NetworkPacakge","Exception on createIdentityPackage");
|
||||
}
|
||||
|
||||
return np;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static public NetworkPackage createPublicKeyPackage(Context context) {
|
||||
|
||||
NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_PAIR);
|
||||
|
@@ -17,9 +17,11 @@ import org.kde.kdeconnect_tp.R;
|
||||
|
||||
public class BatteryPlugin extends Plugin {
|
||||
|
||||
private NetworkPackage lastPackage = null;
|
||||
// keep these fields in sync with kdeconnect-kded:BatteryPlugin.h:ThresholdBatteryEvent
|
||||
private static final int THRESHOLD_EVENT_NONE= 0;
|
||||
private static final int THRESHOLD_EVENT_BATTERY_LOW = 1;
|
||||
|
||||
private IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||
NetworkPackage lastInfo = null;
|
||||
|
||||
/*static {
|
||||
PluginFactory.registerPlugin(BatteryPlugin.class);
|
||||
@@ -50,36 +52,36 @@ public class BatteryPlugin extends Plugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private BroadcastReceiver receiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
public void onReceive(Context context, Intent batteryIntent) {
|
||||
|
||||
Log.i("BatteryPlugin", "Battery event");
|
||||
Intent batteryChargeIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
int level = batteryChargeIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
|
||||
int scale = batteryChargeIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 1);
|
||||
int currentCharge = level*100 / scale;
|
||||
boolean isCharging = (0 != batteryChargeIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0));
|
||||
boolean lowBattery = Intent.ACTION_BATTERY_LOW.equals(batteryIntent.getAction());
|
||||
int thresholdEvent = lowBattery? THRESHOLD_EVENT_BATTERY_LOW : THRESHOLD_EVENT_NONE;
|
||||
|
||||
boolean isCharging = (0 != intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0));
|
||||
|
||||
int currentCharge = 100;
|
||||
int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
||||
if (status != BatteryManager.BATTERY_STATUS_FULL) {
|
||||
Intent batteryStatus = context.registerReceiver(null, filter);
|
||||
int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
|
||||
int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
|
||||
currentCharge = level*100 / scale;
|
||||
}
|
||||
|
||||
//Only notify if change is meaningful enough
|
||||
if (lastPackage == null
|
||||
|| (
|
||||
isCharging != lastPackage.getBoolean("isCharging")
|
||||
|| currentCharge != lastPackage.getInt("currentCharge")
|
||||
)
|
||||
if (lastInfo != null
|
||||
&& isCharging != lastInfo.getBoolean("isCharging")
|
||||
&& currentCharge != lastInfo.getInt("currentCharge")
|
||||
&& thresholdEvent != lastInfo.getInt("thresholdEvent")
|
||||
) {
|
||||
|
||||
//Do not send again if nothing has changed
|
||||
return;
|
||||
|
||||
} else {
|
||||
|
||||
NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_BATTERY);
|
||||
np.set("isCharging", isCharging);
|
||||
np.set("currentCharge", currentCharge);
|
||||
np.set("isCharging", isCharging);
|
||||
np.set("thresholdEvent", thresholdEvent);
|
||||
device.sendPackage(np);
|
||||
lastPackage = np;
|
||||
lastInfo = np;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -87,12 +89,14 @@ public class BatteryPlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
context.registerReceiver(receiver, filter);
|
||||
context.registerReceiver(receiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
context.registerReceiver(receiver, new IntentFilter(Intent.ACTION_BATTERY_LOW));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
//It's okay to call this only once, even though we registered it for two filters
|
||||
context.unregisterReceiver(receiver);
|
||||
}
|
||||
|
||||
@@ -101,8 +105,8 @@ public class BatteryPlugin extends Plugin {
|
||||
if (!np.getType().equals(NetworkPackage.PACKAGE_TYPE_BATTERY)) return false;
|
||||
|
||||
if (np.getBoolean("request")) {
|
||||
if (lastPackage != null) {
|
||||
device.sendPackage(lastPackage);
|
||||
if (lastInfo != null) {
|
||||
device.sendPackage(lastInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ public class NotificationReceiver extends NotificationListenerService {
|
||||
|
||||
@Override
|
||||
public void onNotificationPosted(StatusBarNotification statusBarNotification) {
|
||||
Log.i("NotificationReceiver.onNotificationPosted","listeners: " + listeners.size());
|
||||
//Log.e("NotificationReceiver.onNotificationPosted","listeners: " + listeners.size());
|
||||
for(NotificationListener listener : listeners) {
|
||||
listener.onNotificationPosted(statusBarNotification);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class NotificationReceiver extends NotificationListenerService {
|
||||
//This will be called for each intent launch, even if the service is already started and is reused
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.i("NotificationReceiver", "onStartCommand");
|
||||
//Log.e("NotificationReceiver", "onStartCommand");
|
||||
for (InstanceCallback c : callbacks) {
|
||||
c.onServiceStart(this);
|
||||
}
|
||||
|
@@ -126,12 +126,10 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
||||
public void onServiceStart(NotificationReceiver service) {
|
||||
try {
|
||||
service.addListener(NotificationsPlugin.this);
|
||||
/*
|
||||
StatusBarNotification[] notifications = service.getActiveNotifications();
|
||||
for (StatusBarNotification notification : notifications) {
|
||||
onNotificationPosted(notification);
|
||||
}
|
||||
*/
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("NotificationsPlugin","Exception");
|
||||
@@ -204,7 +202,7 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
||||
np.set("id", id.serialize());
|
||||
np.set("appName", appName == null? packageName : appName);
|
||||
np.set("isClearable", statusBarNotification.isClearable());
|
||||
np.set("ticker", notification.tickerText.toString());
|
||||
np.set("ticker", (notification != null && notification.tickerText != null)? notification.tickerText.toString() : "");
|
||||
np.set("time", Long.toString(statusBarNotification.getPostTime()));
|
||||
if (requestAnswer) np.set("requestAnswer", true);
|
||||
|
||||
|
@@ -96,6 +96,8 @@ public class TelephonyPlugin extends Plugin {
|
||||
|
||||
public void callBroadcastReceived(int state, String phoneNumber) {
|
||||
|
||||
//Log.e("TelephonyPlugin", "callBroadcastReceived");
|
||||
|
||||
NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_TELEPHONY);
|
||||
if (phoneNumber != null) {
|
||||
phoneNumber = ContactsHelper.phoneNumberLookup(context,phoneNumber);
|
||||
@@ -162,6 +164,7 @@ public class TelephonyPlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
//Log.e("TelephonyPlugin", "onCreate");
|
||||
IntentFilter filter = new IntentFilter("android.provider.Telephony.SMS_RECEIVED");
|
||||
filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
||||
context.registerReceiver(receiver, filter);
|
||||
|
@@ -24,6 +24,7 @@ import org.kde.kdeconnect_tp.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DeviceActivity extends ActionBarActivity {
|
||||
@@ -63,18 +64,25 @@ public class DeviceActivity extends ActionBarActivity {
|
||||
}
|
||||
});
|
||||
|
||||
//Buttons list
|
||||
ArrayList<ListAdapter.Item> items = new ArrayList<ListAdapter.Item>();
|
||||
final Collection<Plugin> plugins = device.getLoadedPlugins().values();
|
||||
for (Plugin p : plugins) {
|
||||
Button b = p.getInterfaceButton(DeviceActivity.this);
|
||||
if (b != null) {
|
||||
items.add(new SectionItem(p.getDisplayName()));
|
||||
items.add(new ButtonItem(b));
|
||||
try {
|
||||
//Buttons list
|
||||
ArrayList<ListAdapter.Item> items = new ArrayList<ListAdapter.Item>();
|
||||
final Collection<Plugin> plugins = device.getLoadedPlugins().values();
|
||||
for (Plugin p : plugins) {
|
||||
Button b = p.getInterfaceButton(DeviceActivity.this);
|
||||
if (b != null) {
|
||||
items.add(new SectionItem(p.getDisplayName()));
|
||||
items.add(new ButtonItem(b));
|
||||
}
|
||||
}
|
||||
|
||||
ListView buttonsList = (ListView)findViewById(R.id.buttons_list);
|
||||
buttonsList.setAdapter(new ListAdapter(DeviceActivity.this, items));
|
||||
|
||||
} catch(ConcurrentModificationException e) {
|
||||
Log.e("DeviceActivity", "ConcurrentModificationException");
|
||||
this.run(); //Try again
|
||||
}
|
||||
ListView buttonsList = (ListView)findViewById(R.id.buttons_list);
|
||||
buttonsList.setAdapter(new ListAdapter(DeviceActivity.this, items));
|
||||
|
||||
}
|
||||
});
|
||||
|
@@ -13,7 +13,7 @@ import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.kde.kdeconnect.HumanDeviceNames;
|
||||
import org.kde.kdeconnect.Helpers.DeviceHelper;
|
||||
import org.kde.kdeconnect_tp.R;
|
||||
|
||||
public class MainSettingsActivity extends PreferenceActivity{
|
||||
@@ -79,7 +79,7 @@ public class MainSettingsActivity extends PreferenceActivity{
|
||||
Log.i("MainSettingsActivity", "New device name: " + deviceName);
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putString(
|
||||
KEY_DEVICE_NAME_PREFERENCE,
|
||||
HumanDeviceNames.getDeviceName()).commit();
|
||||
DeviceHelper.getDeviceName()).commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -180,6 +180,9 @@ public class ShareToReceiver extends ActionBarActivity {
|
||||
|
||||
if (uri.getScheme().equals("file")) {
|
||||
// file:// is a non media uri, so we cannot query the ContentProvider
|
||||
|
||||
np.set("filename", uri.getLastPathSegment());
|
||||
|
||||
try {
|
||||
size = (int)new File(uri.getPath()).length();
|
||||
np.setPayload(inputStream, size);
|
||||
@@ -187,35 +190,23 @@ public class ShareToReceiver extends ActionBarActivity {
|
||||
e.printStackTrace();
|
||||
Log.e("ShareToReceiver", "Could not obtain file size");
|
||||
}
|
||||
try{
|
||||
np.set("filename", uri.getLastPathSegment());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("ShareToReceiver", "Could not obtain file name");
|
||||
}
|
||||
|
||||
}else{
|
||||
// Probably a content:// uri, so we query the Media content provider
|
||||
String[] proj = { MediaStore.MediaColumns.DATA, MediaStore.MediaColumns.SIZE, MediaStore.MediaColumns.DISPLAY_NAME };
|
||||
Cursor cursor = managedQuery(uri, proj, null, null, null);
|
||||
try {
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.SIZE);
|
||||
cursor.moveToFirst();
|
||||
size = cursor.getInt(column_index);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("ShareToReceiver", "Could not obtain file size");
|
||||
}
|
||||
|
||||
//Log.e("ShareToReceiver", "Size "+size);
|
||||
np.setPayload(inputStream, size);
|
||||
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
String[] proj = { MediaStore.MediaColumns.DATA, MediaStore.MediaColumns.SIZE, MediaStore.MediaColumns.DISPLAY_NAME };
|
||||
cursor = getContentResolver().query(uri, proj, null, null, null);
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
|
||||
cursor.moveToFirst();
|
||||
String path = cursor.getString(column_index);
|
||||
np.set("filename", Uri.parse(path).getLastPathSegment());
|
||||
np.set("size", (int)new File(path).length());
|
||||
} catch(Exception _) {
|
||||
|
||||
Log.e("ShareToReceiver", "Could not resolve media to a file, trying to get info as media");
|
||||
|
||||
try {
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DISPLAY_NAME);
|
||||
cursor.moveToFirst();
|
||||
@@ -225,9 +216,22 @@ public class ShareToReceiver extends ActionBarActivity {
|
||||
e.printStackTrace();
|
||||
Log.e("ShareToReceiver", "Could not obtain file name");
|
||||
}
|
||||
|
||||
try {
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.SIZE);
|
||||
cursor.moveToFirst();
|
||||
//For some reason this size can differ from the actual file size!
|
||||
size = cursor.getInt(column_index);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("ShareToReceiver", "Could not obtain file size");
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
cursor.close();
|
||||
np.setPayload(inputStream, size);
|
||||
|
||||
}
|
||||
|
||||
device.sendPackage(np, new Device.SendPackageFinishedCallback() {
|
||||
|
@@ -23,6 +23,8 @@
|
||||
<string name="mpris_previous">Předchozí</string>
|
||||
<string name="mpris_next">Následující</string>
|
||||
<string name="mpris_volume">Hlasitost</string>
|
||||
<string name="general_settings">Otevřít nastavení</string>
|
||||
<string name="device_name">Zařízení</string>
|
||||
<string name="general_settings">Obecná nastavení</string>
|
||||
<string name="device_name">Název zařízení</string>
|
||||
<string name="device_name_preference_summary">%s</string>
|
||||
<string name="invalid_device_name">Neplatný název zařízení</string>
|
||||
</resources>
|
||||
|
@@ -7,6 +7,7 @@
|
||||
<string name="pref_plugin_clipboard">Abgleich der Zwischenablage</string>
|
||||
<string name="pref_plugin_clipboard_desc">Inhalt der Zwischenablage freigeben</string>
|
||||
<string name="pref_plugin_mpris">Multimedia-Fernbedienungen</string>
|
||||
<string name="pref_plugin_mpris_desc">Audio und Video mit Ihrem Telefon steuern</string>
|
||||
<string name="pref_plugin_ping">Ping</string>
|
||||
<string name="pref_plugin_ping_desc">Senden und Empfangen von Pings</string>
|
||||
<string name="pref_plugin_notifications">Benachrichtigungs-Abgleich</string>
|
||||
@@ -16,10 +17,12 @@
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Abbrechen</string>
|
||||
<string name="open_settings">Einstellungen öffnen</string>
|
||||
<string name="no_permissions">Sie müssen die Erlaubnis zum Zugriff auf Benachrichtigungen erteilen</string>
|
||||
<string name="send_ping">Ping senden</string>
|
||||
<string name="open_mpris_controls">Fernbedienung öffnen</string>
|
||||
<string name="category_connected_devices">Verbundene Geräte</string>
|
||||
<string name="category_not_paired_devices">Keine angeschlossenen Geräte</string>
|
||||
<string name="category_remembered_devices">Gemerkte Geräte</string>
|
||||
<string name="device_menu_plugins">Module auswählen</string>
|
||||
<string name="device_menu_unpair">Verbindung trennen</string>
|
||||
<string name="unknown_device">Unbekanntes Gerät</string>
|
||||
@@ -44,6 +47,8 @@
|
||||
<string name="settings">KDE-Verbindungseinstellungen</string>
|
||||
<string name="mpris_play">Wiedergabe</string>
|
||||
<string name="mpris_previous">Zurück</string>
|
||||
<string name="mpris_rew">Schneller Rücklauf</string>
|
||||
<string name="mpris_ff">Vorlauf</string>
|
||||
<string name="mpris_next">Weiter</string>
|
||||
<string name="mpris_volume">Lautstärke</string>
|
||||
<string name="protocol_version_older">Dieses Gerät verwendet ein alte Protokollversion</string>
|
||||
|
63
src/main/res/values-it/strings.xml
Normal file
63
src/main/res/values-it/strings.xml
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<resources>
|
||||
<string name="pref_plugin_telephony">Notifiche telefoniche</string>
|
||||
<string name="pref_plugin_telephony_desc">Invia notifiche di SMS e chiamate</string>
|
||||
<string name="pref_plugin_battery">Livello batteria</string>
|
||||
<string name="pref_plugin_battery_desc">Comunica periodicamente lo stato della batteria</string>
|
||||
<string name="pref_plugin_clipboard">Sincronizzazione appunti</string>
|
||||
<string name="pref_plugin_clipboard_desc">Condividi il contenuto degli appunti</string>
|
||||
<string name="pref_plugin_mpris">Telecomando multimediale</string>
|
||||
<string name="pref_plugin_mpris_desc">Controlla la riproduzione audio/video dal telefono</string>
|
||||
<string name="pref_plugin_ping">Ping</string>
|
||||
<string name="pref_plugin_ping_desc">Invia e ricevi ping</string>
|
||||
<string name="pref_plugin_notifications">Sincronizzazione notifiche</string>
|
||||
<string name="pref_plugin_notifications_desc">Consenti l\'accesso alle notifiche dagli altri dispositivi</string>
|
||||
<string name="plugin_not_available">Questa funzionalità non è disponibile sulla tua versione di Android</string>
|
||||
<string name="device_list_empty">Nessun dispositivo</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Annulla</string>
|
||||
<string name="open_settings">Apri impostazioni</string>
|
||||
<string name="no_permissions">Devi garantire a KDE Connect l\'accesso alle notifiche</string>
|
||||
<string name="send_ping">Invia ping</string>
|
||||
<string name="open_mpris_controls">Apri il telecomando multimediale</string>
|
||||
<string name="category_connected_devices">Dispositivi connessi</string>
|
||||
<string name="category_not_paired_devices">Dispositivi non associati</string>
|
||||
<string name="category_remembered_devices">Dispositivi memorizzati</string>
|
||||
<string name="plugins_failed_to_load">Alcune estensioni non si sono avviate correttamente (tocca per maggiori informazioni):</string>
|
||||
<string name="device_menu_plugins">Estensioni</string>
|
||||
<string name="device_menu_unpair">Disassocia</string>
|
||||
<string name="unknown_device">Dispositivo sconosciuto</string>
|
||||
<string name="error_not_reachable">Dispositivo fuori portata</string>
|
||||
<string name="error_already_requested">Richiesta già inviata</string>
|
||||
<string name="error_already_paired">Dispositivo già associato</string>
|
||||
<string name="error_could_not_send_package">Impossibile inviare i dati</string>
|
||||
<string name="error_timed_out">Richiesta scaduta</string>
|
||||
<string name="error_canceled_by_user">Richiesta annullata dall\'utente</string>
|
||||
<string name="error_canceled_by_other_peer">Richiesta annullata dal dispositivo remoto</string>
|
||||
<string name="error_invalid_key">Ricevuta chiave non valida</string>
|
||||
<string name="pair_requested">Richiesta di associazione</string>
|
||||
<string name="pairing_request_from">Richiesta associazione da %1s</string>
|
||||
<string name="tap_to_answer">Tocca per rispondere</string>
|
||||
<string name="reconnect">Riconnetti</string>
|
||||
<string name="device_not_paired">Dispositivo non associato</string>
|
||||
<string name="request_pairing">Richiedi associazione</string>
|
||||
<string name="pairing_accept">Accetta</string>
|
||||
<string name="pairing_reject">Rifiuta</string>
|
||||
<string name="device">Dispositivo</string>
|
||||
<string name="pair_device">Associa dispositivo</string>
|
||||
<string name="remote_control">Telecomando</string>
|
||||
<string name="settings">Impostazioni</string>
|
||||
<string name="mpris_play">Riproduci</string>
|
||||
<string name="mpris_previous">Precedente</string>
|
||||
<string name="mpris_rew">Riavvolgi</string>
|
||||
<string name="mpris_ff">Avanti veloce</string>
|
||||
<string name="mpris_next">Successivo</string>
|
||||
<string name="mpris_volume">Volume</string>
|
||||
<string name="share_to">Condividi…</string>
|
||||
<string name="protocol_version_older">Questo dispositivo usa una vecchia versione del protocollo di rete</string>
|
||||
<string name="protocol_version_newer">Questo dispositivo usa una nuova versione del protocollo di rete</string>
|
||||
<string name="general_settings">Impostazioni generali</string>
|
||||
<string name="device_name">Nome dispositivo</string>
|
||||
<string name="device_name_preference_summary">%s</string>
|
||||
<string name="invalid_device_name">Nome non valido</string>
|
||||
</resources>
|
@@ -49,12 +49,15 @@
|
||||
<string name="settings">Nastavenia KDE Connect</string>
|
||||
<string name="mpris_play">Prehrať</string>
|
||||
<string name="mpris_previous">Predošlé</string>
|
||||
<string name="mpris_rew">Pretočiť dozadu</string>
|
||||
<string name="mpris_ff">Pretočiť dopredu</string>
|
||||
<string name="mpris_next">Nasledovné</string>
|
||||
<string name="mpris_volume">Hlasitosť</string>
|
||||
<string name="share_to">Zdieľať pre...</string>
|
||||
<string name="protocol_version_older">Toto zariadenie používa starú verziu protokolu</string>
|
||||
<string name="protocol_version_newer">Toto zariadenie používa novšiu verziu protokolu</string>
|
||||
<string name="general_settings">Otvoriť nastavenia</string>
|
||||
<string name="device_name">Zariadenie nespárované</string>
|
||||
<string name="invalid_device_name">Získaný nesprávny kľúč</string>
|
||||
<string name="general_settings">Všeobecné nastavenia</string>
|
||||
<string name="device_name">Názov zariadenia</string>
|
||||
<string name="device_name_preference_summary">%s</string>
|
||||
<string name="invalid_device_name">Neplatný názov zariadenia</string>
|
||||
</resources>
|
||||
|
Reference in New Issue
Block a user