2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 06:05:12 +00:00

Merge branch 'master' into sslrefactor

# Conflicts:
#	src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java
#	src/org/kde/kdeconnect/Plugins/TelephonyPlugin/TelephonyPlugin.java
This commit is contained in:
Albert Vaca
2016-06-01 12:58:10 +02:00
18 changed files with 119 additions and 58 deletions

View File

@@ -1,26 +0,0 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="org.kde.kdeconnect.Plugins.FindMyPhonePlugin.FindMyPhoneActivity">
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/findmyphone_found"
android:textSize="50dp"
android:id="@+id/bFindMyPhone"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 959 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -74,10 +74,14 @@
android:id="@+id/unpair_message"
android:visibility="gone"
android:layout_width="match_parent"
android:drawableStart="@drawable/ic_error_outline_black_48dp"
android:drawableLeft="@drawable/ic_error_outline_black_48dp"
android:drawablePadding="8dip"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="@string/unreachable_description"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="center" />
/>
<ListView
android:id="@+id/buttons_list"

View File

@@ -19,6 +19,7 @@
android:layout_height="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="8dp"
android:background="?attr/colorPrimary" />
<FrameLayout

View File

@@ -46,7 +46,7 @@
<item>La más lenta</item>
<item>Above Slowest</item>
<item>Predeterminada</item>
<item>Above Default</item>
<item>Penriba lo predeterminao</item>
<item>La más rápida</item>
</string-array>
<string name="category_connected_devices">Preseos coneutaos</string>

View File

@@ -32,6 +32,7 @@
<string name="mousepad_info">Pohybujte prstem po obrazovce pro pohybování kurzorem myši. Ťukněte pro kliknutí a použijte dva/tři prsty jako pravé a prostřední tlačítko. Pro přetažení dlouze podržte.</string>
<string name="mousepad_double_tap_settings_title">Nastavit činnost pro ťuknutí dvěma prsty</string>
<string name="mousepad_triple_tap_settings_title">Nastavit činnost pro ťuknutí třemi prsty</string>
<string name="mousepad_sensitivity_settings_title">Nastavit citlivost touchpadu</string>
<string name="mousepad_scroll_direction_title">Obrácený směr posunu</string>
<string-array name="mousepad_tap_entries">
<item>Kliknutí pravým tlačítkem myši</item>
@@ -40,12 +41,13 @@
</string-array>
<string name="mousepad_double_default">pravé</string>
<string name="mousepad_triple_default">prostřední</string>
<string name="mousepad_sensitivity_default">výchozí</string>
<string-array name="mousepad_sensitivity_entries">
<item>Slowest</item>
<item>Above Slowest</item>
<item>Default</item>
<item>Above Default</item>
<item>Fastest</item>
<item>Nejpomalejší</item>
<item>Méně pomalý</item>
<item>Výchozí</item>
<item>Rychlejší</item>
<item>Nejrychlejší</item>
</string-array>
<string name="category_connected_devices">Připojená zařízení</string>
<string name="category_not_paired_devices">Dostupná zařízení</string>
@@ -54,6 +56,7 @@
<string name="device_menu_plugins">Nastavení modulů</string>
<string name="device_menu_unpair">Zrušit párování</string>
<string name="device_not_reachable">Spárované zařízení je nedostupné</string>
<string name="pair_new_device">Spárovat nové zařízení</string>
<string name="unknown_device">Neznámé zařízení</string>
<string name="error_not_reachable">Zařízení je nedostupné</string>
<string name="error_already_requested">Párování již bylo vyžádáno</string>

View File

@@ -53,6 +53,7 @@
<string name="device_menu_plugins">Plugin-indstillinger</string>
<string name="device_menu_unpair">Fjern parring</string>
<string name="device_not_reachable">Den parrede enhed kan ikke tilgås</string>
<string name="pair_new_device">Par med ny enhed</string>
<string name="unknown_device">Ukendt enhed</string>
<string name="error_not_reachable">Enheden kan ikke nås</string>
<string name="error_already_requested">Allerede anmodet om parring</string>

