mirror of
https://github.com/pppscn/SmsForwarder
synced 2025-08-04 01:47:40 +08:00
新增:转发短信总开关
This commit is contained in:
parent
6bb5749ee2
commit
0a9c84ad01
@ -62,6 +62,9 @@ public class SettingActivity extends AppCompatActivity {
|
|||||||
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_sms_template = findViewById(R.id.switch_sms_template);
|
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_sms_template = findViewById(R.id.switch_sms_template);
|
||||||
switchSmsTemplate(switch_sms_template);
|
switchSmsTemplate(switch_sms_template);
|
||||||
|
|
||||||
|
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_sms = findViewById(R.id.switch_enable_sms);
|
||||||
|
switchEnableSms(switch_enable_sms);
|
||||||
|
|
||||||
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_phone = findViewById(R.id.switch_enable_phone);
|
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_phone = findViewById(R.id.switch_enable_phone);
|
||||||
switchEnablePhone(switch_enable_phone);
|
switchEnablePhone(switch_enable_phone);
|
||||||
|
|
||||||
@ -72,6 +75,16 @@ public class SettingActivity extends AppCompatActivity {
|
|||||||
editSmsTemplate(textSmsTemplate);
|
editSmsTemplate(textSmsTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//设置转发短信
|
||||||
|
private void switchEnableSms(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_sms) {
|
||||||
|
switch_enable_sms.setChecked(SettingUtil.getSwitchEnableSms());
|
||||||
|
|
||||||
|
switch_enable_sms.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
SettingUtil.switchEnableSms(isChecked);
|
||||||
|
Log.d(TAG, "onCheckedChanged:" + isChecked);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//设置转发来电
|
//设置转发来电
|
||||||
private void switchEnablePhone(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_phone) {
|
private void switchEnablePhone(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_phone) {
|
||||||
switch_enable_phone.setChecked(SettingUtil.getSwitchEnablePhone());
|
switch_enable_phone.setChecked(SettingUtil.getSwitchEnablePhone());
|
||||||
|
@ -29,6 +29,9 @@ public class SmsBroadcastReceiver extends BroadcastReceiver {
|
|||||||
Log.d(TAG, "onReceive intent " + receiveAction);
|
Log.d(TAG, "onReceive intent " + receiveAction);
|
||||||
if ("android.provider.Telephony.SMS_RECEIVED".equals(receiveAction)) {
|
if ("android.provider.Telephony.SMS_RECEIVED".equals(receiveAction)) {
|
||||||
try {
|
try {
|
||||||
|
if (!SettingUtil.getSwitchEnableSms()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Bundle extras = intent.getExtras();
|
Bundle extras = intent.getExtras();
|
||||||
Object[] object = (Object[]) Objects.requireNonNull(extras).get("pdus");
|
Object[] object = (Object[]) Objects.requireNonNull(extras).get("pdus");
|
||||||
|
@ -6,6 +6,7 @@ public class Define {
|
|||||||
|
|
||||||
public static final String SP_MSG_KEY_SWITCH_ADD_EXTRA = "tsms_msg_key_switch_add_extra";
|
public static final String SP_MSG_KEY_SWITCH_ADD_EXTRA = "tsms_msg_key_switch_add_extra";
|
||||||
public static final String SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME = "tsms_msg_key_switch_add_extra_device_name";
|
public static final String SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME = "tsms_msg_key_switch_add_extra_device_name";
|
||||||
|
public static final String SP_MSG_KEY_STRING_ENABLE_SMS = "tsms_msg_key_switch_enable_sms";
|
||||||
public static final String SP_MSG_KEY_STRING_ENABLE_PHONE = "tsms_msg_key_switch_enable_phone";
|
public static final String SP_MSG_KEY_STRING_ENABLE_PHONE = "tsms_msg_key_switch_enable_phone";
|
||||||
public static final String SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY = "tsms_msg_key_switch_enable_app_notify";
|
public static final String SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY = "tsms_msg_key_switch_enable_app_notify";
|
||||||
public static final String SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK = "tsms_msg_key_string_add_extra_device_mark";
|
public static final String SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK = "tsms_msg_key_string_add_extra_device_mark";
|
||||||
|
@ -46,6 +46,16 @@ public class SettingUtil {
|
|||||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME, false);
|
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void switchEnableSms(Boolean enable) {
|
||||||
|
sp_setting.edit()
|
||||||
|
.putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_SMS, enable)
|
||||||
|
.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getSwitchEnableSms() {
|
||||||
|
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_SMS, true);
|
||||||
|
}
|
||||||
|
|
||||||
public static void switchEnablePhone(Boolean enable) {
|
public static void switchEnablePhone(Boolean enable) {
|
||||||
sp_setting.edit()
|
sp_setting.edit()
|
||||||
.putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PHONE, enable)
|
.putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PHONE, enable)
|
||||||
|
@ -268,6 +268,33 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:background="@android:color/white"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:padding="15dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/forward_sms"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="RelativeOverlap" />
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/switch_enable_sms"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="3"
|
||||||
|
android:gravity="end"
|
||||||
|
android:textSize="18sp"
|
||||||
|
tools:ignore="UseSwitchCompatOrMaterialXml" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -10,13 +10,15 @@
|
|||||||
<string name="all">全部</string>
|
<string name="all">全部</string>
|
||||||
<string name="select">选择</string>
|
<string name="select">选择</string>
|
||||||
<string name="clone">一键克隆</string>
|
<string name="clone">一键克隆</string>
|
||||||
<string name="setting">设置</string>
|
<string name="setting">通用设置</string>
|
||||||
<string name="about">关于</string>
|
<string name="about">关于软件</string>
|
||||||
<string name="rule_setting">转发规则</string>
|
<string name="rule_setting">转发规则</string>
|
||||||
<string name="sender_setting">发送通道</string>
|
<string name="sender_setting">发送通道</string>
|
||||||
|
<string name="app_list">应用列表</string>
|
||||||
<string name="log_tips">提示:置顶下拉刷新,长按删除单条记录</string>
|
<string name="log_tips">提示:置顶下拉刷新,长按删除单条记录</string>
|
||||||
<string name="rule_tips">提示:新建规则点击“添加”,长按删除/点击编辑已有</string>
|
<string name="rule_tips">提示:新建规则点击“添加”,长按删除/点击编辑已有</string>
|
||||||
<string name="sender_tips">提示:新建发送通道点击“添加”,长按删除/点击编辑已有</string>
|
<string name="sender_tips">提示:新建发送通道点击“添加”,长按删除/点击编辑已有</string>
|
||||||
|
<string name="app_tips">提示:点击复制APP的包名,长按则启动并跳转该APP</string>
|
||||||
<!--AboutActivity-->
|
<!--AboutActivity-->
|
||||||
<string name="version">当前版本</string>
|
<string name="version">当前版本</string>
|
||||||
<string name="check_for_updates">检查新版本</string>
|
<string name="check_for_updates">检查新版本</string>
|
||||||
@ -152,6 +154,7 @@
|
|||||||
<string name="retry_interval_tips">接口请求失败后将重试5次</string>
|
<string name="retry_interval_tips">接口请求失败后将重试5次</string>
|
||||||
<string name="add_extra">转发时附加卡槽信息</string>
|
<string name="add_extra">转发时附加卡槽信息</string>
|
||||||
<string name="add_device_name">转发时附加设备名称</string>
|
<string name="add_device_name">转发时附加设备名称</string>
|
||||||
|
<string name="forward_sms">转发短信广播</string>
|
||||||
<string name="forward_missed_calls">转发未接来电</string>
|
<string name="forward_missed_calls">转发未接来电</string>
|
||||||
<string name="forward_app_notify">转发APP通知</string>
|
<string name="forward_app_notify">转发APP通知</string>
|
||||||
<string name="enable_custom_templates">启用自定义模版</string>
|
<string name="enable_custom_templates">启用自定义模版</string>
|
||||||
@ -207,4 +210,7 @@
|
|||||||
<string name="sms">短 信</string>
|
<string name="sms">短 信</string>
|
||||||
<string name="call">来 电</string>
|
<string name="call">来 电</string>
|
||||||
<string name="app">应 用</string>
|
<string name="app">应 用</string>
|
||||||
|
<string name="appicon">应用图标</string>
|
||||||
|
<string name="user_app">用户应用</string>
|
||||||
|
<string name="system_app">系统应用</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user