mirror of
https://github.com/pppscn/SmsForwarder
synced 2025-08-04 01:47:40 +08:00
优化:电池状态监听(剩余电量预警上下限,电池状态改变)
This commit is contained in:
parent
0470e4d6ff
commit
cdeed5cfc3
@ -23,6 +23,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
|
|
||||||
import com.idormy.sms.forwarder.adapter.LogAdapter;
|
import com.idormy.sms.forwarder.adapter.LogAdapter;
|
||||||
import com.idormy.sms.forwarder.model.vo.LogVo;
|
import com.idormy.sms.forwarder.model.vo.LogVo;
|
||||||
|
import com.idormy.sms.forwarder.service.BatteryService;
|
||||||
import com.idormy.sms.forwarder.service.FrontService;
|
import com.idormy.sms.forwarder.service.FrontService;
|
||||||
import com.idormy.sms.forwarder.utils.CommonUtil;
|
import com.idormy.sms.forwarder.utils.CommonUtil;
|
||||||
import com.idormy.sms.forwarder.utils.KeepAliveUtils;
|
import com.idormy.sms.forwarder.utils.KeepAliveUtils;
|
||||||
@ -74,7 +75,16 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
|||||||
serviceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
serviceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startService(serviceIntent);
|
startService(serviceIntent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "onCreate:", e);
|
Log.e(TAG, "FrontService:", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
//监听电池状态
|
||||||
|
try {
|
||||||
|
Intent batteryServiceIntent = new Intent(this, BatteryService.class);
|
||||||
|
batteryServiceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startService(batteryServiceIntent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "BatteryService:", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +172,7 @@ public class MainActivity extends AppCompatActivity implements RefreshListView.I
|
|||||||
Log.d(TAG, "SimInfoList = " + MyApplication.SimInfoList.size());
|
Log.d(TAG, "SimInfoList = " + MyApplication.SimInfoList.size());
|
||||||
|
|
||||||
//省电优化设置为无限制
|
//省电优化设置为无限制
|
||||||
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
if (MyApplication.showHelpTip && Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
||||||
if (!KeepAliveUtils.isIgnoreBatteryOptimization(this)) {
|
if (!KeepAliveUtils.isIgnoreBatteryOptimization(this)) {
|
||||||
Toast.makeText(this, R.string.tips_battery_optimization, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.tips_battery_optimization, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import android.os.Build;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.idormy.sms.forwarder.sender.SendHistory;
|
import com.idormy.sms.forwarder.sender.SendHistory;
|
||||||
|
import com.idormy.sms.forwarder.service.BatteryService;
|
||||||
import com.idormy.sms.forwarder.service.FrontService;
|
import com.idormy.sms.forwarder.service.FrontService;
|
||||||
import com.idormy.sms.forwarder.utils.CommonUtil;
|
import com.idormy.sms.forwarder.utils.CommonUtil;
|
||||||
import com.idormy.sms.forwarder.utils.Define;
|
import com.idormy.sms.forwarder.utils.Define;
|
||||||
@ -47,12 +48,14 @@ public class MyApplication extends Application {
|
|||||||
//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) {
|
||||||
startForegroundService(intent);
|
startForegroundService(intent);
|
||||||
} else {
|
} else {
|
||||||
startService(intent);
|
startService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendHistory.init(this);
|
SendHistory.init(this);
|
||||||
SettingUtil.init(this);
|
SettingUtil.init(this);
|
||||||
|
|
||||||
@ -70,6 +73,10 @@ public class MyApplication extends Application {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//电池状态监听
|
||||||
|
Intent batteryServiceIntent = new Intent(this, BatteryService.class);
|
||||||
|
startService(batteryServiceIntent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "onCreate:", e);
|
Log.e(TAG, "onCreate:", e);
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,10 @@ public class SettingActivity extends AppCompatActivity {
|
|||||||
EditText et_add_extra_sim2 = findViewById(R.id.et_add_extra_sim2);
|
EditText et_add_extra_sim2 = findViewById(R.id.et_add_extra_sim2);
|
||||||
editAddExtraSim2(et_add_extra_sim2);
|
editAddExtraSim2(et_add_extra_sim2);
|
||||||
|
|
||||||
EditText et_battery_level_alarm = findViewById(R.id.et_battery_level_alarm);
|
EditText et_battery_level_alarm_min = findViewById(R.id.et_battery_level_alarm_min);
|
||||||
editBatteryLevelAlarm(et_battery_level_alarm);
|
editBatteryLevelAlarmMin(et_battery_level_alarm_min);
|
||||||
|
EditText et_battery_level_alarm_max = findViewById(R.id.et_battery_level_alarm_max);
|
||||||
|
editBatteryLevelAlarmMax(et_battery_level_alarm_max);
|
||||||
|
|
||||||
EditText et_retry_delay_time1 = findViewById(R.id.et_retry_delay_time1);
|
EditText et_retry_delay_time1 = findViewById(R.id.et_retry_delay_time1);
|
||||||
editRetryDelayTime(et_retry_delay_time1, 1);
|
editRetryDelayTime(et_retry_delay_time1, 1);
|
||||||
@ -78,6 +80,9 @@ public class SettingActivity extends AppCompatActivity {
|
|||||||
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_exclude_from_recents = findViewById(R.id.switch_exclude_from_recents);
|
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_exclude_from_recents = findViewById(R.id.switch_exclude_from_recents);
|
||||||
switchExcludeFromRecents(switch_exclude_from_recents);
|
switchExcludeFromRecents(switch_exclude_from_recents);
|
||||||
|
|
||||||
|
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_battery_receiver = findViewById(R.id.switch_battery_receiver);
|
||||||
|
switchBatteryReceiver(switch_battery_receiver);
|
||||||
|
|
||||||
EditText textSmsTemplate = findViewById(R.id.text_sms_template);
|
EditText textSmsTemplate = findViewById(R.id.text_sms_template);
|
||||||
editSmsTemplate(textSmsTemplate);
|
editSmsTemplate(textSmsTemplate);
|
||||||
}
|
}
|
||||||
@ -104,6 +109,17 @@ public class SettingActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//监听电池状态变化
|
||||||
|
private void switchBatteryReceiver(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_battery_receiver) {
|
||||||
|
switch_battery_receiver.setChecked(SettingUtil.getSwitchEnableBatteryReceiver());
|
||||||
|
|
||||||
|
switch_battery_receiver.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
//TODO:校验使用来电转发必备的权限
|
||||||
|
SettingUtil.switchEnableBatteryReceiver(isChecked);
|
||||||
|
Log.d(TAG, "switchEnablePhone:" + isChecked);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//设置转发APP通知
|
//设置转发APP通知
|
||||||
private void switchEnableAppNotify(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_app_notify) {
|
private void switchEnableAppNotify(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_enable_app_notify) {
|
||||||
switch_enable_app_notify.setChecked(SettingUtil.getSwitchEnableAppNotify());
|
switch_enable_app_notify.setChecked(SettingUtil.getSwitchEnableAppNotify());
|
||||||
@ -205,9 +221,9 @@ public class SettingActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//设置低电量报警值
|
//设置低电量报警值下限
|
||||||
private void editBatteryLevelAlarm(final EditText et_battery_level_alarm) {
|
private void editBatteryLevelAlarmMin(final EditText et_battery_level_alarm) {
|
||||||
et_battery_level_alarm.setText(String.valueOf(SettingUtil.getBatteryLevelAlarm()));
|
et_battery_level_alarm.setText(String.valueOf(SettingUtil.getBatteryLevelAlarmMin()));
|
||||||
|
|
||||||
et_battery_level_alarm.addTextChangedListener(new TextWatcher() {
|
et_battery_level_alarm.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
@ -222,9 +238,34 @@ public class SettingActivity extends AppCompatActivity {
|
|||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
String batteryLevel = et_battery_level_alarm.getText().toString().trim();
|
String batteryLevel = et_battery_level_alarm.getText().toString().trim();
|
||||||
if (!batteryLevel.isEmpty()) {
|
if (!batteryLevel.isEmpty()) {
|
||||||
SettingUtil.setBatteryLevelAlarm(Integer.parseInt(batteryLevel));
|
SettingUtil.setBatteryLevelAlarmMin(Integer.parseInt(batteryLevel));
|
||||||
} else {
|
} else {
|
||||||
SettingUtil.setBatteryLevelAlarm(0);
|
SettingUtil.setBatteryLevelAlarmMin(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置低电量报警值上限
|
||||||
|
private void editBatteryLevelAlarmMax(final EditText et_battery_level_alarm) {
|
||||||
|
et_battery_level_alarm.setText(String.valueOf(SettingUtil.getBatteryLevelAlarmMax()));
|
||||||
|
|
||||||
|
et_battery_level_alarm.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
String batteryLevel = et_battery_level_alarm.getText().toString().trim();
|
||||||
|
if (!batteryLevel.isEmpty()) {
|
||||||
|
SettingUtil.setBatteryLevelAlarmMax(Integer.parseInt(batteryLevel));
|
||||||
|
} else {
|
||||||
|
SettingUtil.setBatteryLevelAlarmMax(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,7 @@ import java.util.regex.PatternSyntaxException;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "SpellCheckingInspection"})
|
@SuppressWarnings({"unused"})
|
||||||
@Data
|
@Data
|
||||||
public class RuleModel {
|
public class RuleModel {
|
||||||
public static final String FILED_TRANSPOND_ALL = "transpond_all";
|
public static final String FILED_TRANSPOND_ALL = "transpond_all";
|
||||||
|
@ -9,7 +9,6 @@ public final class RuleTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Inner class that defines the table contents */
|
/* Inner class that defines the table contents */
|
||||||
@SuppressWarnings("SpellCheckingInspection")
|
|
||||||
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_TYPE = "type";
|
||||||
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.idormy.sms.forwarder.service.BatteryService;
|
||||||
import com.idormy.sms.forwarder.service.FrontService;
|
import com.idormy.sms.forwarder.service.FrontService;
|
||||||
import com.idormy.sms.forwarder.utils.InitUtil;
|
import com.idormy.sms.forwarder.utils.InitUtil;
|
||||||
|
|
||||||
@ -18,12 +19,18 @@ public class RebootBroadcastReceiver extends BroadcastReceiver {
|
|||||||
Log.d(TAG, "onReceive intent " + receiveAction);
|
Log.d(TAG, "onReceive intent " + receiveAction);
|
||||||
if (receiveAction.equals("android.intent.action.BOOT_COMPLETED")) {
|
if (receiveAction.equals("android.intent.action.BOOT_COMPLETED")) {
|
||||||
InitUtil.init(context);
|
InitUtil.init(context);
|
||||||
|
|
||||||
|
//前台服务
|
||||||
Intent frontServiceIntent = new Intent(context, FrontService.class);
|
Intent frontServiceIntent = new Intent(context, FrontService.class);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
context.startForegroundService(frontServiceIntent);
|
context.startForegroundService(frontServiceIntent);
|
||||||
} else {
|
} else {
|
||||||
context.startService(frontServiceIntent);
|
context.startService(frontServiceIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//电池状态监听
|
||||||
|
Intent batteryServiceIntent = new Intent(context, BatteryService.class);
|
||||||
|
context.startService(batteryServiceIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ import okhttp3.Request;
|
|||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@SuppressWarnings({"ResultOfMethodCallIgnored", "rawtypes", "unchecked", "deprecation", "SpellCheckingInspection"})
|
@SuppressWarnings({"ResultOfMethodCallIgnored", "rawtypes", "unchecked", "deprecation"})
|
||||||
public class SenderDingdingMsg extends SenderBaseMsg {
|
public class SenderDingdingMsg extends SenderBaseMsg {
|
||||||
|
|
||||||
static final String TAG = "SenderDingdingMsg";
|
static final String TAG = "SenderDingdingMsg";
|
||||||
|
@ -10,7 +10,11 @@ import android.os.BatteryManager;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import com.idormy.sms.forwarder.model.vo.SmsVo;
|
||||||
|
import com.idormy.sms.forwarder.sender.SendUtil;
|
||||||
|
import com.idormy.sms.forwarder.utils.SettingUtil;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class BatteryService extends Service {
|
public class BatteryService extends Service {
|
||||||
@ -26,9 +30,9 @@ public class BatteryService extends Service {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
Log.i(TAG, "onCreate--------------");
|
Log.i(TAG, "onCreate--------------");
|
||||||
IntentFilter batteryFilter = new IntentFilter();
|
IntentFilter batteryfilter = new IntentFilter();
|
||||||
batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
batteryfilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||||
registerReceiver(batteryReceiver, batteryFilter);
|
registerReceiver(batteryReceiver, batteryfilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -39,7 +43,7 @@ public class BatteryService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
Log.i(TAG, "onStartCommand--------------");
|
Log.i(TAG, "onStartCommand--------------");
|
||||||
return Service.START_STICKY; //保证service不被杀死
|
return Service.START_STICKY; //
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -51,7 +55,7 @@ public class BatteryService extends Service {
|
|||||||
|
|
||||||
// 接收电池信息更新的广播
|
// 接收电池信息更新的广播
|
||||||
private final BroadcastReceiver batteryReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver batteryReceiver = new BroadcastReceiver() {
|
||||||
@SuppressWarnings("unused")
|
@SuppressLint("DefaultLocale")
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
Log.i(TAG, "BatteryReceiver--------------");
|
Log.i(TAG, "BatteryReceiver--------------");
|
||||||
@ -60,50 +64,121 @@ public class BatteryService extends Service {
|
|||||||
Log.i(TAG, "ACTION_BATTERY_CHANGED");
|
Log.i(TAG, "ACTION_BATTERY_CHANGED");
|
||||||
int status = intent.getIntExtra("status", 0);
|
int status = intent.getIntExtra("status", 0);
|
||||||
int health = intent.getIntExtra("health", 0);
|
int health = intent.getIntExtra("health", 0);
|
||||||
boolean present = intent.getBooleanExtra("present", false);
|
//boolean present = intent.getBooleanExtra("present", false);
|
||||||
int level = intent.getIntExtra("level", 0);
|
int levelCur = intent.getIntExtra("level", 0);
|
||||||
int scale = intent.getIntExtra("scale", 0);
|
int scale = intent.getIntExtra("scale", 0);
|
||||||
int icon_small = intent.getIntExtra("icon-small", 0);
|
//int icon_small = intent.getIntExtra("icon-small", 0);
|
||||||
int plugged = intent.getIntExtra("plugged", 0);
|
int plugged = intent.getIntExtra("plugged", 0);
|
||||||
int voltage = intent.getIntExtra("voltage", 0);
|
int voltage = intent.getIntExtra("voltage", 0);
|
||||||
int temperature = intent.getIntExtra("temperature", 0);
|
int temperature = intent.getIntExtra("temperature", 0);
|
||||||
String technology = intent.getStringExtra("technology");
|
//String technology = intent.getStringExtra("technology");
|
||||||
|
|
||||||
String statusString = "";
|
String msg = "";
|
||||||
switch (status) {
|
msg += "\n剩余电量:" + levelCur + "%";
|
||||||
case BatteryManager.BATTERY_STATUS_UNKNOWN:
|
|
||||||
statusString = "unknown";
|
if (scale > 0) msg += "\n充满电量:" + scale + "%";
|
||||||
break;
|
|
||||||
case BatteryManager.BATTERY_STATUS_CHARGING:
|
if (voltage > 0) msg += "\n当前电压:" + String.format("%.2f", voltage / 1000F) + "V";
|
||||||
statusString = "charging";
|
|
||||||
break;
|
if (temperature > 0) msg += "\n当前温度:" + String.format("%.2f", temperature / 10F) + "℃";
|
||||||
case BatteryManager.BATTERY_STATUS_DISCHARGING:
|
|
||||||
statusString = "discharging";
|
msg += "\n电池状态:" + getStatus(status);
|
||||||
break;
|
|
||||||
case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
|
if (health > 0) msg += "\n健康度:" + getHealth(health);
|
||||||
statusString = "not charging";
|
|
||||||
break;
|
|
||||||
case BatteryManager.BATTERY_STATUS_FULL:
|
|
||||||
statusString = "full";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
String acString = "";
|
|
||||||
|
|
||||||
switch (plugged) {
|
switch (plugged) {
|
||||||
case BatteryManager.BATTERY_PLUGGED_AC:
|
case BatteryManager.BATTERY_PLUGGED_AC:
|
||||||
acString = "plugged ac";
|
msg += "\n充电器:AC";
|
||||||
break;
|
break;
|
||||||
case BatteryManager.BATTERY_PLUGGED_USB:
|
case BatteryManager.BATTERY_PLUGGED_USB:
|
||||||
acString = "plugged usb";
|
msg += "\n充电器:USB";
|
||||||
|
break;
|
||||||
|
case BatteryManager.BATTERY_PLUGGED_WIRELESS:
|
||||||
|
msg += "\n充电器:无线";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss:SSS ");
|
Log.i(TAG, msg);
|
||||||
String date = sDateFormat.format(new java.util.Date());
|
|
||||||
|
|
||||||
Log.i(TAG, "battery: date=" + date + ",status " + statusString
|
//电量发生变化
|
||||||
+ ",level=" + level + ",scale=" + scale
|
int levelPre = SettingUtil.getBatteryLevelCurrent();
|
||||||
+ ",voltage=" + voltage + ",acString=" + acString);
|
if (levelCur != levelPre) {
|
||||||
|
SettingUtil.setBatteryLevelCurrent(levelCur);
|
||||||
|
|
||||||
|
int levelMin = SettingUtil.getBatteryLevelAlarmMin();
|
||||||
|
int levelMax = SettingUtil.getBatteryLevelAlarmMax();
|
||||||
|
if (levelMin > 0 && levelPre > levelCur && levelCur <= levelMin) { //电量下降到下限
|
||||||
|
msg = "【电量预警】已到达电量预警下限,请及时充电!" + msg;
|
||||||
|
sendMessage(context, msg);
|
||||||
|
return;
|
||||||
|
} else if (levelMax > 0 && levelPre < levelCur && levelCur >= levelMax) { //电量上升到上限
|
||||||
|
msg = "【电量预警】已到达电量预警上限,请拔掉充电器!" + msg;
|
||||||
|
sendMessage(context, msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//充电状态改变
|
||||||
|
if (SettingUtil.getSwitchEnableBatteryReceiver()) {
|
||||||
|
int oldStatus = SettingUtil.getBatteryStatus();
|
||||||
|
if (status != oldStatus) {
|
||||||
|
SettingUtil.setBatteryStatus(status);
|
||||||
|
msg = "【充电状态】发生变化:" + getStatus(oldStatus) + " → " + getStatus(status) + msg;
|
||||||
|
sendMessage(context, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//电池状态
|
||||||
|
private String getStatus(int status) {
|
||||||
|
switch (status) {
|
||||||
|
case BatteryManager.BATTERY_STATUS_CHARGING:
|
||||||
|
return "充电中";
|
||||||
|
case BatteryManager.BATTERY_STATUS_DISCHARGING:
|
||||||
|
return "放电中";
|
||||||
|
case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
|
||||||
|
return "未充电";
|
||||||
|
case BatteryManager.BATTERY_STATUS_FULL:
|
||||||
|
return "充满电";
|
||||||
|
case BatteryManager.BATTERY_STATUS_UNKNOWN:
|
||||||
|
default:
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//健康度
|
||||||
|
private String getHealth(int health) {
|
||||||
|
switch (health) {
|
||||||
|
case 2:
|
||||||
|
return "良好";
|
||||||
|
case 3:
|
||||||
|
return "过热";
|
||||||
|
case 4:
|
||||||
|
return "没电";
|
||||||
|
case 5:
|
||||||
|
return "过电压";
|
||||||
|
case 6:
|
||||||
|
return "未知错误";
|
||||||
|
case 7:
|
||||||
|
return "温度过低";
|
||||||
|
default:
|
||||||
|
case 1:
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//发送信息
|
||||||
|
private void sendMessage(Context context, String msg) {
|
||||||
|
Log.i(TAG, msg);
|
||||||
|
try {
|
||||||
|
SmsVo smsVo = new SmsVo("88888888", msg, new Date(), "电池状态监听");
|
||||||
|
Log.d(TAG, "send_msg" + smsVo.toString());
|
||||||
|
SendUtil.send_msg(context, smsVo, 1, "app");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "getLog e:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -6,7 +6,6 @@ import android.app.NotificationChannel;
|
|||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.ContextWrapper;
|
import android.content.ContextWrapper;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
@ -21,18 +20,11 @@ import androidx.annotation.Nullable;
|
|||||||
import com.idormy.sms.forwarder.MainActivity;
|
import com.idormy.sms.forwarder.MainActivity;
|
||||||
import com.idormy.sms.forwarder.MyApplication;
|
import com.idormy.sms.forwarder.MyApplication;
|
||||||
import com.idormy.sms.forwarder.R;
|
import com.idormy.sms.forwarder.R;
|
||||||
import com.idormy.sms.forwarder.model.vo.SmsVo;
|
|
||||||
import com.idormy.sms.forwarder.sender.SendUtil;
|
|
||||||
import com.idormy.sms.forwarder.sender.SenderUtil;
|
|
||||||
import com.idormy.sms.forwarder.utils.CommonUtil;
|
import com.idormy.sms.forwarder.utils.CommonUtil;
|
||||||
import com.idormy.sms.forwarder.utils.OSUtil;
|
import com.idormy.sms.forwarder.utils.OSUtil;
|
||||||
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 java.util.Date;
|
|
||||||
import java.util.Timer;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
|
|
||||||
public class FrontService extends Service {
|
public class FrontService extends Service {
|
||||||
private static final String TAG = "FrontService";
|
private static final String TAG = "FrontService";
|
||||||
private static final String CHANNEL_ONE_ID = "com.idormy.sms.forwarder";
|
private static final String CHANNEL_ONE_ID = "com.idormy.sms.forwarder";
|
||||||
@ -84,36 +76,6 @@ public class FrontService extends Service {
|
|||||||
MyApplication.SimInfoList = PhoneUtils.getSimMultiInfo();
|
MyApplication.SimInfoList = PhoneUtils.getSimMultiInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 低电量预警
|
|
||||||
final int[] alarmTimes = {0}; //通知次数,只通知2次
|
|
||||||
Context context1 = this;
|
|
||||||
SenderUtil.init(context1);
|
|
||||||
new Timer().schedule(new TimerTask() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
int batteryLevel = getBatteryLevel();
|
|
||||||
//System.out.println("当前剩余电量:" + batteryLevel + "%");
|
|
||||||
int batteryLevelAlarm = SettingUtil.getBatteryLevelAlarm();
|
|
||||||
if (alarmTimes[0] <= 1 && batteryLevelAlarm > 0 && batteryLevelAlarm <= 100 && (batteryLevel == batteryLevelAlarm || batteryLevel == batteryLevelAlarm - 1)) {
|
|
||||||
try {
|
|
||||||
alarmTimes[0] = alarmTimes[0] + 1;
|
|
||||||
SmsVo smsVo = new SmsVo("88888888",
|
|
||||||
"当前剩余电量:" + batteryLevel + "%,已经到达低电量预警阈值,请及时充电!",
|
|
||||||
new Date(),
|
|
||||||
"低电量预警");
|
|
||||||
Log.d(TAG, "send_msg" + smsVo.toString());
|
|
||||||
SendUtil.send_msg(context1, smsVo, 1, "app");
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "getLog e:" + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (batteryLevelAlarm > 0 && batteryLevelAlarm <= 100 && batteryLevel > batteryLevelAlarm) {
|
|
||||||
alarmTimes[0] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0, 10000);
|
|
||||||
|
|
||||||
if (SettingUtil.getSwitchEnableAppNotify() && CommonUtil.isNotificationListenerServiceEnabled(this)) {
|
if (SettingUtil.getSwitchEnableAppNotify() && CommonUtil.isNotificationListenerServiceEnabled(this)) {
|
||||||
CommonUtil.toggleNotificationListenerService(this);
|
CommonUtil.toggleNotificationListenerService(this);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,11 @@ public class Define {
|
|||||||
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";
|
||||||
public static final String SP_MSG_KEY_SWITCH_SMS_TEMPLATE = "tsms_msg_key_switch_sms_template";
|
public static final String SP_MSG_KEY_SWITCH_SMS_TEMPLATE = "tsms_msg_key_switch_sms_template";
|
||||||
public static final String SP_MSG_KEY_STRING_SMS_TEMPLATE = "tsms_msg_key_string_sms_template";
|
public static final String SP_MSG_KEY_STRING_SMS_TEMPLATE = "tsms_msg_key_string_sms_template";
|
||||||
|
public static final String SP_MSG_KEY_STRING_BATTERY_STATUS = "tsms_msg_key_string_battery_status";
|
||||||
|
public static final String SP_MSG_KEY_STRING_BATTERY_RECEIVER = "tsms_msg_key_switch_battery_receiver";
|
||||||
|
public static final String SP_MSG_KEY_STRING_BATTERY_LEVEL_CURRENT = "tsms_msg_key_string_battery_level_current";
|
||||||
public static final String SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM = "tsms_msg_key_string_battery_level_alarm";
|
public static final String SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM = "tsms_msg_key_string_battery_level_alarm";
|
||||||
|
public static final String SP_MSG_KEY_STRING_BATTERY_LEVEL_MAX = "tsms_msg_key_string_battery_level_max";
|
||||||
public static final String SP_MSG_KEY_STRING_RETRY_DELAY_TIME1 = "tsms_msg_key_string_retry_delay_time1";
|
public static final String SP_MSG_KEY_STRING_RETRY_DELAY_TIME1 = "tsms_msg_key_string_retry_delay_time1";
|
||||||
public static final String SP_MSG_KEY_STRING_RETRY_DELAY_TIME2 = "tsms_msg_key_string_retry_delay_time2";
|
public static final String SP_MSG_KEY_STRING_RETRY_DELAY_TIME2 = "tsms_msg_key_string_retry_delay_time2";
|
||||||
public static final String SP_MSG_KEY_STRING_RETRY_DELAY_TIME3 = "tsms_msg_key_string_retry_delay_time3";
|
public static final String SP_MSG_KEY_STRING_RETRY_DELAY_TIME3 = "tsms_msg_key_string_retry_delay_time3";
|
||||||
|
@ -31,7 +31,7 @@ import java.util.Objects;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@SuppressWarnings({"deprecation", "rawtypes", "unchecked", "CommentedOutCode", "SynchronizeOnNonFinalField", "unused", "SameReturnValue", "SpellCheckingInspection"})
|
@SuppressWarnings({"deprecation", "rawtypes", "unchecked", "CommentedOutCode", "SynchronizeOnNonFinalField", "unused", "SameReturnValue"})
|
||||||
public class PhoneUtils {
|
public class PhoneUtils {
|
||||||
static Boolean hasInit = false;
|
static Boolean hasInit = false;
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "SpellCheckingInspection"})
|
@SuppressWarnings({"unused"})
|
||||||
class RuleLine {
|
class RuleLine {
|
||||||
public static final String CONJUNCTION_AND = "并且";
|
public static final String CONJUNCTION_AND = "并且";
|
||||||
public static final String CONJUNCTION_OR = "或者";
|
public static final String CONJUNCTION_OR = "或者";
|
||||||
|
@ -78,6 +78,16 @@ public class SettingUtil {
|
|||||||
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY, false);
|
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_ENABLE_APP_NOTIFY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void switchEnableBatteryReceiver(Boolean enable) {
|
||||||
|
sp_setting.edit()
|
||||||
|
.putBoolean(Define.SP_MSG_KEY_STRING_BATTERY_RECEIVER, enable)
|
||||||
|
.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getSwitchEnableBatteryReceiver() {
|
||||||
|
return sp_setting.getBoolean(Define.SP_MSG_KEY_STRING_BATTERY_RECEIVER, false);
|
||||||
|
}
|
||||||
|
|
||||||
public static void switchExcludeFromRecents(Boolean enable) {
|
public static void switchExcludeFromRecents(Boolean enable) {
|
||||||
sp_setting.edit()
|
sp_setting.edit()
|
||||||
.putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_EXCLUDE_FROM_RECENTS, enable)
|
.putBoolean(Define.SP_MSG_KEY_STRING_ENABLE_EXCLUDE_FROM_RECENTS, enable)
|
||||||
@ -155,17 +165,50 @@ public class SettingUtil {
|
|||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getBatteryLevelAlarm() {
|
public static int getBatteryLevelAlarmMin() {
|
||||||
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, 0);
|
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBatteryLevelAlarm(int battery_level) {
|
public static void setBatteryLevelAlarmMin(int battery_level) {
|
||||||
Log.d(TAG, "battery_level :" + battery_level);
|
Log.d(TAG, "battery_level :" + battery_level);
|
||||||
sp_setting.edit()
|
sp_setting.edit()
|
||||||
.putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, battery_level)
|
.putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, battery_level)
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getBatteryLevelAlarmMax() {
|
||||||
|
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_MAX, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setBatteryLevelAlarmMax(int battery_level) {
|
||||||
|
Log.d(TAG, "battery_level :" + battery_level);
|
||||||
|
sp_setting.edit()
|
||||||
|
.putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_MAX, battery_level)
|
||||||
|
.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getBatteryLevelCurrent() {
|
||||||
|
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_CURRENT, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setBatteryLevelCurrent(int battery_level) {
|
||||||
|
Log.d(TAG, "battery_level :" + battery_level);
|
||||||
|
sp_setting.edit()
|
||||||
|
.putInt(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_CURRENT, battery_level)
|
||||||
|
.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getBatteryStatus() {
|
||||||
|
return sp_setting.getInt(Define.SP_MSG_KEY_STRING_BATTERY_STATUS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setBatteryStatus(int battery_status) {
|
||||||
|
Log.d(TAG, "battery_status :" + battery_status);
|
||||||
|
sp_setting.edit()
|
||||||
|
.putInt(Define.SP_MSG_KEY_STRING_BATTERY_STATUS, battery_status)
|
||||||
|
.apply();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean saveMsgHistory() {
|
public static boolean saveMsgHistory() {
|
||||||
return !sp_setting.getBoolean("option_save_history_on", false);
|
return !sp_setting.getBoolean("option_save_history_on", false);
|
||||||
}
|
}
|
||||||
|
@ -124,150 +124,6 @@
|
|||||||
|
|
||||||
</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">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/low_power_alarm_threshold"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="end"
|
|
||||||
android:text="@string/low_power_alarm_threshold_tips"
|
|
||||||
android:textSize="9sp"
|
|
||||||
tools:ignore="SmallSp" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/et_battery_level_alarm"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:autofillHints=""
|
|
||||||
android:ems="16"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:text=""
|
|
||||||
tools:ignore="LabelFor" />
|
|
||||||
|
|
||||||
</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">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/retry_interval"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="end"
|
|
||||||
android:text="@string/retry_interval_tips"
|
|
||||||
android:textSize="9sp"
|
|
||||||
tools:ignore="SmallSp" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/et_retry_delay_time1"
|
|
||||||
android:layout_width="40dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:autofillHints=""
|
|
||||||
android:ems="16"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:text=""
|
|
||||||
android:textAlignment="center"
|
|
||||||
tools:ignore="LabelFor" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/et_retry_delay_time2"
|
|
||||||
android:layout_width="40dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:autofillHints=""
|
|
||||||
android:ems="16"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:text=""
|
|
||||||
android:textAlignment="center"
|
|
||||||
tools:ignore="LabelFor" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/et_retry_delay_time3"
|
|
||||||
android:layout_width="40dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:autofillHints=""
|
|
||||||
android:ems="16"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:text=""
|
|
||||||
android:textAlignment="center"
|
|
||||||
tools:ignore="LabelFor" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/et_retry_delay_time4"
|
|
||||||
android:layout_width="40dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:autofillHints=""
|
|
||||||
android:ems="16"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:text=""
|
|
||||||
android:textAlignment="center"
|
|
||||||
tools:ignore="LabelFor" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/et_retry_delay_time5"
|
|
||||||
android:layout_width="40dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:autofillHints=""
|
|
||||||
android:ems="16"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:text=""
|
|
||||||
android:textAlignment="center"
|
|
||||||
tools:ignore="LabelFor" />
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -394,48 +250,6 @@
|
|||||||
|
|
||||||
</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">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="4"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/enable_exclude_from_recents"
|
|
||||||
android:textStyle="bold"
|
|
||||||
tools:ignore="RelativeOverlap" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="end"
|
|
||||||
android:text="@string/enable_exclude_from_recents_tips"
|
|
||||||
android:textSize="9sp"
|
|
||||||
tools:ignore="SmallSp" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/switch_exclude_from_recents"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
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"
|
||||||
@ -592,6 +406,272 @@
|
|||||||
|
|
||||||
</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">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/retry_interval"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="end"
|
||||||
|
android:text="@string/retry_interval_tips"
|
||||||
|
android:textSize="9sp"
|
||||||
|
tools:ignore="SmallSp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/et_retry_delay_time1"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:autofillHints=""
|
||||||
|
android:ems="16"
|
||||||
|
android:inputType="number"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text=""
|
||||||
|
android:textAlignment="center"
|
||||||
|
tools:ignore="LabelFor" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/et_retry_delay_time2"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:autofillHints=""
|
||||||
|
android:ems="16"
|
||||||
|
android:inputType="number"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text=""
|
||||||
|
android:textAlignment="center"
|
||||||
|
tools:ignore="LabelFor" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/et_retry_delay_time3"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:autofillHints=""
|
||||||
|
android:ems="16"
|
||||||
|
android:inputType="number"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text=""
|
||||||
|
android:textAlignment="center"
|
||||||
|
tools:ignore="LabelFor" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/et_retry_delay_time4"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:autofillHints=""
|
||||||
|
android:ems="16"
|
||||||
|
android:inputType="number"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text=""
|
||||||
|
android:textAlignment="center"
|
||||||
|
tools:ignore="LabelFor" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/et_retry_delay_time5"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:autofillHints=""
|
||||||
|
android:ems="16"
|
||||||
|
android:inputType="number"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text=""
|
||||||
|
android:textAlignment="center"
|
||||||
|
tools:ignore="LabelFor" />
|
||||||
|
</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">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/low_power_alarm_threshold"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="end"
|
||||||
|
android:text="@string/low_power_alarm_threshold_tips"
|
||||||
|
android:textSize="9sp"
|
||||||
|
tools:ignore="SmallSp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:text="@string/below"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/et_battery_level_alarm_min"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:autofillHints=""
|
||||||
|
android:ems="2"
|
||||||
|
android:inputType="number"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text=""
|
||||||
|
android:textAlignment="center"
|
||||||
|
tools:ignore="LabelFor" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/percent"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:text="@string/above"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/et_battery_level_alarm_max"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:autofillHints=""
|
||||||
|
android:ems="2"
|
||||||
|
android:inputType="number"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/zero"
|
||||||
|
android:textAlignment="center"
|
||||||
|
tools:ignore="LabelFor" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/percent"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
</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">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="4"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/monitor_battery_status_changes"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="RelativeOverlap" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="end"
|
||||||
|
android:text="@string/battery_status_changes_tips"
|
||||||
|
android:textSize="9sp"
|
||||||
|
tools:ignore="SmallSp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/switch_battery_receiver"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="end"
|
||||||
|
android:textSize="18sp"
|
||||||
|
tools:ignore="UseSwitchCompatOrMaterialXml" />
|
||||||
|
|
||||||
|
</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">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="4"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/enable_exclude_from_recents"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:ignore="RelativeOverlap" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="end"
|
||||||
|
android:text="@string/enable_exclude_from_recents_tips"
|
||||||
|
android:textSize="9sp"
|
||||||
|
tools:ignore="SmallSp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/switch_exclude_from_recents"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
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"
|
||||||
@ -628,7 +708,7 @@
|
|||||||
android:background="@color/colorBlueGreyDark"
|
android:background="@color/colorBlueGreyDark"
|
||||||
android:onClick="initSetting"
|
android:onClick="initSetting"
|
||||||
android:text="@string/init_setting"
|
android:text="@string/init_setting"
|
||||||
tools:ignore="ButtonStyle,NestedWeights,UsingOnClickInXml" />
|
tools:ignore="ButtonStyle,NestedWeights,TooManyViews,UsingOnClickInXml" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -248,4 +248,10 @@
|
|||||||
<string name="account">✱Account</string>
|
<string name="account">✱Account</string>
|
||||||
<string name="servers">✱Servers</string>
|
<string name="servers">✱Servers</string>
|
||||||
<string name="email">✱Email</string>
|
<string name="email">✱Email</string>
|
||||||
|
<string name="below">below</string>
|
||||||
|
<string name="percent">%</string>
|
||||||
|
<string name="above">above</string>
|
||||||
|
<string name="zero">0</string>
|
||||||
|
<string name="monitor_battery_status_changes">Monitor battery status changes</string>
|
||||||
|
<string name="battery_status_changes_tips">Notify when charging status changes (charging/discharging/uncharged/fully charged)</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -159,8 +159,8 @@
|
|||||||
<string name="sim1_remark" tools:ignore="Typos">SIM1备注</string>
|
<string name="sim1_remark" tools:ignore="Typos">SIM1备注</string>
|
||||||
<string name="sim2_remark" tools:ignore="Typos">SIM2备注</string>
|
<string name="sim2_remark" tools:ignore="Typos">SIM2备注</string>
|
||||||
<string name="carrier_mobile">运营商_手机号</string>
|
<string name="carrier_mobile">运营商_手机号</string>
|
||||||
<string name="low_power_alarm_threshold">低电量预警阈值(%)</string>
|
<string name="low_power_alarm_threshold">电量预警阈值(%)</string>
|
||||||
<string name="low_power_alarm_threshold_tips">取值范围:0–100,留空或0禁用</string>
|
<string name="low_power_alarm_threshold_tips">取值范围:0–100,0禁用</string>
|
||||||
<string name="retry_interval">每次重试间隔(秒)</string>
|
<string name="retry_interval">每次重试间隔(秒)</string>
|
||||||
<string name="retry_interval_tips">接口请求失败后将重试5次</string>
|
<string name="retry_interval_tips">接口请求失败后将重试5次</string>
|
||||||
<string name="forward_sms">转发短信广播</string>
|
<string name="forward_sms">转发短信广播</string>
|
||||||
@ -247,4 +247,10 @@
|
|||||||
<string name="account">✱帐户管理</string>
|
<string name="account">✱帐户管理</string>
|
||||||
<string name="servers">✱服务器信息</string>
|
<string name="servers">✱服务器信息</string>
|
||||||
<string name="email">✱邮件设置</string>
|
<string name="email">✱邮件设置</string>
|
||||||
|
<string name="below">低于</string>
|
||||||
|
<string name="percent">%</string>
|
||||||
|
<string name="above">高于</string>
|
||||||
|
<string name="zero">0</string>
|
||||||
|
<string name="monitor_battery_status_changes">监听电池状态变化</string>
|
||||||
|
<string name="battery_status_changes_tips">充电状态改变(充电中/放电中/未充电/已充满)时发出通知</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#Fri Jul 16 10:33:23 CST 2021
|
#Fri Jul 16 10:33:23 CST 2021
|
||||||
versionName=2.2.1
|
versionName=2.3.0
|
||||||
versionCode=31
|
versionCode=32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user