View File

@@ -29,6 +29,7 @@
<string name="send_ping">Ping senden</string>
<string name="open_mpris_controls">Multimedia-Bedienung</string>
<string name="open_mousepad">Ferneingabe</string>
<string name="mousepad_scroll_direction_title">Bildlaufrichtung umkehren</string>
<string-array name="mousepad_tap_entries">
<item>Rechtsklick</item>
<item>Mittelklick</item>
@@ -36,12 +37,13 @@
</string-array>
<string name="mousepad_double_default">Rechts</string>
<string name="mousepad_triple_default">Mitte</string>
<string name="mousepad_sensitivity_default">Standard</string>
<string-array name="mousepad_sensitivity_entries">
<item>Slowest</item>
<item>Langsamste</item>
<item>Above Slowest</item>
<item>Default</item>
<item>Standard</item>
<item>Above Default</item>
<item>Fastest</item>
<item>Schnellste</item>
</string-array>
<string name="category_connected_devices">Verbundene Geräte</string>
<string name="category_not_paired_devices">Verfügbare Gerät</string>
@@ -114,6 +116,7 @@
<string name="pair_device_action">Ein neues Gerät verbinden</string>
<string name="unpair_device_action">Verbindung %s trennen</string>
<string name="custom_device_list">Geräte nach IP hinzufügen</string>
<string name="share_notification_preference">Ausführliche Benachrichtigungen</string>
<string name="share_notification_preference_summary">Beim Empfang einer Datei vibrieren und einen Sound abspielen</string>
<string name="title_activity_notification_filter">Benachrichtigungs-Filter</string>
<string name="filter_apps_info">Benachrichtigungen werden zwischen den ausgewählten Anwendungen abgeglichen.</string>
@@ -129,12 +132,17 @@
<string name="mpris_player_on_device">%1$s auf %2$s</string>
<string name="send_files">Dateien senden</string>
<string name="pairing_title">KDE-Connect-Geräte</string>
<string name="pairing_description">Andere Geräte, auf denen KDE-Connect läuft im gleichen Netzwerk,sollte hier angezeigt werden.</string>
<string name="device_paired">Gerät verbunden</string>
<string name="device_rename_title">Geräte umbenennen</string>
<string name="device_rename_confirm">Umbenennen</string>
<string name="refresh">Aktualisieren</string>
<string name="no_file_browser">Es sind keine Dateiverwaltungsprogramme installiert.</string>
<string name="pref_plugin_telepathy">SMS senden</string>
<string name="pref_plugin_telepathy_desc">Text-Nachrichten von Ihrer Arbeitsfläche senden</string>
<string name="plugin_not_supported">Dieses Modul wird durch das Gerät nicht unterstützt</string>
<string name="findmyphone_title">Telefon suchen</string>
<string name="findmyphone_description">Ruft dieses Telefon an, um es zu suchen.</string>
<string name="findmyphone_found">Gefunden</string>
<string name="open">Öffnen</string>
<string name="close">Schließen</string>

View File

@@ -32,6 +32,7 @@
<string name="mousepad_info">Mueva un dedo sobre la pantalla para mover el cursor del ratón. Pulse para ejecutar un clic y use dos/tres dedos para emular los botones derecho y central. Use una pulsación larga para arrastrar y soltar.</string>
<string name="mousepad_double_tap_settings_title">Establecer la acción al pulsar con dos dedos</string>
<string name="mousepad_triple_tap_settings_title">Establecer la acción al pulsar con tres dedos</string>
<string name="mousepad_sensitivity_settings_title">Establecer sensibilidad del panel táctil</string>
<string name="mousepad_scroll_direction_title">Invertir dirección de desplazamiento</string>
<string-array name="mousepad_tap_entries">
<item>Clic derecho</item>
@@ -40,12 +41,13 @@
</string-array>
<string name="mousepad_double_default">derecho</string>
<string name="mousepad_triple_default">medio</string>
<string name="mousepad_sensitivity_default">por defecto</string>
<string-array name="mousepad_sensitivity_entries">
<item>Slowest</item>
<item>Above Slowest</item>
<item>Default</item>
<item>Above Default</item>
<item>Fastest</item>
<item>Muy poco sensible</item>
<item>Poco sensible</item>
<item>Predeterminada</item>
<item>Sensible</item>
<item>Muy sensible</item>
</string-array>
<string name="category_connected_devices">Dispositivos conectados</string>
<string name="category_not_paired_devices">Dispositivos disponibles</string>

