mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-28 04:37:40 +00:00
Removed APN settings from user preferences completely and replaced Klinker's get APN settings method with TelephonyHelper's getPreferredApn method.
This commit is contained in:
parent
83cf689478
commit
2758fba3d0
@ -381,15 +381,6 @@
|
|||||||
<string name="set_long_text_as_mms" translatable="false">set_long_text_as_mms</string>
|
<string name="set_long_text_as_mms" translatable="false">set_long_text_as_mms</string>
|
||||||
<string name="convert_to_mms_after_title">Convert to MMS</string>
|
<string name="convert_to_mms_after_title">Convert to MMS</string>
|
||||||
<string name="convert_to_mms_after" translatable="false">convert_to_mms_after</string>
|
<string name="convert_to_mms_after" translatable="false">convert_to_mms_after</string>
|
||||||
<string name="sms_pref_set_mmsc_dialog_desc">Set MMSC</string>
|
|
||||||
<string name="sms_pref_set_mmsc_title">MMSC</string>
|
|
||||||
<string name="sms_pref_set_mmsc" translatable="false">sms_pref_set_mmsc</string>
|
|
||||||
<string name="sms_pref_set_mms_proxy_dialog_desc">Set MMS proxy</string>
|
|
||||||
<string name="sms_pref_set_mms_proxy_title">MMS proxy</string>
|
|
||||||
<string name="sms_pref_set_mms_proxy" translatable="false">sms_pref_set_mms_proxy</string>
|
|
||||||
<string name="sms_pref_set_mms_port_dialog_desc">Set MMS port</string>
|
|
||||||
<string name="sms_pref_set_mms_port_title">MMS port</string>
|
|
||||||
<string name="sms_pref_set_mms_port" translatable="false">sms_pref_set_mms_port</string>
|
|
||||||
<string name="convert_to_mms_after_default" translatable="false">3</string>
|
<string name="convert_to_mms_after_default" translatable="false">3</string>
|
||||||
<string-array name="convert_to_mms_after_entries">
|
<string-array name="convert_to_mms_after_entries">
|
||||||
<item>After one message</item>
|
<item>After one message</item>
|
||||||
|
@ -1,32 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:keep="@xml/smsplugin_preferences">
|
tools:keep="@xml/smsplugin_preferences">
|
||||||
|
|
||||||
<EditTextPreference
|
|
||||||
android:dialogMessage="@string/sms_pref_set_mmsc_dialog_desc"
|
|
||||||
android:key="@string/sms_pref_set_mmsc"
|
|
||||||
android:title="@string/sms_pref_set_mmsc_title"
|
|
||||||
android:defaultValue="Not set"
|
|
||||||
app:useSimpleSummaryProvider="true" />
|
|
||||||
|
|
||||||
<EditTextPreference
|
|
||||||
android:dialogMessage="@string/sms_pref_set_mms_proxy_dialog_desc"
|
|
||||||
android:key="@string/sms_pref_set_mms_proxy"
|
|
||||||
android:title="@string/sms_pref_set_mms_proxy_title"
|
|
||||||
android:defaultValue="Not set"
|
|
||||||
app:useSimpleSummaryProvider="true" />
|
|
||||||
|
|
||||||
<EditTextPreference
|
|
||||||
android:dialogMessage="@string/sms_pref_set_mms_port_dialog_desc"
|
|
||||||
android:key="@string/sms_pref_set_mms_port"
|
|
||||||
android:title="@string/sms_pref_set_mms_port_title"
|
|
||||||
android:defaultValue="Not set"
|
|
||||||
app:useSimpleSummaryProvider="true" />
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:id="@+id/group_message_preference"
|
android:id="@+id/group_message_preference"
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
|
@ -32,7 +32,7 @@ public class DelegatingMmsReceivedReceiver extends BroadcastReceiver {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
MmsReceivedReceiver delegate = new MmsReceivedReceiver();
|
MmsReceivedReceiver delegate = new MmsReceivedReceiver();
|
||||||
|
|
||||||
delegate.loadFromPreferences(context);
|
delegate.getPreferredApn(context, intent);
|
||||||
delegate.onReceive(context, intent);
|
delegate.onReceive(context, intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,14 @@ package org.kde.kdeconnect.Plugins.SMSPlugin;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.preference.PreferenceManager;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.klinker.android.send_message.Transaction;
|
import com.klinker.android.send_message.Transaction;
|
||||||
|
import com.klinker.android.send_message.Utils;
|
||||||
|
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect.Helpers.TelephonyHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receiver for notifying user when a new MMS has been received by the device. By default it will
|
* Receiver for notifying user when a new MMS has been received by the device. By default it will
|
||||||
@ -38,9 +38,7 @@ import org.kde.kdeconnect_tp.R;
|
|||||||
*/
|
*/
|
||||||
public class MmsReceivedReceiver extends com.klinker.android.send_message.MmsReceivedReceiver {
|
public class MmsReceivedReceiver extends com.klinker.android.send_message.MmsReceivedReceiver {
|
||||||
|
|
||||||
private String mmscUrl = null;
|
private TelephonyHelper.ApnSetting apnSetting = null;
|
||||||
private String mmsProxy = null;
|
|
||||||
private String mmsPort = null;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceived(Context context, Uri messageUri) {
|
public void onMessageReceived(Context context, Uri messageUri) {
|
||||||
@ -56,11 +54,9 @@ public class MmsReceivedReceiver extends com.klinker.android.send_message.MmsRec
|
|||||||
Log.v("MmsReceived", "error: " + error);
|
Log.v("MmsReceived", "error: " + error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadFromPreferences(Context context) {
|
public void getPreferredApn(Context context, Intent intent) {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
int subscriptionId = intent.getIntExtra(SUBSCRIPTION_ID, Utils.getDefaultSubscriptionId());
|
||||||
mmscUrl = prefs.getString(context.getString(R.string.sms_pref_set_mmsc), "");
|
apnSetting = TelephonyHelper.getPreferredApn(context, subscriptionId);
|
||||||
mmsProxy = prefs.getString(context.getString(R.string.sms_pref_set_mms_proxy), "");
|
|
||||||
mmsPort = prefs.getString(context.getString(R.string.sms_pref_set_mms_port), "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,16 +67,17 @@ public class MmsReceivedReceiver extends com.klinker.android.send_message.MmsRec
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MmscInformation getMmscInfoForReceptionAck() {
|
public MmscInformation getMmscInfoForReceptionAck() {
|
||||||
|
if (apnSetting != null) {
|
||||||
|
String mmscUrl = apnSetting.getMmsc().toString();
|
||||||
|
String mmsProxy = apnSetting.getMmsProxyAddressAsString();
|
||||||
|
int mmsPort = apnSetting.getMmsProxyPort();
|
||||||
|
|
||||||
if (mmscUrl != null || mmsProxy != null || mmsPort != null) {
|
|
||||||
try {
|
try {
|
||||||
return new MmscInformation(mmscUrl, mmsProxy, Integer.parseInt(mmsPort));
|
return new MmscInformation(mmscUrl, mmsProxy, mmsPort);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("MmsReceivedReceiver", "Exception", e);
|
Log.e("MmsReceivedReceiver", "Exception", e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ import com.klinker.android.send_message.Utils;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.kde.kdeconnect.Helpers.SMSHelper;
|
import org.kde.kdeconnect.Helpers.SMSHelper;
|
||||||
|
import org.kde.kdeconnect.Helpers.TelephonyHelper;
|
||||||
import org.kde.kdeconnect_tp.R;
|
import org.kde.kdeconnect_tp.R;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -62,17 +63,16 @@ public class SmsMmsUtils {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Settings settings = new Settings();
|
Settings settings = new Settings();
|
||||||
|
TelephonyHelper.ApnSetting apnSettings = TelephonyHelper.getPreferredApn(context, subID);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
if (apnSettings != null) {
|
||||||
// If the build version is less than lollipop then we have to manually take the APN settings
|
settings.setMmsc(apnSettings.getMmsc().toString());
|
||||||
// from the user in order to be able to send MMS.
|
settings.setProxy(apnSettings.getMmsProxyAddressAsString());
|
||||||
settings.setMmsc(prefs.getString(context.getString(R.string.sms_pref_set_mmsc), ""));
|
settings.setPort(Integer.toString(apnSettings.getMmsProxyPort()));
|
||||||
settings.setProxy(prefs.getString(context.getString(R.string.sms_pref_set_mms_proxy), ""));
|
} else {
|
||||||
settings.setPort(prefs.getString(context.getString(R.string.sms_pref_set_mms_port), ""));
|
settings.setUseSystemSending(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.setUseSystemSending(true);
|
|
||||||
|
|
||||||
if (Utils.isDefaultSmsApp(context)) {
|
if (Utils.isDefaultSmsApp(context)) {
|
||||||
settings.setSendLongAsMms(longTextAsMms);
|
settings.setSendLongAsMms(longTextAsMms);
|
||||||
settings.setSendLongAsMmsAfter(sendLongAsMmsAfter);
|
settings.setSendLongAsMmsAfter(sendLongAsMmsAfter);
|
||||||
|
@ -22,6 +22,7 @@ package org.kde.kdeconnect.UserInterface;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@ -41,6 +42,7 @@ import com.klinker.android.send_message.Utils;
|
|||||||
import org.kde.kdeconnect.BackgroundService;
|
import org.kde.kdeconnect.BackgroundService;
|
||||||
import org.kde.kdeconnect.Device;
|
import org.kde.kdeconnect.Device;
|
||||||
import org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper;
|
import org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper;
|
||||||
|
import org.kde.kdeconnect.Helpers.TelephonyHelper;
|
||||||
import org.kde.kdeconnect.Plugins.Plugin;
|
import org.kde.kdeconnect.Plugins.Plugin;
|
||||||
import org.kde.kdeconnect.Plugins.SMSPlugin.SMSPlugin;
|
import org.kde.kdeconnect.Plugins.SMSPlugin.SMSPlugin;
|
||||||
import org.kde.kdeconnect.UserInterface.List.FailedPluginListItem;
|
import org.kde.kdeconnect.UserInterface.List.FailedPluginListItem;
|
||||||
@ -54,6 +56,7 @@ import org.kde.kdeconnect_tp.databinding.ActivityDeviceBinding;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.ConcurrentModificationException;
|
import java.util.ConcurrentModificationException;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
|
||||||
@ -309,10 +312,25 @@ public class DeviceFragment extends Fragment {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Add a button to the pluginList for setting KDE Connect as default sms app for allowing it to send mms
|
// Add a button to the pluginList for setting KDE Connect as default sms app for allowing it to send mms
|
||||||
// for now I'm not able to integrate it with other plugin list, but this needs to be reimplemented in a better way.
|
|
||||||
if (!Utils.isDefaultSmsApp(mActivity)) {
|
if (!Utils.isDefaultSmsApp(mActivity)) {
|
||||||
|
// Check if there are any preferred APN settings available on the device, if not then disable the MMS support
|
||||||
|
boolean hasApnSettings = false;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
|
List<Integer> subIds = TelephonyHelper.getActiveSubscriptionIDs(mActivity);
|
||||||
|
for (final int subId : subIds) {
|
||||||
|
if (TelephonyHelper.getPreferredApn(mActivity, subId) != null) {
|
||||||
|
hasApnSettings = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (TelephonyHelper.getPreferredApn(mActivity, 0) != null) {
|
||||||
|
hasApnSettings = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Plugin p : plugins) {
|
for (Plugin p : plugins) {
|
||||||
if (p.getPluginKey().equals("SMSPlugin")) {
|
if (p.getPluginKey().equals("SMSPlugin") && hasApnSettings) {
|
||||||
pluginListItems.add(new SetDefaultAppPluginListItem(p, mActivity.getResources().getString(R.string.pref_plugin_telepathy_mms), (action) -> {
|
pluginListItems.add(new SetDefaultAppPluginListItem(p, mActivity.getResources().getString(R.string.pref_plugin_telepathy_mms), (action) -> {
|
||||||
DialogFragment dialog = new DefaultSmsAppAlertDialogFragment.Builder()
|
DialogFragment dialog = new DefaultSmsAppAlertDialogFragment.Builder()
|
||||||
.setTitle(R.string.set_default_sms_app_title)
|
.setTitle(R.string.set_default_sms_app_title)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user