diff --git a/res/layout/mpris_control.xml b/res/layout/mpris_control.xml
index 4cbbf076..6752d4b6 100644
--- a/res/layout/mpris_control.xml
+++ b/res/layout/mpris_control.xml
@@ -1,172 +1,157 @@
-
diff --git a/res/layout/nav_header.xml b/res/layout/nav_header.xml
index 47816ac4..18f0ed4f 100644
--- a/res/layout/nav_header.xml
+++ b/res/layout/nav_header.xml
@@ -1,52 +1,36 @@
-
-
diff --git a/src/org/kde/kdeconnect/Plugins/TelepathyPlugin/TelepathyPlugin.java b/src/org/kde/kdeconnect/Plugins/TelepathyPlugin/TelepathyPlugin.java
index f02ce203..e37f949d 100644
--- a/src/org/kde/kdeconnect/Plugins/TelepathyPlugin/TelepathyPlugin.java
+++ b/src/org/kde/kdeconnect/Plugins/TelepathyPlugin/TelepathyPlugin.java
@@ -1,204 +1,114 @@
/*
* Copyright 2014 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.TelepathyPlugin;
import android.Manifest;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.telephony.SmsManager;
import android.util.Log;
import java.util.ArrayList;
import org.kde.kdeconnect.NetworkPackage;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin;
import org.kde.kdeconnect_tp.R;
public class TelepathyPlugin extends Plugin {
public final static String PACKAGE_TYPE_SMS_REQUEST = "kdeconnect.sms.request";
private int telepathyPermissionExplanation = R.string.telepathy_permission_explanation;
@Override
public boolean onCreate() {
permissionExplanation = telepathyPermissionExplanation;
return true;
}
@Override
public String getDisplayName() {
return context.getResources().getString(R.string.pref_plugin_telepathy);
}
@Override
public String getDescription() {
return context.getResources().getString(R.string.pref_plugin_telepathy_desc);
}
@Override
public void onDestroy() {
}
@Override
public boolean onPackageReceived(NetworkPackage np) {
if (!np.getType().equals(PACKAGE_TYPE_SMS_REQUEST)) {
return false;
}
if (np.getBoolean("sendSms")) {
String phoneNo = np.getString("phoneNumber");
String sms = np.getString("messageBody");
try {
int permissionCheck = ContextCompat.checkSelfPermission(context,
Manifest.permission.SEND_SMS);
if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
SmsManager smsManager = SmsManager.getDefault();
ArrayList parts = smsManager.divideMessage(sms);
- // If this message turns out to fit in a single SMS, sendMultpartTextMessage
+ // If this message turns out to fit in a single SMS, sendMultipartTextMessage
// properly handles that case
smsManager.sendMultipartTextMessage(phoneNo, null, parts, null, null);
} else if (permissionCheck == PackageManager.PERMISSION_DENIED) {
// TODO Request Permission SEND_SMS
}
//TODO: Notify other end
} catch (Exception e) {
//TODO: Notify other end
Log.e("TelepathyPlugin", e.getMessage());
e.printStackTrace();
}
}
-/*
- if (np.getBoolean("requestContacts")) {
-
- ArrayList vCards = new ArrayList();
-
- Cursor cursor = context.getContentResolver().query(
- Contacts.CONTENT_URI,
- null,
- Contacts.HAS_PHONE_NUMBER + " > 0 ",
- null,
- null
- );
-
- if (cursor != null && cursor.moveToFirst()) {
- try {
- do {
- String lookupKey = cursor.getString(cursor.getColumnIndex(Contacts.LOOKUP_KEY));
- Uri uri = Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey);
- AssetFileDescriptor fd = null;
- try {
- fd = context.getContentResolver()
- .openAssetFileDescriptor(uri, "r");
- FileInputStream fis = fd.createInputStream();
- byte[] b = new byte[(int) fd.getDeclaredLength()];
- fis.read(b);
- String vCard = new String(b);
- vCards.add(vCard);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- Log.e("RequestContacts", e.getMessage());
- } catch (Exception e) {
- e.printStackTrace();
- Log.e("RequestContacts", e.getMessage());
- } finally {
- if (fd != null) fd.close();
- }
- } while (cursor.moveToNext());
- Log.e("Contacts","Size: "+vCards.size());
- } catch (Exception e) {
- e.printStackTrace();
- Log.e("RequestContacts", e.getMessage());
- } finally {
- cursor.close();
- }
- }
-
- NetworkPackage answer = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_TELEPHONY);
- answer.set("contacts",vCards);
- device.sendPackage(answer);
-
- }
-*/
-/*
- if (np.getBoolean("requestNumbers")) {
-
- ArrayList numbers = new ArrayList();
-
- Cursor cursor = context.getContentResolver().query(
- CommonDataKinds.Phone.CONTENT_URI,
- new String[]{
- CommonDataKinds.Phone.DISPLAY_NAME,
- CommonDataKinds.Phone.NUMBER
- },
- Contacts.HAS_PHONE_NUMBER + " > 0 ",
- null,
- null
- );
-
- if (cursor != null && cursor.moveToFirst()) {
- try {
- do {
- String number = cursor.getString(cursor.getColumnIndex(CommonDataKinds.Phone.NUMBER));
- String name = cursor.getString(cursor.getColumnIndex(CommonDataKinds.Phone.DISPLAY_NAME));
- numbers.add(number);
- } while (cursor.moveToNext());
- Log.e("Numbers","Size: "+numbers.size());
- } catch (Exception e) {
- e.printStackTrace();
- Log.e("RequestContacts", e.getMessage());
- } finally {
- cursor.close();
- }
- }
-
- NetworkPackage answer = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_TELEPHONY);
- answer.set("numbers",numbers);
- device.sendPackage(answer);
- }
-*/
-
return true;
}
@Override
public String[] getSupportedPackageTypes() {
return new String[]{PACKAGE_TYPE_SMS_REQUEST, TelephonyPlugin.PACKAGE_TYPE_TELEPHONY_REQUEST};
}
@Override
public String[] getOutgoingPackageTypes() {
return new String[]{};
}
@Override
public String[] getRequiredPermissions() {
- return new String[]{Manifest.permission.SEND_SMS/*, Manifest.permission.READ_CONTACTS*/};
+ return new String[]{Manifest.permission.SEND_SMS};
}
}