mirror of
https://github.com/pppscn/SmsForwarder
synced 2025-08-02 17:07:41 +08:00
新增:监听其他APP通知信息
This commit is contained in:
parent
e8ea004bc4
commit
5703c7d637
@ -129,9 +129,9 @@ dependencies {
|
||||
implementation "com.alibaba:fastjson:1.2.78"
|
||||
|
||||
//友盟统计SDK
|
||||
implementation 'com.umeng.umsdk:common:9.4.4'// 必选
|
||||
implementation 'com.umeng.umsdk:asms:1.4.1'// 必选
|
||||
implementation 'com.umeng.umsdk:apm:1.4.2' // 错误分析升级为独立SDK,看crash数据请一定集成,可选
|
||||
// implementation 'com.umeng.umsdk:common:9.4.4'// 必选
|
||||
// implementation 'com.umeng.umsdk:asms:1.4.1'// 必选
|
||||
// implementation 'com.umeng.umsdk:apm:1.4.2' // 错误分析升级为独立SDK,看crash数据请一定集成,可选
|
||||
|
||||
//XUpdate
|
||||
implementation 'com.github.xuexiangjys:XUpdate:2.1.0'
|
||||
@ -151,4 +151,8 @@ dependencies {
|
||||
|
||||
//AndroidAsync
|
||||
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.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -55,6 +57,7 @@ public class MainActivity extends AppCompatActivity implements NotifyListener, R
|
||||
private RefreshListView listView;
|
||||
private Intent serviceIntent;
|
||||
private static final int REQUEST_CODE = 9999;
|
||||
private String currentType = "sms";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -98,6 +101,17 @@ public class MainActivity extends AppCompatActivity implements NotifyListener, R
|
||||
initTLogs(); //初始化数据
|
||||
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()方法
|
||||
// 在这个方法中可以通过position参数判断出用户点击的是那一个子项
|
||||
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")
|
||||
@Override
|
||||
protected void onResume() {
|
||||
@ -237,7 +262,7 @@ public class MainActivity extends AppCompatActivity implements NotifyListener, R
|
||||
|
||||
// 初始化数据
|
||||
private void initTLogs() {
|
||||
logVos = LogUtil.getLog(null, null);
|
||||
logVos = LogUtil.getLog(null, null, currentType);
|
||||
}
|
||||
|
||||
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.setInterface(this);
|
||||
adapter = new LogAdapter(MainActivity.this, R.layout.item_log, logVosN);
|
||||
|
||||
listView.setAdapter(adapter);
|
||||
} else {
|
||||
adapter.onDateChange(logVosN);
|
||||
@ -390,6 +414,7 @@ public class MainActivity extends AppCompatActivity implements NotifyListener, R
|
||||
@Override
|
||||
public void onReceiveMessage(StatusBarNotification sbn) {
|
||||
if (sbn.getNotification() == null) return;
|
||||
if (sbn.getNotification().extras == null) return;
|
||||
|
||||
//推送通知的应用包名
|
||||
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);
|
||||
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.SettingUtil;
|
||||
import com.smailnet.emailkit.EmailKit;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.umeng.commonsdk.UMConfigure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -77,11 +75,11 @@ public class MyApplication extends Application {
|
||||
super.onCreate();
|
||||
//初始化组件化基础库, 所有友盟业务SDK都必须调用此初始化接口。
|
||||
//建议在宿主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页面采集模式
|
||||
MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.LEGACY_MANUAL);
|
||||
//MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.LEGACY_MANUAL);
|
||||
//pro close log
|
||||
UMConfigure.setLogEnabled(true);
|
||||
//UMConfigure.setLogEnabled(true);
|
||||
|
||||
Intent intent = new Intent(this, FrontService.class);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
|
@ -12,6 +12,7 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Switch;
|
||||
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.utils.RuleUtil;
|
||||
import com.idormy.sms.forwarder.utils.SettingUtil;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@ -41,6 +41,7 @@ public class RuleActivity extends AppCompatActivity {
|
||||
// 用于存储数据
|
||||
private List<RuleModel> ruleModels = new ArrayList<>();
|
||||
private RuleAdapter adapter;
|
||||
private String currentType = "sms";
|
||||
|
||||
//消息处理者,创建一个Handler的子类对象,目的是重写Handler的处理消息的方法(handleMessage())
|
||||
@SuppressLint("HandlerLeak")
|
||||
@ -108,11 +109,34 @@ public class RuleActivity extends AppCompatActivity {
|
||||
builder.create().show();
|
||||
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() {
|
||||
ruleModels = RuleUtil.getRule(null, null);
|
||||
ruleModels = RuleUtil.getRule(null, null, currentType);
|
||||
}
|
||||
|
||||
public void addRule(View view) {
|
||||
@ -189,6 +213,7 @@ public class RuleActivity extends AppCompatActivity {
|
||||
Log.d(TAG, radioGroupRuleCheck.getCheckedRadioButtonId() + " " + radioGroupRuleCheck2.getCheckedRadioButtonId() + " " + radioGroupRuleCheckId);
|
||||
if (ruleModel == null) {
|
||||
RuleModel newRuleModel = new RuleModel();
|
||||
newRuleModel.setType(currentType);
|
||||
newRuleModel.setFiled(RuleModel.getRuleFiledFromCheckId(radioGroupRuleFiled.getCheckedRadioButtonId()));
|
||||
newRuleModel.setCheck(RuleModel.getRuleCheckFromCheckId(radioGroupRuleCheckId));
|
||||
newRuleModel.setSimSlot(RuleModel.getRuleSimSlotFromCheckId(radioGroupSimSlot.getCheckedRadioButtonId()));
|
||||
@ -449,13 +474,13 @@ public class RuleActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
//MobclickAgent.onResume(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
//MobclickAgent.onPause(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -65,6 +65,9 @@ public class SettingActivity extends AppCompatActivity {
|
||||
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_phone = findViewById(R.id.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);
|
||||
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) {
|
||||
et_add_extra_device_mark.setText(SettingUtil.getAddExtraDeviceMark());
|
||||
|
@ -11,12 +11,14 @@ public class LogModel {
|
||||
private Long ruleId;
|
||||
private Long time;
|
||||
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.content = content;
|
||||
this.simInfo = simInfo;
|
||||
this.ruleId = ruleId;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -27,6 +29,7 @@ public class LogModel {
|
||||
", content='" + content + '\'' +
|
||||
", simInfo=" + simInfo +
|
||||
", ruleId=" + ruleId +
|
||||
", type=" + type +
|
||||
", time=" + time +
|
||||
'}';
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ public final class LogTable {
|
||||
/* Inner class that defines the table contents */
|
||||
public static class LogEntry implements BaseColumns {
|
||||
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_CONTENT = "content";
|
||||
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_2 = "SIM2";
|
||||
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 {
|
||||
FILED_MAP.put("transpond_all", "全部转发");
|
||||
@ -63,6 +70,7 @@ public class RuleModel {
|
||||
|
||||
private String TAG = "RuleModel";
|
||||
private Long id;
|
||||
private String type;
|
||||
private String filed;
|
||||
private String check;
|
||||
private String value;
|
||||
|
@ -11,6 +11,7 @@ public final class RuleTable {
|
||||
/* Inner class that defines the table contents */
|
||||
public static class RuleEntry implements BaseColumns {
|
||||
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_CHECK = "tcheck";
|
||||
public static final String COLUMN_NAME_VALUE = "value";
|
||||
|
@ -32,12 +32,15 @@ public class LogVo {
|
||||
}
|
||||
|
||||
public int getSimImageId() {
|
||||
if (this.simInfo != null && !this.simInfo.isEmpty()
|
||||
&& this.simInfo.replace("-", "").startsWith("SIM2")) {
|
||||
return R.mipmap.sim2;
|
||||
if (this.simInfo != null && !this.simInfo.isEmpty()) {
|
||||
if (this.simInfo.replace("-", "").startsWith("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() {
|
||||
|
@ -90,6 +90,6 @@ public class PhoneStateReceiver extends BroadcastReceiver {
|
||||
}
|
||||
SmsVo smsVo = new SmsVo(phoneNumber, name + context.getString(R.string.calling), new Date(), simInfo);
|
||||
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));
|
||||
}
|
||||
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 {
|
||||
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());
|
||||
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);
|
||||
RuleUtil.init(context);
|
||||
LogUtil.init(context);
|
||||
|
||||
String key = "SIM" + simId;
|
||||
List<RuleModel> ruleList = RuleUtil.getRule(null, key);
|
||||
List<RuleModel> ruleList = RuleUtil.getRule(null, key, type);
|
||||
if (!ruleList.isEmpty()) {
|
||||
SenderUtil.init(context);
|
||||
for (RuleModel ruleModel : ruleList) {
|
||||
@ -62,7 +62,7 @@ public class SendUtil {
|
||||
List<SenderModel> senderModels = SenderUtil.getSender(ruleModel.getSenderId(), null);
|
||||
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() : "";
|
||||
SendUtil.senderSendMsgNoHandError(smsVo, senderModel, logId, smsTemplate);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class FrontService extends Service {
|
||||
@Override
|
||||
public void run() {
|
||||
int batteryLevel = getBatteryLevel();
|
||||
System.out.println("当前剩余电量:" + batteryLevel + "%");
|
||||
//System.out.println("当前剩余电量:" + batteryLevel + "%");
|
||||
int batteryLevelAlarm = SettingUtil.getBatteryLevelAlarm();
|
||||
if (alarmTimes[0] <= 1 && batteryLevelAlarm > 0 && batteryLevelAlarm <= 100 && (batteryLevel == batteryLevelAlarm || batteryLevel == batteryLevelAlarm - 1)) {
|
||||
try {
|
||||
@ -100,7 +100,7 @@ public class FrontService extends Service {
|
||||
new Date(),
|
||||
"低电量预警");
|
||||
Log.d(TAG, "send_msg" + smsVo.toString());
|
||||
SendUtil.send_msg(context1, smsVo, 1);
|
||||
SendUtil.send_msg(context1, smsVo, 1, "app");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getLog e:" + e.getMessage());
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import android.util.Log;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.idormy.sms.forwarder.notify.NotifyHelper;
|
||||
import com.idormy.sms.forwarder.utils.SettingUtil;
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
public class NotifyService extends NotificationListenerService {
|
||||
@ -23,6 +24,9 @@ public class NotifyService extends NotificationListenerService {
|
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
||||
@Override
|
||||
public void onNotificationPosted(StatusBarNotification sbn) {
|
||||
if (!SettingUtil.getSwitchEnableAppNotify()) {
|
||||
return;
|
||||
}
|
||||
if (sbn.getNotification() == null) return;
|
||||
Log.d(TAG, sbn.getPackageName());
|
||||
NotifyHelper.getInstance().onReceive(sbn);
|
||||
@ -36,6 +40,9 @@ public class NotifyService extends NotificationListenerService {
|
||||
@Override
|
||||
public void onNotificationRemoved(StatusBarNotification sbn) {
|
||||
Log.d(TAG, sbn.getPackageName());
|
||||
if (!SettingUtil.getSwitchEnableAppNotify()) {
|
||||
return;
|
||||
}
|
||||
NotifyHelper.getInstance().onRemoved(sbn);
|
||||
}
|
||||
|
||||
|
@ -16,13 +16,14 @@ import java.util.List;
|
||||
public class DbHelper extends SQLiteOpenHelper {
|
||||
// If you change the database schema, you must increment the database version.
|
||||
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";
|
||||
|
||||
private static final List<String> SQL_CREATE_ENTRIES =
|
||||
Arrays.asList(
|
||||
"CREATE TABLE " + LogTable.LogEntry.TABLE_NAME + " (" +
|
||||
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_CONTENT + " 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)"
|
||||
, "CREATE TABLE " + RuleTable.RuleEntry.TABLE_NAME + " (" +
|
||||
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_CHECK + " 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 '' ";
|
||||
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) {
|
||||
|
@ -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_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_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_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";
|
||||
|
@ -50,6 +50,7 @@ public class LogUtil {
|
||||
|
||||
// Create a new map of values, where column names are the keys
|
||||
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_CONTENT, logModel.getContent());
|
||||
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
|
||||
// you will actually use after this query.
|
||||
String[] projection = {
|
||||
@ -130,9 +131,15 @@ public class LogUtil {
|
||||
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) {
|
||||
// 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.
|
||||
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
|
||||
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_CHECK, ruleModel.getCheck());
|
||||
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
|
||||
// you will actually use after this query.
|
||||
String[] projection = {
|
||||
BaseColumns._ID,
|
||||
RuleTable.RuleEntry.COLUMN_NAME_TYPE,
|
||||
RuleTable.RuleEntry.COLUMN_NAME_FILED,
|
||||
RuleTable.RuleEntry.COLUMN_NAME_CHECK,
|
||||
RuleTable.RuleEntry.COLUMN_NAME_VALUE,
|
||||
@ -110,6 +112,11 @@ public class RuleUtil {
|
||||
selectionArgList.add(String.valueOf(id));
|
||||
}
|
||||
|
||||
if (type != null) {
|
||||
selection += " and " + RuleTable.RuleEntry.COLUMN_NAME_TYPE + " = ? ";
|
||||
selectionArgList.add(type);
|
||||
}
|
||||
|
||||
if (key != null) {
|
||||
// Define 'where' part of query.
|
||||
if (key.equals("SIM1") || key.equals("SIM2")) {
|
||||
@ -140,6 +147,8 @@ public class RuleUtil {
|
||||
|
||||
long itemId = cursor.getLong(
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry._ID));
|
||||
String itemType = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_TYPE));
|
||||
String itemFiled = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_FILED));
|
||||
String itemCheck = cursor.getString(
|
||||
@ -158,6 +167,7 @@ public class RuleUtil {
|
||||
Log.d(TAG, "getRule: itemId" + itemId);
|
||||
RuleModel ruleModel = new RuleModel();
|
||||
ruleModel.setId(itemId);
|
||||
ruleModel.setType(itemType);
|
||||
ruleModel.setFiled(itemFiled);
|
||||
ruleModel.setCheck(itemCheck);
|
||||
ruleModel.setValue(itemValue);
|
||||
|
@ -1,169 +1,179 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
@SuppressWarnings({"SynchronizeOnNonFinalField", "unused"})
|
||||
public class SettingUtil {
|
||||
static Boolean hasInit = false;
|
||||
private static final String TAG = "SettingUtil";
|
||||
private static SharedPreferences sp_setting = null;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Context context = null;
|
||||
|
||||
public static void init(Context context1) {
|
||||
synchronized (hasInit) {
|
||||
if (hasInit) return;
|
||||
hasInit = true;
|
||||
context = context1;
|
||||
Log.d(TAG, "init ");
|
||||
sp_setting = PreferenceManager.getDefaultSharedPreferences(context1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void switchAddExtra(Boolean switchAddExtra) {
|
||||
Log.d(TAG, "switchAddExtra :" + switchAddExtra);
|
||||
sp_setting.edit()
|
||||
.putBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, switchAddExtra)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean getSwitchAddExtra() {
|
||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, false);
|
||||
}
|
||||
|
||||
public static void switchAddDeviceName(Boolean switchAddDeviceName) {
|
||||
Log.d(TAG, "switchAddDeviceName :" + switchAddDeviceName);
|
||||
sp_setting.edit()
|
||||
.putBoolean(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME, switchAddDeviceName)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean getSwitchAddDeviceName() {
|
||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME, false);
|
||||
}
|
||||
|
||||
public static void switchEnablePhone(Boolean enable) {
|
||||
sp_setting.edit()
|
||||
.putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PHONE, enable)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean getSwitchEnablePhone() {
|
||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PHONE, true);
|
||||
}
|
||||
|
||||
public static void switchSmsTemplate(Boolean switchSmsTemplate) {
|
||||
Log.d(TAG, "switchSmsTemplate :" + switchSmsTemplate);
|
||||
sp_setting.edit()
|
||||
.putBoolean(Define.SP_MSG_KEY_SWITCH_SMS_TEMPLATE, switchSmsTemplate)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean getSwitchSmsTemplate() {
|
||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_SMS_TEMPLATE, false);
|
||||
}
|
||||
|
||||
public static String getAddExtraDeviceMark() {
|
||||
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, "");
|
||||
if (res == null || res.equals("")) {
|
||||
res = android.os.Build.MODEL;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void setAddExtraDeviceMark(String addExtraDeviceMark) {
|
||||
Log.d(TAG, "addExtraDeviceMark :" + addExtraDeviceMark);
|
||||
sp_setting.edit()
|
||||
.putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, addExtraDeviceMark)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static String getSmsTemplate() {
|
||||
return sp_setting.getString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE, "{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}");
|
||||
}
|
||||
|
||||
public static void setSmsTemplate(String textSmsTemplate) {
|
||||
Log.d(TAG, "textSmsTemplate :" + textSmsTemplate);
|
||||
sp_setting.edit()
|
||||
.putString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE, textSmsTemplate)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static String getAddExtraSim1() {
|
||||
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, "");
|
||||
if (res == null || res.equals("")) {
|
||||
res = SimUtil.getSimInfo(1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void setAddExtraSim1(String sim1) {
|
||||
Log.d(TAG, "sim1 :" + sim1);
|
||||
sp_setting.edit()
|
||||
.putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, sim1)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static String getAddExtraSim2() {
|
||||
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, "");
|
||||
if (res == null || res.equals("")) {
|
||||
res = SimUtil.getSimInfo(2);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void setAddExtraSim2(String sim2) {
|
||||
Log.d(TAG, "sim2 :" + sim2);
|
||||
sp_setting.edit()
|
||||
.putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, sim2)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static int getBatteryLevelAlarm() {
|
||||
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, 0);
|
||||
}
|
||||
|
||||
public static void setBatteryLevelAlarm(int battery_level) {
|
||||
Log.d(TAG, "battery_level :" + battery_level);
|
||||
sp_setting.edit()
|
||||
.putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, battery_level)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean saveMsgHistory() {
|
||||
return !sp_setting.getBoolean("option_save_history_on", false);
|
||||
}
|
||||
|
||||
//接口请求失败重试
|
||||
private static String getRetryDelayTimeKey(int index) {
|
||||
switch (index) {
|
||||
case 1:
|
||||
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME1;
|
||||
case 2:
|
||||
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME2;
|
||||
case 3:
|
||||
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME3;
|
||||
case 4:
|
||||
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME4;
|
||||
case 5:
|
||||
default:
|
||||
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME5;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
@SuppressWarnings({"SynchronizeOnNonFinalField", "unused"})
|
||||
public class SettingUtil {
|
||||
static Boolean hasInit = false;
|
||||
private static final String TAG = "SettingUtil";
|
||||
private static SharedPreferences sp_setting = null;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Context context = null;
|
||||
|
||||
public static void init(Context context1) {
|
||||
synchronized (hasInit) {
|
||||
if (hasInit) return;
|
||||
hasInit = true;
|
||||
context = context1;
|
||||
Log.d(TAG, "init ");
|
||||
sp_setting = PreferenceManager.getDefaultSharedPreferences(context1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void switchAddExtra(Boolean switchAddExtra) {
|
||||
Log.d(TAG, "switchAddExtra :" + switchAddExtra);
|
||||
sp_setting.edit()
|
||||
.putBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, switchAddExtra)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean getSwitchAddExtra() {
|
||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, false);
|
||||
}
|
||||
|
||||
public static void switchAddDeviceName(Boolean switchAddDeviceName) {
|
||||
Log.d(TAG, "switchAddDeviceName :" + switchAddDeviceName);
|
||||
sp_setting.edit()
|
||||
.putBoolean(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME, switchAddDeviceName)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean getSwitchAddDeviceName() {
|
||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME, false);
|
||||
}
|
||||
|
||||
public static void switchEnablePhone(Boolean enable) {
|
||||
sp_setting.edit()
|
||||
.putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PHONE, enable)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean getSwitchEnablePhone() {
|
||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_PHONE, true);
|
||||
}
|
||||
|
||||
public static void switchEnableAppNotify(Boolean enable) {
|
||||
sp_setting.edit()
|
||||
.putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY, enable)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean getSwitchEnableAppNotify() {
|
||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY, true);
|
||||
}
|
||||
|
||||
public static void switchSmsTemplate(Boolean switchSmsTemplate) {
|
||||
Log.d(TAG, "switchSmsTemplate :" + switchSmsTemplate);
|
||||
sp_setting.edit()
|
||||
.putBoolean(Define.SP_MSG_KEY_SWITCH_SMS_TEMPLATE, switchSmsTemplate)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean getSwitchSmsTemplate() {
|
||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_SMS_TEMPLATE, false);
|
||||
}
|
||||
|
||||
public static String getAddExtraDeviceMark() {
|
||||
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, "");
|
||||
if (res == null || res.equals("")) {
|
||||
res = android.os.Build.MODEL;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void setAddExtraDeviceMark(String addExtraDeviceMark) {
|
||||
Log.d(TAG, "addExtraDeviceMark :" + addExtraDeviceMark);
|
||||
sp_setting.edit()
|
||||
.putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK, addExtraDeviceMark)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static String getSmsTemplate() {
|
||||
return sp_setting.getString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE, "{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}");
|
||||
}
|
||||
|
||||
public static void setSmsTemplate(String textSmsTemplate) {
|
||||
Log.d(TAG, "textSmsTemplate :" + textSmsTemplate);
|
||||
sp_setting.edit()
|
||||
.putString(Define.SP_MSG_KEY_STRING_SMS_TEMPLATE, textSmsTemplate)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static String getAddExtraSim1() {
|
||||
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, "");
|
||||
if (res == null || res.equals("")) {
|
||||
res = SimUtil.getSimInfo(1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void setAddExtraSim1(String sim1) {
|
||||
Log.d(TAG, "sim1 :" + sim1);
|
||||
sp_setting.edit()
|
||||
.putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM1, sim1)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static String getAddExtraSim2() {
|
||||
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, "");
|
||||
if (res == null || res.equals("")) {
|
||||
res = SimUtil.getSimInfo(2);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void setAddExtraSim2(String sim2) {
|
||||
Log.d(TAG, "sim2 :" + sim2);
|
||||
sp_setting.edit()
|
||||
.putString(Define.SP_MSG_KEY_STRING_ADD_EXTRA_SIM2, sim2)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static int getBatteryLevelAlarm() {
|
||||
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, 0);
|
||||
}
|
||||
|
||||
public static void setBatteryLevelAlarm(int battery_level) {
|
||||
Log.d(TAG, "battery_level :" + battery_level);
|
||||
sp_setting.edit()
|
||||
.putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, battery_level)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static boolean saveMsgHistory() {
|
||||
return !sp_setting.getBoolean("option_save_history_on", false);
|
||||
}
|
||||
|
||||
//接口请求失败重试
|
||||
private static String getRetryDelayTimeKey(int index) {
|
||||
switch (index) {
|
||||
case 1:
|
||||
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME1;
|
||||
case 2:
|
||||
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME2;
|
||||
case 3:
|
||||
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME3;
|
||||
case 4:
|
||||
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME4;
|
||||
case 5:
|
||||
default:
|
||||
return Define.SP_MSG_KEY_STRING_RETRY_DELAY_TIME5;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
10
app/src/main/res/drawable/app.xml
Normal file
10
app/src/main/res/drawable/app.xml
Normal file
@ -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>
|
9
app/src/main/res/drawable/bg_select_default.xml
Normal file
9
app/src/main/res/drawable/bg_select_default.xml
Normal file
@ -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>
|
9
app/src/main/res/drawable/bg_select_pressed.xml
Normal file
9
app/src/main/res/drawable/bg_select_pressed.xml
Normal file
@ -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>
|
7
app/src/main/res/drawable/select_selector.xml
Normal file
7
app/src/main/res/drawable/select_selector.xml
Normal file
@ -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>
|
10
app/src/main/res/drawable/sim1.xml
Normal file
10
app/src/main/res/drawable/sim1.xml
Normal file
@ -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>
|
10
app/src/main/res/drawable/sim2.xml
Normal file
10
app/src/main/res/drawable/sim2.xml
Normal file
@ -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>
|
6
app/src/main/res/drawable/txt_select_selector.xml
Normal file
6
app/src/main/res/drawable/txt_select_selector.xml
Normal file
@ -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"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.idormy.sms.forwarder.RefreshListView
|
||||
android:id="@+id/list_view_log"
|
||||
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/log_tips"
|
||||
android:textColor="@color/colorPrimary" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<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="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>
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="5dip"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/radioGroupTypeCheck"
|
||||
style="@style/rg_style"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnTypeSms"
|
||||
style="@style/select_style"
|
||||
android:tag="sms"
|
||||
android:text="@string/sms"
|
||||
android:checked="true" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnTypeCall"
|
||||
style="@style/select_style"
|
||||
android:tag="call"
|
||||
android:text="@string/call" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnTypeApp"
|
||||
style="@style/select_style"
|
||||
android:tag="app"
|
||||
android:text="@string/app" />
|
||||
</RadioGroup>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.idormy.sms.forwarder.RefreshListView
|
||||
android:id="@+id/list_view_log"
|
||||
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/log_tips"
|
||||
android:textColor="@color/colorPrimary" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<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="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>
|
@ -1,37 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<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>
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="5dip"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/radioGroupTypeCheck"
|
||||
style="@style/rg_style"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnTypeSms"
|
||||
style="@style/select_style"
|
||||
android:tag="sms"
|
||||
android:text="@string/sms"
|
||||
android:checked="true" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnTypeCall"
|
||||
style="@style/select_style"
|
||||
android:tag="call"
|
||||
android:text="@string/call" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnTypeApp"
|
||||
style="@style/select_style"
|
||||
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>
|
@ -295,6 +295,33 @@
|
||||
|
||||
</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
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -6,4 +6,14 @@
|
||||
<color name="colorBlueGreyLight">#B0BBC5</color>
|
||||
<color name="colorBlueGrey">#78909C</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>
|
||||
|
@ -149,6 +149,7 @@
|
||||
<string name="add_extra">Sim slot info attached</string>
|
||||
<string name="add_device_name">Device Name attached</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="custom_templates">Custom templates</string>
|
||||
<string name="custom_templates_tips">Tip:Insert labels as needed;Leave blank to default template</string>
|
||||
@ -197,4 +198,7 @@
|
||||
<string name="no_network">No network at present</string>
|
||||
<string name="not_connected_wifi">Not connected WIFI</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>
|
||||
|
@ -19,4 +19,19 @@
|
||||
<item name="android:layout_weight">1</item>
|
||||
</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>
|
||||
|
@ -6,4 +6,14 @@
|
||||
<color name="colorBlueGreyLight">#B0BBC5</color>
|
||||
<color name="colorBlueGrey">#78909C</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>
|
||||
|
@ -149,6 +149,7 @@
|
||||
<string name="add_extra">转发时附加卡槽信息</string>
|
||||
<string name="add_device_name">转发时附加设备名称</string>
|
||||
<string name="forward_missed_calls">转发未接来电</string>
|
||||
<string name="forward_app_notify">转发APP通知</string>
|
||||
<string name="enable_custom_templates">启用自定义模版</string>
|
||||
<string name="custom_templates">转发信息模版</string>
|
||||
<string name="custom_templates_tips">Tip:按需插入内容标签;留空使用默认模版</string>
|
||||
@ -196,4 +197,7 @@
|
||||
<string name="no_network">当前没有网络</string>
|
||||
<string name="not_connected_wifi">未连接Wifi</string>
|
||||
<string name="failed_to_get_ip">获取IP失败</string>
|
||||
<string name="sms">短 信</string>
|
||||
<string name="call">来 电</string>
|
||||
<string name="app">应 用</string>
|
||||
</resources>
|
||||
|
@ -19,4 +19,18 @@
|
||||
<item name="android:layout_weight">1</item>
|
||||
</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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user