mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-31 14:15:14 +00:00
Clean up TelepathyPlugin
Summary: Depends on D10907 Remove permission checks, unused imports, empty methode Inline permissionexplanation Reviewers: #kde_connect, albertvaka Reviewed By: #kde_connect, albertvaka Subscribers: #kde_connect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D10908
This commit is contained in:
@@ -21,29 +21,23 @@
|
|||||||
package org.kde.kdeconnect.Plugins.TelepathyPlugin;
|
package org.kde.kdeconnect.Plugins.TelepathyPlugin;
|
||||||
|
|
||||||
import android.Manifest;
|
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.telephony.SmsManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.kde.kdeconnect.NetworkPackage;
|
import org.kde.kdeconnect.NetworkPackage;
|
||||||
import org.kde.kdeconnect.Plugins.Plugin;
|
import org.kde.kdeconnect.Plugins.Plugin;
|
||||||
import org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin;
|
import org.kde.kdeconnect.Plugins.TelephonyPlugin.TelephonyPlugin;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class TelepathyPlugin extends Plugin {
|
public class TelepathyPlugin extends Plugin {
|
||||||
|
|
||||||
|
private final static String PACKAGE_TYPE_SMS_REQUEST = "kdeconnect.sms.request";
|
||||||
public final static String PACKAGE_TYPE_SMS_REQUEST = "kdeconnect.sms.request";
|
|
||||||
|
|
||||||
private int telepathyPermissionExplanation = R.string.telepathy_permission_explanation;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
permissionExplanation = telepathyPermissionExplanation;
|
permissionExplanation = R.string.telepathy_permission_explanation;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,10 +51,6 @@ public class TelepathyPlugin extends Plugin {
|
|||||||
return context.getResources().getString(R.string.pref_plugin_telepathy_desc);
|
return context.getResources().getString(R.string.pref_plugin_telepathy_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPackageReceived(NetworkPackage np) {
|
public boolean onPackageReceived(NetworkPackage np) {
|
||||||
|
|
||||||
@@ -71,21 +61,15 @@ public class TelepathyPlugin extends Plugin {
|
|||||||
if (np.getBoolean("sendSms")) {
|
if (np.getBoolean("sendSms")) {
|
||||||
String phoneNo = np.getString("phoneNumber");
|
String phoneNo = np.getString("phoneNumber");
|
||||||
String sms = np.getString("messageBody");
|
String sms = np.getString("messageBody");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int permissionCheck = ContextCompat.checkSelfPermission(context,
|
|
||||||
Manifest.permission.SEND_SMS);
|
|
||||||
|
|
||||||
if (permissionCheck == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
SmsManager smsManager = SmsManager.getDefault();
|
SmsManager smsManager = SmsManager.getDefault();
|
||||||
|
|
||||||
ArrayList<String> parts = smsManager.divideMessage(sms);
|
ArrayList<String> parts = smsManager.divideMessage(sms);
|
||||||
|
|
||||||
// If this message turns out to fit in a single SMS, sendMultipartTextMessage
|
// If this message turns out to fit in a single SMS, sendMultipartTextMessage
|
||||||
// properly handles that case
|
// properly handles that case
|
||||||
smsManager.sendMultipartTextMessage(phoneNo, null, parts, null, null);
|
smsManager.sendMultipartTextMessage(phoneNo, null, parts, null, null);
|
||||||
} else if (permissionCheck == PackageManager.PERMISSION_DENIED) {
|
|
||||||
// TODO Request Permission SEND_SMS
|
|
||||||
}
|
|
||||||
//TODO: Notify other end
|
//TODO: Notify other end
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//TODO: Notify other end
|
//TODO: Notify other end
|
||||||
|
Reference in New Issue
Block a user