mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-02 15:15:09 +00:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6c8fdb0be7 | ||
|
749170a29c | ||
|
81b08cf89f | ||
|
786ea7658f | ||
|
996516ec88 | ||
|
a36e4a0c88 | ||
|
e08de81c73 |
@@ -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="10"
|
||||
android:versionName="0.4.1">
|
||||
|
||||
<uses-sdk android:minSdkVersion="9"
|
||||
android:targetSdkVersion="18" />
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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>
|
||||
|
@@ -44,6 +44,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>
|
Reference in New Issue
Block a user