新增:监听其他APP通知信息

pull/67/head
pppscn 3 years ago
parent e8ea004bc4
commit 5703c7d637

@ -129,9 +129,9 @@ dependencies {
implementation "com.alibaba:fastjson:1.2.78" implementation "com.alibaba:fastjson:1.2.78"
//SDK //SDK
implementation 'com.umeng.umsdk:common:9.4.4'// // implementation 'com.umeng.umsdk:common:9.4.4'//
implementation 'com.umeng.umsdk:asms:1.4.1'// // implementation 'com.umeng.umsdk:asms:1.4.1'//
implementation 'com.umeng.umsdk:apm:1.4.2' // SDKcrash // implementation 'com.umeng.umsdk:apm:1.4.2' // SDKcrash
//XUpdate //XUpdate
implementation 'com.github.xuexiangjys:XUpdate:2.1.0' implementation 'com.github.xuexiangjys:XUpdate:2.1.0'
@ -151,4 +151,8 @@ dependencies {
//AndroidAsync //AndroidAsync
implementation 'com.koushikdutta.async:androidasync:3.1.0' implementation 'com.koushikdutta.async:androidasync:3.1.0'
//Bind Android views and callbacks to fields and methods.
//implementation 'com.jakewharton:butterknife-gradle-plugin:10.2.3'
//annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
} }