View File

@@ -32,6 +32,7 @@
<string name="mousepad_info">Posúvajte prst na obrazovke na posun kurzora. Ťuknutie vyvolá klik a použite dva/tri prsty pre pravé a stredné tlačidlo. Použite dlhé stlačenie pre drag and drop.</string>
<string name="mousepad_double_tap_settings_title">Nastaviť akciu dvoch prstov</string>
<string name="mousepad_triple_tap_settings_title">Nastaviť akciu troch prstov</string>
<string name="mousepad_sensitivity_settings_title">Nastaviť citlivosť touchpadu</string>
<string name="mousepad_scroll_direction_title">Obrátený smer rolovania</string>
<string-array name="mousepad_tap_entries">
<item>Kliknutie pravým tlačidlom</item>
@@ -40,12 +41,13 @@
</string-array>
<string name="mousepad_double_default">vpravo</string>
<string name="mousepad_triple_default">stred</string>
<string name="mousepad_sensitivity_default">predvolené</string>
<string-array name="mousepad_sensitivity_entries">
<item>Slowest</item>
<item>Above Slowest</item>
<item>Default</item>
<item>Above Default</item>
<item>Fastest</item>
<item>Najpomalšie</item>
<item>Nad najpomalším</item>
<item>Predvolené</item>
<item>Nad priemerným</item>
<item>Najrýchlejšie</item>
</string-array>
<string name="category_connected_devices">Pripojené zariadenia</string>
<string name="category_not_paired_devices">Dostupné zariadenia</string>
@@ -54,6 +56,7 @@
<string name="device_menu_plugins">Nastavenia pluginu</string>
<string name="device_menu_unpair">Odpárovať</string>
<string name="device_not_reachable">Spárované zariadenie nedostupné</string>
<string name="pair_new_device">Spárovať nové zariadenie</string>
<string name="unknown_device">Neznáme zariadenie</string>
<string name="error_not_reachable">Zariadenie nedostupné</string>
<string name="error_already_requested">Spárovanie už vyžiadané</string>

View File

@@ -53,6 +53,7 @@
<string name="device_menu_plugins">插件设置</string>
<string name="device_menu_unpair">取消配对</string>
<string name="device_not_reachable">配对设备不可及</string>
<string name="pair_new_device">配对新设备</string>
<string name="unknown_device">未知设备</string>
<string name="error_not_reachable">设备不可及</string>
<string name="error_already_requested">已在请求配对</string>

View File