@ -15,6 +15,8 @@ import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -55,6 +57,7 @@ public class MainActivity extends AppCompatActivity implements NotifyListener, R
private RefreshListView listView; private RefreshListView listView;
private Intent serviceIntent; private Intent serviceIntent;
private static final int REQUEST_CODE = 9999; private static final int REQUEST_CODE = 9999;
private String currentType = "sms";
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -98,6 +101,17 @@ public class MainActivity extends AppCompatActivity implements NotifyListener, R
initTLogs(); //初始化数据 initTLogs(); //初始化数据
showList(logVos); showList(logVos);
//切换日志类别
int typeCheckId = getTypeCheckId(currentType);
final RadioGroup radioGroupTypeCheck = findViewById(R.id.radioGroupTypeCheck);
radioGroupTypeCheck.check(typeCheckId);
radioGroupTypeCheck.setOnCheckedChangeListener((group, checkedId) -> {
RadioButton rb = findViewById(checkedId);
currentType = (String) rb.getTag();
initTLogs();
showList(logVos);
});
// 为ListView注册一个监听器当用户点击了ListView中的任何一个子项时就会回调onItemClick()方法 // 为ListView注册一个监听器当用户点击了ListView中的任何一个子项时就会回调onItemClick()方法
// 在这个方法中可以通过position参数判断出用户点击的是那一个子项 // 在这个方法中可以通过position参数判断出用户点击的是那一个子项
listView.setOnItemClickListener((parent, view, position, id) -> { listView.setOnItemClickListener((parent, view, position, id) -> {
@ -134,6 +148,17 @@ public class MainActivity extends AppCompatActivity implements NotifyListener, R
}); });
} }
private int getTypeCheckId(String currentType) {
switch (currentType) {
case "call":
return R.id.btnTypeCall;
case "app":
return R.id.btnTypeApp;
default:
return R.id.btnTypeSms;
}
}
@SuppressLint("ObsoleteSdkInt") @SuppressLint("ObsoleteSdkInt")
@Override @Override
protected void onResume() { protected void onResume() {
@ -237,7 +262,7 @@ public class MainActivity extends AppCompatActivity implements NotifyListener, R
// 初始化数据 // 初始化数据
private void initTLogs() { private void initTLogs() {
logVos = LogUtil.getLog(null, null); logVos = LogUtil.getLog(null, null, currentType);
} }
private void showList(List<LogVo> logVosN) { private void showList(List<LogVo> logVosN) {
@ -247,7 +272,6 @@ public class MainActivity extends AppCompatActivity implements NotifyListener, R
listView = findViewById(R.id.list_view_log); listView = findViewById(R.id.list_view_log);
listView.setInterface(this); listView.setInterface(this);
adapter = new LogAdapter(MainActivity.this, R.layout.item_log, logVosN); adapter = new LogAdapter(MainActivity.this, R.layout.item_log, logVosN);
listView.setAdapter(adapter); listView.setAdapter(adapter);
} else { } else {
adapter.onDateChange(logVosN); adapter.onDateChange(logVosN);
@ -390,6 +414,7 @@ public class MainActivity extends AppCompatActivity implements NotifyListener, R
@Override @Override
public void onReceiveMessage(StatusBarNotification sbn) { public void onReceiveMessage(StatusBarNotification sbn) {
if (sbn.getNotification() == null) return; if (sbn.getNotification() == null) return;
if (sbn.getNotification().extras == null) return;
//推送通知的应用包名 //推送通知的应用包名
String packageName = sbn.getPackageName(); String packageName = sbn.getPackageName();
@ -414,7 +439,7 @@ public class MainActivity extends AppCompatActivity implements NotifyListener, R
SmsVo smsVo = new SmsVo(packageName, text, new Date(), title); SmsVo smsVo = new SmsVo(packageName, text, new Date(), title);
Log.d(TAG, "send_msg" + smsVo.toString()); Log.d(TAG, "send_msg" + smsVo.toString());
SendUtil.send_msg(this, smsVo, 1); SendUtil.send_msg(this, smsVo, 1, "app");
} }
/** /**

@ -16,8 +16,6 @@ import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.PhoneUtils; import com.idormy.sms.forwarder.utils.PhoneUtils;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtil;
import com.smailnet.emailkit.EmailKit; import com.smailnet.emailkit.EmailKit;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -77,11 +75,11 @@ public class MyApplication extends Application {
super.onCreate(); super.onCreate();
//初始化组件化基础库, 所有友盟业务SDK都必须调用此初始化接口。 //初始化组件化基础库, 所有友盟业务SDK都必须调用此初始化接口。
//建议在宿主App的Application.onCreate函数中调用基础组件库初始化函数。 //建议在宿主App的Application.onCreate函数中调用基础组件库初始化函数。
UMConfigure.init(this, "60254fc7425ec25f10f4293e", getChannelName(this), UMConfigure.DEVICE_TYPE_PHONE, ""); //UMConfigure.init(this, "60254fc7425ec25f10f4293e", getChannelName(this), UMConfigure.DEVICE_TYPE_PHONE, "");
// 选用LEGACY_AUTO页面采集模式 // 选用LEGACY_AUTO页面采集模式
MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.LEGACY_MANUAL); //MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.LEGACY_MANUAL);
//pro close log //pro close log
UMConfigure.setLogEnabled(true); //UMConfigure.setLogEnabled(true);
Intent intent = new Intent(this, FrontService.class); Intent intent = new Intent(this, FrontService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

@ -12,6 +12,7 @@ import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup; import android.widget.RadioGroup;
import android.widget.Switch; import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
@ -28,7 +29,6 @@ import com.idormy.sms.forwarder.sender.SendUtil;
import com.idormy.sms.forwarder.sender.SenderUtil; import com.idormy.sms.forwarder.sender.SenderUtil;
import com.idormy.sms.forwarder.utils.RuleUtil; import com.idormy.sms.forwarder.utils.RuleUtil;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtil;
import com.umeng.analytics.MobclickAgent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -41,6 +41,7 @@ public class RuleActivity extends AppCompatActivity {
// 用于存储数据 // 用于存储数据
private List<RuleModel> ruleModels = new ArrayList<>(); private List<RuleModel> ruleModels = new ArrayList<>();
private RuleAdapter adapter; private RuleAdapter adapter;
private String currentType = "sms";
//消息处理者,创建一个Handler的子类对象,目的是重写Handler的处理消息的方法(handleMessage()) //消息处理者,创建一个Handler的子类对象,目的是重写Handler的处理消息的方法(handleMessage())
@SuppressLint("HandlerLeak") @SuppressLint("HandlerLeak")
@ -108,11 +109,34 @@ public class RuleActivity extends AppCompatActivity {
builder.create().show(); builder.create().show();
return true; return true;
}); });
//切换日志类别
int typeCheckId = getTypeCheckId(currentType);
final RadioGroup radioGroupTypeCheck = findViewById(R.id.radioGroupTypeCheck);
radioGroupTypeCheck.check(typeCheckId);
radioGroupTypeCheck.setOnCheckedChangeListener((group, checkedId) -> {
RadioButton rb = findViewById(checkedId);
currentType = (String) rb.getTag();
initRules(); //初始化数据
adapter = new RuleAdapter(RuleActivity.this, R.layout.item_rule, ruleModels);
listView.setAdapter(adapter);
});
}
private int getTypeCheckId(String currentType) {
switch (currentType) {
case "call":
return R.id.btnTypeCall;
case "app":
return R.id.btnTypeApp;
default:
return R.id.btnTypeSms;
}
} }
// 初始化数据 // 初始化数据
private void initRules() { private void initRules() {
ruleModels = RuleUtil.getRule(null, null); ruleModels = RuleUtil.getRule(null, null, currentType);
} }
public void addRule(View view) { public void addRule(View view) {
@ -189,6 +213,7 @@ public class RuleActivity extends AppCompatActivity {
Log.d(TAG, radioGroupRuleCheck.getCheckedRadioButtonId() + " " + radioGroupRuleCheck2.getCheckedRadioButtonId() + " " + radioGroupRuleCheckId); Log.d(TAG, radioGroupRuleCheck.getCheckedRadioButtonId() + " " + radioGroupRuleCheck2.getCheckedRadioButtonId() + " " + radioGroupRuleCheckId);
if (ruleModel == null) { if (ruleModel == null) {
RuleModel newRuleModel = new RuleModel(); RuleModel newRuleModel = new RuleModel();
newRuleModel.setType(currentType);
newRuleModel.setFiled(RuleModel.getRuleFiledFromCheckId(radioGroupRuleFiled.getCheckedRadioButtonId())); newRuleModel.setFiled(RuleModel.getRuleFiledFromCheckId(radioGroupRuleFiled.getCheckedRadioButtonId()));
newRuleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId)); newRuleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId));
newRuleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId())); newRuleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId()));
@ -449,13 +474,13 @@ public class RuleActivity extends AppCompatActivity {
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
MobclickAgent.onResume(this); //MobclickAgent.onResume(this);
} }
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
MobclickAgent.onPause(this); //MobclickAgent.onPause(this);
} }
} }

@ -65,6 +65,9 @@ public class SettingActivity extends AppCompatActivity {
@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);
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_app_notify = findViewById(R.id.switch_enable_app_notify);
switchEnableAppNotify(switch_enable_app_notify);
EditText textSmsTemplate = findViewById(R.id.text_sms_template); EditText textSmsTemplate = findViewById(R.id.text_sms_template);
editSmsTemplate(textSmsTemplate); editSmsTemplate(textSmsTemplate);
} }
@ -79,6 +82,16 @@ public class SettingActivity extends AppCompatActivity {
}); });
} }
//设置转发APP通知
private void switchEnableAppNotify(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_app_notify) {
switch_enable_app_notify.setChecked(SettingUtil.getSwitchEnableAppNotify());
switch_enable_app_notify.setOnCheckedChangeListener((buttonView, isChecked) -> {
SettingUtil.switchEnableAppNotify(isChecked);
Log.d(TAG, "onCheckedChanged:" + isChecked);
});
}
//设置设备名称 //设置设备名称
private void editAddExtraDeviceMark(final EditText et_add_extra_device_mark) { private void editAddExtraDeviceMark(final EditText et_add_extra_device_mark) {
et_add_extra_device_mark.setText(SettingUtil.getAddExtraDeviceMark()); et_add_extra_device_mark.setText(SettingUtil.getAddExtraDeviceMark());

@ -11,12 +11,14 @@ public class LogModel {
private Long ruleId; private Long ruleId;
private Long time; private Long time;
private String simInfo; private String simInfo;
private String type;
public LogModel(String from, String content, String simInfo, Long ruleId) { public LogModel(String type, String from, String content, String simInfo, Long ruleId) {
this.from = from; this.from = from;
this.content = content; this.content = content;
this.simInfo = simInfo; this.simInfo = simInfo;
this.ruleId = ruleId; this.ruleId = ruleId;
this.type = type;
} }
@NonNull @NonNull
@ -27,6 +29,7 @@ public class LogModel {
", content='" + content + '\'' + ", content='" + content + '\'' +
", simInfo=" + simInfo + ", simInfo=" + simInfo +
", ruleId=" + ruleId + ", ruleId=" + ruleId +
", type=" + type +
", time=" + time + ", time=" + time +
'}'; '}';
} }

@ -11,6 +11,7 @@ public final class LogTable {
/* Inner class that defines the table contents */ /* Inner class that defines the table contents */
public static class LogEntry implements BaseColumns { public static class LogEntry implements BaseColumns {
public static final String TABLE_NAME = "log"; public static final String TABLE_NAME = "log";
public static final String COLUMN_NAME_TYPE = "type";
public static final String COLUMN_NAME_FROM = "l_from"; public static final String COLUMN_NAME_FROM = "l_from";
public static final String COLUMN_NAME_CONTENT = "content"; public static final String COLUMN_NAME_CONTENT = "content";
public static final String COLUMN_NAME_RULE_ID = "rule_id"; public static final String COLUMN_NAME_RULE_ID = "rule_id";

@ -37,6 +37,13 @@ public class RuleModel {
public static final String CHECK_SIM_SLOT_1 = "SIM1"; public static final String CHECK_SIM_SLOT_1 = "SIM1";
public static final String CHECK_SIM_SLOT_2 = "SIM2"; public static final String CHECK_SIM_SLOT_2 = "SIM2";
public static final Map<String, String> SIM_SLOT_MAP = new HashMap<>(); public static final Map<String, String> SIM_SLOT_MAP = new HashMap<>();
public static final Map<String, String> TYPE_MAP = new HashMap<>();
static {
TYPE_MAP.put("sms", "短信");
TYPE_MAP.put("call", "来电");
TYPE_MAP.put("app", "应用");
}
static { static {
FILED_MAP.put("transpond_all", "全部转发"); FILED_MAP.put("transpond_all", "全部转发");
@ -63,6 +70,7 @@ public class RuleModel {
private String TAG = "RuleModel"; private String TAG = "RuleModel";
private Long id; private Long id;
private String type;
private String filed; private String filed;
private String check; private String check;
private String value; private String value;

@ -11,6 +11,7 @@ public final class RuleTable {
/* Inner class that defines the table contents */ /* Inner class that defines the table contents */
public static class RuleEntry implements BaseColumns { public static class RuleEntry implements BaseColumns {
public static final String TABLE_NAME = "rule"; public static final String TABLE_NAME = "rule";
public static final String COLUMN_NAME_TYPE = "type";
public static final String COLUMN_NAME_FILED = "filed"; public static final String COLUMN_NAME_FILED = "filed";
public static final String COLUMN_NAME_CHECK = "tcheck"; public static final String COLUMN_NAME_CHECK = "tcheck";
public static final String COLUMN_NAME_VALUE = "value"; public static final String COLUMN_NAME_VALUE = "value";

@ -32,12 +32,15 @@ public class LogVo {
} }
public int getSimImageId() { public int getSimImageId() {
if (this.simInfo != null && !this.simInfo.isEmpty() if (this.simInfo != null && !this.simInfo.isEmpty()) {
&& this.simInfo.replace("-", "").startsWith("SIM2")) { if (this.simInfo.replace("-", "").startsWith("SIM2")) {
return R.mipmap.sim2; return R.drawable.sim2; //mipmap
} else if (this.simInfo.replace("-", "").startsWith("SIM1")) {
return R.drawable.sim1;
}
} }
return R.mipmap.sim1; return R.drawable.app;
} }
public int getStatusImageId() { public int getStatusImageId() {

@ -90,6 +90,6 @@ public class PhoneStateReceiver extends BroadcastReceiver {
} }
SmsVo smsVo = new SmsVo(phoneNumber, name + context.getString(R.string.calling), new Date(), simInfo); SmsVo smsVo = new SmsVo(phoneNumber, name + context.getString(R.string.calling), new Date(), simInfo);
Log.d(TAG, "send_msg" + smsVo.toString()); Log.d(TAG, "send_msg" + smsVo.toString());
SendUtil.send_msg(context, smsVo, simId); SendUtil.send_msg(context, smsVo, simId, "call");
} }
} }

@ -81,7 +81,7 @@ public class SmsForwarderBroadcastReceiver extends BroadcastReceiver {
smsVoList.add(new SmsVo(mobile, mobileToContent.get(mobile), date, simInfo)); smsVoList.add(new SmsVo(mobile, mobileToContent.get(mobile), date, simInfo));
} }
Log.d(TAG, "短信:" + smsVoList); Log.d(TAG, "短信:" + smsVoList);
SendUtil.send_msg_list(context, smsVoList, simId); SendUtil.send_msg_list(context, smsVoList, simId, "sms");
} }

@ -39,20 +39,20 @@ import java.util.List;
public class SendUtil { public class SendUtil {
private static final String TAG = "SendUtil"; private static final String TAG = "SendUtil";
public static void send_msg_list(Context context, List<SmsVo> smsVoList, int simId) { public static void send_msg_list(Context context, List<SmsVo> smsVoList, int simId, String type) {
Log.i(TAG, "send_msg_list size: " + smsVoList.size()); Log.i(TAG, "send_msg_list size: " + smsVoList.size());
for (SmsVo smsVo : smsVoList) { for (SmsVo smsVo : smsVoList) {
SendUtil.send_msg(context, smsVo, simId); SendUtil.send_msg(context, smsVo, simId, type);
} }
} }
public static void send_msg(Context context, SmsVo smsVo, int simId) { public static void send_msg(Context context, SmsVo smsVo, int simId, String type) {
Log.i(TAG, "send_msg smsVo:" + smsVo); Log.i(TAG, "send_msg smsVo:" + smsVo);
RuleUtil.init(context); RuleUtil.init(context);
LogUtil.init(context); LogUtil.init(context);
String key = "SIM" + simId; String key = "SIM" + simId;
List<RuleModel> ruleList = RuleUtil.getRule(null, key); List<RuleModel> ruleList = RuleUtil.getRule(null, key, type);
if (!ruleList.isEmpty()) { if (!ruleList.isEmpty()) {
SenderUtil.init(context); SenderUtil.init(context);
for (RuleModel ruleModel : ruleList) { for (RuleModel ruleModel : ruleList) {
@ -62,7 +62,7 @@ public class SendUtil {
List<SenderModel> senderModels = SenderUtil.getSender(ruleModel.getSenderId(), null); List<SenderModel> senderModels = SenderUtil.getSender(ruleModel.getSenderId(), null);
for (SenderModel senderModel : senderModels for (SenderModel senderModel : senderModels
) { ) {
long logId = LogUtil.addLog(new LogModel(smsVo.getMobile(), smsVo.getContent(), smsVo.getSimInfo(), ruleModel.getId())); long logId = LogUtil.addLog(new LogModel(type, smsVo.getMobile(), smsVo.getContent(), smsVo.getSimInfo(), ruleModel.getId()));
String smsTemplate = ruleModel.getSwitchSmsTemplate() ? ruleModel.getSmsTemplate() : ""; String smsTemplate = ruleModel.getSwitchSmsTemplate() ? ruleModel.getSmsTemplate() : "";
SendUtil.senderSendMsgNoHandError(smsVo, senderModel, logId, smsTemplate); SendUtil.senderSendMsgNoHandError(smsVo, senderModel, logId, smsTemplate);
} }

@ -90,7 +90,7 @@ public class FrontService extends Service {
@Override @Override
public void run() { public void run() {
int batteryLevel = getBatteryLevel(); int batteryLevel = getBatteryLevel();
System.out.println("当前剩余电量:" + batteryLevel + "%"); //System.out.println("当前剩余电量:" + batteryLevel + "%");
int batteryLevelAlarm = SettingUtil.getBatteryLevelAlarm(); int batteryLevelAlarm = SettingUtil.getBatteryLevelAlarm();
if (alarmTimes[0] <= 1 && batteryLevelAlarm > 0 && batteryLevelAlarm <= 100 && (batteryLevel == batteryLevelAlarm || batteryLevel == batteryLevelAlarm - 1)) { if (alarmTimes[0] <= 1 && batteryLevelAlarm > 0 && batteryLevelAlarm <= 100 && (batteryLevel == batteryLevelAlarm || batteryLevel == batteryLevelAlarm - 1)) {
try { try {
@ -100,7 +100,7 @@ public class FrontService extends Service {
new Date(), new Date(),
"低电量预警"); "低电量预警");
Log.d(TAG, "send_msg" + smsVo.toString()); Log.d(TAG, "send_msg" + smsVo.toString());
SendUtil.send_msg(context1, smsVo, 1); SendUtil.send_msg(context1, smsVo, 1, "app");
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "getLog e:" + e.getMessage()); Log.e(TAG, "getLog e:" + e.getMessage());
} }

@ -9,6 +9,7 @@ import android.util.Log;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import com.idormy.sms.forwarder.notify.NotifyHelper; import com.idormy.sms.forwarder.notify.NotifyHelper;
import com.idormy.sms.forwarder.utils.SettingUtil;
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2) @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
public class NotifyService extends NotificationListenerService { public class NotifyService extends NotificationListenerService {
@ -23,6 +24,9 @@ public class NotifyService extends NotificationListenerService {
@RequiresApi(api = Build.VERSION_CODES.KITKAT) @RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override @Override
public void onNotificationPosted(StatusBarNotification sbn) { public void onNotificationPosted(StatusBarNotification sbn) {
if (!SettingUtil.getSwitchEnableAppNotify()) {
return;
}
if (sbn.getNotification() == null) return; if (sbn.getNotification() == null) return;
Log.d(TAG, sbn.getPackageName()); Log.d(TAG, sbn.getPackageName());
NotifyHelper.getInstance().onReceive(sbn); NotifyHelper.getInstance().onReceive(sbn);
@ -36,6 +40,9 @@ public class NotifyService extends NotificationListenerService {
@Override @Override
public void onNotificationRemoved(StatusBarNotification sbn) { public void onNotificationRemoved(StatusBarNotification sbn) {
Log.d(TAG, sbn.getPackageName()); Log.d(TAG, sbn.getPackageName());
if (!SettingUtil.getSwitchEnableAppNotify()) {
return;
}
NotifyHelper.getInstance().onRemoved(sbn); NotifyHelper.getInstance().onRemoved(sbn);
} }

@ -16,13 +16,14 @@ import java.util.List;
public class DbHelper extends SQLiteOpenHelper { public class DbHelper extends SQLiteOpenHelper {
// If you change the database schema, you must increment the database version. // If you change the database schema, you must increment the database version.
public static final String TAG = "DbHelper"; public static final String TAG = "DbHelper";
public static final int DATABASE_VERSION = 5; public static final int DATABASE_VERSION = 6;
public static final String DATABASE_NAME = "sms_forwarder.db"; public static final String DATABASE_NAME = "sms_forwarder.db";
private static final List<String> SQL_CREATE_ENTRIES = private static final List<String> SQL_CREATE_ENTRIES =
Arrays.asList( Arrays.asList(
"CREATE TABLE " + LogTable.LogEntry.TABLE_NAME + " (" + "CREATE TABLE " + LogTable.LogEntry.TABLE_NAME + " (" +
LogTable.LogEntry._ID + " INTEGER PRIMARY KEY," + LogTable.LogEntry._ID + " INTEGER PRIMARY KEY," +
LogTable.LogEntry.COLUMN_NAME_TYPE + " TEXT NOT NULL DEFAULT 'sms'," +
LogTable.LogEntry.COLUMN_NAME_FROM + " TEXT," + LogTable.LogEntry.COLUMN_NAME_FROM + " TEXT," +
LogTable.LogEntry.COLUMN_NAME_CONTENT + " TEXT," + LogTable.LogEntry.COLUMN_NAME_CONTENT + " TEXT," +
LogTable.LogEntry.COLUMN_NAME_SIM_INFO + " TEXT," + LogTable.LogEntry.COLUMN_NAME_SIM_INFO + " TEXT," +
@ -32,6 +33,7 @@ public class DbHelper extends SQLiteOpenHelper {
LogTable.LogEntry.COLUMN_NAME_TIME + " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)" LogTable.LogEntry.COLUMN_NAME_TIME + " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)"
, "CREATE TABLE " + RuleTable.RuleEntry.TABLE_NAME + " (" + , "CREATE TABLE " + RuleTable.RuleEntry.TABLE_NAME + " (" +
RuleTable.RuleEntry._ID + " INTEGER PRIMARY KEY," + RuleTable.RuleEntry._ID + " INTEGER PRIMARY KEY," +
RuleTable.RuleEntry.COLUMN_NAME_TYPE + " TEXT NOT NULL DEFAULT 'sms'," +
RuleTable.RuleEntry.COLUMN_NAME_FILED + " TEXT," + RuleTable.RuleEntry.COLUMN_NAME_FILED + " TEXT," +
RuleTable.RuleEntry.COLUMN_NAME_CHECK + " TEXT," + RuleTable.RuleEntry.COLUMN_NAME_CHECK + " TEXT," +
RuleTable.RuleEntry.COLUMN_NAME_VALUE + " TEXT," + RuleTable.RuleEntry.COLUMN_NAME_VALUE + " TEXT," +
@ -96,6 +98,12 @@ public class DbHelper extends SQLiteOpenHelper {
String sql = "Alter table " + RuleTable.RuleEntry.TABLE_NAME + " add column " + RuleTable.RuleEntry.COLUMN_SMS_TEMPLATE + " TEXT NOT NULL DEFAULT '' "; String sql = "Alter table " + RuleTable.RuleEntry.TABLE_NAME + " add column " + RuleTable.RuleEntry.COLUMN_SMS_TEMPLATE + " TEXT NOT NULL DEFAULT '' ";
db.execSQL(sql); db.execSQL(sql);
} }
if (oldVersion < 6) { //增加转发规则与日志的分类
String sql = "Alter table " + RuleTable.RuleEntry.TABLE_NAME + " add column " + RuleTable.RuleEntry.COLUMN_NAME_TYPE + " TEXT NOT NULL DEFAULT 'sms' ";
db.execSQL(sql);
sql = "Alter table " + LogTable.LogEntry.TABLE_NAME + " add column " + RuleTable.RuleEntry.COLUMN_NAME_TYPE + " TEXT NOT NULL DEFAULT 'sms' ";
db.execSQL(sql);
}
} }
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {

@ -7,6 +7,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_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_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";
public static final String SP_MSG_KEY_STRING_ADD_EXTRA_SIM1 = "tsms_msg_key_string_add_extra_sim1"; public static final String SP_MSG_KEY_STRING_ADD_EXTRA_SIM1 = "tsms_msg_key_string_add_extra_sim1";
public static final String SP_MSG_KEY_STRING_ADD_EXTRA_SIM2 = "tsms_msg_key_string_add_extra_sim2"; public static final String SP_MSG_KEY_STRING_ADD_EXTRA_SIM2 = "tsms_msg_key_string_add_extra_sim2";

@ -50,6 +50,7 @@ public class LogUtil {
// Create a new map of values, where column names are the keys // Create a new map of values, where column names are the keys
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(LogTable.LogEntry.COLUMN_NAME_TYPE, logModel.getType());
values.put(LogTable.LogEntry.COLUMN_NAME_FROM, logModel.getFrom()); values.put(LogTable.LogEntry.COLUMN_NAME_FROM, logModel.getFrom());
values.put(LogTable.LogEntry.COLUMN_NAME_CONTENT, logModel.getContent()); values.put(LogTable.LogEntry.COLUMN_NAME_CONTENT, logModel.getContent());
values.put(LogTable.LogEntry.COLUMN_NAME_SIM_INFO, logModel.getSimInfo()); values.put(LogTable.LogEntry.COLUMN_NAME_SIM_INFO, logModel.getSimInfo());
@ -101,7 +102,7 @@ public class LogUtil {
} }
public static List<LogVo> getLog(Long id, String key) { public static List<LogVo> getLog(Long id, String key, String type) {
// Define a projection that specifies which columns from the database // Define a projection that specifies which columns from the database
// you will actually use after this query. // you will actually use after this query.
String[] projection = { String[] projection = {
@ -130,9 +131,15 @@ public class LogUtil {
selectionArgList.add(String.valueOf(id)); selectionArgList.add(String.valueOf(id));
} }
if (type != null) {
// Define 'where' part of query.
selection += " and " + LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_TYPE + " = ? ";
selectionArgList.add(type);
}
if (key != null) { if (key != null) {
// Define 'where' part of query. // Define 'where' part of query.
selection = " and (" + LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_FROM + " LIKE ? or " + LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_CONTENT + " LIKE ? ) "; selection += " and (" + LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_FROM + " LIKE ? or " + LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_CONTENT + " LIKE ? ) ";
// Specify arguments in placeholder order. // Specify arguments in placeholder order.
selectionArgList.add(key); selectionArgList.add(key);
selectionArgList.add(key); selectionArgList.add(key);

@ -38,6 +38,7 @@ public class RuleUtil {
// Create a new map of values, where column names are the keys // Create a new map of values, where column names are the keys
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(RuleTable.RuleEntry.COLUMN_NAME_TYPE, ruleModel.getType());
values.put(RuleTable.RuleEntry.COLUMN_NAME_FILED, ruleModel.getFiled()); values.put(RuleTable.RuleEntry.COLUMN_NAME_FILED, ruleModel.getFiled());
values.put(RuleTable.RuleEntry.COLUMN_NAME_CHECK, ruleModel.getCheck()); values.put(RuleTable.RuleEntry.COLUMN_NAME_CHECK, ruleModel.getCheck());
values.put(RuleTable.RuleEntry.COLUMN_NAME_VALUE, ruleModel.getValue()); values.put(RuleTable.RuleEntry.COLUMN_NAME_VALUE, ruleModel.getValue());
@ -86,11 +87,12 @@ public class RuleUtil {
} }
public static List<RuleModel> getRule(Long id, String key) { public static List<RuleModel> getRule(Long id, String key, String type) {
// Define a projection that specifies which columns from the database // Define a projection that specifies which columns from the database
// you will actually use after this query. // you will actually use after this query.
String[] projection = { String[] projection = {
BaseColumns._ID, BaseColumns._ID,
RuleTable.RuleEntry.COLUMN_NAME_TYPE,
RuleTable.RuleEntry.COLUMN_NAME_FILED, RuleTable.RuleEntry.COLUMN_NAME_FILED,
RuleTable.RuleEntry.COLUMN_NAME_CHECK, RuleTable.RuleEntry.COLUMN_NAME_CHECK,
RuleTable.RuleEntry.COLUMN_NAME_VALUE, RuleTable.RuleEntry.COLUMN_NAME_VALUE,
@ -110,6 +112,11 @@ public class RuleUtil {
selectionArgList.add(String.valueOf(id)); selectionArgList.add(String.valueOf(id));
} }
if (type != null) {
selection += " and " + RuleTable.RuleEntry.COLUMN_NAME_TYPE + " = ? ";
selectionArgList.add(type);
}
if (key != null) { if (key != null) {
// Define 'where' part of query. // Define 'where' part of query.
if (key.equals("SIM1") || key.equals("SIM2")) { if (key.equals("SIM1") || key.equals("SIM2")) {
@ -140,6 +147,8 @@ public class RuleUtil {
long itemId = cursor.getLong( long itemId = cursor.getLong(
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry._ID)); cursor.getColumnIndexOrThrow(RuleTable.RuleEntry._ID));
String itemType = cursor.getString(
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_TYPE));
String itemFiled = cursor.getString( String itemFiled = cursor.getString(
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_FILED)); cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_FILED));
String itemCheck = cursor.getString( String itemCheck = cursor.getString(
@ -158,6 +167,7 @@ public class RuleUtil {
Log.d(TAG, "getRule: itemId" + itemId); Log.d(TAG, "getRule: itemId" + itemId);
RuleModel ruleModel = new RuleModel(); RuleModel ruleModel = new RuleModel();
ruleModel.setId(itemId); ruleModel.setId(itemId);
ruleModel.setType(itemType);
ruleModel.setFiled(itemFiled); ruleModel.setFiled(itemFiled);
ruleModel.setCheck(itemCheck); ruleModel.setCheck(itemCheck);
ruleModel.setValue(itemValue); ruleModel.setValue(itemValue);

@ -1,169 +1,179 @@
package com.idormy.sms.forwarder.utils; package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
@SuppressWarnings({"SynchronizeOnNonFinalField", "unused"}) @SuppressWarnings({"SynchronizeOnNonFinalField", "unused"})
public class SettingUtil { public class SettingUtil {
static Boolean hasInit = false; static Boolean hasInit = false;
private static final String TAG = "SettingUtil"; private static final String TAG = "SettingUtil";
private static SharedPreferences sp_setting = null; private static SharedPreferences sp_setting = null;
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
private static Context context = null; private static Context context = null;
public static void init(Context context1) { public static void init(Context context1) {
synchronized (hasInit) { synchronized (hasInit) {
if (hasInit) return; if (hasInit) return;
hasInit = true; hasInit = true;
context = context1; context = context1;
Log.d(TAG, "init "); Log.d(TAG, "init ");
sp_setting = PreferenceManager.getDefaultSharedPreferences(context1); sp_setting = PreferenceManager.getDefaultSharedPreferences(context1);
} }
} }
public static void switchAddExtra(Boolean switchAddExtra) { public static void switchAddExtra(Boolean switchAddExtra) {
Log.d(TAG, "switchAddExtra :" + switchAddExtra); Log.d(TAG, "switchAddExtra :" + switchAddExtra);
sp_setting.edit() sp_setting.edit()
.putBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, switchAddExtra) .putBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, switchAddExtra)
.apply(); .apply();
} }
public static boolean getSwitchAddExtra() { public static boolean getSwitchAddExtra() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, false); return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, false);
} }
public static void switchAddDeviceName(Boolean switchAddDeviceName) { public static void switchAddDeviceName(Boolean switchAddDeviceName) {
Log.d(TAG, "switchAddDeviceName :" + switchAddDeviceName); Log.d(TAG, "switchAddDeviceName :" + switchAddDeviceName);
sp_setting.edit() sp_setting.edit()
.putBoolean(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME, switchAddDeviceName) .putBoolean(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME, switchAddDeviceName)
.apply(); .apply();
} }
public static boolean getSwitchAddDeviceName() { public static boolean getSwitchAddDeviceName() {
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 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)
.apply(); .apply();
} }
public static boolean getSwitchEnablePhone() { public static boolean getSwitchEnablePhone() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PHONE, true); return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PHONE, true);
} }
public static void switchSmsTemplate(Boolean switchSmsTemplate) { public static void switchEnableAppNotify(Boolean enable) {
Log.d(TAG, "switchSmsTemplate :" + switchSmsTemplate); sp_setting.edit()
sp_setting.edit() .putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY, enable)
.putBoolean(Define.SP_MSG_KEY_SWITCH_SMS_TEMPLATE, switchSmsTemplate) .apply();
.apply(); }
}
public static boolean getSwitchEnableAppNotify() {
public static boolean getSwitchSmsTemplate() { return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY, true);
return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_SMS_TEMPLATE, false); }
}
public static void switchSmsTemplate(Boolean switchSmsTemplate) {
public static String getAddExtraDeviceMark() { Log.d(TAG, "switchSmsTemplate :" + switchSmsTemplate);
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, ""); sp_setting.edit()
if (res == null || res.equals("")) { .putBoolean(Define.SP_MSG_KEY_SWITCH_SMS_TEMPLATE, switchSmsTemplate)
res = android.os.Build.MODEL; .apply();
} }
return res;
} public static boolean getSwitchSmsTemplate() {
return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_SMS_TEMPLATE, false);
public static void setAddExtraDeviceMark(String addExtraDeviceMark) { }
Log.d(TAG, "addExtraDeviceMark :" + addExtraDeviceMark);
sp_setting.edit() public static String getAddExtraDeviceMark() {
.putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, addExtraDeviceMark) String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, "");
.apply(); if (res == null || res.equals("")) {
} res = android.os.Build.MODEL;
}
public static String getSmsTemplate() { return res;
return sp_setting.getString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE, "{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}"); }
}
public static void setAddExtraDeviceMark(String addExtraDeviceMark) {
public static void setSmsTemplate(String textSmsTemplate) { Log.d(TAG, "addExtraDeviceMark :" + addExtraDeviceMark);
Log.d(TAG, "textSmsTemplate :" + textSmsTemplate); sp_setting.edit()
sp_setting.edit() .putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, addExtraDeviceMark)
.putString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE, textSmsTemplate) .apply();
.apply(); }
}
public static String getSmsTemplate() {
public static String getAddExtraSim1() { return sp_setting.getString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE, "{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}");
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, ""); }
if (res == null || res.equals("")) {
res = SimUtil.getSimInfo(1); public static void setSmsTemplate(String textSmsTemplate) {
} Log.d(TAG, "textSmsTemplate :" + textSmsTemplate);
return res; sp_setting.edit()
} .putString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE, textSmsTemplate)
.apply();
public static void setAddExtraSim1(String sim1) { }
Log.d(TAG, "sim1 :" + sim1);
sp_setting.edit() public static String getAddExtraSim1() {
.putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, sim1) String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, "");
.apply(); if (res == null || res.equals("")) {
} res = SimUtil.getSimInfo(1);
}
public static String getAddExtraSim2() { return res;
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, ""); }
if (res == null || res.equals("")) {
res = SimUtil.getSimInfo(2); public static void setAddExtraSim1(String sim1) {
} Log.d(TAG, "sim1 :" + sim1);
return res; sp_setting.edit()
} .putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, sim1)
.apply();
public static void setAddExtraSim2(String sim2) { }
Log.d(TAG, "sim2 :" + sim2);
sp_setting.edit() public static String getAddExtraSim2() {
.putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, sim2) String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, "");
.apply(); if (res == null || res.equals("")) {
} res = SimUtil.getSimInfo(2);
}
public static int getBatteryLevelAlarm() { return res;
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, 0); }
}
public static void setAddExtraSim2(String sim2) {
public static void setBatteryLevelAlarm(int battery_level) { Log.d(TAG, "sim2 :" + sim2);
Log.d(TAG, "battery_level :" + battery_level); sp_setting.edit()
sp_setting.edit() .putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, sim2)
.putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, battery_level) .apply();
.apply(); }
}
public static int getBatteryLevelAlarm() {
public static boolean saveMsgHistory() { return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, 0);
return !sp_setting.getBoolean("option_save_history_on", false); }
}
public static void setBatteryLevelAlarm(int battery_level) {
//接口请求失败重试 Log.d(TAG, "battery_level :" + battery_level);
private static String getRetryDelayTimeKey(int index) { sp_setting.edit()
switch (index) { .putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, battery_level)
case 1: .apply();
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME1; }
case 2:
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME2; public static boolean saveMsgHistory() {
case 3: return !sp_setting.getBoolean("option_save_history_on", false);
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME3; }
case 4:
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME4; //接口请求失败重试
case 5: private static String getRetryDelayTimeKey(int index) {
default: switch (index) {
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME5; case 1:
} return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME1;
} case 2:
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME2;
public static int getRetryDelayTime(int index) { case 3:
String key = getRetryDelayTimeKey(index); return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME3;
return sp_setting.getInt(key, (int) Math.pow(2, (index - 1))); case 4:
} return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME4;
case 5:
public static void setRetryDelayTime(int index, int retry_delay_time) { default:
String key = getRetryDelayTimeKey(index); return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME5;
Log.d(TAG, "retry_delay_time_" + index + " :" + retry_delay_time); }
sp_setting.edit().putInt(key, retry_delay_time).apply(); }
}
public static int getRetryDelayTime(int index) {
} String key = getRetryDelayTimeKey(index);
return sp_setting.getInt(key, (int) Math.pow(2, (index - 1)));
}
public static void setRetryDelayTime(int index, int retry_delay_time) {
String key = getRetryDelayTimeKey(index);
Log.d(TAG, "retry_delay_time_" + index + " :" + retry_delay_time);
sp_setting.edit().putInt(key, retry_delay_time).apply();
}
}

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M4,8h4L8,4L4,4v4zM10,20h4v-4h-4v4zM4,20h4v-4L4,16v4zM4,14h4v-4L4,10v4zM10,14h4v-4h-4v4zM16,4v4h4L20,4h-4zM10,8h4L14,4h-4v4zM16,14h4v-4h-4v4zM16,20h4v-4h-4v4z"/>
</vector>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="1dip" android:color="@color/gray_text_light" />
<corners android:radius="30dip" />
</shape>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="1dip" android:color="@color/colorPrimary" />
<corners android:radius="30dip" />
</shape>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/bg_select_pressed"/>
<item android:state_selected="true" android:drawable="@drawable/bg_select_pressed"/>
<item android:state_checked="true" android:drawable="@drawable/bg_select_pressed"/>
<item android:drawable="@drawable/bg_select_default" />
</selector>

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M3,5L1,5v16c0,1.1 0.9,2 2,2h16v-2L3,21L3,5zM14,15h2L16,5h-4v2h2v8zM21,1L7,1c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L23,3c0,-1.1 -0.9,-2 -2,-2zM21,17L7,17L7,3h14v14z"/>
</vector>

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M3,5L1,5v16c0,1.1 0.9,2 2,2h16v-2L3,21L3,5zM21,1L7,1c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L23,3c0,-1.1 -0.9,-2 -2,-2zM21,17L7,17L7,3h14v14zM17,13h-4v-2h2c1.1,0 2,-0.89 2,-2L17,7c0,-1.11 -0.9,-2 -2,-2h-4v2h4v2h-2c-1.1,0 -2,0.89 -2,2v4h6v-2z"/>
</vector>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorPrimary" android:state_selected="true" />
<item android:color="@color/colorPrimary" android:state_checked="true" />
<item android:color="@color/gray_text_light" />
</selector>

@ -1,72 +1,106 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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"
android:orientation="vertical"> android:orientation="vertical">
<com.idormy.sms.forwarder.RefreshListView <LinearLayout
android:id="@+id/list_view_log" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="0dp" android:layout_gravity="center_horizontal"
android:layout_margin="5dp" android:layout_marginTop="5dip"
android:layout_weight="1" /> android:orientation="horizontal">
<LinearLayout <RadioGroup
android:layout_width="match_parent" android:id="@+id/radioGroupTypeCheck"
android:layout_height="wrap_content" style="@style/rg_style"
android:orientation="vertical"> android:orientation="horizontal">
<TextView <RadioButton
android:id="@+id/help_tip" android:id="@+id/btnTypeSms"
android:layout_width="match_parent" style="@style/select_style"
android:layout_height="wrap_content" android:tag="sms"
android:gravity="center" android:text="@string/sms"
android:text="@string/log_tips" android:checked="true" />
android:textColor="@color/colorPrimary" />
<RadioButton
<LinearLayout android:id="@+id/btnTypeCall"
android:layout_width="match_parent" style="@style/select_style"
android:layout_height="wrap_content" android:tag="call"
android:orientation="horizontal"> android:text="@string/call" />
<Button <RadioButton
android:layout_width="match_parent" android:id="@+id/btnTypeApp"
android:layout_height="35dp" style="@style/select_style"
android:layout_marginStart="10dp" android:tag="app"
android:layout_marginTop="5dp" android:text="@string/app" />
android:layout_marginBottom="10dp" </RadioGroup>
android:layout_weight="1"
android:background="@color/colorPrimary" </LinearLayout>
android:onClick="cleanLog"
android:text="@string/bt_refresh_log" <com.idormy.sms.forwarder.RefreshListView
tools:ignore="ButtonStyle,NestedWeights" /> android:id="@+id/list_view_log"
android:layout_width="match_parent"
<Button android:layout_height="0dp"
android:layout_width="match_parent" android:layout_margin="5dp"
android:layout_height="35dp" android:layout_weight="1" />
android:layout_marginStart="10dp"
android:layout_marginTop="5dp" <LinearLayout
android:layout_marginBottom="10dp" android:layout_width="match_parent"
android:layout_weight="1" android:layout_height="wrap_content"
android:background="@color/colorPrimary" android:orientation="vertical">
android:onClick="toRuleSetting"
android:text="@string/rule_setting" <TextView
tools:ignore="ButtonStyle,NestedWeights" /> android:id="@+id/help_tip"
android:layout_width="match_parent"
<Button android:layout_height="wrap_content"
android:layout_width="match_parent" android:gravity="center"
android:layout_height="35dp" android:text="@string/log_tips"
android:layout_marginLeft="10dp" android:textColor="@color/colorPrimary" />
android:layout_marginTop="5dp"
android:layout_marginRight="10dp" <LinearLayout
android:layout_marginBottom="10dp" android:layout_width="match_parent"
android:layout_weight="1" android:layout_height="wrap_content"
android:background="@color/colorPrimary" android:orientation="horizontal">
android:onClick="toSendSetting"
android:text="@string/sender_setting" <Button
tools:ignore="ButtonStyle" /> android:layout_width="match_parent"
</LinearLayout> android:layout_height="35dp"
</LinearLayout> android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:onClick="cleanLog"
android:text="@string/bt_refresh_log"
tools:ignore="ButtonStyle,NestedWeights" />
<Button
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:onClick="toRuleSetting"
android:text="@string/rule_setting"
tools:ignore="ButtonStyle,NestedWeights" />
<Button
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:onClick="toSendSetting"
android:text="@string/sender_setting"
tools:ignore="ButtonStyle" />
</LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

@ -1,37 +1,71 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<ListView <LinearLayout
android:id="@+id/list_view_rule" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="0dp" android:layout_gravity="center_horizontal"
android:layout_margin="5dp" android:layout_marginTop="5dip"
android:layout_weight="1" /> android:orientation="horizontal">
<LinearLayout <RadioGroup
android:layout_width="match_parent" android:id="@+id/radioGroupTypeCheck"
android:layout_height="wrap_content" style="@style/rg_style"
android:orientation="vertical"> android:orientation="horizontal">
<TextView <RadioButton
android:id="@+id/help_tip" android:id="@+id/btnTypeSms"
android:layout_width="match_parent" style="@style/select_style"
android:layout_height="wrap_content" android:tag="sms"
android:gravity="center" android:text="@string/sms"
android:text="@string/rule_tips" android:checked="true" />
android:textColor="@color/colorPrimary" />
<RadioButton
<Button android:id="@+id/btnTypeCall"
android:layout_width="match_parent" style="@style/select_style"
android:layout_height="35dp" android:tag="call"
android:layout_margin="10dp" android:text="@string/call" />
android:background="@color/colorPrimary"
android:onClick="addRule" <RadioButton
android:padding="0dp" android:id="@+id/btnTypeApp"
android:text="@string/new_forwarding_rule" /> style="@style/select_style"
</LinearLayout> android:tag="app"
android:text="@string/app" />
</RadioGroup>
</LinearLayout>
<ListView
android:id="@+id/list_view_rule"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/help_tip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/rule_tips"
android:textColor="@color/colorPrimary" />
<Button
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_margin="10dp"
android:background="@color/colorPrimary"
android:onClick="addRule"
android:padding="0dp"
android:text="@string/new_forwarding_rule" />
</LinearLayout>
</LinearLayout> </LinearLayout>

@ -295,6 +295,33 @@
</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_app_notify"
android:textStyle="bold"
tools:ignore="RelativeOverlap" />
<Switch
android:id="@+id/switch_enable_app_notify"
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"

@ -6,4 +6,14 @@
<color name="colorBlueGreyLight">#B0BBC5</color> <color name="colorBlueGreyLight">#B0BBC5</color>
<color name="colorBlueGrey">#78909C</color> <color name="colorBlueGrey">#78909C</color>
<color name="colorBlueGreyDark">#546E7A</color> <color name="colorBlueGreyDark">#546E7A</color>
<color name="white">#ffffff</color>
<color name="black">#000000</color>
<color name="line_gray">#dcdcdc</color>
<color name="line_gray_light">#f1f1f1</color>
<color name="gray_page_bg">#ecedf1</color>
<color name="gray_text">#5b5b5b</color>
<color name="gray_text_dark">#292929</color>
<color name="gray_text_light">#979797</color>
<color name="window_half_transparent">#90000000</color>
<color name="blue_white">#0eabe5</color>
</resources> </resources>

@ -149,6 +149,7 @@
<string name="add_extra">Sim slot info attached</string> <string name="add_extra">Sim slot info attached</string>
<string name="add_device_name">Device Name attached</string> <string name="add_device_name">Device Name attached</string>
<string name="forward_missed_calls">Forward missed calls</string> <string name="forward_missed_calls">Forward missed calls</string>
<string name="forward_app_notify">Forward app notify</string>
<string name="enable_custom_templates">Enable custom templates</string> <string name="enable_custom_templates">Enable custom templates</string>
<string name="custom_templates">Custom templates</string> <string name="custom_templates">Custom templates</string>
<string name="custom_templates_tips">TipInsert labels as needed;Leave blank to default template</string> <string name="custom_templates_tips">TipInsert labels as needed;Leave blank to default template</string>
@ -197,4 +198,7 @@
<string name="no_network">No network at present</string> <string name="no_network">No network at present</string>
<string name="not_connected_wifi">Not connected WIFI</string> <string name="not_connected_wifi">Not connected WIFI</string>
<string name="failed_to_get_ip">Failed to get IP address</string> <string name="failed_to_get_ip">Failed to get IP address</string>
<string name="sms">短 信</string>
<string name="call">来 电</string>
<string name="app">应 用</string>
</resources> </resources>

@ -19,4 +19,19 @@
<item name="android:layout_weight">1</item> <item name="android:layout_weight">1</item>
</style> </style>
<!-- 选择框自定义主题 -->
<style name="select_style">
<item name="android:layout_width">60dip</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">4dip</item>
<item name="android:layout_marginRight">4dip</item>
<item name="android:paddingTop">4dip</item>
<item name="android:paddingBottom">4dip</item>
<item name="android:background">@drawable/select_selector</item>
<item name="android:button">@null</item>
<item name="android:gravity">center</item>
<item name="android:textSize">13sp</item>
<item name="android:textColor">@drawable/txt_select_selector</item>
</style>
</resources> </resources>

@ -6,4 +6,14 @@
<color name="colorBlueGreyLight">#B0BBC5</color> <color name="colorBlueGreyLight">#B0BBC5</color>
<color name="colorBlueGrey">#78909C</color> <color name="colorBlueGrey">#78909C</color>
<color name="colorBlueGreyDark">#546E7A</color> <color name="colorBlueGreyDark">#546E7A</color>
<color name="white">#ffffff</color>
<color name="black">#000000</color>
<color name="line_gray">#dcdcdc</color>
<color name="line_gray_light">#f1f1f1</color>
<color name="gray_page_bg">#ecedf1</color>
<color name="gray_text">#5b5b5b</color>
<color name="gray_text_dark">#292929</color>
<color name="gray_text_light">#979797</color>
<color name="window_half_transparent">#90000000</color>
<color name="blue_white">#0eabe5</color>
</resources> </resources>

@ -149,6 +149,7 @@
<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_missed_calls">转发未接来电</string> <string name="forward_missed_calls">转发未接来电</string>
<string name="forward_app_notify">转发APP通知</string>
<string name="enable_custom_templates">启用自定义模版</string> <string name="enable_custom_templates">启用自定义模版</string>
<string name="custom_templates">转发信息模版</string> <string name="custom_templates">转发信息模版</string>
<string name="custom_templates_tips">Tip按需插入内容标签留空使用默认模版</string> <string name="custom_templates_tips">Tip按需插入内容标签留空使用默认模版</string>
@ -196,4 +197,7 @@
<string name="no_network">当前没有网络</string> <string name="no_network">当前没有网络</string>
<string name="not_connected_wifi">未连接Wifi</string> <string name="not_connected_wifi">未连接Wifi</string>
<string name="failed_to_get_ip">获取IP失败</string> <string name="failed_to_get_ip">获取IP失败</string>
<string name="sms">短 信</string>
<string name="call">来 电</string>
<string name="app">应 用</string>
</resources> </resources>

@ -19,4 +19,18 @@
<item name="android:layout_weight">1</item> <item name="android:layout_weight">1</item>
</style> </style>
<!-- 选择框自定义主题 -->
<style name="select_style">
<item name="android:layout_width">60dip</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">4dip</item>
<item name="android:layout_marginRight">4dip</item>
<item name="android:paddingTop">4dip</item>
<item name="android:paddingBottom">4dip</item>
<item name="android:background">@drawable/select_selector</item>
<item name="android:button">@null</item>
<item name="android:gravity">center</item>
<item name="android:textSize">13sp</item>
<item name="android:textColor">@drawable/txt_select_selector</item>
</style>
</resources> </resources>

Loading…
Cancel
Save