@@ -21,46 +21,87 @@
package org.kde.kdeconnect.Helpers;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.PhoneLookup;
import android.util.Base64;
import android.util.Base64OutputStream;
import android.util.Log;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
public class ContactsHelper {
public static String phoneNumberLookup(Context context, String number) {
public static Map<String, String> phoneNumberLookup(Context context, String number) {
//Log.e("PhoneNumberLookup", number);
Map<String, String> contactInfo = new HashMap<String, String>();
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(
uri,
new String[] {
PhoneLookup.DISPLAY_NAME
PhoneLookup.DISPLAY_NAME,
ContactsContract.PhoneLookup.PHOTO_URI
/*, PhoneLookup.TYPE
, PhoneLookup.LABEL
, PhoneLookup.ID */
},
null, null, null);
} catch (IllegalArgumentException e) {
return number;
return contactInfo;
}
// Take the first match only
if (cursor != null && cursor.moveToFirst()) {
int nameIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME);
if (nameIndex != -1) {
String name = cursor.getString(nameIndex);
//Log.e("PhoneNumberLookup", "success: " + name);
contactInfo.put("name", cursor.getString(nameIndex));
}
nameIndex = cursor.getColumnIndex(PhoneLookup.PHOTO_URI);
if (nameIndex != -1) {
contactInfo.put("photoID", cursor.getString(nameIndex));
}
if (!contactInfo.isEmpty()) {
cursor.close();
return name;
return contactInfo;
}
}
if (cursor != null) cursor.close();
return contactInfo;
}
return number;
public static String photoId64Encoded(Context context, String photoId) {
Uri photoUri = Uri.parse(photoId);
Uri displayPhotoUri = Uri.withAppendedPath(photoUri, ContactsContract.Contacts.Photo.DISPLAY_PHOTO);
byte[] buffer = null;
Base64OutputStream out = null;
ByteArrayOutputStream encodedPhoto = null;
try {
encodedPhoto = new ByteArrayOutputStream();
out = new Base64OutputStream(encodedPhoto, Base64.DEFAULT);
InputStream fd2 = context.getContentResolver().openInputStream(photoUri);
buffer = new byte[1024];
int len;
while ((len = fd2.read(buffer)) != -1) {
out.write(buffer, 0, len);
}
return encodedPhoto.toString();
} catch (Exception ex) {
Log.e("ContactsHelper", ex.toString());
return new String();
}
}
}

View File

@@ -26,8 +26,11 @@ public class FindMyPhoneActivity extends Activity {
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
ringtone = RingtoneManager.getRingtone(getApplicationContext(), notification);
Uri soundFile = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
if (soundFile == null) {
soundFile = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
}
ringtone = RingtoneManager.getRingtone(getApplicationContext(), soundFile);
if (android.os.Build.VERSION.SDK_INT >= 21) {
AudioAttributes.Builder b = new AudioAttributes.Builder();

View File

@@ -35,6 +35,7 @@ import org.kde.kdeconnect.NetworkPackage;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect_tp.R;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
@@ -100,10 +101,21 @@ public class TelephonyPlugin extends Plugin {
//Log.e("TelephonyPlugin", "callBroadcastReceived");
Map<String, String> contactInfo = ContactsHelper.phoneNumberLookup(context, phoneNumber);
NetworkPackage np = new NetworkPackage(PACKAGE_TYPE_TELEPHONY);
if (phoneNumber != null) {
np.set("phoneNumber", phoneNumber);
np.set("contactName", ContactsHelper.phoneNumberLookup(context, phoneNumber));
}
if (contactInfo.containsKey("name")) {
np.set("contactName", contactInfo.get("name"));
} else {
np.set("contactName", phoneNumber);
}
if (contactInfo.containsKey("photoID")) {
np.set("phoneThumbnail", ContactsHelper.photoId64Encoded(context, contactInfo.get("photoID")));
}
switch (state) {
@@ -176,9 +188,17 @@ public class TelephonyPlugin extends Plugin {
}
String phoneNumber = message.getOriginatingAddress();
Map<String, String> contactInfo = ContactsHelper.phoneNumberLookup(context, phoneNumber);
if (phoneNumber != null) {
np.set("phoneNumber", phoneNumber);
np.set("contactName", ContactsHelper.phoneNumberLookup(context, phoneNumber));
}
if (contactInfo.containsKey("name")) {
np.set("contactName", contactInfo.get("name"));
}
if (contactInfo.containsKey("photoID")) {
np.set("phoneThumbnail", ContactsHelper.photoId64Encoded(context, contactInfo.get("photoID")));
}
device.sendPackage(np);