重新梳理代码

This commit is contained in:
pppscn 2021-09-29 00:23:44 +08:00
parent 99718c0b5e
commit c2d2beb8ef
95 changed files with 2129 additions and 1816 deletions

3
.gitignore vendored
View File

@ -3,6 +3,7 @@
.git .git
build build
local.properties local.properties
gradle.properties
*.iml *.iml
*.project *.project
*/*.project */*.project
@ -11,4 +12,6 @@ local.properties
.settings/* .settings/*
*/.settings/* */.settings/*
/app/pppscn.jks /app/pppscn.jks
/app/release/*
/app/build/*
/psd /psd

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "keystore"]
path = keystore
url = https://github.com/pppscn/keystore.git

View File

@ -1,10 +1,21 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
//apply plugin: 'kotlin-android-extensions' def keyProps = new Properties()
apply from: 'version.gradle' def keyPropsFile = rootProject.file('keystore/keystore.properties')
if (keyPropsFile.exists()) {
keyProps.load(new FileInputStream(keyPropsFile))
}
// version.properties
def versionProps = new Properties()
def versionPropsFile = rootProject.file('version.properties')
if (versionPropsFile.exists()) {
versionProps.load(new FileInputStream(versionPropsFile))
}
android { android {
compileSdkVersion 29 buildToolsVersion '30.0.3'
compileSdkVersion 30
compileOptions { compileOptions {
sourceCompatibility 1.8 sourceCompatibility 1.8
targetCompatibility 1.8 targetCompatibility 1.8
@ -12,74 +23,115 @@ android {
defaultConfig { defaultConfig {
applicationId "com.idormy.sms.forwarder" applicationId "com.idormy.sms.forwarder"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 29 targetSdkVersion 30
versionCode appVersionCode versionCode versionProps['versionCode'].toInteger()
versionName appVersionName versionName versionProps['versionName']
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
} }
lintOptions { lintOptions {
checkReleaseBuilds false checkReleaseBuilds false
} }
signingConfigs { signingConfigs {
// C:\Users\<Username>\.gradle\gradle.properties
release { release {
storeFile file(RELEASE_STORE_FILE) keyAlias keyProps['keyAlias']
keyAlias RELEASE_KEY_ALIAS keyPassword keyProps['keyPassword']
storePassword RELEASE_KEY_PASSWORD storeFile keyProps['storeFile'] ? file(keyProps['storeFile']) : null
keyPassword RELEASE_STORE_PASSWORD storePassword keyProps['storePassword']
}
debug {
keyAlias keyProps['keyAlias']
keyPassword keyProps['keyPassword']
storeFile keyProps['storeFile'] ? file(keyProps['storeFile']) : null
storePassword keyProps['storePassword']
} }
} }
buildTypes { buildTypes {
release { release {
minifyEnabled false minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release signingConfig signingConfigs.release
} }
debug { debug {
signingConfig signingConfigs.release minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
} }
} }
//apk file name //apk file name
android.applicationVariants.all { variant -> /* android.applicationVariants.all { variant ->
variant.outputs.all { variant.outputs.all {
//def date = new Date().format("yyyyMMdd" , TimeZone.getTimeZone("Asia/Shanghai")) //def date = new Date().format("yyyyMMdd" , TimeZone.getTimeZone("Asia/Shanghai"))
def date = new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT+08")) def date = new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT+08"))
if (variant.buildType.name.equals('debug')) { if (variant.buildType.name == 'debug') {
outputFileName = "SmsForwarder_debug_${date}_${versionName}.apk" outputFileName = "SmsForwarder_debug_${date}_${versionName}.apk"
} }
if (variant.buildType.name.equals('release')) { if (variant.buildType.name == 'release') {
outputFileName = "SmsForwarder_release_${date}_${versionName}.apk" outputFileName = "SmsForwarder_release_${date}_${versionName}.apk"
} }
} }
}*/
}
task upgradeVersion {
group 'help'
description '构建新版本'
doLast {
println("---自动升级版本号---\n")
String oldVersionCode = versionProps['versionCode']
String oldVersionName = versionProps['versionName']
if (oldVersionCode == null || oldVersionName == null ||
oldVersionCode.isEmpty() || oldVersionName.isEmpty()) {
println("error:版本号不能为空")
return
}
versionProps['versionCode'] = String.valueOf(versionProps['versionCode'].toInteger() + 1)
String str = versionProps['versionName'].toString()
versionProps['versionName'] = str.substring(0, str.lastIndexOf('.') + 1) +
(str.substring(str.lastIndexOf('.') + 1).toInteger() + 1)
String tip =
"版本号从$oldVersionName($oldVersionCode)升级到${versionProps['versionName']}(${versionProps['versionCode']})"
println(tip)
def writer = new FileWriter(versionPropsFile)
versionProps.store(writer, null)
writer.flush()
writer.close()
def tag = "v${versionProps['versionName']}"
cmdExecute("git pull")
cmdExecute("git add version.properties")
cmdExecute("git commit -m \"版本号升级为:$tag\"")
cmdExecute("git push origin")
cmdExecute("git tag $tag")
cmdExecute("git push origin $tag")
} }
} }
void cmdExecute(String cmd) {
println "\n执行$cmd"
println cmd.execute().text
}
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.13.2'
//testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
//androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
//okhttp //okhttp
implementation 'com.squareup.okhttp3:okhttp:4.9.0' implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'com.squareup.okio:okio:2.10.0' implementation 'com.squareup.okio:okio:2.10.0'
//fastjson //fastjson
implementation "com.alibaba:fastjson:1.2.75" implementation "com.alibaba:fastjson:1.2.78"
//android8.0使api和动态代理隐藏的抽象类回调
//使ProxyBuilder类
//implementation 'com.linkedin.dexmaker:dexmaker-mockito:2.12.1'
// SDK // SDK
implementation 'com.umeng.umsdk:common:9.4.4'// implementation 'com.umeng.umsdk:common:9.4.4'//
implementation 'com.umeng.umsdk:asms:1.4.1'// implementation 'com.umeng.umsdk:asms:1.4.1'//
implementation 'com.umeng.umsdk:apm:1.4.2' // SDKcrash数据请一定集成 implementation 'com.umeng.umsdk:apm:1.4.2' // SDKcrash数据请一定集成
implementation 'com.umeng.umsdk:abtest:1.0.0'//使U-App中ABTest能力
//XUpdate //XUpdate
implementation 'com.github.xuexiangjys:XUpdate:2.1.0' implementation 'com.github.xuexiangjys:XUpdate:2.1.0'
@ -88,8 +140,6 @@ dependencies {
//EmailKit //EmailKit
implementation 'com.github.mailhu:emailkit:4.2.2' implementation 'com.github.mailhu:emailkit:4.2.2'
implementation 'androidx.test.ext:junit-ktx:1.1.2'
testImplementation 'junit:junit:4.12'
//Lombok //Lombok
compileOnly 'org.projectlombok:lombok:1.18.20' compileOnly 'org.projectlombok:lombok:1.18.20'

View File

@ -19,3 +19,4 @@
# If you keep the line number information, uncomment this to # If you keep the line number information, uncomment this to
# hide the original source file name. # hide the original source file name.
#-renamesourcefileattribute SourceFile #-renamesourcefileattribute SourceFile
-keep class com.idormy.sms.forwarder.model.**{*;}

View File

@ -16,7 +16,7 @@ class ExampleInstrumentedTest {
@Test @Test
fun useAppContext() { fun useAppContext() {
// Context of the app under test. // Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext() val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.idormy.sms.forwarder", appContext.packageName) assertEquals("com.idormy.sms.forwarder", appContext.packageName)
} }
} }

View File

@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.idormy.sms.forwarder"> package="com.idormy.sms.forwarder">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<!-- 授予应用程序访问系统开机事件的权限 --> <!-- 授予应用程序访问系统开机事件的权限 -->
@ -10,16 +11,21 @@
tools:ignore="ProtectedPermissions" /> tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" /> <uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" /> <uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<!--Android 9API 级别 28或更高版本并使用前台服务则其必须请求 FOREGROUND_SERVICE 权限--> <!--Android 9API 级别 28或更高版本并使用前台服务则其必须请求 FOREGROUND_SERVICE 权限-->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.BATTERY_STATS" <uses-permission
android:name="android.permission.BATTERY_STATS"
tools:ignore="ProtectedPermissions" /> tools:ignore="ProtectedPermissions" />
<application <application
@ -31,7 +37,8 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true"
android:fullBackupContent="@xml/backup_descriptor">
<meta-data <meta-data
android:name="UPDATE_APP_KEY" android:name="UPDATE_APP_KEY"
@ -43,12 +50,16 @@
android:name="UMENG_CHANNEL" android:name="UMENG_CHANNEL"
android:value="Umeng" /> android:value="Umeng" />
<activity android:name=".MainActivity"> <activity
android:name=".MainActivity"
tools:ignore="IntentFilterExportedReceiver">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
<!--协议部分,随便设置--> <!--协议部分,随便设置-->
<data android:scheme="forwarder" android:host="main"/> <data
android:scheme="forwarder"
android:host="main" />
<!--下面这几行也必须得设置--> <!--下面这几行也必须得设置-->
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
@ -68,21 +79,34 @@
android:name=".SenderActivity" android:name=".SenderActivity"
android:label="发送方" /> android:label="发送方" />
<receiver android:name=".BroadCastReceiver.RebootBroadcastReceiver"> <receiver
android:name=".receiver.RebootBroadcastReceiver"
tools:ignore="IntentFilterExportedReceiver">
<intent-filter android:priority="2147483647"> <intent-filter android:priority="2147483647">
<!--重启广播--> <!--重启广播-->
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver <receiver
android:name=".BroadCastReceiver.SmsForwarderBroadcastReceiver" android:name=".receiver.SmsForwarderBroadcastReceiver"
android:permission="android.permission.BROADCAST_SMS"> android:permission="android.permission.BROADCAST_SMS"
tools:ignore="IntentFilterExportedReceiver">
<intent-filter android:priority="2147483647"> <intent-filter android:priority="2147483647">
<!--短信广播--> <!--短信广播-->
<action android:name="android.provider.Telephony.SMS_RECEIVED" /> <action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver
android:name=".receiver.PhoneStateReceiver"
tools:ignore="IntentFilterExportedReceiver">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
<service android:name=".service.FrontService" /> <service android:name=".service.FrontService" />
<service android:name=".service.BatteryService" />
</application> </application>
</manifest> </manifest>

View File

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder; package com.idormy.sms.forwarder;
import android.annotation.SuppressLint;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -8,16 +9,14 @@ import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.Switch; import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.idormy.sms.forwarder.BroadCastReceiver.RebootBroadcastReceiver; import com.idormy.sms.forwarder.receiver.RebootBroadcastReceiver;
import com.idormy.sms.forwarder.utils.CacheUtil; import com.idormy.sms.forwarder.utils.CacheUtil;
import com.idormy.sms.forwarder.utils.Define; import com.idormy.sms.forwarder.utils.Define;
import com.idormy.sms.forwarder.utils.aUtil; import com.idormy.sms.forwarder.utils.aUtil;
@ -25,13 +24,14 @@ import com.xuexiang.xupdate.easy.EasyUpdate;
import com.xuexiang.xupdate.proxy.impl.DefaultUpdateChecker; import com.xuexiang.xupdate.proxy.impl.DefaultUpdateChecker;
@SuppressWarnings("SpellCheckingInspection")
public class AboutActivity extends AppCompatActivity { public class AboutActivity extends AppCompatActivity {
private String TAG = "com.idormy.sms.forwarder.AboutActivity"; private final String TAG = "com.idormy.sms.forwarder.AboutActivity";
private Context context; private Context context;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "oncreate"); Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
context = AboutActivity.this; context = AboutActivity.this;
@ -39,24 +39,21 @@ public class AboutActivity extends AppCompatActivity {
setContentView(R.layout.activity_about); setContentView(R.layout.activity_about);
Log.d(TAG, "onCreate: " + RebootBroadcastReceiver.class.getName()); Log.d(TAG, "onCreate: " + RebootBroadcastReceiver.class.getName());
Switch check_with_reboot = (Switch) findViewById(R.id.switch_with_reboot); @SuppressLint("UseSwitchCompatOrMaterialCode") Switch check_with_reboot = findViewById(R.id.switch_with_reboot);
checkWithReboot(check_with_reboot); checkWithReboot(check_with_reboot);
Switch switch_help_tip = (Switch) findViewById(R.id.switch_help_tip); @SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_help_tip = findViewById(R.id.switch_help_tip);
SwitchHelpTip(switch_help_tip); SwitchHelpTip(switch_help_tip);
final TextView version_now = (TextView) findViewById(R.id.version_now); final TextView version_now = findViewById(R.id.version_now);
Button check_version_now = (Button) findViewById(R.id.check_version_now); Button check_version_now = findViewById(R.id.check_version_now);
try { try {
version_now.setText(aUtil.getVersionName(AboutActivity.this)); version_now.setText(aUtil.getVersionName(AboutActivity.this));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
check_version_now.setOnClickListener(new View.OnClickListener() { check_version_now.setOnClickListener(v -> {
@Override
public void onClick(View v) {
//checkNewVersion();
try { try {
String updateUrl = "https://xupdate.bms.ink/update/checkVersion?appKey=com.idormy.sms.forwarder&versionCode="; String updateUrl = "https://xupdate.bms.ink/update/checkVersion?appKey=com.idormy.sms.forwarder&versionCode=";
updateUrl += aUtil.getVersionCode(AboutActivity.this); updateUrl += aUtil.getVersionCode(AboutActivity.this);
@ -69,11 +66,6 @@ public class AboutActivity extends AppCompatActivity {
Toast.makeText(AboutActivity.this, "查询中...", Toast.LENGTH_LONG).show(); Toast.makeText(AboutActivity.this, "查询中...", Toast.LENGTH_LONG).show();
} }
@Override
public void onAfterCheck() {
super.onAfterCheck();
}
@Override @Override
public void noNewVersion(Throwable throwable) { public void noNewVersion(Throwable throwable) {
super.noNewVersion(throwable); super.noNewVersion(throwable);
@ -85,19 +77,17 @@ public class AboutActivity extends AppCompatActivity {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}
}); });
final TextView cache_size = (TextView) findViewById(R.id.cache_size); final TextView cache_size = findViewById(R.id.cache_size);
try { try {
cache_size.setText(CacheUtil.getTotalCacheSize(AboutActivity.this)); cache_size.setText(CacheUtil.getTotalCacheSize(AboutActivity.this));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
Button clear_all_cache = (Button) findViewById(R.id.clear_all_cache); Button clear_all_cache = findViewById(R.id.clear_all_cache);
clear_all_cache.setOnClickListener(new View.OnClickListener() { clear_all_cache.setOnClickListener(v -> {
@Override
public void onClick(View v) {
CacheUtil.clearAllCache(AboutActivity.this); CacheUtil.clearAllCache(AboutActivity.this);
try { try {
cache_size.setText(CacheUtil.getTotalCacheSize(AboutActivity.this)); cache_size.setText(CacheUtil.getTotalCacheSize(AboutActivity.this));
@ -105,72 +95,56 @@ public class AboutActivity extends AppCompatActivity {
e.printStackTrace(); e.printStackTrace();
} }
Toast.makeText(AboutActivity.this, "缓存清理完成", Toast.LENGTH_LONG).show(); Toast.makeText(AboutActivity.this, "缓存清理完成", Toast.LENGTH_LONG).show();
}
}); });
Button join_qq_group = (Button) findViewById(R.id.join_qq_group); Button join_qq_group = findViewById(R.id.join_qq_group);
join_qq_group.setOnClickListener(new View.OnClickListener() { join_qq_group.setOnClickListener(v -> {
@Override
public void onClick(View v) {
String key = "HvroJRfvK7GGfnQgaIQ4Rh1un9O83N7M"; String key = "HvroJRfvK7GGfnQgaIQ4Rh1un9O83N7M";
joinQQGroup(key); joinQQGroup(key);
}
}); });
} }
//检查重启广播接受器状态并设置 //检查重启广播接受器状态并设置
private void checkWithReboot(Switch withrebootSwitch) { private void checkWithReboot(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch withrebootSwitch) {
//获取组件 //获取组件
final ComponentName cm = new ComponentName(this.getPackageName(), RebootBroadcastReceiver.class.getName()); final ComponentName cm = new ComponentName(this.getPackageName(), RebootBroadcastReceiver.class.getName());
final PackageManager pm = getPackageManager(); final PackageManager pm = getPackageManager();
int state = pm.getComponentEnabledSetting(cm); int state = pm.getComponentEnabledSetting(cm);
if (state != PackageManager.COMPONENT_ENABLED_STATE_DISABLED withrebootSwitch.setChecked(state != PackageManager.COMPONENT_ENABLED_STATE_DISABLED
&& state != PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) { && state != PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER);
withrebootSwitch.setChecked(true); withrebootSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
} else { int newState = isChecked ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
withrebootSwitch.setChecked(false);
}
withrebootSwitch.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int newState = (Boolean) isChecked ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED; : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
pm.setComponentEnabledSetting(cm, newState, PackageManager.DONT_KILL_APP); pm.setComponentEnabledSetting(cm, newState, PackageManager.DONT_KILL_APP);
Log.d(TAG, "onCheckedChanged:" + isChecked); Log.d(TAG, "onCheckedChanged:" + isChecked);
}
}); });
} }
//页面帮助提示 //页面帮助提示
private void SwitchHelpTip(Switch switchHelpTip) { private void SwitchHelpTip(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switchHelpTip) {
switchHelpTip.setChecked(MyApplication.showHelpTip); switchHelpTip.setChecked(MyApplication.showHelpTip);
switchHelpTip.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() { switchHelpTip.setOnCheckedChangeListener((buttonView, isChecked) -> {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
MyApplication.showHelpTip = isChecked; MyApplication.showHelpTip = isChecked;
SharedPreferences sp = context.getSharedPreferences(Define.SP_CONFIG, Context.MODE_PRIVATE); SharedPreferences sp = context.getSharedPreferences(Define.SP_CONFIG, Context.MODE_PRIVATE);
sp.edit().putBoolean(Define.SP_CONFIG_SWITCH_HELP_TIP, isChecked).apply(); sp.edit().putBoolean(Define.SP_CONFIG_SWITCH_HELP_TIP, isChecked).apply();
Log.d(TAG, "onCheckedChanged:" + isChecked); Log.d(TAG, "onCheckedChanged:" + isChecked);
}
}); });
} }
//发起添加群流程 //发起添加群流程
public boolean joinQQGroup(String key) { public void joinQQGroup(String key) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26jump_from%3Dwebapi%26k%3D" + key)); intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26jump_from%3Dwebapi%26k%3D" + key));
// 此Flag可根据具体产品需要自定义如设置则在加群界面按返回返回手Q主界面不设置按返回会返回到呼起产品界面 // 此Flag可根据具体产品需要自定义如设置则在加群界面按返回返回手Q主界面不设置按返回会返回到呼起产品界面
//intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
try { try {
startActivity(intent); startActivity(intent);
return true;
} catch (Exception e) { } catch (Exception e) {
// 未安装手Q或安装的版本不支持 // 未安装手Q或安装的版本不支持
Toast.makeText(AboutActivity.this, "未安装手Q或安装的版本不支持", Toast.LENGTH_LONG).show(); Toast.makeText(AboutActivity.this, "未安装手Q或安装的版本不支持", Toast.LENGTH_LONG).show();
return false;
} }
} }

View File

@ -1,27 +1,21 @@
package com.idormy.sms.forwarder; package com.idormy.sms.forwarder;
import android.content.ComponentName; import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder;
import android.util.Log; import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.idormy.sms.forwarder.BroadCastReceiver.SmsForwarderBroadcastReceiver;
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.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtil;
@ -29,30 +23,13 @@ import com.idormy.sms.forwarder.utils.NetUtil;
import com.idormy.sms.forwarder.utils.PhoneUtils; import com.idormy.sms.forwarder.utils.PhoneUtils;
import com.idormy.sms.forwarder.utils.SmsUtil; import com.idormy.sms.forwarder.utils.SmsUtil;
import com.idormy.sms.forwarder.utils.aUtil; import com.idormy.sms.forwarder.utils.aUtil;
import com.umeng.analytics.MobclickAgent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class MainActivity extends AppCompatActivity implements ReFlashListView.IReflashListener { public class MainActivity extends AppCompatActivity implements ReFlashListView.IRefreshListener {
ServiceConnection conn = new ServiceConnection() { private final String TAG = "MainActivity";
@Override
public void onServiceDisconnected(ComponentName name) {
// TODO Auto-generated method stub
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
// 当service绑定成功时会调用次方法可以在此申请权限
PackageManager pm = getPackageManager();
PhoneUtils.CheckPermission(pm, MainActivity.this);
}
};
private IntentFilter intentFilter;
private SmsForwarderBroadcastReceiver smsBroadcastReceiver;
private String TAG = "MainActivity";
// logVoList用于存储数据 // logVoList用于存储数据
private List<LogVo> logVos = new ArrayList<>(); private List<LogVo> logVos = new ArrayList<>();
private LogAdapter adapter; private LogAdapter adapter;
@ -62,7 +39,7 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
LogUtil.init(this); LogUtil.init(this);
Log.d(TAG, "oncreate"); Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
@ -94,19 +71,14 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
// 为ListView注册一个监听器当用户点击了ListView中的任何一个子项时就会回调onItemClick()方法 // 为ListView注册一个监听器当用户点击了ListView中的任何一个子项时就会回调onItemClick()方法
// 在这个方法中可以通过position参数判断出用户点击的是那一个子项 // 在这个方法中可以通过position参数判断出用户点击的是那一个子项
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener((parent, view, position, id) -> {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position <= 0) return; if (position <= 0) return;
LogVo logVo = logVos.get(position - 1); LogVo logVo = logVos.get(position - 1);
logDetail(logVo); logDetail(logVo);
}
}); });
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { listView.setOnItemLongClickListener((parent, view, position, id) -> {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
if (position <= 0) return false; if (position <= 0) return false;
//定义AlertDialog.Builder对象当长按列表项的时候弹出确认删除对话框 //定义AlertDialog.Builder对象当长按列表项的时候弹出确认删除对话框
@ -115,31 +87,34 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
builder.setTitle("提示"); builder.setTitle("提示");
//添加AlertDialog.Builder对象的setPositiveButton()方法 //添加AlertDialog.Builder对象的setPositiveButton()方法
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { builder.setPositiveButton("确定", (dialog, which) -> {
@Override Long id1 = logVos.get(position - 1).getId();
public void onClick(DialogInterface dialog, int which) { Log.d(TAG, "id = " + id1);
Long id = logVos.get(position - 1).getId(); LogUtil.delLog(id1, null);
Log.d(TAG, "id = " + id);
LogUtil.delLog(id, null);
initTLogs(); //初始化数据 initTLogs(); //初始化数据
showList(logVos); showList(logVos);
Toast.makeText(getBaseContext(), "删除列表项", Toast.LENGTH_SHORT).show(); Toast.makeText(getBaseContext(), "删除列表项", Toast.LENGTH_SHORT).show();
}
}); });
//添加AlertDialog.Builder对象的setNegativeButton()方法 //添加AlertDialog.Builder对象的setNegativeButton()方法
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { builder.setNegativeButton("取消", (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}); });
builder.create().show(); builder.create().show();
return true; return true;
}
}); });
} }
@Override
protected void onResume() {
super.onResume();
//第一次打开未授权无法获取SIM信息尝试在此重新获取
if (MyApplication.SimInfoList.isEmpty()) {
MyApplication.SimInfoList = PhoneUtils.getSimMultiInfo();
}
Log.d(TAG, "SimInfoList = " + MyApplication.SimInfoList.size());
}
// 初始化数据 // 初始化数据
private void initTLogs() { private void initTLogs() {
logVos = LogUtil.getLog(null, null); logVos = LogUtil.getLog(null, null);
@ -160,35 +135,19 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
} }
@Override @Override
public void onReflash() { public void onRefresh() {
Handler handler = new Handler(); Handler handler = new Handler();
handler.postDelayed(new Runnable() { handler.postDelayed(() -> {
@Override
public void run() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
//获取最新数据 //获取最新数据
initTLogs(); initTLogs();
//通知界面显示 //通知界面显示
showList(logVos); showList(logVos);
//通知listview 刷新数据完毕 //通知listview 刷新数据完毕
listView.reflashComplete(); listView.refreshComplete();
}
}, 2000); }, 2000);
} }
@Override
protected void onDestroy() {
Log.d(TAG, "onDestroy");
super.onDestroy();
//取消注册广播
try {
if (smsBroadcastReceiver != null)
unregisterReceiver(smsBroadcastReceiver);
} catch (Exception e) {
Log.e(TAG, "unregisterReceiver fail:" + e.getMessage());
}
}
public void logDetail(LogVo logVo) { public void logDetail(LogVo logVo) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
@ -200,21 +159,15 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
builder.setMessage(logVo.getFrom() + "\n\n" + logVo.getContent() + "\n\n" + logVo.getRule() + "\n\n" + aUtil.utc2Local(logVo.getTime()) + "\n\nResponse" + logVo.getForwardResponse()); builder.setMessage(logVo.getFrom() + "\n\n" + logVo.getContent() + "\n\n" + logVo.getRule() + "\n\n" + aUtil.utc2Local(logVo.getTime()) + "\n\nResponse" + logVo.getForwardResponse());
} }
//重发 //重发
builder.setPositiveButton("重发", new DialogInterface.OnClickListener() { builder.setPositiveButton("重发", (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
System.out.println(logVo.toString());
Long id = logVo.getId(); Long id = logVo.getId();
Log.d(TAG, "id = " + id); Log.d(TAG, "id = " + id);
Log.d(TAG, logVo.toString()); Log.d(TAG, logVo.toString());
Toast.makeText(MainActivity.this, "你确定要重发吗?", Toast.LENGTH_SHORT).show(); Toast.makeText(MainActivity.this, "你确定要重发吗?", Toast.LENGTH_SHORT).show();
dialog.dismiss(); dialog.dismiss();
}
}); });
//删除 //删除
builder.setNegativeButton("删除", new DialogInterface.OnClickListener() { builder.setNegativeButton("删除", (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
Long id = logVo.getId(); Long id = logVo.getId();
Log.d(TAG, "id = " + id); Log.d(TAG, "id = " + id);
LogUtil.delLog(id, null); LogUtil.delLog(id, null);
@ -222,7 +175,6 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
showList(logVos); showList(logVos);
Toast.makeText(MainActivity.this, "已删除该条记录", Toast.LENGTH_SHORT).show(); Toast.makeText(MainActivity.this, "已删除该条记录", Toast.LENGTH_SHORT).show();
dialog.dismiss(); dialog.dismiss();
}
}); });
builder.show(); builder.show();
} }
@ -250,16 +202,11 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
public void cleanLog(View view) { public void cleanLog(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("确定要清空转发记录吗?") builder.setTitle("确定要清空转发记录吗?")
.setPositiveButton("清空", new DialogInterface.OnClickListener() {// 积极 .setPositiveButton("清空", (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
LogUtil.delLog(null, null); LogUtil.delLog(null, null);
initTLogs(); initTLogs();
adapter.add(logVos); adapter.add(logVos);
}
}); });
builder.show(); builder.show();
} }
@ -273,6 +220,7 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
startActivity(intent); startActivity(intent);
} }
@SuppressLint("NonConstantResourceId")
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection // Handle item selection
@ -296,21 +244,4 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
} }
@Override
protected void onResume() {
super.onResume();
MobclickAgent.onResume(this);
//第一次打开申请权限前无法获取SIM信息尝试在此重新获取
if (MyApplication.SimInfoList.isEmpty()) {
MyApplication.SimInfoList = PhoneUtils.getSimMultiInfo();
}
Log.d(TAG, "SimInfoList = " + MyApplication.SimInfoList.size());
}
@Override
protected void onPause() {
super.onPause();
MobclickAgent.onPause(this);
}
} }

View File

@ -38,8 +38,8 @@ public class MyApplication extends Application {
* android:value="Umeng"> * android:value="Umeng">
* </meta-data> * </meta-data>
* *
* @param ctx * @param ctx 上下文
* @return * @return 渠道名称
*/ */
// 获取渠道工具函数 // 获取渠道工具函数
public static String getChannelName(Context ctx) { public static String getChannelName(Context ctx) {
@ -52,12 +52,10 @@ public class MyApplication extends Application {
if (packageManager != null) { if (packageManager != null) {
//注意此处为ApplicationInfo 而不是 ActivityInfo,因为友盟设置的meta-data是在application标签中而不是activity标签中所以用ApplicationInfo //注意此处为ApplicationInfo 而不是 ActivityInfo,因为友盟设置的meta-data是在application标签中而不是activity标签中所以用ApplicationInfo
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(ctx.getPackageName(), PackageManager.GET_META_DATA); ApplicationInfo applicationInfo = packageManager.getApplicationInfo(ctx.getPackageName(), PackageManager.GET_META_DATA);
if (applicationInfo != null) {
if (applicationInfo.metaData != null) { if (applicationInfo.metaData != null) {
channelName = applicationInfo.metaData.get("UMENG_CHANNEL") + ""; channelName = applicationInfo.metaData.get("UMENG_CHANNEL") + "";
} }
} }
}
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -84,7 +82,7 @@ public class MyApplication extends Application {
MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.LEGACY_MANUAL); MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.LEGACY_MANUAL);
//pro close log //pro close log
UMConfigure.setLogEnabled(true); UMConfigure.setLogEnabled(true);
Log.i(TAG, "uminit");
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);

View File

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder; package com.idormy.sms.forwarder;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
@ -20,11 +21,12 @@ import java.util.Locale;
/** /**
* 自定义listview * 自定义listview
*/ */
@SuppressWarnings({"CommentedOutCode", "unused"})
public class ReFlashListView extends ListView implements AbsListView.OnScrollListener { public class ReFlashListView extends ListView implements AbsListView.OnScrollListener {
private static final String TAG = "ReFlashListView"; //private static final String TAG = "ReFlashListView";
final int NONE = 0;// 正常状态 final int NONE = 0;// 正常状态
final int PULL = 1;// 提示下拉状态 final int PULL = 1;// 提示下拉状态
final int RELESE = 2;// 提示释放状态 final int RELEASE = 2;// 提示释放状态
final int REFLASHING = 3;// 刷新状态 final int REFLASHING = 3;// 刷新状态
View header;// 顶部布局文件 View header;// 顶部布局文件
int headerHeight;// 顶部布局文件的高度 int headerHeight;// 顶部布局文件的高度
@ -33,7 +35,7 @@ public class ReFlashListView extends ListView implements AbsListView.OnScrollLis
boolean isRemark;// 标记当前是在listview最顶端摁下的 boolean isRemark;// 标记当前是在listview最顶端摁下的
int startY;// 摁下时的Y值 int startY;// 摁下时的Y值
int state;// 当前的状态 int state;// 当前的状态
IReflashListener iReflashListener;//刷新数据的接口 IRefreshListener iRefreshListener;//刷新数据的接口
public ReFlashListView(Context context) { public ReFlashListView(Context context) {
super(context); super(context);
@ -55,9 +57,8 @@ public class ReFlashListView extends ListView implements AbsListView.OnScrollLis
/** /**
* 初始化界面添加顶部布局文件到 listview * 初始化界面添加顶部布局文件到 listview
*
* @param context
*/ */
@SuppressLint("InflateParams")
private void initView(Context context) { private void initView(Context context) {
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
header = inflater.inflate(R.layout.header, null); header = inflater.inflate(R.layout.header, null);
@ -71,8 +72,6 @@ public class ReFlashListView extends ListView implements AbsListView.OnScrollLis
/** /**
* 通知父布局占用的宽 * 通知父布局占用的宽
*
* @param view
*/ */
private void measureView(View view) { private void measureView(View view) {
ViewGroup.LayoutParams p = view.getLayoutParams(); ViewGroup.LayoutParams p = view.getLayoutParams();
@ -94,8 +93,6 @@ public class ReFlashListView extends ListView implements AbsListView.OnScrollLis
/** /**
* 设置header 布局 上边距 * 设置header 布局 上边距
*
* @param topPadding
*/ */
private void topPadding(int topPadding) { private void topPadding(int topPadding) {
header.setPadding(header.getPaddingLeft(), topPadding, header.setPadding(header.getPaddingLeft(), topPadding,
@ -116,6 +113,7 @@ public class ReFlashListView extends ListView implements AbsListView.OnScrollLis
this.scrollState = scrollState; this.scrollState = scrollState;
} }
@SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onTouchEvent(MotionEvent ev) { public boolean onTouchEvent(MotionEvent ev) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -131,23 +129,23 @@ public class ReFlashListView extends ListView implements AbsListView.OnScrollLis
onMove(ev); onMove(ev);
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
if (state == RELESE || state == PULL) { if (state == RELEASE || state == PULL) {
state = REFLASHING; state = REFLASHING;
// 加载最新数据 // 加载最新数据
reflashViewByState(); refreshViewByState();
iReflashListener.onReflash(); iRefreshListener.onRefresh();
} }
// if (state == RELESE) { // if (state == RELEASE) {
// Log.d(TAG, "onTouchEvent: up release"); // Log.d(TAG, "onTouchEvent: up release");
// state = REFLASHING; // state = REFLASHING;
// // 加载最新数据 // // 加载最新数据
// reflashViewByState(); // refreshViewByState();
// iReflashListener.onReflash(); // iRefreshListener.onRefresh();
// } else if (state == PULL) { // } else if (state == PULL) {
// Log.d(TAG, "onTouchEvent: up pull"); // Log.d(TAG, "onTouchEvent: up pull");
// state = NONE; // state = NONE;
// isRemark = false; // isRemark = false;
// reflashViewByState(); // refreshViewByState();
// } // }
break; break;
} }
@ -156,8 +154,6 @@ public class ReFlashListView extends ListView implements AbsListView.OnScrollLis
/** /**
* 判断移动过程操作 * 判断移动过程操作
*
* @param ev
*/ */
private void onMove(MotionEvent ev) { private void onMove(MotionEvent ev) {
if (!isRemark) { if (!isRemark) {
@ -170,26 +166,26 @@ public class ReFlashListView extends ListView implements AbsListView.OnScrollLis
case NONE: case NONE:
if (space > 0) { if (space > 0) {
state = PULL; state = PULL;
reflashViewByState(); refreshViewByState();
} }
break; break;
case PULL: case PULL:
topPadding(topPadding); topPadding(topPadding);
if (space > headerHeight + 30 if (space > headerHeight + 30
&& scrollState == SCROLL_STATE_TOUCH_SCROLL) { && scrollState == SCROLL_STATE_TOUCH_SCROLL) {
state = RELESE; state = RELEASE;
reflashViewByState(); refreshViewByState();
} }
break; break;
case RELESE: case RELEASE:
topPadding(topPadding); topPadding(topPadding);
if (space < headerHeight + 30) { if (space < headerHeight + 30) {
state = PULL; state = PULL;
reflashViewByState(); refreshViewByState();
} else if (space <= 0) { } else if (space <= 0) {
state = NONE; state = NONE;
isRemark = false; isRemark = false;
reflashViewByState(); refreshViewByState();
} }
break; break;
} }
@ -198,10 +194,10 @@ public class ReFlashListView extends ListView implements AbsListView.OnScrollLis
/** /**
* 根据当前状态改变界面显示 * 根据当前状态改变界面显示
*/ */
private void reflashViewByState() { private void refreshViewByState() {
TextView tip = (TextView) header.findViewById(R.id.tip); TextView tip = header.findViewById(R.id.tip);
ImageView arrow = (ImageView) header.findViewById(R.id.arrow); ImageView arrow = header.findViewById(R.id.arrow);
ProgressBar progress = (ProgressBar) header.findViewById(R.id.progress); ProgressBar progress = header.findViewById(R.id.progress);
RotateAnimation anim = new RotateAnimation(0, 180, RotateAnimation anim = new RotateAnimation(0, 180,
RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f); RotateAnimation.RELATIVE_TO_SELF, 0.5f);
@ -225,7 +221,7 @@ public class ReFlashListView extends ListView implements AbsListView.OnScrollLis
arrow.clearAnimation(); arrow.clearAnimation();
arrow.setAnimation(anim1); arrow.setAnimation(anim1);
break; break;
case RELESE: case RELEASE:
arrow.setVisibility(View.VISIBLE); arrow.setVisibility(View.VISIBLE);
progress.setVisibility(View.GONE); progress.setVisibility(View.GONE);
tip.setText("松开可以刷新!"); tip.setText("松开可以刷新!");
@ -245,19 +241,19 @@ public class ReFlashListView extends ListView implements AbsListView.OnScrollLis
/** /**
* 获取完数据 * 获取完数据
*/ */
public void reflashComplete() { public void refreshComplete() {
state = NONE; state = NONE;
isRemark = false; isRemark = false;
reflashViewByState(); refreshViewByState();
TextView lastupdatetime = (TextView) header TextView lastUpdateTime = header
.findViewById(R.id.lastupdate_time); .findViewById(R.id.lastUpdateTime);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
String time = sdf.format(new java.util.Date()); String time = sdf.format(new java.util.Date());
lastupdatetime.setText(time); lastUpdateTime.setText(time);
} }
public void setInterface(IReflashListener iReflashListener) { public void setInterface(IRefreshListener iRefreshListener) {
this.iReflashListener = iReflashListener; this.iRefreshListener = iRefreshListener;
} }
/** /**
@ -265,7 +261,7 @@ public class ReFlashListView extends ListView implements AbsListView.OnScrollLis
* *
* @author Administrator * @author Administrator
*/ */
public interface IReflashListener { public interface IRefreshListener {
public void onReflash(); void onRefresh();
} }
} }

View File

@ -1,18 +1,17 @@
package com.idormy.sms.forwarder; package com.idormy.sms.forwarder;
import static com.idormy.sms.forwarder.SenderActivity.NOTIFY;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.AdapterView;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup; import android.widget.RadioGroup;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -34,32 +33,28 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import static com.idormy.sms.forwarder.SenderActivity.NOTIFY; @SuppressWarnings("deprecation")
public class RuleActivity extends AppCompatActivity { public class RuleActivity extends AppCompatActivity {
private String TAG = "RuleActivity"; private final String TAG = "RuleActivity";
// 用于存储数据 // 用于存储数据
private List<RuleModel> ruleModels = new ArrayList<>(); private List<RuleModel> ruleModels = new ArrayList<>();
private RuleAdapter adapter; private RuleAdapter adapter;
private Long selectSenderId = 0l;
private String selectSenderName = "";
//消息处理者,创建一个Handler的子类对象,目的是重写Handler的处理消息的方法(handleMessage()) //消息处理者,创建一个Handler的子类对象,目的是重写Handler的处理消息的方法(handleMessage())
private Handler handler = new Handler() { @SuppressLint("HandlerLeak")
private final Handler handler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
switch (msg.what) { if (msg.what == NOTIFY) {
case NOTIFY:
Toast.makeText(RuleActivity.this, msg.getData().getString("DATA"), Toast.LENGTH_LONG).show(); Toast.makeText(RuleActivity.this, msg.getData().getString("DATA"), Toast.LENGTH_LONG).show();
break;
} }
} }
}; };
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "oncreate"); Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rule); setContentView(R.layout.activity_rule);
RuleUtil.init(RuleActivity.this); RuleUtil.init(RuleActivity.this);
@ -85,17 +80,12 @@ public class RuleActivity extends AppCompatActivity {
// 为ListView注册一个监听器当用户点击了ListView中的任何一个子项时就会回调onItemClick()方法 // 为ListView注册一个监听器当用户点击了ListView中的任何一个子项时就会回调onItemClick()方法
// 在这个方法中可以通过position参数判断出用户点击的是那一个子项 // 在这个方法中可以通过position参数判断出用户点击的是那一个子项
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener((parent, view, position, id) -> {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
RuleModel ruleModel = ruleModels.get(position); RuleModel ruleModel = ruleModels.get(position);
Log.d(TAG, "onItemClick: " + ruleModel); Log.d(TAG, "onItemClick: " + ruleModel);
setRule(ruleModel); setRule(ruleModel);
}
}); });
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { listView.setOnItemLongClickListener((parent, view, position, id) -> {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
//定义AlertDialog.Builder对象当长按列表项的时候弹出确认删除对话框 //定义AlertDialog.Builder对象当长按列表项的时候弹出确认删除对话框
AlertDialog.Builder builder = new AlertDialog.Builder(RuleActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(RuleActivity.this);
@ -103,28 +93,20 @@ public class RuleActivity extends AppCompatActivity {
builder.setTitle("提示"); builder.setTitle("提示");
//添加AlertDialog.Builder对象的setPositiveButton()方法 //添加AlertDialog.Builder对象的setPositiveButton()方法
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { builder.setPositiveButton("确定", (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
RuleUtil.delRule(ruleModels.get(position).getId()); RuleUtil.delRule(ruleModels.get(position).getId());
initRules(); initRules();
adapter.del(ruleModels); adapter.del(ruleModels);
Toast.makeText(getBaseContext(), "删除列表项", Toast.LENGTH_SHORT).show(); Toast.makeText(getBaseContext(), "删除列表项", Toast.LENGTH_SHORT).show();
}
}); });
//添加AlertDialog.Builder对象的setNegativeButton()方法 //添加AlertDialog.Builder对象的setNegativeButton()方法
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { builder.setNegativeButton("取消", (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}); });
builder.create().show(); builder.create().show();
return true; return true;
}
}); });
} }
@ -141,11 +123,11 @@ public class RuleActivity extends AppCompatActivity {
final AlertDialog.Builder alertDialog71 = new AlertDialog.Builder(RuleActivity.this); final AlertDialog.Builder alertDialog71 = new AlertDialog.Builder(RuleActivity.this);
final View view1 = View.inflate(RuleActivity.this, R.layout.alert_dialog_setview_rule, null); final View view1 = View.inflate(RuleActivity.this, R.layout.alert_dialog_setview_rule, null);
final RadioGroup radioGroupRuleFiled = (RadioGroup) view1.findViewById(R.id.radioGroupRuleFiled); final RadioGroup radioGroupRuleFiled = view1.findViewById(R.id.radioGroupRuleFiled);
if (ruleModel != null) radioGroupRuleFiled.check(ruleModel.getRuleFiledCheckId()); if (ruleModel != null) radioGroupRuleFiled.check(ruleModel.getRuleFiledCheckId());
final RadioGroup radioGroupRuleCheck = (RadioGroup) view1.findViewById(R.id.radioGroupRuleCheck); final RadioGroup radioGroupRuleCheck = view1.findViewById(R.id.radioGroupRuleCheck);
final RadioGroup radioGroupRuleCheck2 = (RadioGroup) view1.findViewById(R.id.radioGroupRuleCheck2); final RadioGroup radioGroupRuleCheck2 = view1.findViewById(R.id.radioGroupRuleCheck2);
if (ruleModel != null) { if (ruleModel != null) {
int ruleCheckCheckId = ruleModel.getRuleCheckCheckId(); int ruleCheckCheckId = ruleModel.getRuleCheckCheckId();
if (ruleCheckCheckId == R.id.btnIs || ruleCheckCheckId == R.id.btnNotContain || ruleCheckCheckId == R.id.btnContain) { if (ruleCheckCheckId == R.id.btnIs || ruleCheckCheckId == R.id.btnNotContain || ruleCheckCheckId == R.id.btnContain) {
@ -157,25 +139,22 @@ public class RuleActivity extends AppCompatActivity {
radioGroupRuleCheck.check(R.id.btnIs); radioGroupRuleCheck.check(R.id.btnIs);
} }
final RadioGroup radioGroupSimSlot = (RadioGroup) view1.findViewById(R.id.radioGroupSimSlot); final RadioGroup radioGroupSimSlot = view1.findViewById(R.id.radioGroupSimSlot);
if (ruleModel != null) radioGroupSimSlot.check(ruleModel.getRuleSimSlotCheckId()); if (ruleModel != null) radioGroupSimSlot.check(ruleModel.getRuleSimSlotCheckId());
final TextView tv_mu_rule_tips = (TextView) view1.findViewById(R.id.tv_mu_rule_tips); final TextView tv_mu_rule_tips = view1.findViewById(R.id.tv_mu_rule_tips);
final TextView ruleSenderTv = (TextView) view1.findViewById(R.id.ruleSenderTv); final TextView ruleSenderTv = view1.findViewById(R.id.ruleSenderTv);
if (ruleModel != null && ruleModel.getSenderId() != null) { if (ruleModel != null && ruleModel.getSenderId() != null) {
List<SenderModel> getSeners = SenderUtil.getSender(ruleModel.getSenderId(), null); List<SenderModel> getSenders = SenderUtil.getSender(ruleModel.getSenderId(), null);
if (!getSeners.isEmpty()) { if (!getSenders.isEmpty()) {
ruleSenderTv.setText(getSeners.get(0).getName()); ruleSenderTv.setText(getSenders.get(0).getName());
ruleSenderTv.setTag(getSeners.get(0).getId()); ruleSenderTv.setTag(getSenders.get(0).getId());
} }
} }
final Button btSetRuleSender = (Button) view1.findViewById(R.id.btSetRuleSender); final Button btSetRuleSender = view1.findViewById(R.id.btSetRuleSender);
btSetRuleSender.setOnClickListener(new View.OnClickListener() { btSetRuleSender.setOnClickListener(view -> {
@Override
public void onClick(View view) {
//Toast.makeText(RuleActivity.this, "selectSender", Toast.LENGTH_LONG).show(); //Toast.makeText(RuleActivity.this, "selectSender", Toast.LENGTH_LONG).show();
selectSender(ruleSenderTv); selectSender(ruleSenderTv);
}
}); });
final EditText editTextRuleValue = view1.findViewById(R.id.editTextRuleValue); final EditText editTextRuleValue = view1.findViewById(R.id.editTextRuleValue);
@ -183,25 +162,23 @@ public class RuleActivity extends AppCompatActivity {
editTextRuleValue.setText(ruleModel.getValue()); editTextRuleValue.setText(ruleModel.getValue());
//当更新选择的字段的时候更新之下各个选项的状态 //当更新选择的字段的时候更新之下各个选项的状态
final LinearLayout matchTypeLayout = (LinearLayout) view1.findViewById(R.id.matchTypeLayout); final LinearLayout matchTypeLayout = view1.findViewById(R.id.matchTypeLayout);
final LinearLayout matchValueLayout = (LinearLayout) view1.findViewById(R.id.matchValueLayout); final LinearLayout matchValueLayout = view1.findViewById(R.id.matchValueLayout);
refreshSelectRadioGroupRuleFiled(radioGroupRuleFiled, radioGroupRuleCheck, radioGroupRuleCheck2, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout); refreshSelectRadioGroupRuleFiled(radioGroupRuleFiled, radioGroupRuleCheck, radioGroupRuleCheck2, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout);
Button buttonruleok = view1.findViewById(R.id.buttonruleok); Button buttonRuleOk = view1.findViewById(R.id.buttonRuleOk);
Button buttonruledel = view1.findViewById(R.id.buttonruledel); Button buttonRuleDel = view1.findViewById(R.id.buttonRuleDel);
Button buttonruletest = view1.findViewById(R.id.buttonruletest); Button buttonRuleTest = view1.findViewById(R.id.buttonRuleTest);
alertDialog71 alertDialog71
.setTitle(R.string.setrule) .setTitle(R.string.setrule)
//.setIcon(R.drawable.ic_sms_forwarder) //.setIcon(R.drawable.ic_sms_forwarder)
.setView(view1) .setView(view1)
.create(); .create();
final AlertDialog show = alertDialog71.show(); final AlertDialog show = alertDialog71.show();
buttonruleok.setOnClickListener(new View.OnClickListener() { buttonRuleOk.setOnClickListener(view -> {
@Override
public void onClick(View view) {
Object senderId = ruleSenderTv.getTag(); Object senderId = ruleSenderTv.getTag();
int radioGroupRuleCheckId = Math.max(radioGroupRuleCheck.getCheckedRadioButtonId(), radioGroupRuleCheck2.getCheckedRadioButtonId()); int radioGroupRuleCheckId = Math.max(radioGroupRuleCheck.getCheckedRadioButtonId(), radioGroupRuleCheck2.getCheckedRadioButtonId());
Log.d(TAG, "XXXX " + radioGroupRuleCheck.getCheckedRadioButtonId() + " " + radioGroupRuleCheck2.getCheckedRadioButtonId() + " " + radioGroupRuleCheckId); Log.d(TAG, radioGroupRuleCheck.getCheckedRadioButtonId() + " " + radioGroupRuleCheck2.getCheckedRadioButtonId() + " " + radioGroupRuleCheckId);
if (ruleModel == null) { if (ruleModel == null) {
RuleModel newRuleModel = new RuleModel(); RuleModel newRuleModel = new RuleModel();
newRuleModel.setFiled(RuleModel.getRuleFiledFromCheckId(radioGroupRuleFiled.getCheckedRadioButtonId())); newRuleModel.setFiled(RuleModel.getRuleFiledFromCheckId(radioGroupRuleFiled.getCheckedRadioButtonId()));
@ -228,24 +205,18 @@ public class RuleActivity extends AppCompatActivity {
} }
show.dismiss(); show.dismiss();
}
}); });
buttonruledel.setOnClickListener(new View.OnClickListener() { buttonRuleDel.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (ruleModel != null) { if (ruleModel != null) {
RuleUtil.delRule(ruleModel.getId()); RuleUtil.delRule(ruleModel.getId());
initRules(); initRules();
adapter.del(ruleModels); adapter.del(ruleModels);
} }
show.dismiss(); show.dismiss();
}
}); });
buttonruletest.setOnClickListener(new View.OnClickListener() { buttonRuleTest.setOnClickListener(view -> {
@Override
public void onClick(View view) {
Object senderId = ruleSenderTv.getTag(); Object senderId = ruleSenderTv.getTag();
if (senderId == null) { if (senderId == null) {
Toast.makeText(RuleActivity.this, "请先创建选择发送方", Toast.LENGTH_LONG).show(); Toast.makeText(RuleActivity.this, "请先创建选择发送方", Toast.LENGTH_LONG).show();
@ -270,7 +241,6 @@ public class RuleActivity extends AppCompatActivity {
testRule(ruleModel, Long.valueOf(senderId.toString())); testRule(ruleModel, Long.valueOf(senderId.toString()));
} }
} }
}
}); });
} }
@ -281,10 +251,7 @@ public class RuleActivity extends AppCompatActivity {
private void refreshSelectRadioGroupRuleFiled(RadioGroup radioGroupRuleFiled, final RadioGroup radioGroupRuleCheck, final RadioGroup radioGroupRuleCheck2, final EditText editTextRuleValue, final TextView tv_mu_rule_tips, final LinearLayout matchTypeLayout, final LinearLayout matchValueLayout) { private void refreshSelectRadioGroupRuleFiled(RadioGroup radioGroupRuleFiled, final RadioGroup radioGroupRuleCheck, final RadioGroup radioGroupRuleCheck2, final EditText editTextRuleValue, final TextView tv_mu_rule_tips, final LinearLayout matchTypeLayout, final LinearLayout matchValueLayout) {
refreshSelectRadioGroupRuleFiledAction(radioGroupRuleFiled.getCheckedRadioButtonId(), radioGroupRuleCheck, radioGroupRuleCheck2, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout); refreshSelectRadioGroupRuleFiledAction(radioGroupRuleFiled.getCheckedRadioButtonId(), radioGroupRuleCheck, radioGroupRuleCheck2, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout);
radioGroupRuleCheck.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { radioGroupRuleCheck.setOnCheckedChangeListener((group, checkedId) -> {
@SuppressLint("ResourceType")
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
Log.d(TAG, String.valueOf(group)); Log.d(TAG, String.valueOf(group));
Log.d(TAG, String.valueOf(checkedId)); Log.d(TAG, String.valueOf(checkedId));
if (group != null && checkedId > 0) { if (group != null && checkedId > 0) {
@ -295,12 +262,8 @@ public class RuleActivity extends AppCompatActivity {
} }
group.check(checkedId); group.check(checkedId);
} }
}
}); });
radioGroupRuleCheck2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { radioGroupRuleCheck2.setOnCheckedChangeListener((group, checkedId) -> {
@SuppressLint("ResourceType")
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
Log.d(TAG, String.valueOf(group)); Log.d(TAG, String.valueOf(group));
Log.d(TAG, String.valueOf(checkedId)); Log.d(TAG, String.valueOf(checkedId));
if (group != null && checkedId > 0) { if (group != null && checkedId > 0) {
@ -311,11 +274,8 @@ public class RuleActivity extends AppCompatActivity {
} }
group.check(checkedId); group.check(checkedId);
} }
}
}); });
radioGroupRuleFiled.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { radioGroupRuleFiled.setOnCheckedChangeListener((group, checkedId) -> {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
Log.d(TAG, String.valueOf(group)); Log.d(TAG, String.valueOf(group));
Log.d(TAG, String.valueOf(checkedId)); Log.d(TAG, String.valueOf(checkedId));
if (group == radioGroupRuleCheck) { if (group == radioGroupRuleCheck) {
@ -324,10 +284,10 @@ public class RuleActivity extends AppCompatActivity {
radioGroupRuleCheck.clearCheck(); radioGroupRuleCheck.clearCheck();
} }
refreshSelectRadioGroupRuleFiledAction(checkedId, radioGroupRuleCheck, radioGroupRuleCheck2, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout); refreshSelectRadioGroupRuleFiledAction(checkedId, radioGroupRuleCheck, radioGroupRuleCheck2, editTextRuleValue, tv_mu_rule_tips, matchTypeLayout, matchValueLayout);
}
}); });
} }
@SuppressLint("NonConstantResourceId")
private void refreshSelectRadioGroupRuleFiledAction(int checkedRuleFiledId, final RadioGroup radioGroupRuleCheck, final RadioGroup radioGroupRuleCheck2, final EditText editTextRuleValue, final TextView tv_mu_rule_tips, final LinearLayout matchTypeLayout, final LinearLayout matchValueLayout) { private void refreshSelectRadioGroupRuleFiledAction(int checkedRuleFiledId, final RadioGroup radioGroupRuleCheck, final RadioGroup radioGroupRuleCheck2, final EditText editTextRuleValue, final TextView tv_mu_rule_tips, final LinearLayout matchTypeLayout, final LinearLayout matchValueLayout) {
tv_mu_rule_tips.setVisibility(View.GONE); tv_mu_rule_tips.setVisibility(View.GONE);
matchTypeLayout.setVisibility(View.VISIBLE); matchTypeLayout.setVisibility(View.VISIBLE);
@ -336,10 +296,10 @@ public class RuleActivity extends AppCompatActivity {
switch (checkedRuleFiledId) { switch (checkedRuleFiledId) {
case R.id.btnTranspondAll: case R.id.btnTranspondAll:
for (int i = 0; i < radioGroupRuleCheck.getChildCount(); i++) { for (int i = 0; i < radioGroupRuleCheck.getChildCount(); i++) {
((RadioButton) radioGroupRuleCheck.getChildAt(i)).setEnabled(false); radioGroupRuleCheck.getChildAt(i).setEnabled(false);
} }
for (int i = 0; i < radioGroupRuleCheck2.getChildCount(); i++) { for (int i = 0; i < radioGroupRuleCheck2.getChildCount(); i++) {
((RadioButton) radioGroupRuleCheck2.getChildAt(i)).setEnabled(false); radioGroupRuleCheck2.getChildAt(i).setEnabled(false);
} }
editTextRuleValue.setEnabled(false); editTextRuleValue.setEnabled(false);
matchTypeLayout.setVisibility(View.GONE); matchTypeLayout.setVisibility(View.GONE);
@ -347,10 +307,10 @@ public class RuleActivity extends AppCompatActivity {
break; break;
case R.id.btnMultiMatch: case R.id.btnMultiMatch:
for (int i = 0; i < radioGroupRuleCheck.getChildCount(); i++) { for (int i = 0; i < radioGroupRuleCheck.getChildCount(); i++) {
((RadioButton) radioGroupRuleCheck.getChildAt(i)).setEnabled(false); radioGroupRuleCheck.getChildAt(i).setEnabled(false);
} }
for (int i = 0; i < radioGroupRuleCheck2.getChildCount(); i++) { for (int i = 0; i < radioGroupRuleCheck2.getChildCount(); i++) {
((RadioButton) radioGroupRuleCheck2.getChildAt(i)).setEnabled(false); radioGroupRuleCheck2.getChildAt(i).setEnabled(false);
} }
editTextRuleValue.setEnabled(true); editTextRuleValue.setEnabled(true);
matchTypeLayout.setVisibility(View.GONE); matchTypeLayout.setVisibility(View.GONE);
@ -358,10 +318,10 @@ public class RuleActivity extends AppCompatActivity {
break; break;
default: default:
for (int i = 0; i < radioGroupRuleCheck.getChildCount(); i++) { for (int i = 0; i < radioGroupRuleCheck.getChildCount(); i++) {
((RadioButton) radioGroupRuleCheck.getChildAt(i)).setEnabled(true); radioGroupRuleCheck.getChildAt(i).setEnabled(true);
} }
for (int i = 0; i < radioGroupRuleCheck2.getChildCount(); i++) { for (int i = 0; i < radioGroupRuleCheck2.getChildCount(); i++) {
((RadioButton) radioGroupRuleCheck2.getChildAt(i)).setEnabled(true); radioGroupRuleCheck2.getChildAt(i).setEnabled(true);
} }
editTextRuleValue.setEnabled(true); editTextRuleValue.setEnabled(true);
break; break;
@ -380,37 +340,33 @@ public class RuleActivity extends AppCompatActivity {
} }
AlertDialog.Builder builder = new AlertDialog.Builder(RuleActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(RuleActivity.this);
builder.setTitle("选择发送方"); builder.setTitle("选择发送方");
builder.setItems(senderNames, new DialogInterface.OnClickListener() {//添加列表 //添加列表
@Override builder.setItems(senderNames, (dialogInterface, which) -> {
public void onClick(DialogInterface dialogInterface, int which) {
Toast.makeText(RuleActivity.this, senderNames[which], Toast.LENGTH_LONG).show(); Toast.makeText(RuleActivity.this, senderNames[which], Toast.LENGTH_LONG).show();
showTv.setText(senderNames[which]); showTv.setText(senderNames[which]);
showTv.setTag(senderModels.get(which).getId()); showTv.setTag(senderModels.get(which).getId());
}
}); });
builder.show(); builder.show();
} }
public void testRule(final RuleModel ruleModel, final Long senderId) { public void testRule(final RuleModel ruleModel, final Long senderId) {
final View view = View.inflate(RuleActivity.this, R.layout.alert_dialog_setview_rule_test, null); final View view = View.inflate(RuleActivity.this, R.layout.alert_dialog_setview_rule_test, null);
final RadioGroup radioGroupTestSimSlot = (RadioGroup) view.findViewById(R.id.radioGroupTestSimSlot); final RadioGroup radioGroupTestSimSlot = view.findViewById(R.id.radioGroupTestSimSlot);
final EditText editTextTestPhone = (EditText) view.findViewById(R.id.editTextTestPhone); final EditText editTextTestPhone = view.findViewById(R.id.editTextTestPhone);
final EditText editTextTestMsgContent = (EditText) view.findViewById(R.id.editTextTestMsgContent); final EditText editTextTestMsgContent = view.findViewById(R.id.editTextTestMsgContent);
Button buttonruletest = view.findViewById(R.id.buttonruletest); Button buttonRuleTest = view.findViewById(R.id.buttonRuleTest);
AlertDialog.Builder ad1 = new AlertDialog.Builder(RuleActivity.this); AlertDialog.Builder ad1 = new AlertDialog.Builder(RuleActivity.this);
ad1.setTitle("测试规则"); ad1.setTitle("测试规则");
ad1.setIcon(android.R.drawable.ic_dialog_email); ad1.setIcon(android.R.drawable.ic_dialog_email);
ad1.setView(view); ad1.setView(view);
buttonruletest.setOnClickListener(new View.OnClickListener() { buttonRuleTest.setOnClickListener(v -> {
@Override
public void onClick(View v) {
Log.i("editTextTestPhone", editTextTestPhone.getText().toString()); Log.i("editTextTestPhone", editTextTestPhone.getText().toString());
Log.i("editTextTestMsgContent", editTextTestMsgContent.getText().toString()); Log.i("editTextTestMsgContent", editTextTestMsgContent.getText().toString());
try { try {
String simSlot = RuleModel.getRuleSimSlotFromCheckId(radioGroupTestSimSlot.getCheckedRadioButtonId()); String simSlot = RuleModel.getRuleSimSlotFromCheckId(radioGroupTestSimSlot.getCheckedRadioButtonId());
String simInfo = ""; String simInfo;
if (simSlot.equals("SIM2")) { if (simSlot.equals("SIM2")) {
simInfo = simSlot + "_" + SettingUtil.getAddExtraSim2(); simInfo = simSlot + "_" + SettingUtil.getAddExtraSim2();
} else { } else {
@ -421,7 +377,6 @@ public class RuleActivity extends AppCompatActivity {
} catch (Exception e) { } catch (Exception e) {
Toast.makeText(RuleActivity.this, e.getMessage(), Toast.LENGTH_LONG).show(); Toast.makeText(RuleActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
} }
}
}); });
ad1.show();// 显示对话框 ad1.show();// 显示对话框
} }

View File

@ -12,15 +12,13 @@ import static com.idormy.sms.forwarder.model.SenderModel.TYPE_SMS;
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_TELEGRAM; import static com.idormy.sms.forwarder.model.SenderModel.TYPE_TELEGRAM;
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_WEB_NOTIFY; import static com.idormy.sms.forwarder.model.SenderModel.TYPE_WEB_NOTIFY;
import android.content.DialogInterface; import android.annotation.SuppressLint;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.AdapterView;
import android.widget.Button; import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
@ -63,28 +61,28 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@SuppressWarnings("deprecation")
public class SenderActivity extends AppCompatActivity { public class SenderActivity extends AppCompatActivity {
public static final int NOTIFY = 0x9731993; public static final int NOTIFY = 0x9731993;
private String TAG = "SenderActivity"; private final String TAG = "SenderActivity";
// 用于存储数据 // 用于存储数据
private List<SenderModel> senderModels = new ArrayList<>(); private List<SenderModel> senderModels = new ArrayList<>();
private SenderAdapter adapter; private SenderAdapter adapter;
//消息处理者,创建一个Handler的子类对象,目的是重写Handler的处理消息的方法(handleMessage()) //消息处理者,创建一个Handler的子类对象,目的是重写Handler的处理消息的方法(handleMessage())
private Handler handler = new Handler() { @SuppressLint("HandlerLeak")
private final Handler handler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
switch (msg.what) { if (msg.what == NOTIFY) {
case NOTIFY:
Toast.makeText(SenderActivity.this, msg.getData().getString("DATA"), Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, msg.getData().getString("DATA"), Toast.LENGTH_LONG).show();
break;
} }
} }
}; };
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "oncreate"); Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sender); setContentView(R.layout.activity_sender);
SenderUtil.init(SenderActivity.this); SenderUtil.init(SenderActivity.this);
@ -109,9 +107,7 @@ public class SenderActivity extends AppCompatActivity {
// 为ListView注册一个监听器当用户点击了ListView中的任何一个子项时就会回调onItemClick()方法 // 为ListView注册一个监听器当用户点击了ListView中的任何一个子项时就会回调onItemClick()方法
// 在这个方法中可以通过position参数判断出用户点击的是那一个子项 // 在这个方法中可以通过position参数判断出用户点击的是那一个子项
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener((parent, view, position, id) -> {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
SenderModel senderModel = senderModels.get(position); SenderModel senderModel = senderModels.get(position);
Log.d(TAG, "onItemClick: " + senderModel); Log.d(TAG, "onItemClick: " + senderModel);
@ -148,20 +144,15 @@ public class SenderActivity extends AppCompatActivity {
break; break;
default: default:
Toast.makeText(SenderActivity.this, "异常的发送方类型,自动删除!", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "异常的发送方类型,自动删除!", Toast.LENGTH_LONG).show();
if (senderModel != null) {
SenderUtil.delSender(senderModel.getId()); SenderUtil.delSender(senderModel.getId());
initSenders(); initSenders();
adapter.del(senderModels); adapter.del(senderModels);
}
break; break;
} }
}
}); });
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { listView.setOnItemLongClickListener((parent, view, position, id) -> {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
//定义AlertDialog.Builder对象当长按列表项的时候弹出确认删除对话框 //定义AlertDialog.Builder对象当长按列表项的时候弹出确认删除对话框
AlertDialog.Builder builder = new AlertDialog.Builder(SenderActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(SenderActivity.this);
@ -169,27 +160,20 @@ public class SenderActivity extends AppCompatActivity {
builder.setTitle("提示"); builder.setTitle("提示");
//添加AlertDialog.Builder对象的setPositiveButton()方法 //添加AlertDialog.Builder对象的setPositiveButton()方法
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { builder.setPositiveButton("确定", (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
SenderUtil.delSender(senderModels.get(position).getId()); SenderUtil.delSender(senderModels.get(position).getId());
initSenders(); initSenders();
adapter.del(senderModels); adapter.del(senderModels);
Toast.makeText(getBaseContext(), "删除列表项", Toast.LENGTH_SHORT).show(); Toast.makeText(getBaseContext(), "删除列表项", Toast.LENGTH_SHORT).show();
}
}); });
//添加AlertDialog.Builder对象的setNegativeButton()方法 //添加AlertDialog.Builder对象的setNegativeButton()方法
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { builder.setNegativeButton("取消", (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}); });
builder.create().show(); builder.create().show();
return true; return true;
}
}); });
} }
@ -201,9 +185,8 @@ public class SenderActivity extends AppCompatActivity {
public void addSender(View view) { public void addSender(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(SenderActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(SenderActivity.this);
builder.setTitle("选择发送方类型"); builder.setTitle("选择发送方类型");
builder.setItems(R.array.add_sender_menu, new DialogInterface.OnClickListener() {//添加列表 //添加列表
@Override builder.setItems(R.array.add_sender_menu, (dialogInterface, which) -> {
public void onClick(DialogInterface dialogInterface, int which) {
switch (which) { switch (which) {
case TYPE_DINGDING: case TYPE_DINGDING:
setDingDing(null); setDingDing(null);
@ -239,13 +222,13 @@ public class SenderActivity extends AppCompatActivity {
Toast.makeText(SenderActivity.this, "暂不支持这种转发!", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "暂不支持这种转发!", Toast.LENGTH_LONG).show();
break; break;
} }
}
}); });
builder.show(); builder.show();
Log.d(TAG, "setDingDing show" + senderModels.size()); Log.d(TAG, "setDingDing show" + senderModels.size());
} }
//钉钉机器人 //钉钉机器人
@SuppressLint("SimpleDateFormat")
private void setDingDing(final SenderModel senderModel) { private void setDingDing(final SenderModel senderModel) {
DingDingSettingVo dingDingSettingVo = null; DingDingSettingVo dingDingSettingVo = null;
//try phrase json setting //try phrase json setting
@ -268,36 +251,34 @@ public class SenderActivity extends AppCompatActivity {
if (dingDingSettingVo != null) if (dingDingSettingVo != null)
editTextDingdingSecret.setText(dingDingSettingVo.getSecret()); editTextDingdingSecret.setText(dingDingSettingVo.getSecret());
final EditText editTextDingdingAtMobiles = view1.findViewById(R.id.editTextDingdingAtMobiles); final EditText editTextDingdingAtMobiles = view1.findViewById(R.id.editTextDingdingAtMobiles);
if (dingDingSettingVo != null && dingDingSettingVo.getAtMobils() != null) if (dingDingSettingVo != null && dingDingSettingVo.getAtMobiles() != null)
editTextDingdingAtMobiles.setText(dingDingSettingVo.getAtMobils()); editTextDingdingAtMobiles.setText(dingDingSettingVo.getAtMobiles());
final Switch switchDingdingAtAll = view1.findViewById(R.id.switchDingdingAtAll); @SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchDingdingAtAll = view1.findViewById(R.id.switchDingdingAtAll);
if (dingDingSettingVo != null && dingDingSettingVo.getAtAll() != null) if (dingDingSettingVo != null && dingDingSettingVo.getAtAll() != null)
switchDingdingAtAll.setChecked(dingDingSettingVo.getAtAll()); switchDingdingAtAll.setChecked(dingDingSettingVo.getAtAll());
Button buttondingdingok = view1.findViewById(R.id.buttondingdingok); Button buttonDingdingOk = view1.findViewById(R.id.buttonDingdingOk);
Button buttondingdingdel = view1.findViewById(R.id.buttondingdingdel); Button buttonDingdingDel = view1.findViewById(R.id.buttonDingdingDel);
Button buttondingdingtest = view1.findViewById(R.id.buttondingdingtest); Button buttonDingdingTest = view1.findViewById(R.id.buttonDingdingTest);
alertDialog71 alertDialog71
.setTitle(R.string.setdingdingtitle) .setTitle(R.string.setdingdingtitle)
.setIcon(R.mipmap.dingding) .setIcon(R.mipmap.dingding)
.setView(view1) .setView(view1)
.create(); .create();
final AlertDialog show = alertDialog71.show(); final AlertDialog show = alertDialog71.show();
buttondingdingok.setOnClickListener(new View.OnClickListener() { buttonDingdingOk.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel == null) { if (senderModel == null) {
SenderModel newSenderModel = new SenderModel(); SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextDingdingName.getText().toString()); newSenderModel.setName(editTextDingdingName.getText().toString());
newSenderModel.setType(TYPE_DINGDING); newSenderModel.setType(TYPE_DINGDING);
newSenderModel.setStatus(STATUS_ON); newSenderModel.setStatus(STATUS_ON);
DingDingSettingVo dingDingSettingVonew = new DingDingSettingVo( DingDingSettingVo dingDingSettingVoNew = new DingDingSettingVo(
editTextDingdingToken.getText().toString(), editTextDingdingToken.getText().toString(),
editTextDingdingSecret.getText().toString(), editTextDingdingSecret.getText().toString(),
editTextDingdingAtMobiles.getText().toString(), editTextDingdingAtMobiles.getText().toString(),
switchDingdingAtAll.isChecked()); switchDingdingAtAll.isChecked());
newSenderModel.setJsonSetting(JSON.toJSONString(dingDingSettingVonew)); newSenderModel.setJsonSetting(JSON.toJSONString(dingDingSettingVoNew));
SenderUtil.addSender(newSenderModel); SenderUtil.addSender(newSenderModel);
initSenders(); initSenders();
adapter.add(senderModels); adapter.add(senderModels);
@ -306,12 +287,12 @@ public class SenderActivity extends AppCompatActivity {
senderModel.setName(editTextDingdingName.getText().toString()); senderModel.setName(editTextDingdingName.getText().toString());
senderModel.setType(TYPE_DINGDING); senderModel.setType(TYPE_DINGDING);
senderModel.setStatus(STATUS_ON); senderModel.setStatus(STATUS_ON);
DingDingSettingVo dingDingSettingVonew = new DingDingSettingVo( DingDingSettingVo dingDingSettingVoNew = new DingDingSettingVo(
editTextDingdingToken.getText().toString(), editTextDingdingToken.getText().toString(),
editTextDingdingSecret.getText().toString(), editTextDingdingSecret.getText().toString(),
editTextDingdingAtMobiles.getText().toString(), editTextDingdingAtMobiles.getText().toString(),
switchDingdingAtAll.isChecked()); switchDingdingAtAll.isChecked());
senderModel.setJsonSetting(JSON.toJSONString(dingDingSettingVonew)); senderModel.setJsonSetting(JSON.toJSONString(dingDingSettingVoNew));
SenderUtil.updateSender(senderModel); SenderUtil.updateSender(senderModel);
initSenders(); initSenders();
adapter.update(senderModels); adapter.update(senderModels);
@ -322,11 +303,8 @@ public class SenderActivity extends AppCompatActivity {
show.dismiss(); show.dismiss();
}
}); });
buttondingdingdel.setOnClickListener(new View.OnClickListener() { buttonDingdingDel.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel != null) { if (senderModel != null) {
SenderUtil.delSender(senderModel.getId()); SenderUtil.delSender(senderModel.getId());
initSenders(); initSenders();
@ -335,16 +313,13 @@ public class SenderActivity extends AppCompatActivity {
} }
show.dismiss(); show.dismiss();
}
}); });
buttondingdingtest.setOnClickListener(new View.OnClickListener() { buttonDingdingTest.setOnClickListener(view -> {
@Override
public void onClick(View view) {
String token = editTextDingdingToken.getText().toString(); String token = editTextDingdingToken.getText().toString();
String secret = editTextDingdingSecret.getText().toString(); String secret = editTextDingdingSecret.getText().toString();
String atMobiles = editTextDingdingAtMobiles.getText().toString(); String atMobiles = editTextDingdingAtMobiles.getText().toString();
Boolean atAll = switchDingdingAtAll.isChecked(); Boolean atAll = switchDingdingAtAll.isChecked();
if (token != null && !token.isEmpty()) { if (!token.isEmpty()) {
try { try {
SenderDingdingMsg.sendMsg(0, handler, token, secret, atMobiles, atAll, "测试内容(content)@" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))); SenderDingdingMsg.sendMsg(0, handler, token, secret, atMobiles, atAll, "测试内容(content)@" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
} catch (Exception e) { } catch (Exception e) {
@ -354,11 +329,11 @@ public class SenderActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(SenderActivity.this, "token 不能为空", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "token 不能为空", Toast.LENGTH_LONG).show();
} }
}
}); });
} }
//邮箱 //邮箱
@SuppressLint("SimpleDateFormat")
private void setEmail(final SenderModel senderModel) { private void setEmail(final SenderModel senderModel) {
EmailSettingVo emailSettingVo = null; EmailSettingVo emailSettingVo = null;
//try phrase json setting //try phrase json setting
@ -379,7 +354,7 @@ public class SenderActivity extends AppCompatActivity {
final EditText editTextEmailPort = view1.findViewById(R.id.editTextEmailPort); final EditText editTextEmailPort = view1.findViewById(R.id.editTextEmailPort);
if (emailSettingVo != null) editTextEmailPort.setText(emailSettingVo.getPort()); if (emailSettingVo != null) editTextEmailPort.setText(emailSettingVo.getPort());
final Switch switchEmailSSl = view1.findViewById(R.id.switchEmailSSl); @SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchEmailSSl = view1.findViewById(R.id.switchEmailSSl);
if (emailSettingVo != null) switchEmailSSl.setChecked(emailSettingVo.getSsl()); if (emailSettingVo != null) switchEmailSSl.setChecked(emailSettingVo.getSsl());
final EditText editTextEmailFromAdd = view1.findViewById(R.id.editTextEmailFromAdd); final EditText editTextEmailFromAdd = view1.findViewById(R.id.editTextEmailFromAdd);
if (emailSettingVo != null) editTextEmailFromAdd.setText(emailSettingVo.getFromEmail()); if (emailSettingVo != null) editTextEmailFromAdd.setText(emailSettingVo.getFromEmail());
@ -390,9 +365,9 @@ public class SenderActivity extends AppCompatActivity {
final EditText editTextEmailToAdd = view1.findViewById(R.id.editTextEmailToAdd); final EditText editTextEmailToAdd = view1.findViewById(R.id.editTextEmailToAdd);
if (emailSettingVo != null) editTextEmailToAdd.setText(emailSettingVo.getToEmail()); if (emailSettingVo != null) editTextEmailToAdd.setText(emailSettingVo.getToEmail());
Button buttonemailok = view1.findViewById(R.id.buttonemailok); Button buttonEmailOk = view1.findViewById(R.id.buttonEmailOk);
Button buttonemaildel = view1.findViewById(R.id.buttonemaildel); Button buttonEmailDel = view1.findViewById(R.id.buttonEmailDel);
Button buttonemailtest = view1.findViewById(R.id.buttonemailtest); Button buttonEmailTest = view1.findViewById(R.id.buttonEmailTest);
alertDialog71 alertDialog71
.setTitle(R.string.setemailtitle) .setTitle(R.string.setemailtitle)
.setIcon(R.mipmap.email) .setIcon(R.mipmap.email)
@ -400,16 +375,14 @@ public class SenderActivity extends AppCompatActivity {
.create(); .create();
final AlertDialog show = alertDialog71.show(); final AlertDialog show = alertDialog71.show();
buttonemailok.setOnClickListener(new View.OnClickListener() { buttonEmailOk.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel == null) { if (senderModel == null) {
SenderModel newSenderModel = new SenderModel(); SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextEmailName.getText().toString()); newSenderModel.setName(editTextEmailName.getText().toString());
newSenderModel.setType(TYPE_EMAIL); newSenderModel.setType(TYPE_EMAIL);
newSenderModel.setStatus(STATUS_ON); newSenderModel.setStatus(STATUS_ON);
EmailSettingVo emailSettingVonew = new EmailSettingVo( EmailSettingVo emailSettingVoNew = new EmailSettingVo(
editTextEmailHost.getText().toString(), editTextEmailHost.getText().toString(),
editTextEmailPort.getText().toString(), editTextEmailPort.getText().toString(),
switchEmailSSl.isChecked(), switchEmailSSl.isChecked(),
@ -418,7 +391,7 @@ public class SenderActivity extends AppCompatActivity {
editTextEmailPsw.getText().toString(), editTextEmailPsw.getText().toString(),
editTextEmailToAdd.getText().toString() editTextEmailToAdd.getText().toString()
); );
newSenderModel.setJsonSetting(JSON.toJSONString(emailSettingVonew)); newSenderModel.setJsonSetting(JSON.toJSONString(emailSettingVoNew));
SenderUtil.addSender(newSenderModel); SenderUtil.addSender(newSenderModel);
initSenders(); initSenders();
adapter.add(senderModels); adapter.add(senderModels);
@ -426,7 +399,7 @@ public class SenderActivity extends AppCompatActivity {
senderModel.setName(editTextEmailName.getText().toString()); senderModel.setName(editTextEmailName.getText().toString());
senderModel.setType(TYPE_EMAIL); senderModel.setType(TYPE_EMAIL);
senderModel.setStatus(STATUS_ON); senderModel.setStatus(STATUS_ON);
EmailSettingVo emailSettingVonew = new EmailSettingVo( EmailSettingVo emailSettingVoNew = new EmailSettingVo(
editTextEmailHost.getText().toString(), editTextEmailHost.getText().toString(),
editTextEmailPort.getText().toString(), editTextEmailPort.getText().toString(),
switchEmailSSl.isChecked(), switchEmailSSl.isChecked(),
@ -435,7 +408,7 @@ public class SenderActivity extends AppCompatActivity {
editTextEmailPsw.getText().toString(), editTextEmailPsw.getText().toString(),
editTextEmailToAdd.getText().toString() editTextEmailToAdd.getText().toString()
); );
senderModel.setJsonSetting(JSON.toJSONString(emailSettingVonew)); senderModel.setJsonSetting(JSON.toJSONString(emailSettingVoNew));
SenderUtil.updateSender(senderModel); SenderUtil.updateSender(senderModel);
initSenders(); initSenders();
adapter.update(senderModels); adapter.update(senderModels);
@ -444,37 +417,31 @@ public class SenderActivity extends AppCompatActivity {
show.dismiss(); show.dismiss();
}
}); });
buttonemaildel.setOnClickListener(new View.OnClickListener() { buttonEmailDel.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel != null) { if (senderModel != null) {
SenderUtil.delSender(senderModel.getId()); SenderUtil.delSender(senderModel.getId());
initSenders(); initSenders();
adapter.del(senderModels); adapter.del(senderModels);
} }
show.dismiss(); show.dismiss();
}
}); });
buttonemailtest.setOnClickListener(new View.OnClickListener() { buttonEmailTest.setOnClickListener(view -> {
@Override
public void onClick(View view) {
String host = editTextEmailHost.getText().toString(); String host = editTextEmailHost.getText().toString();
String port = editTextEmailPort.getText().toString(); String port = editTextEmailPort.getText().toString();
Boolean ssl = switchEmailSSl.isChecked(); boolean ssl = switchEmailSSl.isChecked();
String fromemail = editTextEmailFromAdd.getText().toString(); String fromEmail = editTextEmailFromAdd.getText().toString();
String pwd = editTextEmailPsw.getText().toString(); String pwd = editTextEmailPsw.getText().toString();
String toemail = editTextEmailToAdd.getText().toString(); String toEmail = editTextEmailToAdd.getText().toString();
String nickname = editTextEmailNickname.getText().toString(); String nickname = editTextEmailNickname.getText().toString();
if (nickname == null || nickname.equals("")) { if (nickname.equals("")) {
nickname = "SmsForwarder"; nickname = "SmsForwarder";
} }
if (!host.isEmpty() && !port.isEmpty() && !fromemail.isEmpty() && !pwd.isEmpty() && !toemail.isEmpty()) { if (!host.isEmpty() && !port.isEmpty() && !fromEmail.isEmpty() && !pwd.isEmpty() && !toEmail.isEmpty()) {
try { try {
SenderMailMsg.sendEmail(0, handler, host, port, ssl, fromemail, nickname, pwd, toemail, "SmsForwarder Title", "测试内容(content)@" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))); SenderMailMsg.sendEmail(0, handler, host, port, ssl, fromEmail, nickname, pwd, toEmail, "SmsForwarder Title", "测试内容(content)@" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
} catch (Exception e) { } catch (Exception e) {
Toast.makeText(SenderActivity.this, "发送失败:" + e.getMessage(), Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "发送失败:" + e.getMessage(), Toast.LENGTH_LONG).show();
e.printStackTrace(); e.printStackTrace();
@ -482,7 +449,6 @@ public class SenderActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(SenderActivity.this, "邮箱参数不完整", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "邮箱参数不完整", Toast.LENGTH_LONG).show();
} }
}
}); });
} }
@ -515,9 +481,7 @@ public class SenderActivity extends AppCompatActivity {
.create(); .create();
final AlertDialog show = alertDialog71.show(); final AlertDialog show = alertDialog71.show();
buttonBarkOk.setOnClickListener(new View.OnClickListener() { buttonBarkOk.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel == null) { if (senderModel == null) {
SenderModel newSenderModel = new SenderModel(); SenderModel newSenderModel = new SenderModel();
@ -546,22 +510,16 @@ public class SenderActivity extends AppCompatActivity {
show.dismiss(); show.dismiss();
}
}); });
buttonBarkDel.setOnClickListener(new View.OnClickListener() { buttonBarkDel.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel != null) { if (senderModel != null) {
SenderUtil.delSender(senderModel.getId()); SenderUtil.delSender(senderModel.getId());
initSenders(); initSenders();
adapter.del(senderModels); adapter.del(senderModels);
} }
show.dismiss(); show.dismiss();
}
}); });
buttonBarkTest.setOnClickListener(new View.OnClickListener() { buttonBarkTest.setOnClickListener(view -> {
@Override
public void onClick(View view) {
String barkServer = editTextBarkServer.getText().toString(); String barkServer = editTextBarkServer.getText().toString();
if (!barkServer.isEmpty()) { if (!barkServer.isEmpty()) {
try { try {
@ -573,7 +531,6 @@ public class SenderActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(SenderActivity.this, "bark-server 不能为空", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "bark-server 不能为空", Toast.LENGTH_LONG).show();
} }
}
}); });
} }
@ -607,19 +564,17 @@ public class SenderActivity extends AppCompatActivity {
.create(); .create();
final AlertDialog show = alertDialog71.show(); final AlertDialog show = alertDialog71.show();
buttonServerChanOk.setOnClickListener(new View.OnClickListener() { buttonServerChanOk.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel == null) { if (senderModel == null) {
SenderModel newSenderModel = new SenderModel(); SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextServerChanName.getText().toString()); newSenderModel.setName(editTextServerChanName.getText().toString());
newSenderModel.setType(TYPE_SERVER_CHAN); newSenderModel.setType(TYPE_SERVER_CHAN);
newSenderModel.setStatus(STATUS_ON); newSenderModel.setStatus(STATUS_ON);
ServerChanSettingVo serverchanSettingVoNew = new ServerChanSettingVo( ServerChanSettingVo serverChanSettingVoNew = new ServerChanSettingVo(
editTextServerChanSendKey.getText().toString() editTextServerChanSendKey.getText().toString()
); );
newSenderModel.setJsonSetting(JSON.toJSONString(serverchanSettingVoNew)); newSenderModel.setJsonSetting(JSON.toJSONString(serverChanSettingVoNew));
SenderUtil.addSender(newSenderModel); SenderUtil.addSender(newSenderModel);
initSenders(); initSenders();
adapter.add(senderModels); adapter.add(senderModels);
@ -627,10 +582,10 @@ public class SenderActivity extends AppCompatActivity {
senderModel.setName(editTextServerChanName.getText().toString()); senderModel.setName(editTextServerChanName.getText().toString());
senderModel.setType(TYPE_SERVER_CHAN); senderModel.setType(TYPE_SERVER_CHAN);
senderModel.setStatus(STATUS_ON); senderModel.setStatus(STATUS_ON);
ServerChanSettingVo serverchanSettingVoNew = new ServerChanSettingVo( ServerChanSettingVo serverChanSettingVoNew = new ServerChanSettingVo(
editTextServerChanSendKey.getText().toString() editTextServerChanSendKey.getText().toString()
); );
senderModel.setJsonSetting(JSON.toJSONString(serverchanSettingVoNew)); senderModel.setJsonSetting(JSON.toJSONString(serverChanSettingVoNew));
SenderUtil.updateSender(senderModel); SenderUtil.updateSender(senderModel);
initSenders(); initSenders();
adapter.update(senderModels); adapter.update(senderModels);
@ -638,26 +593,20 @@ public class SenderActivity extends AppCompatActivity {
show.dismiss(); show.dismiss();
}
}); });
buttonServerChanDel.setOnClickListener(new View.OnClickListener() { buttonServerChanDel.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel != null) { if (senderModel != null) {
SenderUtil.delSender(senderModel.getId()); SenderUtil.delSender(senderModel.getId());
initSenders(); initSenders();
adapter.del(senderModels); adapter.del(senderModels);
} }
show.dismiss(); show.dismiss();
}
}); });
buttonServerChanTest.setOnClickListener(new View.OnClickListener() { buttonServerChanTest.setOnClickListener(view -> {
@Override String serverChanServer = editTextServerChanSendKey.getText().toString();
public void onClick(View view) { if (!serverChanServer.isEmpty()) {
String serverchanServer = editTextServerChanSendKey.getText().toString();
if (!serverchanServer.isEmpty()) {
try { try {
SenderServerChanMsg.sendMsg(0, handler, serverchanServer, "19999999999", "【京东】验证码为387481切勿将验证码告知他人请在页面中输入完成验证如有问题请点击 ihelp.jd.com 联系京东客服"); SenderServerChanMsg.sendMsg(0, handler, serverChanServer, "19999999999", "【京东】验证码为387481切勿将验证码告知他人请在页面中输入完成验证如有问题请点击 ihelp.jd.com 联系京东客服");
} catch (Exception e) { } catch (Exception e) {
Toast.makeText(SenderActivity.this, "发送失败:" + e.getMessage(), Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "发送失败:" + e.getMessage(), Toast.LENGTH_LONG).show();
e.printStackTrace(); e.printStackTrace();
@ -665,11 +614,11 @@ public class SenderActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(SenderActivity.this, "Server酱·Turbo版的 SendKey 不能为空", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "Server酱·Turbo版的 SendKey 不能为空", Toast.LENGTH_LONG).show();
} }
}
}); });
} }
//webhook //webhook
@SuppressLint("SimpleDateFormat")
private void setWebNotify(final SenderModel senderModel) { private void setWebNotify(final SenderModel senderModel) {
WebNotifySettingVo webNotifySettingVo = null; WebNotifySettingVo webNotifySettingVo = null;
//try phrase json setting //try phrase json setting
@ -691,12 +640,12 @@ public class SenderActivity extends AppCompatActivity {
if (webNotifySettingVo != null) editTextWebNotifyWebParams.setText(webNotifySettingVo.getWebParams()); if (webNotifySettingVo != null) editTextWebNotifyWebParams.setText(webNotifySettingVo.getWebParams());
final EditText editTextWebNotifySecret = view1.findViewById(R.id.editTextWebNotifySecret); final EditText editTextWebNotifySecret = view1.findViewById(R.id.editTextWebNotifySecret);
if (webNotifySettingVo != null) editTextWebNotifySecret.setText(webNotifySettingVo.getSecret()); if (webNotifySettingVo != null) editTextWebNotifySecret.setText(webNotifySettingVo.getSecret());
final RadioGroup radioGroupWebNotifyMethod = (RadioGroup) view1.findViewById(R.id.radioGroupWebNotifyMethod); final RadioGroup radioGroupWebNotifyMethod = view1.findViewById(R.id.radioGroupWebNotifyMethod);
if (webNotifySettingVo != null) radioGroupWebNotifyMethod.check(webNotifySettingVo.getWebNotifyMethodCheckId()); if (webNotifySettingVo != null) radioGroupWebNotifyMethod.check(webNotifySettingVo.getWebNotifyMethodCheckId());
Button buttonbebnotifyok = view1.findViewById(R.id.buttonbebnotifyok); Button buttonWebNotifyOk = view1.findViewById(R.id.buttonWebNotifyOk);
Button buttonbebnotifydel = view1.findViewById(R.id.buttonbebnotifydel); Button buttonWebNotifyDel = view1.findViewById(R.id.buttonWebNotifyDel);
Button buttonbebnotifytest = view1.findViewById(R.id.buttonbebnotifytest); Button buttonWebNotifyTest = view1.findViewById(R.id.buttonWebNotifyTest);
alertDialog71 alertDialog71
.setTitle(R.string.setwebnotifytitle) .setTitle(R.string.setwebnotifytitle)
.setIcon(R.mipmap.webhook) .setIcon(R.mipmap.webhook)
@ -704,9 +653,7 @@ public class SenderActivity extends AppCompatActivity {
.create(); .create();
final AlertDialog show = alertDialog71.show(); final AlertDialog show = alertDialog71.show();
buttonbebnotifyok.setOnClickListener(new View.OnClickListener() { buttonWebNotifyOk.setOnClickListener(view -> {
@Override
public void onClick(View view) {
WebNotifySettingVo webNotifySettingVoNew = new WebNotifySettingVo( WebNotifySettingVo webNotifySettingVoNew = new WebNotifySettingVo(
editTextWebNotifyWebServer.getText().toString(), editTextWebNotifyWebServer.getText().toString(),
editTextWebNotifySecret.getText().toString(), editTextWebNotifySecret.getText().toString(),
@ -730,22 +677,16 @@ public class SenderActivity extends AppCompatActivity {
initSenders(); initSenders();
adapter.update(senderModels); adapter.update(senderModels);
show.dismiss(); show.dismiss();
}
}); });
buttonbebnotifydel.setOnClickListener(new View.OnClickListener() { buttonWebNotifyDel.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel != null) { if (senderModel != null) {
SenderUtil.delSender(senderModel.getId()); SenderUtil.delSender(senderModel.getId());
initSenders(); initSenders();
adapter.del(senderModels); adapter.del(senderModels);
} }
show.dismiss(); show.dismiss();
}
}); });
buttonbebnotifytest.setOnClickListener(new View.OnClickListener() { buttonWebNotifyTest.setOnClickListener(view -> {
@Override
public void onClick(View view) {
String webServer = editTextWebNotifyWebServer.getText().toString(); String webServer = editTextWebNotifyWebServer.getText().toString();
String webParams = editTextWebNotifyWebParams.getText().toString(); String webParams = editTextWebNotifyWebParams.getText().toString();
String secret = editTextWebNotifySecret.getText().toString(); String secret = editTextWebNotifySecret.getText().toString();
@ -760,11 +701,11 @@ public class SenderActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(SenderActivity.this, "WebServer 不能为空", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "WebServer 不能为空", Toast.LENGTH_LONG).show();
} }
}
}); });
} }
//企业微信群机器人 //企业微信群机器人
@SuppressLint("SimpleDateFormat")
private void setQYWXGroupRobot(final SenderModel senderModel) { private void setQYWXGroupRobot(final SenderModel senderModel) {
QYWXGroupRobotSettingVo qywxGroupRobotSettingVo = null; QYWXGroupRobotSettingVo qywxGroupRobotSettingVo = null;
//try phrase json setting //try phrase json setting
@ -794,9 +735,7 @@ public class SenderActivity extends AppCompatActivity {
.create(); .create();
final AlertDialog show = alertDialog71.show(); final AlertDialog show = alertDialog71.show();
buttonQyWxGroupRobotOk.setOnClickListener(new View.OnClickListener() { buttonQyWxGroupRobotOk.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel == null) { if (senderModel == null) {
SenderModel newSenderModel = new SenderModel(); SenderModel newSenderModel = new SenderModel();
@ -825,22 +764,16 @@ public class SenderActivity extends AppCompatActivity {
show.dismiss(); show.dismiss();
}
}); });
buttonQyWxGroupRobotDel.setOnClickListener(new View.OnClickListener() { buttonQyWxGroupRobotDel.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel != null) { if (senderModel != null) {
SenderUtil.delSender(senderModel.getId()); SenderUtil.delSender(senderModel.getId());
initSenders(); initSenders();
adapter.del(senderModels); adapter.del(senderModels);
} }
show.dismiss(); show.dismiss();
}
}); });
buttonQyWxGroupRobotTest.setOnClickListener(new View.OnClickListener() { buttonQyWxGroupRobotTest.setOnClickListener(view -> {
@Override
public void onClick(View view) {
String webHook = editTextQYWXGroupRobotWebHook.getText().toString(); String webHook = editTextQYWXGroupRobotWebHook.getText().toString();
if (!webHook.isEmpty()) { if (!webHook.isEmpty()) {
try { try {
@ -852,11 +785,11 @@ public class SenderActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(SenderActivity.this, "webHook 不能为空", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "webHook 不能为空", Toast.LENGTH_LONG).show();
} }
}
}); });
} }
//企业微信应用 //企业微信应用
@SuppressLint({"SimpleDateFormat", "SetTextI18n"})
private void setQYWXApp(final SenderModel senderModel) { private void setQYWXApp(final SenderModel senderModel) {
QYWXAppSettingVo QYWXAppSettingVo = null; QYWXAppSettingVo QYWXAppSettingVo = null;
//try phrase json setting //try phrase json setting
@ -877,18 +810,16 @@ public class SenderActivity extends AppCompatActivity {
final EditText editTextQYWXAppSecret = view1.findViewById(R.id.editTextQYWXAppSecret); final EditText editTextQYWXAppSecret = view1.findViewById(R.id.editTextQYWXAppSecret);
final LinearLayout linearLayoutQYWXAppToUser = view1.findViewById(R.id.linearLayoutQYWXAppToUser); final LinearLayout linearLayoutQYWXAppToUser = view1.findViewById(R.id.linearLayoutQYWXAppToUser);
final EditText editTextQYWXAppToUser = view1.findViewById(R.id.editTextQYWXAppToUser); final EditText editTextQYWXAppToUser = view1.findViewById(R.id.editTextQYWXAppToUser);
final Switch switchQYWXAppAtAll = view1.findViewById(R.id.switchQYWXAppAtAll); @SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchQYWXAppAtAll = view1.findViewById(R.id.switchQYWXAppAtAll);
if (QYWXAppSettingVo != null) { if (QYWXAppSettingVo != null) {
editTextQYWXAppCorpID.setText(QYWXAppSettingVo.getCorpID()); editTextQYWXAppCorpID.setText(QYWXAppSettingVo.getCorpID());
editTextQYWXAppAgentID.setText(QYWXAppSettingVo.getAgentID()); editTextQYWXAppAgentID.setText(QYWXAppSettingVo.getAgentID());
editTextQYWXAppSecret.setText(QYWXAppSettingVo.getSecret()); editTextQYWXAppSecret.setText(QYWXAppSettingVo.getSecret());
editTextQYWXAppToUser.setText(QYWXAppSettingVo.getToUser()); editTextQYWXAppToUser.setText(QYWXAppSettingVo.getToUser());
switchQYWXAppAtAll.setChecked(QYWXAppSettingVo.getAtAll()); switchQYWXAppAtAll.setChecked(QYWXAppSettingVo.getAtAll());
linearLayoutQYWXAppToUser.setVisibility((Boolean) QYWXAppSettingVo.getAtAll() ? View.GONE : View.VISIBLE); linearLayoutQYWXAppToUser.setVisibility(QYWXAppSettingVo.getAtAll() ? View.GONE : View.VISIBLE);
} }
switchQYWXAppAtAll.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() { switchQYWXAppAtAll.setOnCheckedChangeListener((buttonView, isChecked) -> {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) { if (isChecked) {
linearLayoutQYWXAppToUser.setVisibility(View.GONE); linearLayoutQYWXAppToUser.setVisibility(View.GONE);
editTextQYWXAppToUser.setText("@all"); editTextQYWXAppToUser.setText("@all");
@ -897,23 +828,20 @@ public class SenderActivity extends AppCompatActivity {
editTextQYWXAppToUser.setText(""); editTextQYWXAppToUser.setText("");
} }
Log.d(TAG, "onCheckedChanged:" + isChecked); Log.d(TAG, "onCheckedChanged:" + isChecked);
}
}); });
Button buttonQYWXAppok = view1.findViewById(R.id.buttonQYWXAppOk); Button buttonQYWXAppOk = view1.findViewById(R.id.buttonQYWXAppOk);
Button buttonQYWXAppdel = view1.findViewById(R.id.buttonQYWXAppDel); Button buttonQYWXAppDel = view1.findViewById(R.id.buttonQYWXAppDel);
Button buttonQYWXApptest = view1.findViewById(R.id.buttonQYWXAppTest); Button buttonQYWXAppTest = view1.findViewById(R.id.buttonQYWXAppTest);
alertDialog71 alertDialog71
.setTitle(R.string.setqywxapptitle) .setTitle(R.string.setqywxapptitle)
.setIcon(R.mipmap.qywxapp) .setIcon(R.mipmap.qywxapp)
.setView(view1) .setView(view1)
.create(); .create();
final AlertDialog show = alertDialog71.show(); final AlertDialog show = alertDialog71.show();
buttonQYWXAppok.setOnClickListener(new View.OnClickListener() { buttonQYWXAppOk.setOnClickListener(view -> {
@Override
public void onClick(View view) {
String toUser = editTextQYWXAppToUser.getText().toString(); String toUser = editTextQYWXAppToUser.getText().toString();
if (toUser == null || toUser.isEmpty()) { if (toUser.isEmpty()) {
Toast.makeText(SenderActivity.this, "指定成员 不能为空 或者 选择@all", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "指定成员 不能为空 或者 选择@all", Toast.LENGTH_LONG).show();
editTextQYWXAppToUser.setFocusable(true); editTextQYWXAppToUser.setFocusable(true);
editTextQYWXAppToUser.requestFocus(); editTextQYWXAppToUser.requestFocus();
@ -925,13 +853,13 @@ public class SenderActivity extends AppCompatActivity {
newSenderModel.setName(editTextQYWXAppName.getText().toString()); newSenderModel.setName(editTextQYWXAppName.getText().toString());
newSenderModel.setType(TYPE_QYWX_APP); newSenderModel.setType(TYPE_QYWX_APP);
newSenderModel.setStatus(STATUS_ON); newSenderModel.setStatus(STATUS_ON);
QYWXAppSettingVo QYWXAppSettingVonew = new QYWXAppSettingVo( QYWXAppSettingVo QYWXAppSettingVoNew = new QYWXAppSettingVo(
editTextQYWXAppCorpID.getText().toString(), editTextQYWXAppCorpID.getText().toString(),
editTextQYWXAppAgentID.getText().toString(), editTextQYWXAppAgentID.getText().toString(),
editTextQYWXAppSecret.getText().toString(), editTextQYWXAppSecret.getText().toString(),
editTextQYWXAppToUser.getText().toString(), editTextQYWXAppToUser.getText().toString(),
switchQYWXAppAtAll.isChecked()); switchQYWXAppAtAll.isChecked());
newSenderModel.setJsonSetting(JSON.toJSONString(QYWXAppSettingVonew)); newSenderModel.setJsonSetting(JSON.toJSONString(QYWXAppSettingVoNew));
SenderUtil.addSender(newSenderModel); SenderUtil.addSender(newSenderModel);
initSenders(); initSenders();
adapter.add(senderModels); adapter.add(senderModels);
@ -939,41 +867,35 @@ public class SenderActivity extends AppCompatActivity {
senderModel.setName(editTextQYWXAppName.getText().toString()); senderModel.setName(editTextQYWXAppName.getText().toString());
senderModel.setType(TYPE_QYWX_APP); senderModel.setType(TYPE_QYWX_APP);
senderModel.setStatus(STATUS_ON); senderModel.setStatus(STATUS_ON);
QYWXAppSettingVo QYWXAppSettingVonew = new QYWXAppSettingVo( QYWXAppSettingVo QYWXAppSettingVoNew = new QYWXAppSettingVo(
editTextQYWXAppCorpID.getText().toString(), editTextQYWXAppCorpID.getText().toString(),
editTextQYWXAppAgentID.getText().toString(), editTextQYWXAppAgentID.getText().toString(),
editTextQYWXAppSecret.getText().toString(), editTextQYWXAppSecret.getText().toString(),
editTextQYWXAppToUser.getText().toString(), editTextQYWXAppToUser.getText().toString(),
switchQYWXAppAtAll.isChecked()); switchQYWXAppAtAll.isChecked());
senderModel.setJsonSetting(JSON.toJSONString(QYWXAppSettingVonew)); senderModel.setJsonSetting(JSON.toJSONString(QYWXAppSettingVoNew));
SenderUtil.updateSender(senderModel); SenderUtil.updateSender(senderModel);
initSenders(); initSenders();
adapter.update(senderModels); adapter.update(senderModels);
} }
show.dismiss(); show.dismiss();
}
}); });
buttonQYWXAppdel.setOnClickListener(new View.OnClickListener() { buttonQYWXAppDel.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel != null) { if (senderModel != null) {
SenderUtil.delSender(senderModel.getId()); SenderUtil.delSender(senderModel.getId());
initSenders(); initSenders();
adapter.del(senderModels); adapter.del(senderModels);
} }
show.dismiss(); show.dismiss();
}
}); });
buttonQYWXApptest.setOnClickListener(new View.OnClickListener() { buttonQYWXAppTest.setOnClickListener(view -> {
@Override
public void onClick(View view) {
String cropID = editTextQYWXAppCorpID.getText().toString(); String cropID = editTextQYWXAppCorpID.getText().toString();
String agentID = editTextQYWXAppAgentID.getText().toString(); String agentID = editTextQYWXAppAgentID.getText().toString();
String secret = editTextQYWXAppSecret.getText().toString(); String secret = editTextQYWXAppSecret.getText().toString();
String toUser = editTextQYWXAppToUser.getText().toString(); String toUser = editTextQYWXAppToUser.getText().toString();
//Boolean atAll = switchQYWXAppAtAll.isChecked(); //Boolean atAll = switchQYWXAppAtAll.isChecked();
if (toUser != null && !toUser.isEmpty()) { if (!toUser.isEmpty()) {
try { try {
SenderQyWxAppMsg.sendMsg(0, handler, cropID, agentID, secret, toUser, "测试内容(content)@" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())), true); SenderQyWxAppMsg.sendMsg(0, handler, cropID, agentID, secret, toUser, "测试内容(content)@" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())), true);
} catch (Exception e) { } catch (Exception e) {
@ -983,7 +905,6 @@ public class SenderActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(SenderActivity.this, "指定成员 不能为空 或者 选择@all", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "指定成员 不能为空 或者 选择@all", Toast.LENGTH_LONG).show();
} }
}
}); });
} }
@ -1020,9 +941,7 @@ public class SenderActivity extends AppCompatActivity {
.create(); .create();
final AlertDialog show = alertDialog71.show(); final AlertDialog show = alertDialog71.show();
buttonTelegramOk.setOnClickListener(new View.OnClickListener() { buttonTelegramOk.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel == null) { if (senderModel == null) {
SenderModel newSenderModel = new SenderModel(); SenderModel newSenderModel = new SenderModel();
@ -1053,22 +972,16 @@ public class SenderActivity extends AppCompatActivity {
show.dismiss(); show.dismiss();
}
}); });
buttonTelegramDel.setOnClickListener(new View.OnClickListener() { buttonTelegramDel.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel != null) { if (senderModel != null) {
SenderUtil.delSender(senderModel.getId()); SenderUtil.delSender(senderModel.getId());
initSenders(); initSenders();
adapter.del(senderModels); adapter.del(senderModels);
} }
show.dismiss(); show.dismiss();
}
}); });
buttonTelegramTest.setOnClickListener(new View.OnClickListener() { buttonTelegramTest.setOnClickListener(view -> {
@Override
public void onClick(View view) {
String apiToken = editTextTelegramApiToken.getText().toString(); String apiToken = editTextTelegramApiToken.getText().toString();
String chatId = editTextTelegramChatId.getText().toString(); String chatId = editTextTelegramChatId.getText().toString();
if (!apiToken.isEmpty() && !chatId.isEmpty()) { if (!apiToken.isEmpty() && !chatId.isEmpty()) {
@ -1081,7 +994,6 @@ public class SenderActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(SenderActivity.this, "机器人的ApiToken 和 被通知人的ChatId 都不能为空", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "机器人的ApiToken 和 被通知人的ChatId 都不能为空", Toast.LENGTH_LONG).show();
} }
}
}); });
} }
@ -1102,11 +1014,11 @@ public class SenderActivity extends AppCompatActivity {
final EditText editTextSmsName = view1.findViewById(R.id.editTextSmsName); final EditText editTextSmsName = view1.findViewById(R.id.editTextSmsName);
if (senderModel != null) editTextSmsName.setText(senderModel.getName()); if (senderModel != null) editTextSmsName.setText(senderModel.getName());
final RadioGroup radioGroupSmsSimSlot = (RadioGroup) view1.findViewById(R.id.radioGroupSmsSimSlot); final RadioGroup radioGroupSmsSimSlot = view1.findViewById(R.id.radioGroupSmsSimSlot);
if (smsSettingVo != null) radioGroupSmsSimSlot.check(smsSettingVo.getSmsSimSlotCheckId()); if (smsSettingVo != null) radioGroupSmsSimSlot.check(smsSettingVo.getSmsSimSlotCheckId());
final EditText editTextSmsMobiles = view1.findViewById(R.id.editTextSmsMobiles); final EditText editTextSmsMobiles = view1.findViewById(R.id.editTextSmsMobiles);
if (smsSettingVo != null) editTextSmsMobiles.setText(smsSettingVo.getMobiles()); if (smsSettingVo != null) editTextSmsMobiles.setText(smsSettingVo.getMobiles());
final Switch switchSmsOnlyNoNetwork = view1.findViewById(R.id.switchSmsOnlyNoNetwork); @SuppressLint("UseSwitchCompatOrMaterialCode") final Switch switchSmsOnlyNoNetwork = view1.findViewById(R.id.switchSmsOnlyNoNetwork);
if (smsSettingVo != null) switchSmsOnlyNoNetwork.setChecked(smsSettingVo.getOnlyNoNetwork()); if (smsSettingVo != null) switchSmsOnlyNoNetwork.setChecked(smsSettingVo.getOnlyNoNetwork());
Button buttonSmsOk = view1.findViewById(R.id.buttonSmsOk); Button buttonSmsOk = view1.findViewById(R.id.buttonSmsOk);
@ -1119,9 +1031,7 @@ public class SenderActivity extends AppCompatActivity {
.create(); .create();
final AlertDialog show = alertDialog71.show(); final AlertDialog show = alertDialog71.show();
buttonSmsOk.setOnClickListener(new View.OnClickListener() { buttonSmsOk.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel == null) { if (senderModel == null) {
SenderModel newSenderModel = new SenderModel(); SenderModel newSenderModel = new SenderModel();
@ -1154,29 +1064,23 @@ public class SenderActivity extends AppCompatActivity {
show.dismiss(); show.dismiss();
}
}); });
buttonSmsDel.setOnClickListener(new View.OnClickListener() { buttonSmsDel.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel != null) { if (senderModel != null) {
SenderUtil.delSender(senderModel.getId()); SenderUtil.delSender(senderModel.getId());
initSenders(); initSenders();
adapter.del(senderModels); adapter.del(senderModels);
} }
show.dismiss(); show.dismiss();
}
}); });
buttonSmsTest.setOnClickListener(new View.OnClickListener() { buttonSmsTest.setOnClickListener(view -> {
@Override
public void onClick(View view) {
int simSlot = 0; int simSlot = 0;
if (R.id.btnSmsSimSlot2 == radioGroupSmsSimSlot.getCheckedRadioButtonId()) { if (R.id.btnSmsSimSlot2 == radioGroupSmsSimSlot.getCheckedRadioButtonId()) {
simSlot = 1; simSlot = 1;
} }
String mobiles = editTextSmsMobiles.getText().toString(); String mobiles = editTextSmsMobiles.getText().toString();
Boolean onlyNoNetwork = switchSmsOnlyNoNetwork.isChecked(); Boolean onlyNoNetwork = switchSmsOnlyNoNetwork.isChecked();
if (!mobiles.isEmpty() && !mobiles.isEmpty()) { if (!mobiles.isEmpty()) {
try { try {
SenderSmsMsg.sendMsg(0, handler, simSlot, mobiles, onlyNoNetwork, "19999999999", "【京东】验证码为387481切勿将验证码告知他人请在页面中输入完成验证如有问题请点击 ihelp.jd.com 联系京东客服"); SenderSmsMsg.sendMsg(0, handler, simSlot, mobiles, onlyNoNetwork, "19999999999", "【京东】验证码为387481切勿将验证码告知他人请在页面中输入完成验证如有问题请点击 ihelp.jd.com 联系京东客服");
} catch (Exception e) { } catch (Exception e) {
@ -1186,11 +1090,11 @@ public class SenderActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(SenderActivity.this, "接收手机号不能为空", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "接收手机号不能为空", Toast.LENGTH_LONG).show();
} }
}
}); });
} }
//飞书机器人 //飞书机器人
@SuppressLint("SimpleDateFormat")
private void setFeiShu(final SenderModel senderModel) { private void setFeiShu(final SenderModel senderModel) {
FeiShuSettingVo feiShuSettingVo = null; FeiShuSettingVo feiShuSettingVo = null;
//try phrase json setting //try phrase json setting
@ -1213,28 +1117,26 @@ public class SenderActivity extends AppCompatActivity {
if (feiShuSettingVo != null) if (feiShuSettingVo != null)
editTextFeishuSecret.setText(feiShuSettingVo.getSecret()); editTextFeishuSecret.setText(feiShuSettingVo.getSecret());
Button buttonfeishuok = view1.findViewById(R.id.buttonfeishuok); Button buttonFeishuOk = view1.findViewById(R.id.buttonFeishuOk);
Button buttonfeishudel = view1.findViewById(R.id.buttonfeishudel); Button buttonFeishuDel = view1.findViewById(R.id.buttonFeishuDel);
Button buttonfeishutest = view1.findViewById(R.id.buttonfeishutest); Button buttonFeishuTest = view1.findViewById(R.id.buttonFeishuTest);
alertDialog71 alertDialog71
.setTitle(R.string.setfeishutitle) .setTitle(R.string.setfeishutitle)
.setIcon(R.mipmap.feishu) .setIcon(R.mipmap.feishu)
.setView(view1) .setView(view1)
.create(); .create();
final AlertDialog show = alertDialog71.show(); final AlertDialog show = alertDialog71.show();
buttonfeishuok.setOnClickListener(new View.OnClickListener() { buttonFeishuOk.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel == null) { if (senderModel == null) {
SenderModel newSenderModel = new SenderModel(); SenderModel newSenderModel = new SenderModel();
newSenderModel.setName(editTextFeishuName.getText().toString()); newSenderModel.setName(editTextFeishuName.getText().toString());
newSenderModel.setType(TYPE_FEISHU); newSenderModel.setType(TYPE_FEISHU);
newSenderModel.setStatus(STATUS_ON); newSenderModel.setStatus(STATUS_ON);
FeiShuSettingVo feiShuSettingVonew = new FeiShuSettingVo( FeiShuSettingVo feiShuSettingVoNew = new FeiShuSettingVo(
editTextFeishuWebhook.getText().toString(), editTextFeishuWebhook.getText().toString(),
editTextFeishuSecret.getText().toString()); editTextFeishuSecret.getText().toString());
newSenderModel.setJsonSetting(JSON.toJSONString(feiShuSettingVonew)); newSenderModel.setJsonSetting(JSON.toJSONString(feiShuSettingVoNew));
SenderUtil.addSender(newSenderModel); SenderUtil.addSender(newSenderModel);
initSenders(); initSenders();
adapter.add(senderModels); adapter.add(senderModels);
@ -1242,36 +1144,30 @@ public class SenderActivity extends AppCompatActivity {
senderModel.setName(editTextFeishuName.getText().toString()); senderModel.setName(editTextFeishuName.getText().toString());
senderModel.setType(TYPE_FEISHU); senderModel.setType(TYPE_FEISHU);
senderModel.setStatus(STATUS_ON); senderModel.setStatus(STATUS_ON);
FeiShuSettingVo feiShuSettingVonew = new FeiShuSettingVo( FeiShuSettingVo feiShuSettingVoNew = new FeiShuSettingVo(
editTextFeishuWebhook.getText().toString(), editTextFeishuWebhook.getText().toString(),
editTextFeishuSecret.getText().toString()); editTextFeishuSecret.getText().toString());
senderModel.setJsonSetting(JSON.toJSONString(feiShuSettingVonew)); senderModel.setJsonSetting(JSON.toJSONString(feiShuSettingVoNew));
SenderUtil.updateSender(senderModel); SenderUtil.updateSender(senderModel);
initSenders(); initSenders();
adapter.update(senderModels); adapter.update(senderModels);
} }
show.dismiss(); show.dismiss();
}
}); });
buttonfeishudel.setOnClickListener(new View.OnClickListener() { buttonFeishuDel.setOnClickListener(view -> {
@Override
public void onClick(View view) {
if (senderModel != null) { if (senderModel != null) {
SenderUtil.delSender(senderModel.getId()); SenderUtil.delSender(senderModel.getId());
initSenders(); initSenders();
adapter.del(senderModels); adapter.del(senderModels);
} }
show.dismiss(); show.dismiss();
}
}); });
buttonfeishutest.setOnClickListener(new View.OnClickListener() { buttonFeishuTest.setOnClickListener(view -> {
@Override
public void onClick(View view) {
String token = editTextFeishuWebhook.getText().toString(); String token = editTextFeishuWebhook.getText().toString();
String secret = editTextFeishuSecret.getText().toString(); String secret = editTextFeishuSecret.getText().toString();
if (token != null && !token.isEmpty()) { if (!token.isEmpty()) {
try { try {
SenderFeishuMsg.sendMsg(0, handler, token, secret, "测试内容(content)@" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))); SenderFeishuMsg.sendMsg(0, handler, token, secret, "测试内容(content)@" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
} catch (Exception e) { } catch (Exception e) {
@ -1281,7 +1177,6 @@ public class SenderActivity extends AppCompatActivity {
} else { } else {
Toast.makeText(SenderActivity.this, "token 不能为空", Toast.LENGTH_LONG).show(); Toast.makeText(SenderActivity.this, "token 不能为空", Toast.LENGTH_LONG).show();
} }
}
}); });
} }

View File

@ -1,11 +1,11 @@
package com.idormy.sms.forwarder; package com.idormy.sms.forwarder;
import android.annotation.SuppressLint;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.CompoundButton;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Switch; import android.widget.Switch;
@ -18,61 +18,58 @@ import com.idormy.sms.forwarder.utils.SettingUtil;
public class SettingActivity extends AppCompatActivity { public class SettingActivity extends AppCompatActivity {
private String TAG = "SettingActivity"; private final String TAG = "SettingActivity";
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "oncreate"); Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting); setContentView(R.layout.activity_setting);
Switch switch_add_extra = (Switch) findViewById(R.id.switch_add_extra); @SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_add_extra = findViewById(R.id.switch_add_extra);
switchAddExtra(switch_add_extra); switchAddExtra(switch_add_extra);
EditText et_add_extra_device_mark = (EditText) findViewById(R.id.et_add_extra_device_mark); EditText et_add_extra_device_mark = findViewById(R.id.et_add_extra_device_mark);
editAddExtraDeviceMark(et_add_extra_device_mark); editAddExtraDeviceMark(et_add_extra_device_mark);
EditText et_add_extra_sim1 = (EditText) findViewById(R.id.et_add_extra_sim1); EditText et_add_extra_sim1 = findViewById(R.id.et_add_extra_sim1);
editAddExtraSim1(et_add_extra_sim1); editAddExtraSim1(et_add_extra_sim1);
EditText et_add_extra_sim2 = (EditText) 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 = (EditText) findViewById(R.id.et_battery_level_alarm); EditText et_battery_level_alarm = findViewById(R.id.et_battery_level_alarm);
editBatteryLevelAlarm(et_battery_level_alarm); editBatteryLevelAlarm(et_battery_level_alarm);
EditText et_retry_delay_time1 = (EditText) 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);
EditText et_retry_delay_time2 = (EditText) findViewById(R.id.et_retry_delay_time2); EditText et_retry_delay_time2 = findViewById(R.id.et_retry_delay_time2);
editRetryDelayTime(et_retry_delay_time2, 2); editRetryDelayTime(et_retry_delay_time2, 2);
EditText et_retry_delay_time3 = (EditText) findViewById(R.id.et_retry_delay_time3); EditText et_retry_delay_time3 = findViewById(R.id.et_retry_delay_time3);
editRetryDelayTime(et_retry_delay_time3, 3); editRetryDelayTime(et_retry_delay_time3, 3);
EditText et_retry_delay_time4 = (EditText) findViewById(R.id.et_retry_delay_time4); EditText et_retry_delay_time4 = findViewById(R.id.et_retry_delay_time4);
editRetryDelayTime(et_retry_delay_time4, 4); editRetryDelayTime(et_retry_delay_time4, 4);
EditText et_retry_delay_time5 = (EditText) findViewById(R.id.et_retry_delay_time5); EditText et_retry_delay_time5 = findViewById(R.id.et_retry_delay_time5);
editRetryDelayTime(et_retry_delay_time5, 5); editRetryDelayTime(et_retry_delay_time5, 5);
Switch switch_sms_template = (Switch) findViewById(R.id.switch_sms_template); @SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_sms_template = findViewById(R.id.switch_sms_template);
switchSmsTemplate(switch_sms_template); switchSmsTemplate(switch_sms_template);
EditText textSmsTemplate = (EditText) findViewById(R.id.text_sms_template); EditText textSmsTemplate = findViewById(R.id.text_sms_template);
editSmsTemplate(textSmsTemplate); editSmsTemplate(textSmsTemplate);
} }
//设置转发附加信息 //设置转发附加信息
private void switchAddExtra(Switch switch_add_extra) { private void switchAddExtra(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_add_extra) {
switch_add_extra.setChecked(SettingUtil.getSwitchAddExtra()); switch_add_extra.setChecked(SettingUtil.getSwitchAddExtra());
switch_add_extra.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() { switch_add_extra.setOnCheckedChangeListener((buttonView, isChecked) -> {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SettingUtil.switchAddExtra(isChecked); SettingUtil.switchAddExtra(isChecked);
Log.d(TAG, "onCheckedChanged:" + isChecked); Log.d(TAG, "onCheckedChanged:" + isChecked);
}
}); });
} }
//设置转发附加信息devicemark //设置转发附加信息deviceMark
private void editAddExtraDeviceMark(final EditText et_add_extra_device_mark) { private void editAddExtraDeviceMark(final EditText et_add_extra_device_mark) {
et_add_extra_device_mark.setText(SettingUtil.getAddExtraDeviceMark()); et_add_extra_device_mark.setText(SettingUtil.getAddExtraDeviceMark());
@ -94,7 +91,7 @@ public class SettingActivity extends AppCompatActivity {
}); });
} }
//设置转发附加信息devicemark //设置转发附加信息deviceMark
private void editAddExtraSim1(final EditText et_add_extra_sim1) { private void editAddExtraSim1(final EditText et_add_extra_sim1) {
et_add_extra_sim1.setText(SettingUtil.getAddExtraSim1()); et_add_extra_sim1.setText(SettingUtil.getAddExtraSim1());
@ -116,7 +113,7 @@ public class SettingActivity extends AppCompatActivity {
}); });
} }
//设置转发附加信息devicemark //设置转发附加信息deviceMark
private void editAddExtraSim2(final EditText et_add_extra_sim2) { private void editAddExtraSim2(final EditText et_add_extra_sim2) {
et_add_extra_sim2.setText(SettingUtil.getAddExtraSim2()); et_add_extra_sim2.setText(SettingUtil.getAddExtraSim2());
@ -180,28 +177,25 @@ public class SettingActivity extends AppCompatActivity {
} }
//设置转发时启用自定义模版 //设置转发时启用自定义模版
private void switchSmsTemplate(Switch switch_sms_template) { private void switchSmsTemplate(@SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_sms_template) {
boolean isOn = SettingUtil.getSwitchSmsTemplate(); boolean isOn = SettingUtil.getSwitchSmsTemplate();
switch_sms_template.setChecked(isOn); switch_sms_template.setChecked(isOn);
final LinearLayout layout_sms_template = (LinearLayout) findViewById(R.id.layout_sms_template); final LinearLayout layout_sms_template = findViewById(R.id.layout_sms_template);
layout_sms_template.setVisibility(isOn ? View.VISIBLE : View.GONE); layout_sms_template.setVisibility(isOn ? View.VISIBLE : View.GONE);
final EditText textSmsTemplate = (EditText) findViewById(R.id.text_sms_template); final EditText textSmsTemplate = findViewById(R.id.text_sms_template);
switch_sms_template.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() { switch_sms_template.setOnCheckedChangeListener((buttonView, isChecked) -> {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Log.d(TAG, "onCheckedChanged:" + isChecked); Log.d(TAG, "onCheckedChanged:" + isChecked);
layout_sms_template.setVisibility(isChecked ? View.VISIBLE : View.GONE); layout_sms_template.setVisibility(isChecked ? View.VISIBLE : View.GONE);
SettingUtil.switchSmsTemplate(isChecked); SettingUtil.switchSmsTemplate(isChecked);
if (!isChecked) { if (!isChecked) {
textSmsTemplate.setText("{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}"); textSmsTemplate.setText("{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}");
} }
}
}); });
} }
//设置转发附加信息devicemark //设置转发附加信息deviceMark
private void editSmsTemplate(final EditText textSmsTemplate) { private void editSmsTemplate(final EditText textSmsTemplate) {
textSmsTemplate.setText(SettingUtil.getSmsTemplate()); textSmsTemplate.setText(SettingUtil.getSmsTemplate());
@ -224,17 +218,15 @@ public class SettingActivity extends AppCompatActivity {
} }
//插入标签 //插入标签
@SuppressLint("NonConstantResourceId")
public void toInsertLabel(View v) { public void toInsertLabel(View v) {
EditText textSmsTemplate = (EditText) findViewById(R.id.text_sms_template); EditText textSmsTemplate = findViewById(R.id.text_sms_template);
textSmsTemplate.setFocusable(true); textSmsTemplate.setFocusable(true);
textSmsTemplate.requestFocus(); textSmsTemplate.requestFocus();
switch (v.getId()) { switch (v.getId()) {
case R.id.bt_insert_sender: case R.id.bt_insert_sender:
textSmsTemplate.append("{{来源号码}}"); textSmsTemplate.append("{{来源号码}}");
return; return;
/*case R.id.bt_insert_receiver:
textSmsTemplate.append("{{接收号码}}");
return;*/
case R.id.bt_insert_content: case R.id.bt_insert_content:
textSmsTemplate.append("{{短信内容}}"); textSmsTemplate.append("{{短信内容}}");
return; return;
@ -248,33 +240,32 @@ public class SettingActivity extends AppCompatActivity {
textSmsTemplate.append("{{设备名称}}"); textSmsTemplate.append("{{设备名称}}");
return; return;
default: default:
return;
} }
} }
//恢复初始化配置 //恢复初始化配置
public void initSetting(View v) { public void initSetting(View view) {
Switch switch_add_extra = (Switch) findViewById(R.id.switch_add_extra); @SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_add_extra = findViewById(R.id.switch_add_extra);
switch_add_extra.setChecked(false); switch_add_extra.setChecked(false);
switchAddExtra(switch_add_extra); switchAddExtra(switch_add_extra);
EditText et_add_extra_device_mark = (EditText) findViewById(R.id.et_add_extra_device_mark); EditText et_add_extra_device_mark = findViewById(R.id.et_add_extra_device_mark);
et_add_extra_device_mark.setText(""); et_add_extra_device_mark.setText("");
editAddExtraDeviceMark(et_add_extra_device_mark); editAddExtraDeviceMark(et_add_extra_device_mark);
EditText et_add_extra_sim1 = (EditText) findViewById(R.id.et_add_extra_sim1); EditText et_add_extra_sim1 = findViewById(R.id.et_add_extra_sim1);
et_add_extra_sim1.setText(""); et_add_extra_sim1.setText("");
editAddExtraSim1(et_add_extra_sim1); editAddExtraSim1(et_add_extra_sim1);
EditText et_add_extra_sim2 = (EditText) findViewById(R.id.et_add_extra_sim2); EditText et_add_extra_sim2 = findViewById(R.id.et_add_extra_sim2);
et_add_extra_sim2.setText(""); et_add_extra_sim2.setText("");
editAddExtraSim2(et_add_extra_sim2); editAddExtraSim2(et_add_extra_sim2);
Switch switch_sms_template = (Switch) findViewById(R.id.switch_sms_template); @SuppressLint("UseSwitchCompatOrMaterialCode") Switch switch_sms_template = findViewById(R.id.switch_sms_template);
switch_sms_template.setChecked(false); switch_sms_template.setChecked(false);
switchSmsTemplate(switch_sms_template); switchSmsTemplate(switch_sms_template);
EditText textSmsTemplate = (EditText) findViewById(R.id.text_sms_template); EditText textSmsTemplate = findViewById(R.id.text_sms_template);
textSmsTemplate.setText("{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}"); textSmsTemplate.setText("{{来源号码}}\n{{短信内容}}\n{{卡槽信息}}\n{{接收时间}}\n{{设备名称}}");
editSmsTemplate(textSmsTemplate); editSmsTemplate(textSmsTemplate);

View File

@ -1,7 +1,6 @@
package com.idormy.sms.forwarder.adapter; package com.idormy.sms.forwarder.adapter;
import android.content.Context; import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -15,8 +14,9 @@ import com.idormy.sms.forwarder.utils.aUtil;
import java.util.List; import java.util.List;
@SuppressWarnings("unused")
public class LogAdapter extends ArrayAdapter<LogVo> { public class LogAdapter extends ArrayAdapter<LogVo> {
private int resourceId; private final int resourceId;
private List<LogVo> list; private List<LogVo> list;
// 适配器的构造函数把要适配的数据传入这里 // 适配器的构造函数把要适配的数据传入这里
@ -112,7 +112,7 @@ public class LogAdapter extends ArrayAdapter<LogVo> {
} }
// 定义一个内部类用于对控件的实例进行缓存 // 定义一个内部类用于对控件的实例进行缓存
class ViewHolder { static class ViewHolder {
TextView tLogFrom; TextView tLogFrom;
TextView tLogContent; TextView tLogContent;
TextView tLogRule; TextView tLogRule;

View File

@ -16,7 +16,7 @@ import com.idormy.sms.forwarder.sender.SenderUtil;
import java.util.List; import java.util.List;
public class RuleAdapter extends ArrayAdapter<RuleModel> { public class RuleAdapter extends ArrayAdapter<RuleModel> {
private int resourceId; private final int resourceId;
private List<RuleModel> list; private List<RuleModel> list;
// 适配器的构造函数把要适配的数据传入这里 // 适配器的构造函数把要适配的数据传入这里
@ -108,7 +108,7 @@ public class RuleAdapter extends ArrayAdapter<RuleModel> {
} }
// 定义一个内部类用于对控件的实例进行缓存 // 定义一个内部类用于对控件的实例进行缓存
class ViewHolder { static class ViewHolder {
TextView ruleMatch; TextView ruleMatch;
TextView ruleSender; TextView ruleSender;
ImageView ruleSenderImage; ImageView ruleSenderImage;

View File

@ -13,8 +13,9 @@ import com.idormy.sms.forwarder.model.SenderModel;
import java.util.List; import java.util.List;
@SuppressWarnings("unused")
public class SenderAdapter extends ArrayAdapter<SenderModel> { public class SenderAdapter extends ArrayAdapter<SenderModel> {
private int resourceId; private final int resourceId;
private List<SenderModel> list; private List<SenderModel> list;
// 适配器的构造函数把要适配的数据传入这里 // 适配器的构造函数把要适配的数据传入这里
@ -120,7 +121,7 @@ public class SenderAdapter extends ArrayAdapter<SenderModel> {
} }
// 定义一个内部类用于对控件的实例进行缓存 // 定义一个内部类用于对控件的实例进行缓存
class ViewHolder { static class ViewHolder {
ImageView senderImage; ImageView senderImage;
TextView senderName; TextView senderName;
} }

View File

@ -1,5 +1,7 @@
package com.idormy.sms.forwarder.model; package com.idormy.sms.forwarder.model;
import androidx.annotation.NonNull;
import lombok.Data; import lombok.Data;
@Data @Data
@ -17,6 +19,7 @@ public class LogModel {
this.ruleId = ruleId; this.ruleId = ruleId;
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return "LogModel{" + return "LogModel{" +

View File

@ -0,0 +1,14 @@
package com.idormy.sms.forwarder.model;
import lombok.Data;
@Data
public class PhoneBookEntity {
private String name;
private String phoneNumber;
public PhoneBookEntity(String name, String phoneNumber) {
this.name = name;
this.phoneNumber = phoneNumber;
}
}

View File

@ -1,7 +1,10 @@
package com.idormy.sms.forwarder.model; package com.idormy.sms.forwarder.model;
import android.annotation.SuppressLint;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
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.model.vo.SmsVo;
import com.idormy.sms.forwarder.utils.RuleLineUtils; import com.idormy.sms.forwarder.utils.RuleLineUtils;
@ -14,13 +17,14 @@ import java.util.regex.PatternSyntaxException;
import lombok.Data; import lombok.Data;
@SuppressWarnings({"unused", "LoopStatementThatDoesntLoop"})
@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";
public static final String FILED_PHONE_NUM = "phone_num"; public static final String FILED_PHONE_NUM = "phone_num";
public static final String FILED_MSG_CONTENT = "msg_content"; public static final String FILED_MSG_CONTENT = "msg_content";
public static final String FILED_MULTI_MATCH = "multi_match"; public static final String FILED_MULTI_MATCH = "multi_match";
public static final Map<String, String> FILED_MAP = new HashMap<String, String>(); public static final Map<String, String> FILED_MAP = new HashMap<>();
public static final String CHECK_IS = "is"; public static final String CHECK_IS = "is";
public static final String CHECK_CONTAIN = "contain"; public static final String CHECK_CONTAIN = "contain";
public static final String CHECK_NOT_CONTAIN = "notcontain"; public static final String CHECK_NOT_CONTAIN = "notcontain";
@ -28,11 +32,11 @@ public class RuleModel {
public static final String CHECK_END_WITH = "endwith"; public static final String CHECK_END_WITH = "endwith";
public static final String CHECK_NOT_IS = "notis"; public static final String CHECK_NOT_IS = "notis";
public static final String CHECK_REGEX = "regex"; public static final String CHECK_REGEX = "regex";
public static final Map<String, String> CHECK_MAP = new HashMap<String, String>(); public static final Map<String, String> CHECK_MAP = new HashMap<>();
public static final String CHECK_SIM_SLOT_ALL = "ALL"; public static final String CHECK_SIM_SLOT_ALL = "ALL";
public static final String CHECK_SIM_SLOT_1 = "SIM1"; public static final String CHECK_SIM_SLOT_1 = "SIM1";
public static final String CHECK_SIM_SLOT_2 = "SIM2"; public static final String CHECK_SIM_SLOT_2 = "SIM2";
public static final Map<String, String> SIM_SLOT_MAP = new HashMap<String, String>(); public static final Map<String, String> SIM_SLOT_MAP = new HashMap<>();
static { static {
FILED_MAP.put("transpond_all", "全部转发"); FILED_MAP.put("transpond_all", "全部转发");
@ -75,6 +79,7 @@ public class RuleModel {
} }
} }
@SuppressLint("NonConstantResourceId")
public static String getRuleFiledFromCheckId(int id) { public static String getRuleFiledFromCheckId(int id) {
switch (id) { switch (id) {
case R.id.btnContent: case R.id.btnContent:
@ -88,6 +93,7 @@ public class RuleModel {
} }
} }
@SuppressLint("NonConstantResourceId")
public static String getRuleCheckFromCheckId(int id) { public static String getRuleCheckFromCheckId(int id) {
switch (id) { switch (id) {
case R.id.btnContain: case R.id.btnContain:
@ -105,6 +111,7 @@ public class RuleModel {
} }
} }
@SuppressLint("NonConstantResourceId")
public static String getRuleSimSlotFromCheckId(int id) { public static String getRuleSimSlotFromCheckId(int id) {
switch (id) { switch (id) {
case R.id.btnSimSlot1: case R.id.btnSimSlot1:
@ -191,7 +198,6 @@ public class RuleModel {
break; break;
} }
} catch (PatternSyntaxException e) { } catch (PatternSyntaxException e) {
checked = false;
Log.d(TAG, "PatternSyntaxException: "); Log.d(TAG, "PatternSyntaxException: ");
Log.d(TAG, "Description: " + e.getDescription()); Log.d(TAG, "Description: " + e.getDescription());
Log.d(TAG, "Index: " + e.getIndex()); Log.d(TAG, "Index: " + e.getIndex());
@ -265,6 +271,7 @@ public class RuleModel {
} }
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return "RuleModel{" + return "RuleModel{" +

View File

@ -1,9 +1,12 @@
package com.idormy.sms.forwarder.model; package com.idormy.sms.forwarder.model;
import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.R; import com.idormy.sms.forwarder.R;
import lombok.Data; import lombok.Data;
@SuppressWarnings("unused")
@Data @Data
public class SenderModel { public class SenderModel {
public static final int STATUS_ON = 1; public static final int STATUS_ON = 1;
@ -98,6 +101,7 @@ public class SenderModel {
} }
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return "SenderModel{" + return "SenderModel{" +

View File

@ -8,9 +8,6 @@ import lombok.Data;
public class BarkSettingVo implements Serializable { public class BarkSettingVo implements Serializable {
private String server; private String server;
public BarkSettingVo() {
}
public BarkSettingVo(String server) { public BarkSettingVo(String server) {
this.server = server; this.server = server;
} }

View File

@ -8,16 +8,13 @@ import lombok.Data;
public class DingDingSettingVo implements Serializable { public class DingDingSettingVo implements Serializable {
private String token; private String token;
private String secret; private String secret;
private String atMobils; private String atMobiles;
private Boolean atAll; private Boolean atAll;
public DingDingSettingVo() { public DingDingSettingVo(String token, String secret, String atMobiles, Boolean atAll) {
}
public DingDingSettingVo(String token, String secret, String atMobils, Boolean atAll) {
this.token = token; this.token = token;
this.secret = secret; this.secret = secret;
this.atMobils = atMobils; this.atMobiles = atMobiles;
this.atAll = atAll; this.atAll = atAll;
} }
} }

View File

@ -8,15 +8,12 @@ import lombok.Data;
public class EmailSettingVo implements Serializable { public class EmailSettingVo implements Serializable {
private String host; private String host;
private String port; private String port;
private Boolean ssl = true; private Boolean ssl;
private String fromEmail; private String fromEmail;
private String nickname; private String nickname;
private String pwd; private String pwd;
private String toEmail; private String toEmail;
public EmailSettingVo() {
}
public EmailSettingVo(String host, String port, Boolean ssl, String fromEmail, String nickname, String pwd, String toEmail) { public EmailSettingVo(String host, String port, Boolean ssl, String fromEmail, String nickname, String pwd, String toEmail) {
this.host = host; this.host = host;
this.port = port; this.port = port;

View File

@ -9,9 +9,6 @@ public class FeiShuSettingVo implements Serializable {
private String webhook; private String webhook;
private String secret; private String secret;
public FeiShuSettingVo() {
}
public FeiShuSettingVo(String webhook, String secret) { public FeiShuSettingVo(String webhook, String secret) {
this.webhook = webhook; this.webhook = webhook;
this.secret = secret; this.secret = secret;

View File

@ -16,9 +16,6 @@ public class LogVo {
private int forwardStatus; private int forwardStatus;
private String forwardResponse; private String forwardResponse;
public LogVo() {
}
public LogVo(Long id, String from, String content, String simInfo, String time, String rule, int senderImageId, int forwardStatus, String forwardResponse) { public LogVo(Long id, String from, String content, String simInfo, String time, String rule, int senderImageId, int forwardStatus, String forwardResponse) {
this.id = id; this.id = id;
this.from = from; this.from = from;
@ -33,7 +30,7 @@ public class LogVo {
public int getSimImageId() { public int getSimImageId() {
if (this.simInfo != null && !this.simInfo.isEmpty() if (this.simInfo != null && !this.simInfo.isEmpty()
&& this.simInfo.replace("-", "").substring(0, 4).equals("SIM2")) { && this.simInfo.replace("-", "").startsWith("SIM2")) {
return R.mipmap.sim2; return R.mipmap.sim2;
} }

View File

@ -12,9 +12,6 @@ public class QYWXAppSettingVo implements Serializable {
private String toUser; private String toUser;
private Boolean atAll; private Boolean atAll;
public QYWXAppSettingVo() {
}
public QYWXAppSettingVo(String corpID, String agentID, String secret, String toUser, Boolean atAll) { public QYWXAppSettingVo(String corpID, String agentID, String secret, String toUser, Boolean atAll) {
this.corpID = corpID; this.corpID = corpID;
this.agentID = agentID; this.agentID = agentID;

View File

@ -8,9 +8,6 @@ import lombok.Data;
public class QYWXGroupRobotSettingVo implements Serializable { public class QYWXGroupRobotSettingVo implements Serializable {
private String webHook; private String webHook;
public QYWXGroupRobotSettingVo() {
}
public QYWXGroupRobotSettingVo(String webHook) { public QYWXGroupRobotSettingVo(String webHook) {
this.webHook = webHook; this.webHook = webHook;
} }

View File

@ -1,5 +1,8 @@
package com.idormy.sms.forwarder.model.vo; package com.idormy.sms.forwarder.model.vo;
import lombok.Data;
@Data
public class RuleVo { public class RuleVo {
private String matchStr; private String matchStr;
private String senderStr; private String senderStr;

View File

@ -8,9 +8,6 @@ import lombok.Data;
public class ServerChanSettingVo implements Serializable { public class ServerChanSettingVo implements Serializable {
private String sendKey; private String sendKey;
public ServerChanSettingVo() {
}
public ServerChanSettingVo(String sendKey) { public ServerChanSettingVo(String sendKey) {
this.sendKey = sendKey; this.sendKey = sendKey;
} }

View File

@ -12,9 +12,6 @@ public class SmsSettingVo implements Serializable {
private String mobiles; private String mobiles;
private Boolean onlyNoNetwork; private Boolean onlyNoNetwork;
public SmsSettingVo() {
}
public SmsSettingVo(int simSlot, String mobiles, Boolean onlyNoNetwork) { public SmsSettingVo(int simSlot, String mobiles, Boolean onlyNoNetwork) {
this.simSlot = simSlot; this.simSlot = simSlot;
this.mobiles = mobiles; this.mobiles = mobiles;

View File

@ -1,5 +1,9 @@
package com.idormy.sms.forwarder.model.vo; package com.idormy.sms.forwarder.model.vo;
import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtil;
import java.io.Serializable; import java.io.Serializable;
@ -13,10 +17,7 @@ public class SmsVo implements Serializable {
String mobile; String mobile;
String content; String content;
Date date; Date date;
String simInfo = "SIM1_unknown_unknown"; String simInfo;
public SmsVo() {
}
public SmsVo(String mobile, String content, Date date, String simInfo) { public SmsVo(String mobile, String content, Date date, String simInfo) {
this.mobile = mobile; this.mobile = mobile;
@ -25,6 +26,7 @@ public class SmsVo implements Serializable {
this.simInfo = simInfo; this.simInfo = simInfo;
} }
@SuppressLint("SimpleDateFormat")
public String getSmsVoForSend() { public String getSmsVoForSend() {
boolean switchAddExtra = SettingUtil.getSwitchAddExtra(); boolean switchAddExtra = SettingUtil.getSwitchAddExtra();
boolean switchSmsTemplate = SettingUtil.getSwitchSmsTemplate(); boolean switchSmsTemplate = SettingUtil.getSwitchSmsTemplate();
@ -46,6 +48,7 @@ public class SmsVo implements Serializable {
.trim(); .trim();
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return "SmsVo{" + return "SmsVo{" +

View File

@ -9,9 +9,6 @@ public class TelegramSettingVo implements Serializable {
private String apiToken; private String apiToken;
private String chatId; private String chatId;
public TelegramSettingVo() {
}
public TelegramSettingVo(String apiToken, String chatId) { public TelegramSettingVo(String apiToken, String chatId) {
this.apiToken = apiToken; this.apiToken = apiToken;
this.chatId = chatId; this.chatId = chatId;

View File

@ -13,9 +13,6 @@ public class WebNotifySettingVo implements Serializable {
private String method; private String method;
private String webParams; private String webParams;
public WebNotifySettingVo() {
}
public WebNotifySettingVo(String webServer, String secret, String method, String webParams) { public WebNotifySettingVo(String webServer, String secret, String method, String webParams) {
this.webServer = webServer; this.webServer = webServer;
this.secret = secret; this.secret = secret;

View File

@ -0,0 +1,66 @@
package com.idormy.sms.forwarder.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import com.idormy.sms.forwarder.R;
import com.idormy.sms.forwarder.model.PhoneBookEntity;
import com.idormy.sms.forwarder.model.vo.SmsVo;
import com.idormy.sms.forwarder.sender.SendUtil;
import com.idormy.sms.forwarder.utils.ContactHelper;
import com.idormy.sms.forwarder.utils.SettingUtil;
import java.util.Date;
import java.util.List;
public class PhoneStateReceiver extends BroadcastReceiver {
private TelephonyManager mTelephonyManager;
@Override
public void onReceive(Context context, Intent intent) {
if (!SettingUtil.getSwitchEnablePhone()) {
return;
}
String action = intent.getAction();
if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
String phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
if (mTelephonyManager == null) {
mTelephonyManager =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
}
int state = mTelephonyManager.getCallState();
Log.d("PhoneStateReceiver", "onReceive state=" + state + " phoneNumber = " + phoneNumber);
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
if (!TextUtils.isEmpty(phoneNumber)) {
sendReceiveCallMsg(context, phoneNumber);
}
break;
case TelephonyManager.CALL_STATE_IDLE:
case TelephonyManager.CALL_STATE_OFFHOOK:
break;
}
}
}
private void sendReceiveCallMsg(Context context, String phoneNumber) {
List<PhoneBookEntity> contacts = ContactHelper.getInstance().getContactByNumber(context, phoneNumber);
String name = "";
if (contacts != null && contacts.size() > 0) {
PhoneBookEntity phoneBookEntity = contacts.get(0);
name = phoneBookEntity.getName();
}
if (TextUtils.isEmpty(name)) {
name = context.getString(R.string.unknown_number);
}
SmsVo smsVo = new SmsVo(phoneNumber, name + context.getString(R.string.calling), new Date(), name);
Log.d("PhoneStateReceiver", "send_msg" + smsVo.toString());
SendUtil.send_msg(context, smsVo, 1);
}
}

View File

@ -1,4 +1,4 @@
package com.idormy.sms.forwarder.BroadCastReceiver; package com.idormy.sms.forwarder.receiver;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
@ -10,15 +10,13 @@ import com.idormy.sms.forwarder.service.FrontService;
import com.idormy.sms.forwarder.utils.InitUtil; import com.idormy.sms.forwarder.utils.InitUtil;
public class RebootBroadcastReceiver extends BroadcastReceiver { public class RebootBroadcastReceiver extends BroadcastReceiver {
private String TAG = "RebootBroadcastReceiver";
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
String receiveAction = intent.getAction(); String receiveAction = intent.getAction();
String TAG = "RebootBroadcastReceiver";
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")) {
Log.d(TAG, "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) {
@ -26,9 +24,6 @@ public class RebootBroadcastReceiver extends BroadcastReceiver {
} else { } else {
context.startService(frontServiceIntent); context.startService(frontServiceIntent);
} }
//监控当前电量
//Intent batteryServiceIntent = new Intent(context, BatteryService.class);
//context.startService(batteryServiceIntent);
} }
} }

View File

@ -1,4 +1,4 @@
package com.idormy.sms.forwarder.BroadCastReceiver; package com.idormy.sms.forwarder.receiver;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
@ -20,14 +20,12 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
public class SmsForwarderBroadcastReceiver extends BroadcastReceiver { public class SmsForwarderBroadcastReceiver extends BroadcastReceiver {
private String TAG = "SmsForwarderBroadcastReceiver";
private int intLevel;
private int intScale;
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
String receiveAction = intent.getAction(); String receiveAction = intent.getAction();
String TAG = "SmsForwarderBroadcastReceiver";
Log.d(TAG, "onReceive intent " + receiveAction); Log.d(TAG, "onReceive intent " + receiveAction);
if ("android.provider.Telephony.SMS_RECEIVED".equals(receiveAction)) { if ("android.provider.Telephony.SMS_RECEIVED".equals(receiveAction)) {
try { try {

View File

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder.sender; package com.idormy.sms.forwarder.sender;
import android.annotation.SuppressLint;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -19,10 +20,12 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@SuppressWarnings({"SynchronizeOnNonFinalField", "unused", "MismatchedQueryAndUpdateOfCollection"})
public class SendHistory { public class SendHistory {
static String TAG = "SendHistory"; static final String TAG = "SendHistory";
static Boolean hasInit = false; static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")
static Context context; static Context context;
static DbHelper dbHelper; static DbHelper dbHelper;
static SQLiteDatabase db; static SQLiteDatabase db;
@ -37,16 +40,17 @@ public class SendHistory {
} }
} }
@SuppressLint("MutatingSharedPrefs")
public static void addHistory(String msg) { public static void addHistory(String msg) {
//不保存转发消息 //不保存转发消息
if (!SettingUtil.saveMsgHistory()) return; if (SettingUtil.saveMsgHistory()) return;
//保存 //保存
SharedPreferences sp = context.getSharedPreferences(Define.SP_MSG, Context.MODE_PRIVATE); SharedPreferences sp = context.getSharedPreferences(Define.SP_MSG, Context.MODE_PRIVATE);
Set<String> msg_set_default = new HashSet<>(); Set<String> msg_set_default = new HashSet<>();
Set<String> msg_set; Set<String> msg_set;
msg_set = sp.getStringSet(Define.SP_MSG_SET_KEY, msg_set_default); msg_set = sp.getStringSet(Define.SP_MSG_SET_KEY, msg_set_default);
Log.d(TAG, "msg_set" + msg_set.toString()); Log.d(TAG, "msg_set" + msg_set.toString());
Log.d(TAG, "msg_set" + Integer.toString(msg_set.size())); Log.d(TAG, "msg_set_size" + msg_set.size());
msg_set.add(msg); msg_set.add(msg);
sp.edit().putStringSet(Define.SP_MSG_SET_KEY, msg_set).apply(); sp.edit().putStringSet(Define.SP_MSG_SET_KEY, msg_set).apply();
} }
@ -56,16 +60,16 @@ public class SendHistory {
Set<String> msg_set = new HashSet<>(); Set<String> msg_set = new HashSet<>();
msg_set = sp.getStringSet(Define.SP_MSG_SET_KEY, msg_set); msg_set = sp.getStringSet(Define.SP_MSG_SET_KEY, msg_set);
Log.d(TAG, "msg_set.toString()" + msg_set.toString()); Log.d(TAG, "msg_set.toString()" + msg_set.toString());
String getMsg = ""; StringBuilder getMsg = new StringBuilder();
for (String str : msg_set) { for (String str : msg_set) {
getMsg += str + "\n"; getMsg.append(str).append("\n");
} }
return getMsg; return getMsg.toString();
} }
public static long addHistoryDb(LogModel logModel) { public static long addHistoryDb(LogModel logModel) {
//不保存转发消息 //不保存转发消息
if (!SettingUtil.saveMsgHistory()) return 0; if (SettingUtil.saveMsgHistory()) return 0;
// Gets the data repository in write mode // Gets the data repository in write mode
SQLiteDatabase db = dbHelper.getWritableDatabase(); SQLiteDatabase db = dbHelper.getWritableDatabase();
@ -101,7 +105,7 @@ public class SendHistory {
selectionArgList.add(key); selectionArgList.add(key);
selectionArgList.add(key); selectionArgList.add(key);
} }
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]); String[] selectionArgs = selectionArgList.toArray(new String[0]);
// Issue SQL statement. // Issue SQL statement.
return db.delete(LogTable.LogEntry.TABLE_NAME, selection, selectionArgs); return db.delete(LogTable.LogEntry.TABLE_NAME, selection, selectionArgs);
@ -134,7 +138,7 @@ public class SendHistory {
selectionArgList.add(key); selectionArgList.add(key);
selectionArgList.add(key); selectionArgList.add(key);
} }
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]); String[] selectionArgs = selectionArgList.toArray(new String[0]);
// How you want the results sorted in the resulting Cursor // How you want the results sorted in the resulting Cursor
String sortOrder = String sortOrder =
@ -161,11 +165,11 @@ public class SendHistory {
Set<String> msg_set = new HashSet<>(); Set<String> msg_set = new HashSet<>();
msg_set = sp.getStringSet(Define.SP_MSG_SET_KEY, msg_set); msg_set = sp.getStringSet(Define.SP_MSG_SET_KEY, msg_set);
Log.d(TAG, "msg_set.toString()" + msg_set.toString()); Log.d(TAG, "msg_set.toString()" + msg_set.toString());
String getMsg = ""; StringBuilder getMsg = new StringBuilder();
for (String str : msg_set) { for (String str : msg_set) {
getMsg += str + "\n"; getMsg.append(str).append("\n");
} }
return getMsg; return getMsg.toString();
} }
} }

View File

@ -37,7 +37,7 @@ import com.idormy.sms.forwarder.utils.RuleUtil;
import java.util.List; import java.util.List;
public class SendUtil { public class SendUtil {
private static String TAG = "SendUtil"; private static final String TAG = "SendUtil";
public static void send_msg_list(Context context, List<SmsVo> smsVoList, int simId) { public static void send_msg_list(Context context, List<SmsVo> smsVoList, int simId) {
Log.i(TAG, "send_msg_list size: " + smsVoList.size()); Log.i(TAG, "send_msg_list size: " + smsVoList.size());
@ -52,10 +52,10 @@ public class SendUtil {
LogUtil.init(context); LogUtil.init(context);
String key = "SIM" + simId; String key = "SIM" + simId;
List<RuleModel> rulelist = RuleUtil.getRule(null, key); List<RuleModel> ruleList = RuleUtil.getRule(null, key);
if (!rulelist.isEmpty()) { if (!ruleList.isEmpty()) {
SenderUtil.init(context); SenderUtil.init(context);
for (RuleModel ruleModel : rulelist) { for (RuleModel ruleModel : ruleList) {
//规则匹配发现需要发送 //规则匹配发现需要发送
try { try {
if (ruleModel.checkMsg(smsVo)) { if (ruleModel.checkMsg(smsVo)) {
@ -114,7 +114,7 @@ public class SendUtil {
DingDingSettingVo dingDingSettingVo = JSON.parseObject(senderModel.getJsonSetting(), DingDingSettingVo.class); DingDingSettingVo dingDingSettingVo = JSON.parseObject(senderModel.getJsonSetting(), DingDingSettingVo.class);
if (dingDingSettingVo != null) { if (dingDingSettingVo != null) {
try { try {
SenderDingdingMsg.sendMsg(logId, handError, dingDingSettingVo.getToken(), dingDingSettingVo.getSecret(), dingDingSettingVo.getAtMobils(), dingDingSettingVo.getAtAll(), smsVo.getSmsVoForSend()); SenderDingdingMsg.sendMsg(logId, handError, dingDingSettingVo.getToken(), dingDingSettingVo.getSecret(), dingDingSettingVo.getAtMobiles(), dingDingSettingVo.getAtAll(), smsVo.getSmsVoForSend());
} catch (Exception e) { } catch (Exception e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtil.updateLog(logId, 0, e.getMessage());
Log.e(TAG, "senderSendMsg: dingding error " + e.getMessage()); Log.e(TAG, "senderSendMsg: dingding error " + e.getMessage());
@ -235,7 +235,7 @@ public class SendUtil {
SmsSettingVo smsSettingVo = JSON.parseObject(senderModel.getJsonSetting(), SmsSettingVo.class); SmsSettingVo smsSettingVo = JSON.parseObject(senderModel.getJsonSetting(), SmsSettingVo.class);
if (smsSettingVo != null) { if (smsSettingVo != null) {
//仅当无网络时启用 //仅当无网络时启用
if (true == smsSettingVo.getOnlyNoNetwork() && 0 != NetUtil.getNetWorkStatus()) { if (smsSettingVo.getOnlyNoNetwork() && 0 != NetUtil.getNetWorkStatus()) {
String msg = "仅当无网络时启用,当前网络状态:" + NetUtil.getNetWorkStatus(); String msg = "仅当无网络时启用,当前网络状态:" + NetUtil.getNetWorkStatus();
LogUtil.updateLog(logId, 0, msg); LogUtil.updateLog(logId, 0, msg);
Log.d(TAG, msg); Log.d(TAG, msg);

View File

@ -3,11 +3,14 @@ package com.idormy.sms.forwarder.sender;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtil;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -20,9 +23,10 @@ import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
@SuppressWarnings("ResultOfMethodCallIgnored")
public class SenderBarkMsg extends SenderBaseMsg { public class SenderBarkMsg extends SenderBaseMsg {
static String TAG = "SenderBarkMsg"; static final String TAG = "SenderBarkMsg";
public static void sendMsg(final long logId, final Handler handError, String barkServer, String from, String content, String groupName) throws Exception { public static void sendMsg(final long logId, final Handler handError, String barkServer, String from, String content, String groupName) throws Exception {
Log.i(TAG, "sendMsg barkServer:" + barkServer + " from:" + from + " content:" + content); Log.i(TAG, "sendMsg barkServer:" + barkServer + " from:" + from + " content:" + content);
@ -61,15 +65,15 @@ public class SenderBarkMsg extends SenderBaseMsg {
Call call = client.newCall(request); Call call = client.newCall(request);
call.enqueue(new Callback() { call.enqueue(new Callback() {
@Override @Override
public void onFailure(Call call, final IOException e) { public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtil.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage()); Toast(handError, TAG, "发送失败:" + e.getMessage());
emitter.onError(new RuntimeException("请求接口异常...")); emitter.onError(new RuntimeException("请求接口异常..."));
} }
@Override @Override
public void onResponse(Call call, Response response) throws IOException { public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
final String responseStr = response.body().string(); final String responseStr = Objects.requireNonNull(response.body()).string();
Log.d(TAG, "Response" + response.code() + "" + responseStr); Log.d(TAG, "Response" + response.code() + "" + responseStr);
Toast(handError, TAG, "发送状态:" + responseStr); Toast(handError, TAG, "发送状态:" + responseStr);

View File

@ -5,16 +5,20 @@ import android.text.TextUtils;
import android.util.Base64; import android.util.Base64;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtil;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.crypto.Mac; import javax.crypto.Mac;
@ -30,9 +34,10 @@ import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
@SuppressWarnings({"ResultOfMethodCallIgnored", "rawtypes", "unchecked", "deprecation"})
public class SenderDingdingMsg extends SenderBaseMsg { public class SenderDingdingMsg extends SenderBaseMsg {
static String TAG = "SenderDingdingMsg"; static final String TAG = "SenderDingdingMsg";
public static void sendMsg(final long logId, final Handler handError, String token, String secret, String atMobiles, Boolean atAll, String content) throws Exception { public static void sendMsg(final long logId, final Handler handError, String token, String secret, String atMobiles, Boolean atAll, String content) throws Exception {
Log.i(TAG, "sendMsg token:" + token + " secret:" + secret + " atMobiles:" + atMobiles + " atAll:" + atAll + " content:" + content); Log.i(TAG, "sendMsg token:" + token + " secret:" + secret + " atMobiles:" + atMobiles + " atAll:" + atAll + " content:" + content);
@ -45,8 +50,8 @@ public class SenderDingdingMsg extends SenderBaseMsg {
Long timestamp = System.currentTimeMillis(); Long timestamp = System.currentTimeMillis();
String stringToSign = timestamp + "\n" + secret; String stringToSign = timestamp + "\n" + secret;
Mac mac = Mac.getInstance("HmacSHA256"); Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256")); mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8")); byte[] signData = mac.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8));
String sign = URLEncoder.encode(new String(Base64.encode(signData, Base64.NO_WRAP)), "UTF-8"); String sign = URLEncoder.encode(new String(Base64.encode(signData, Base64.NO_WRAP)), "UTF-8");
token += "&timestamp=" + timestamp + "&sign=" + sign; token += "&timestamp=" + timestamp + "&sign=" + sign;
Log.i(TAG, "token:" + token); Log.i(TAG, "token:" + token);
@ -103,15 +108,15 @@ public class SenderDingdingMsg extends SenderBaseMsg {
Call call = client.newCall(request); Call call = client.newCall(request);
call.enqueue(new Callback() { call.enqueue(new Callback() {
@Override @Override
public void onFailure(Call call, final IOException e) { public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtil.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage()); Toast(handError, TAG, "发送失败:" + e.getMessage());
emitter.onError(new RuntimeException("请求接口异常...")); emitter.onError(new RuntimeException("请求接口异常..."));
} }
@Override @Override
public void onResponse(Call call, Response response) throws IOException { public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
final String responseStr = response.body().string(); final String responseStr = Objects.requireNonNull(response.body()).string();
Log.d(TAG, "Response" + response.code() + "" + responseStr); Log.d(TAG, "Response" + response.code() + "" + responseStr);
Toast(handError, TAG, "发送状态:" + responseStr); Toast(handError, TAG, "发送状态:" + responseStr);

View File

@ -4,14 +4,18 @@ import android.os.Handler;
import android.util.Base64; import android.util.Base64;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtil;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.crypto.Mac; import javax.crypto.Mac;
@ -27,9 +31,10 @@ import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
@SuppressWarnings({"ResultOfMethodCallIgnored", "rawtypes", "unchecked", "deprecation"})
public class SenderFeishuMsg extends SenderBaseMsg { public class SenderFeishuMsg extends SenderBaseMsg {
static String TAG = "SenderFeishuMsg"; static final String TAG = "SenderFeishuMsg";
public static void sendMsg(final long logId, final Handler handError, String webhook, String secret, String content) throws Exception { public static void sendMsg(final long logId, final Handler handError, String webhook, String secret, String content) throws Exception {
Log.i(TAG, "sendMsg webhook:" + webhook + " secret:" + secret + " content:" + content); Log.i(TAG, "sendMsg webhook:" + webhook + " secret:" + secret + " content:" + content);
@ -45,8 +50,8 @@ public class SenderFeishuMsg extends SenderBaseMsg {
Long timestamp = System.currentTimeMillis(); Long timestamp = System.currentTimeMillis();
String stringToSign = timestamp + "\n" + secret; String stringToSign = timestamp + "\n" + secret;
Mac mac = Mac.getInstance("HmacSHA256"); Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256")); mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8")); byte[] signData = mac.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8));
String sign = URLEncoder.encode(new String(Base64.encode(signData, Base64.NO_WRAP)), "UTF-8"); String sign = URLEncoder.encode(new String(Base64.encode(signData, Base64.NO_WRAP)), "UTF-8");
textMsgMap.put("timestamp", timestamp); textMsgMap.put("timestamp", timestamp);
textMsgMap.put("sign", sign); textMsgMap.put("sign", sign);
@ -78,15 +83,15 @@ public class SenderFeishuMsg extends SenderBaseMsg {
Call call = client.newCall(request); Call call = client.newCall(request);
call.enqueue(new Callback() { call.enqueue(new Callback() {
@Override @Override
public void onFailure(Call call, final IOException e) { public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtil.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage()); Toast(handError, TAG, "发送失败:" + e.getMessage());
emitter.onError(new RuntimeException("请求接口异常...")); emitter.onError(new RuntimeException("请求接口异常..."));
} }
@Override @Override
public void onResponse(Call call, Response response) throws IOException { public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
final String responseStr = response.body().string(); final String responseStr = Objects.requireNonNull(response.body()).string();
Log.d(TAG, "Response" + response.code() + "" + responseStr); Log.d(TAG, "Response" + response.code() + "" + responseStr);
Toast(handError, TAG, "发送状态:" + responseStr); Toast(handError, TAG, "发送状态:" + responseStr);

View File

@ -14,12 +14,13 @@ import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableEmitter; import io.reactivex.rxjava3.core.ObservableEmitter;
@SuppressWarnings("ResultOfMethodCallIgnored")
public class SenderMailMsg extends SenderBaseMsg { public class SenderMailMsg extends SenderBaseMsg {
private static String TAG = "SenderMailMsg"; private static final String TAG = "SenderMailMsg";
public static void sendEmail(final long logId, final Handler handError, final String host, final String port, final boolean ssl, final String fromemail, final String nickname, final String pwd, final String toAdd, final String title, final String content) { public static void sendEmail(final long logId, final Handler handError, final String host, final String port, final boolean ssl, final String fromEmail, final String nickname, final String pwd, final String toAdd, final String title, final String content) {
Log.d(TAG, "sendEmail: host:" + host + " port:" + port + " ssl:" + ssl + " fromemail:" + fromemail + " nickname:" + nickname + " pwd:" + pwd + " toAdd:" + toAdd); Log.d(TAG, "sendEmail: host:" + host + " port:" + port + " ssl:" + ssl + " fromEmail:" + fromEmail + " nickname:" + nickname + " pwd:" + pwd + " toAdd:" + toAdd);
Observable Observable
.create((ObservableEmitter<Object> emitter) -> { .create((ObservableEmitter<Object> emitter) -> {
@ -31,7 +32,7 @@ public class SenderMailMsg extends SenderBaseMsg {
//配置发件人邮件服务器参数 //配置发件人邮件服务器参数
EmailKit.Config config = new EmailKit.Config() EmailKit.Config config = new EmailKit.Config()
.setSMTP(host, Integer.parseInt(port), ssl) //设置SMTP服务器主机地址端口和是否开启ssl .setSMTP(host, Integer.parseInt(port), ssl) //设置SMTP服务器主机地址端口和是否开启ssl
.setAccount(fromemail) //发件人邮箱 .setAccount(fromEmail) //发件人邮箱
.setPassword(pwd); //密码或授权码 .setPassword(pwd); //密码或授权码
//设置一封草稿邮件 //设置一封草稿邮件

View File

@ -7,6 +7,8 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.idormy.sms.forwarder.MyApplication; import com.idormy.sms.forwarder.MyApplication;
@ -16,6 +18,7 @@ import com.idormy.sms.forwarder.utils.SettingUtil;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import io.reactivex.rxjava3.core.Observable; import io.reactivex.rxjava3.core.Observable;
@ -28,9 +31,10 @@ import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
@SuppressWarnings({"rawtypes", "unchecked", "deprecation", "ResultOfMethodCallIgnored"})
public class SenderQyWxAppMsg extends SenderBaseMsg { public class SenderQyWxAppMsg extends SenderBaseMsg {
static String TAG = "SenderQyWxAppMsg"; static final String TAG = "SenderQyWxAppMsg";
public static void sendMsg(final long logId, final Handler handError, String corpID, String agentID, String secret, String toUser, String content, boolean forceRefresh) throws Exception { public static void sendMsg(final long logId, final Handler handError, String corpID, String agentID, String secret, String toUser, String content, boolean forceRefresh) throws Exception {
Log.i(TAG, "sendMsg corpID:" + corpID + " agentID:" + agentID + " secret:" + secret + " toUser:" + toUser + " content:" + content + " forceRefresh:" + forceRefresh); Log.i(TAG, "sendMsg corpID:" + corpID + " agentID:" + agentID + " secret:" + secret + " toUser:" + toUser + " content:" + content + " forceRefresh:" + forceRefresh);
@ -40,20 +44,20 @@ public class SenderQyWxAppMsg extends SenderBaseMsg {
} }
//TODO:判断access_token是否失效 //TODO:判断access_token是否失效
if (forceRefresh == true if (forceRefresh
|| MyApplication.QyWxAccessToken == null || MyApplication.QyWxAccessToken.isEmpty() || MyApplication.QyWxAccessToken == null || MyApplication.QyWxAccessToken.isEmpty()
|| System.currentTimeMillis() > MyApplication.QyWxAccessTokenExpiresIn) { || System.currentTimeMillis() > MyApplication.QyWxAccessTokenExpiresIn) {
String gettokenUrl = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?"; String getTokenUrl = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?";
gettokenUrl += "corpid=" + corpID; getTokenUrl += "corpid=" + corpID;
gettokenUrl += "&corpsecret=" + secret; getTokenUrl += "&corpsecret=" + secret;
Log.d(TAG, "gettokenUrl" + gettokenUrl); Log.d(TAG, "getTokenUrl" + getTokenUrl);
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient();
final Request request = new Request.Builder().url(gettokenUrl).get().build(); final Request request = new Request.Builder().url(getTokenUrl).get().build();
Call call = client.newCall(request); Call call = client.newCall(request);
call.enqueue(new Callback() { call.enqueue(new Callback() {
@Override @Override
public void onFailure(Call call, final IOException e) { public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtil.updateLog(logId, 0, e.getMessage());
Log.d(TAG, "onFailure" + e.getMessage()); Log.d(TAG, "onFailure" + e.getMessage());
if (handError != null) { if (handError != null) {
@ -67,14 +71,14 @@ public class SenderQyWxAppMsg extends SenderBaseMsg {
} }
@Override @Override
public void onResponse(Call call, Response response) throws IOException { public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
final String json = response.body().string(); final String json = Objects.requireNonNull(response.body()).string();
Log.d(TAG, "Code" + response.code() + " Response: " + json); Log.d(TAG, "Code" + response.code() + " Response: " + json);
JSONObject jsonObject = JSON.parseObject(json); JSONObject jsonObject = JSON.parseObject(json);
int errcode = jsonObject.getInteger("errcode"); int errcode = jsonObject.getInteger("errcode");
if (errcode == 0) { if (errcode == 0) {
MyApplication.QyWxAccessToken = jsonObject.getString("access_token"); MyApplication.QyWxAccessToken = jsonObject.getString("access_token");
MyApplication.QyWxAccessTokenExpiresIn = System.currentTimeMillis() + (jsonObject.getInteger("expires_in") - 120) * 1000; //提前2分钟过期 MyApplication.QyWxAccessTokenExpiresIn = System.currentTimeMillis() + (jsonObject.getInteger("expires_in") - 120) * 1000L; //提前2分钟过期
Log.d(TAG, "access_token" + MyApplication.QyWxAccessToken); Log.d(TAG, "access_token" + MyApplication.QyWxAccessToken);
Log.d(TAG, "expires_in" + MyApplication.QyWxAccessTokenExpiresIn); Log.d(TAG, "expires_in" + MyApplication.QyWxAccessTokenExpiresIn);
@ -133,15 +137,15 @@ public class SenderQyWxAppMsg extends SenderBaseMsg {
Call call = client.newCall(request); Call call = client.newCall(request);
call.enqueue(new Callback() { call.enqueue(new Callback() {
@Override @Override
public void onFailure(Call call, final IOException e) { public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtil.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage()); Toast(handError, TAG, "发送失败:" + e.getMessage());
emitter.onError(new RuntimeException("请求接口异常...")); emitter.onError(new RuntimeException("请求接口异常..."));
} }
@Override @Override
public void onResponse(Call call, Response response) throws IOException { public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
final String responseStr = response.body().string(); final String responseStr = Objects.requireNonNull(response.body()).string();
Log.d(TAG, "Response" + response.code() + "" + responseStr); Log.d(TAG, "Response" + response.code() + "" + responseStr);
Toast(handError, TAG, "发送状态:" + responseStr); Toast(handError, TAG, "发送状态:" + responseStr);

View File

@ -3,6 +3,8 @@ package com.idormy.sms.forwarder.sender;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtil;
@ -10,6 +12,7 @@ import com.idormy.sms.forwarder.utils.SettingUtil;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import io.reactivex.rxjava3.core.Observable; import io.reactivex.rxjava3.core.Observable;
@ -22,9 +25,10 @@ import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
@SuppressWarnings({"rawtypes", "unchecked", "deprecation", "ResultOfMethodCallIgnored"})
public class SenderQyWxGroupRobotMsg extends SenderBaseMsg { public class SenderQyWxGroupRobotMsg extends SenderBaseMsg {
static String TAG = "SenderQyWxGroupRobotMsg"; static final String TAG = "SenderQyWxGroupRobotMsg";
public static void sendMsg(final long logId, final Handler handError, String webHook, String from, String content) throws Exception { public static void sendMsg(final long logId, final Handler handError, String webHook, String from, String content) throws Exception {
Log.i(TAG, "sendMsg webHook:" + webHook + " from:" + from + " content:" + content); Log.i(TAG, "sendMsg webHook:" + webHook + " from:" + from + " content:" + content);
@ -59,15 +63,15 @@ public class SenderQyWxGroupRobotMsg extends SenderBaseMsg {
Call call = client.newCall(request); Call call = client.newCall(request);
call.enqueue(new Callback() { call.enqueue(new Callback() {
@Override @Override
public void onFailure(Call call, final IOException e) { public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtil.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage()); Toast(handError, TAG, "发送失败:" + e.getMessage());
emitter.onError(new RuntimeException("请求接口异常...")); emitter.onError(new RuntimeException("请求接口异常..."));
} }
@Override @Override
public void onResponse(Call call, Response response) throws IOException { public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
final String responseStr = response.body().string(); final String responseStr = Objects.requireNonNull(response.body()).string();
Log.d(TAG, "Response" + response.code() + "" + responseStr); Log.d(TAG, "Response" + response.code() + "" + responseStr);
Toast(handError, TAG, "发送状态:" + responseStr); Toast(handError, TAG, "发送状态:" + responseStr);

View File

@ -3,10 +3,13 @@ package com.idormy.sms.forwarder.sender;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtil;
import java.io.IOException; import java.io.IOException;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import io.reactivex.rxjava3.core.Observable; import io.reactivex.rxjava3.core.Observable;
@ -19,9 +22,10 @@ import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
@SuppressWarnings("ResultOfMethodCallIgnored")
public class SenderServerChanMsg extends SenderBaseMsg { public class SenderServerChanMsg extends SenderBaseMsg {
static String TAG = "SenderServerChanMsg"; static final String TAG = "SenderServerChanMsg";
public static void sendMsg(final long logId, final Handler handError, final String sendKey, final String title, final String desp) throws Exception { public static void sendMsg(final long logId, final Handler handError, final String sendKey, final String title, final String desp) throws Exception {
Log.i(TAG, "sendMsg sendKey:" + sendKey + " title:" + title + " desp:" + desp); Log.i(TAG, "sendMsg sendKey:" + sendKey + " title:" + title + " desp:" + desp);
@ -50,15 +54,15 @@ public class SenderServerChanMsg extends SenderBaseMsg {
Call call = client.newCall(request); Call call = client.newCall(request);
call.enqueue(new Callback() { call.enqueue(new Callback() {
@Override @Override
public void onFailure(Call call, final IOException e) { public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtil.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage()); Toast(handError, TAG, "发送失败:" + e.getMessage());
emitter.onError(new RuntimeException("请求接口异常...")); emitter.onError(new RuntimeException("请求接口异常..."));
} }
@Override @Override
public void onResponse(Call call, Response response) throws IOException { public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
final String responseStr = response.body().string(); final String responseStr = Objects.requireNonNull(response.body()).string();
Log.d(TAG, "Response" + response.code() + "" + responseStr); Log.d(TAG, "Response" + response.code() + "" + responseStr);
Toast(handError, TAG, "发送状态:" + responseStr); Toast(handError, TAG, "发送状态:" + responseStr);

View File

@ -13,9 +13,10 @@ import java.util.concurrent.TimeUnit;
import io.reactivex.rxjava3.core.Observable; import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableEmitter; import io.reactivex.rxjava3.core.ObservableEmitter;
@SuppressWarnings("ResultOfMethodCallIgnored")
public class SenderSmsMsg extends SenderBaseMsg { public class SenderSmsMsg extends SenderBaseMsg {
static String TAG = "SenderSmsMsg"; static final String TAG = "SenderSmsMsg";
public static void sendMsg(final long logId, final Handler handError, int simSlot, String mobiles, Boolean onlyNoNetwork, String from, String text) throws Exception { public static void sendMsg(final long logId, final Handler handError, int simSlot, String mobiles, Boolean onlyNoNetwork, String from, String text) throws Exception {
Log.i(TAG, "sendMsg simSlot:" + simSlot + " mobiles:" + mobiles + " onlyNoNetwork:" + onlyNoNetwork + " from:" + from + " text:" + text); Log.i(TAG, "sendMsg simSlot:" + simSlot + " mobiles:" + mobiles + " onlyNoNetwork:" + onlyNoNetwork + " from:" + from + " text:" + text);

View File

@ -3,6 +3,8 @@ package com.idormy.sms.forwarder.sender;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtil;
@ -10,6 +12,7 @@ import com.idormy.sms.forwarder.utils.SettingUtil;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import io.reactivex.rxjava3.core.Observable; import io.reactivex.rxjava3.core.Observable;
@ -22,9 +25,10 @@ import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
@SuppressWarnings({"rawtypes", "unchecked", "deprecation", "ResultOfMethodCallIgnored"})
public class SenderTelegramMsg extends SenderBaseMsg { public class SenderTelegramMsg extends SenderBaseMsg {
static String TAG = "SenderTelegramMsg"; static final String TAG = "SenderTelegramMsg";
public static void sendMsg(final long logId, final Handler handError, String apiToken, String chatId, String from, String text) throws Exception { public static void sendMsg(final long logId, final Handler handError, String apiToken, String chatId, String from, String text) throws Exception {
Log.i(TAG, "sendMsg apiToken:" + apiToken + " chatId:" + chatId + " text:" + text); Log.i(TAG, "sendMsg apiToken:" + apiToken + " chatId:" + chatId + " text:" + text);
@ -62,15 +66,15 @@ public class SenderTelegramMsg extends SenderBaseMsg {
Call call = client.newCall(request); Call call = client.newCall(request);
call.enqueue(new Callback() { call.enqueue(new Callback() {
@Override @Override
public void onFailure(Call call, final IOException e) { public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtil.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage()); Toast(handError, TAG, "发送失败:" + e.getMessage());
emitter.onError(new RuntimeException("请求接口异常...")); emitter.onError(new RuntimeException("请求接口异常..."));
} }
@Override @Override
public void onResponse(Call call, Response response) throws IOException { public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
final String responseStr = response.body().string(); final String responseStr = Objects.requireNonNull(response.body()).string();
Log.d(TAG, "Response" + response.code() + "" + responseStr); Log.d(TAG, "Response" + response.code() + "" + responseStr);
Toast(handError, TAG, "发送状态:" + responseStr); Toast(handError, TAG, "发送状态:" + responseStr);

View File

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder.sender; package com.idormy.sms.forwarder.sender;
import android.annotation.SuppressLint;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
@ -14,10 +15,12 @@ import com.idormy.sms.forwarder.utils.DbHelper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@SuppressWarnings({"SynchronizeOnNonFinalField", "UnusedReturnValue", "unused"})
public class SenderUtil { public class SenderUtil {
static String TAG = "SenderUtil"; static final String TAG = "SenderUtil";
static Boolean hasInit = false; static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")
static Context context; static Context context;
static DbHelper dbHelper; static DbHelper dbHelper;
static SQLiteDatabase db; static SQLiteDatabase db;
@ -76,7 +79,7 @@ public class SenderUtil {
selectionArgList.add(String.valueOf(id)); selectionArgList.add(String.valueOf(id));
} }
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]); String[] selectionArgs = selectionArgList.toArray(new String[0]);
// Issue SQL statement. // Issue SQL statement.
return db.delete(SenderTable.SenderEntry.TABLE_NAME, selection, selectionArgs); return db.delete(SenderTable.SenderEntry.TABLE_NAME, selection, selectionArgs);
@ -111,7 +114,7 @@ public class SenderUtil {
selectionArgList.add(key); selectionArgList.add(key);
selectionArgList.add(key); selectionArgList.add(key);
} }
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]); String[] selectionArgs = selectionArgList.toArray(new String[0]);
// How you want the results sorted in the resulting Cursor // How you want the results sorted in the resulting Cursor
String sortOrder = String sortOrder =
@ -174,7 +177,7 @@ public class SenderUtil {
selectionArgList.add(key); selectionArgList.add(key);
selectionArgList.add(key); selectionArgList.add(key);
} }
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]); String[] selectionArgs = selectionArgList.toArray(new String[0]);
// How you want the results sorted in the resulting Cursor // How you want the results sorted in the resulting Cursor

View File

@ -4,12 +4,16 @@ import android.os.Handler;
import android.util.Base64; import android.util.Base64;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.utils.CertUtils; import com.idormy.sms.forwarder.utils.CertUtils;
import com.idormy.sms.forwarder.utils.LogUtil; import com.idormy.sms.forwarder.utils.LogUtil;
import com.idormy.sms.forwarder.utils.SettingUtil; import com.idormy.sms.forwarder.utils.SettingUtil;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.crypto.Mac; import javax.crypto.Mac;
@ -26,9 +30,10 @@ import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
@SuppressWarnings({"deprecation", "ResultOfMethodCallIgnored"})
public class SenderWebNotifyMsg extends SenderBaseMsg { public class SenderWebNotifyMsg extends SenderBaseMsg {
static String TAG = "SenderWebNotifyMsg"; static final String TAG = "SenderWebNotifyMsg";
public static void sendMsg(final long logId, final Handler handError, String webServer, String webParams, String secret, String method, String from, String content) throws Exception { public static void sendMsg(final long logId, final Handler handError, String webServer, String webParams, String secret, String method, String from, String content) throws Exception {
Log.i(TAG, "sendMsg webServer:" + webServer + " webParams:" + webParams + " from:" + from + " content:" + content); Log.i(TAG, "sendMsg webServer:" + webServer + " webParams:" + webParams + " from:" + from + " content:" + content);
@ -42,8 +47,8 @@ public class SenderWebNotifyMsg extends SenderBaseMsg {
if (secret != null && !secret.isEmpty()) { if (secret != null && !secret.isEmpty()) {
String stringToSign = timestamp + "\n" + secret; String stringToSign = timestamp + "\n" + secret;
Mac mac = Mac.getInstance("HmacSHA256"); Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256")); mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8")); byte[] signData = mac.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8));
sign = URLEncoder.encode(new String(Base64.encode(signData, Base64.NO_WRAP)), "UTF-8"); sign = URLEncoder.encode(new String(Base64.encode(signData, Base64.NO_WRAP)), "UTF-8");
Log.i(TAG, "sign:" + sign); Log.i(TAG, "sign:" + sign);
} }
@ -102,15 +107,15 @@ public class SenderWebNotifyMsg extends SenderBaseMsg {
Call call = client.newCall(request); Call call = client.newCall(request);
call.enqueue(new Callback() { call.enqueue(new Callback() {
@Override @Override
public void onFailure(Call call, final IOException e) { public void onFailure(@NonNull Call call, @NonNull final IOException e) {
LogUtil.updateLog(logId, 0, e.getMessage()); LogUtil.updateLog(logId, 0, e.getMessage());
Toast(handError, TAG, "发送失败:" + e.getMessage()); Toast(handError, TAG, "发送失败:" + e.getMessage());
emitter.onError(new RuntimeException("请求接口异常...")); emitter.onError(new RuntimeException("请求接口异常..."));
} }
@Override @Override
public void onResponse(Call call, Response response) throws IOException { public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
final String responseStr = response.body().string(); final String responseStr = Objects.requireNonNull(response.body()).string();
Log.d(TAG, "Response" + response.code() + "" + responseStr); Log.d(TAG, "Response" + response.code() + "" + responseStr);
Toast(handError, TAG, "发送状态:" + responseStr); Toast(handError, TAG, "发送状态:" + responseStr);

View File

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder.service; package com.idormy.sms.forwarder.service;
import android.annotation.SuppressLint;
import android.app.Service; import android.app.Service;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
@ -11,6 +12,7 @@ import android.util.Log;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@SuppressWarnings("deprecation")
public class BatteryService extends Service { public class BatteryService extends Service {
private static final String TAG = "BatteryReceiver"; private static final String TAG = "BatteryReceiver";
@ -24,9 +26,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
@ -49,7 +51,8 @@ public class BatteryService extends Service {
} }
// 接收电池信息更新的广播 // 接收电池信息更新的广播
private BroadcastReceiver batteryReceiver = new BroadcastReceiver() { private final BroadcastReceiver batteryReceiver = new BroadcastReceiver() {
@SuppressWarnings("unused")
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Log.i(TAG, "BatteryReceiver--------------"); Log.i(TAG, "BatteryReceiver--------------");
@ -96,7 +99,7 @@ public class BatteryService extends Service {
break; break;
} }
SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss:SSS "); @SuppressLint("SimpleDateFormat") SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss:SSS ");
String date = sDateFormat.format(new java.util.Date()); String date = sDateFormat.format(new java.util.Date());
Log.i(TAG, "battery: date=" + date + ",status " + statusString Log.i(TAG, "battery: date=" + date + ",status " + statusString

View File

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder.service; package com.idormy.sms.forwarder.service;
import android.annotation.SuppressLint;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
@ -39,6 +40,7 @@ public class FrontService extends Service {
private static final String CHANNEL_ONE_ID = "com.idormy.sms.forwarder"; private static final String CHANNEL_ONE_ID = "com.idormy.sms.forwarder";
private static final String CHANNEL_ONE_NAME = "com.idormy.sms.forwarderName"; private static final String CHANNEL_ONE_NAME = "com.idormy.sms.forwarderName";
@SuppressLint("IconColors")
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
@ -48,11 +50,11 @@ public class FrontService extends Service {
OSUtils.ROM_TYPE romType = OSUtils.getRomType(); OSUtils.ROM_TYPE romType = OSUtils.getRomType();
//Log.d(TAG, "onCreate: " + romType); //Log.d(TAG, "onCreate: " + romType);
if (romType == OSUtils.ROM_TYPE.MIUI_ROM) { if (romType == OSUtils.ROM_TYPE.MIUI_ROM) {
builder.setContentTitle("短信转发器"); builder.setContentTitle(getString(R.string.app_name));
} }
builder.setContentText("根据规则转发到钉钉/微信/邮箱/bark/Server酱/Telegram/webhook等"); builder.setContentText(getString(R.string.notification_content));
Intent intent = new Intent(this, MainActivity.class); Intent intent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity @SuppressLint("UnspecifiedImmutableFlag") PendingIntent pendingIntent = PendingIntent.getActivity
(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); (this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent); builder.setContentIntent(pendingIntent);

View File

@ -11,6 +11,7 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
@SuppressWarnings("rawtypes")
public class BuildProperties { public class BuildProperties {
private static BuildProperties ourInstance; private static BuildProperties ourInstance;
private final Properties properties; private final Properties properties;

View File

@ -10,11 +10,10 @@ public class CacheUtil {
/** /**
* 获取缓存大小 * 获取缓存大小
* *
* @param context * @param context 上下文
* @return * @return 缓存大小
* @throws Exception
*/ */
public static String getTotalCacheSize(Context context) throws Exception { public static String getTotalCacheSize(Context context) {
long cacheSize = getFolderSize(context.getCacheDir()); long cacheSize = getFolderSize(context.getCacheDir());
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
cacheSize += getFolderSize(context.getExternalCacheDir()); cacheSize += getFolderSize(context.getExternalCacheDir());
@ -24,7 +23,7 @@ public class CacheUtil {
/*** /***
* 清理所有缓存 * 清理所有缓存
* @param context * @param context 上下文
*/ */
public static void clearAllCache(Context context) { public static void clearAllCache(Context context) {
deleteDir(context.getCacheDir()); deleteDir(context.getCacheDir());
@ -36,29 +35,32 @@ public class CacheUtil {
private static boolean deleteDir(File dir) { private static boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) { if (dir != null && dir.isDirectory()) {
String[] children = dir.list(); String[] children = dir.list();
for (int i = 0; i < children.length; i++) { assert children != null;
boolean success = deleteDir(new File(dir, children[i])); for (String child : children) {
boolean success = deleteDir(new File(dir, child));
if (!success) { if (!success) {
return false; return false;
} }
} }
} }
assert dir != null;
return dir.delete(); return dir.delete();
} }
// 获取文件 // 获取文件
//Context.getExternalFilesDir() --> SDCard/Android/data/你的应用的包名/files/ 目录一般放一些长时间保存的数据 //Context.getExternalFilesDir() --> SDCard/Android/data/你的应用的包名/files/ 目录一般放一些长时间保存的数据
//Context.getExternalCacheDir() --> SDCard/Android/data/你的应用包名/cache/目录一般存放临时缓存数据 //Context.getExternalCacheDir() --> SDCard/Android/data/你的应用包名/cache/目录一般存放临时缓存数据
public static long getFolderSize(File file) throws Exception { public static long getFolderSize(File file) {
long size = 0; long size = 0;
try { try {
File[] fileList = file.listFiles(); File[] fileList = file.listFiles();
for (int i = 0; i < fileList.length; i++) { assert fileList != null;
for (File value : fileList) {
// 如果下面还有文件 // 如果下面还有文件
if (fileList[i].isDirectory()) { if (value.isDirectory()) {
size = size + getFolderSize(fileList[i]); size = size + getFolderSize(value);
} else { } else {
size = size + fileList[i].length(); size = size + value.length();
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -70,8 +72,8 @@ public class CacheUtil {
/** /**
* 格式化单位 * 格式化单位
* *
* @param size * @param size 文件大小
* @return * @return 结果
*/ */
public static String getFormatSize(double size) { public static String getFormatSize(double size) {
double kiloByte = size / 1024; double kiloByte = size / 1024;

View File

@ -1,5 +1,7 @@
package com.idormy.sms.forwarder.utils; package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import java.security.KeyStore; import java.security.KeyStore;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
@ -29,10 +31,12 @@ public class CertUtils {
private static TrustManager[] getTrustManager() { private static TrustManager[] getTrustManager() {
return new TrustManager[]{ return new TrustManager[]{
new X509TrustManager() { new X509TrustManager() {
@SuppressLint("TrustAllX509TrustManager")
@Override @Override
public void checkClientTrusted(X509Certificate[] chain, String authType) { public void checkClientTrusted(X509Certificate[] chain, String authType) {
} }
@SuppressLint("TrustAllX509TrustManager")
@Override @Override
public void checkServerTrusted(X509Certificate[] chain, String authType) { public void checkServerTrusted(X509Certificate[] chain, String authType) {
} }

View File

@ -0,0 +1,191 @@
package com.idormy.sms.forwarder.utils;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.provider.ContactsContract;
import com.idormy.sms.forwarder.model.PhoneBookEntity;
import java.util.ArrayList;
import java.util.List;
/**
* 获取联系人工具类
*/
@SuppressWarnings("unused")
public class ContactHelper {
private static final String[] PROJECTION = new String[]{
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER
};
private final List<PhoneBookEntity> contacts = new ArrayList<>();
private ContactHelper() {
}
public static ContactHelper getInstance() {
return InstanceHolder.INSTANCE;
}
private static class InstanceHolder {
private static final ContactHelper INSTANCE = new ContactHelper();
}
/**
* 获取所有联系人
*
* @param context 上下文
* @return 联系人集合
*/
public List<PhoneBookEntity> getContacts(Context context) {
contacts.clear();
ContentResolver cr = context.getContentResolver();
try (Cursor cursor = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, PROJECTION, null, null, "sort_key")) {
if (cursor != null) {
final int displayNameIndex = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
final int mobileNoIndex = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
String mobileNo, displayName;
while (cursor.moveToNext()) {
mobileNo = cursor.getString(mobileNoIndex);
displayName = cursor.getString(displayNameIndex);
contacts.add(new PhoneBookEntity(displayName, mobileNo));
}
}
} catch (Exception e) {
e.printStackTrace();
}
return contacts;
}
/**
* 通过姓名获取联系人
*
* @param context 上下文
* @param contactName 联系人姓名
* @return 联系人集合
*/
public List<PhoneBookEntity> getContactByName(Context context, String contactName) {
contacts.clear();
ContentResolver cr = context.getContentResolver();
String selection = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " like ? ";
String[] selectionArgs = new String[]{"%" + contactName + "%"};
try (Cursor cursor = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, PROJECTION, selection, selectionArgs, "sort_key")) {
if (cursor != null) {
final int displayNameIndex = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
final int mobileNoIndex = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
String mobileNo, displayName;
while (cursor.moveToNext()) {
mobileNo = cursor.getString(mobileNoIndex);
displayName = cursor.getString(displayNameIndex);
contacts.add(new PhoneBookEntity(displayName, mobileNo));
}
}
} catch (Exception e) {
e.printStackTrace();
}
return contacts;
}
/**
* 通过手机号获取联系人
*
* @param context 上下文
* @param phoneNum 手机号码
* @return 联系人集合
*/
public List<PhoneBookEntity> getContactByNumber(Context context, String phoneNum) {
contacts.clear();
Cursor cursor = null;
if (phoneNum.length() < 11) {
return null;
}
try {
ContentResolver cr = context.getContentResolver();
String selection = ContactsContract.CommonDataKinds.Phone.NUMBER + " in(?,?,?) ";
String phone1 = phoneNum.subSequence(0, 3) + " " + phoneNum.substring(3, 7) +
" " + phoneNum.substring(7, 11);
String phone2 = phoneNum.subSequence(0, 3) + "-" + phoneNum.substring(3, 7) +
"-" + phoneNum.substring(7, 11);
String[] selectionArgs = new String[]{phoneNum, phone1, phone2};
cursor = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, PROJECTION, selection, selectionArgs, "sort_key");
if (cursor != null) {
final int displayNameIndex = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
final int mobileNoIndex = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
String mobileNo, displayName;
while (cursor.moveToNext()) {
mobileNo = cursor.getString(mobileNoIndex);
displayName = cursor.getString(displayNameIndex);
contacts.add(new PhoneBookEntity(displayName, mobileNo));
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
return contacts;
}
/**
* 分页查询联系人
*
* @param context 上下文
* @param page 页数
* @param pageSize 每页数据量
* @return 联系人集合
*/
public List<PhoneBookEntity> getContactsByPage(Context context, int page, int pageSize) {
contacts.clear();
Cursor cursor = null;
ContentResolver cr = context.getContentResolver();
try {
String sortOrder = "_id limit " + page + "," + pageSize;
cursor = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, PROJECTION, null, null, sortOrder);
if (cursor != null) {
final int displayNameIndex = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
final int mobileNoIndex = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
String mobileNo, displayName;
while (cursor.moveToNext()) {
mobileNo = cursor.getString(mobileNoIndex);
displayName = cursor.getString(displayNameIndex);
contacts.add(new PhoneBookEntity(displayName, mobileNo));
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
return contacts;
}
/**
* 获取联系人总数
*
* @param context 上下文
* @return 数量
*/
public int getContactCount(Context context) {
ContentResolver cr = context.getContentResolver();
try (Cursor cursor = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, PROJECTION, null, null, "sort_key")) {
if (cursor != null) {
return cursor.getCount();
}
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
}

View File

@ -12,6 +12,7 @@ import com.idormy.sms.forwarder.model.SenderTable;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@SuppressWarnings("unused")
public class DbHelper extends SQLiteOpenHelper { public class DbHelper extends SQLiteOpenHelper {
// If you change the database schema, you must increment the database version. // If you change the database schema, you must increment the database version.
public static final String TAG = "DbHelper"; public static final String TAG = "DbHelper";

View File

@ -1,22 +1,24 @@
package com.idormy.sms.forwarder.utils; package com.idormy.sms.forwarder.utils;
public class Define { public class Define {
public static String SP_CONFIG = "forwarder_config"; public static final String SP_CONFIG = "forwarder_config";
public static String SP_CONFIG_SWITCH_HELP_TIP = "forwarder_config_switch_help_tip"; public static final String SP_CONFIG_SWITCH_HELP_TIP = "forwarder_config_switch_help_tip";
public static String SP_MSG_KEY_SWITCH_ADD_EXTRA = "tsms_msg_key_switch_add_extra"; public static final String SP_MSG_KEY_SWITCH_ADD_EXTRA = "tsms_msg_key_switch_add_extra";
public static String SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_MARK = "tsms_msg_key_string_add_extra_device_mark"; public static final String SP_MSG_KEY_STRING_ADD_EXTRA_DEVICE_NAME = "tsms_msg_key_switch_add_extra_device_name";
public static String SP_MSG_KEY_STRING_ADD_EXTRA_SIM1 = "tsms_msg_key_string_add_extra_sim1"; public static final String SP_MSG_KEY_STRING_ENABLE_PHONE = "tsms_msg_key_switch_enable_phone";
public static 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_DEVICE_MARK = "tsms_msg_key_string_add_extra_device_mark";
public static String SP_MSG_KEY_SWITCH_SMS_TEMPLATE = "tsms_msg_key_switch_sms_template"; public static final String SP_MSG_KEY_STRING_ADD_EXTRA_SIM1 = "tsms_msg_key_string_add_extra_sim1";
public static String SP_MSG_KEY_STRING_SMS_TEMPLATE = "tsms_msg_key_string_sms_template"; public static final String SP_MSG_KEY_STRING_ADD_EXTRA_SIM2 = "tsms_msg_key_string_add_extra_sim2";
public static String SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM = "tsms_msg_key_string_battery_level_alarm"; public static final String SP_MSG_KEY_SWITCH_SMS_TEMPLATE = "tsms_msg_key_switch_sms_template";
public static String SP_MSG_KEY_STRING_RETRY_DELAY_TIME1 = "tsms_msg_key_string_retry_delay_time1"; public static final String SP_MSG_KEY_STRING_SMS_TEMPLATE = "tsms_msg_key_string_sms_template";
public static String SP_MSG_KEY_STRING_RETRY_DELAY_TIME2 = "tsms_msg_key_string_retry_delay_time2"; public static final String SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM = "tsms_msg_key_string_battery_level_alarm";
public static 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_TIME1 = "tsms_msg_key_string_retry_delay_time1";
public static String SP_MSG_KEY_STRING_RETRY_DELAY_TIME4 = "tsms_msg_key_string_retry_delay_time4"; public static final String SP_MSG_KEY_STRING_RETRY_DELAY_TIME2 = "tsms_msg_key_string_retry_delay_time2";
public static String SP_MSG_KEY_STRING_RETRY_DELAY_TIME5 = "tsms_msg_key_string_retry_delay_time5"; 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_TIME4 = "tsms_msg_key_string_retry_delay_time4";
public static final String SP_MSG_KEY_STRING_RETRY_DELAY_TIME5 = "tsms_msg_key_string_retry_delay_time5";
public static String SP_MSG = "forwarder_msg"; public static final String SP_MSG = "forwarder_msg";
public static String SP_MSG_SET_KEY = "forwarder_msg_set_key"; public static final String SP_MSG_SET_KEY = "forwarder_msg_set_key";
} }

View File

@ -10,6 +10,7 @@ import java.util.Map;
/** /**
* app版本更新接口 * app版本更新接口
*/ */
@SuppressWarnings("unused")
public interface HttpI extends Serializable { public interface HttpI extends Serializable {
/** /**
* 异步get * 异步get

View File

@ -1,15 +1,19 @@
package com.idormy.sms.forwarder.utils; package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
@SuppressWarnings("SynchronizeOnNonFinalField")
public class InitUtil { public class InitUtil {
static Boolean hasInit = false; static Boolean hasInit = false;
private static String TAG = "InitUtil"; private static final String TAG = "InitUtil";
@SuppressLint("StaticFieldLeak")
private static Context context = null; private static Context context = null;
public static void init(Context context1) { public static void init(Context context1) {
Log.d(TAG, "TMSG init"); Log.d(TAG, "SmsForwarder init");
//noinspection SynchronizeOnNonFinalField
synchronized (hasInit) { synchronized (hasInit) {
if (hasInit) return; if (hasInit) return;
hasInit = true; hasInit = true;

View File

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder.utils; package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -15,7 +16,7 @@ public class KeepAliveUtils {
public static boolean isIgnoreBatteryOptimization(Activity activity) { public static boolean isIgnoreBatteryOptimization(Activity activity) {
PowerManager powerManager = (PowerManager) activity.getSystemService(Context.POWER_SERVICE); PowerManager powerManager = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M && powerManager != null) { if (powerManager != null) {
return powerManager.isIgnoringBatteryOptimizations(activity.getPackageName()); return powerManager.isIgnoringBatteryOptimizations(activity.getPackageName());
} else { } else {
return true; return true;
@ -26,7 +27,7 @@ public class KeepAliveUtils {
if (isIgnoreBatteryOptimization(activity)) { if (isIgnoreBatteryOptimization(activity)) {
return; return;
} }
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); @SuppressLint("BatteryLife") Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + activity.getPackageName())); intent.setData(Uri.parse("package:" + activity.getPackageName()));
ResolveInfo resolveInfo = activity.getPackageManager().resolveActivity(intent, 0); ResolveInfo resolveInfo = activity.getPackageManager().resolveActivity(intent, 0);
if (resolveInfo != null) { if (resolveInfo != null) {

View File

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder.utils; package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
@ -19,15 +20,18 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@SuppressWarnings("UnusedReturnValue")
public class LogUtil { public class LogUtil {
static String TAG = "LogUtil"; static final String TAG = "LogUtil";
static Boolean hasInit = false; static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")
static Context context; static Context context;
static DbHelper dbHelper; static DbHelper dbHelper;
static SQLiteDatabase db; static SQLiteDatabase db;
public static void init(Context context1) { public static void init(Context context1) {
//noinspection SynchronizeOnNonFinalField
synchronized (hasInit) { synchronized (hasInit) {
if (hasInit) return; if (hasInit) return;
hasInit = true; hasInit = true;
@ -56,7 +60,7 @@ public class LogUtil {
return db.insert(LogTable.LogEntry.TABLE_NAME, null, values); return db.insert(LogTable.LogEntry.TABLE_NAME, null, values);
} }
public static int delLog(Long id, String key) { public static void delLog(Long id, String key) {
// Define 'where' part of query. // Define 'where' part of query.
String selection = " 1 "; String selection = " 1 ";
// Specify arguments in placeholder order. // Specify arguments in placeholder order.
@ -66,7 +70,6 @@ public class LogUtil {
selection += " and " + LogTable.LogEntry._ID + " = ? "; selection += " and " + LogTable.LogEntry._ID + " = ? ";
// Specify arguments in placeholder order. // Specify arguments in placeholder order.
selectionArgList.add(String.valueOf(id)); selectionArgList.add(String.valueOf(id));
} }
if (key != null) { if (key != null) {
@ -76,9 +79,9 @@ public class LogUtil {
selectionArgList.add(key); selectionArgList.add(key);
selectionArgList.add(key); selectionArgList.add(key);
} }
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]); String[] selectionArgs = selectionArgList.toArray(new String[0]);
// Issue SQL statement. // Issue SQL statement.
return db.delete(LogTable.LogEntry.TABLE_NAME, selection, selectionArgs); db.delete(LogTable.LogEntry.TABLE_NAME, selection, selectionArgs);
} }
@ -93,7 +96,7 @@ public class LogUtil {
values.put(LogTable.LogEntry.COLUMN_NAME_FORWARD_STATUS, forward_status); values.put(LogTable.LogEntry.COLUMN_NAME_FORWARD_STATUS, forward_status);
values.put(LogTable.LogEntry.COLUMN_NAME_FORWARD_RESPONSE, forward_response); values.put(LogTable.LogEntry.COLUMN_NAME_FORWARD_RESPONSE, forward_response);
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]); String[] selectionArgs = selectionArgList.toArray(new String[0]);
return db.update(LogTable.LogEntry.TABLE_NAME, values, selection, selectionArgs); return db.update(LogTable.LogEntry.TABLE_NAME, values, selection, selectionArgs);
} }
@ -134,7 +137,7 @@ public class LogUtil {
selectionArgList.add(key); selectionArgList.add(key);
selectionArgList.add(key); selectionArgList.add(key);
} }
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]); String[] selectionArgs = selectionArgList.toArray(new String[0]);
// How you want the results sorted in the resulting Cursor // How you want the results sorted in the resulting Cursor
String sortOrder = String sortOrder =
@ -160,9 +163,9 @@ public class LogUtil {
Log.d(TAG, "getLog: itemId cursor" + Arrays.toString(cursor.getColumnNames())); Log.d(TAG, "getLog: itemId cursor" + Arrays.toString(cursor.getColumnNames()));
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
try { try {
Long itemid = cursor.getLong( Long itemId = cursor.getLong(
cursor.getColumnIndexOrThrow(BaseColumns._ID)); cursor.getColumnIndexOrThrow(BaseColumns._ID));
String itemfrom = cursor.getString( String itemFrom = cursor.getString(
cursor.getColumnIndexOrThrow(LogTable.LogEntry.COLUMN_NAME_FROM)); cursor.getColumnIndexOrThrow(LogTable.LogEntry.COLUMN_NAME_FROM));
String content = cursor.getString( String content = cursor.getString(
cursor.getColumnIndexOrThrow(LogTable.LogEntry.COLUMN_NAME_CONTENT)); cursor.getColumnIndexOrThrow(LogTable.LogEntry.COLUMN_NAME_CONTENT));
@ -184,14 +187,14 @@ public class LogUtil {
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT)); cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_SIM_SLOT));
String senderName = cursor.getString( String senderName = cursor.getString(
cursor.getColumnIndexOrThrow(SenderTable.SenderEntry.COLUMN_NAME_NAME)); cursor.getColumnIndexOrThrow(SenderTable.SenderEntry.COLUMN_NAME_NAME));
Integer senderType = cursor.getInt( int senderType = cursor.getInt(
cursor.getColumnIndexOrThrow(SenderTable.SenderEntry.COLUMN_NAME_TYPE)); cursor.getColumnIndexOrThrow(SenderTable.SenderEntry.COLUMN_NAME_TYPE));
String rule = RuleModel.getRuleMatch(ruleFiled, ruleCheck, ruleValue, ruleSimSlot); String rule = RuleModel.getRuleMatch(ruleFiled, ruleCheck, ruleValue, ruleSimSlot);
if (senderName != null) rule += senderName.trim(); if (senderName != null) rule += senderName.trim();
int senderImageId = SenderModel.getImageId(senderType); int senderImageId = SenderModel.getImageId(senderType);
LogVo logVo = new LogVo(itemid, itemfrom, content, simInfo, time, rule, senderImageId, forwardStatus, forwardResponse); LogVo logVo = new LogVo(itemId, itemFrom, content, simInfo, time, rule, senderImageId, forwardStatus, forwardResponse);
LogVos.add(logVo); LogVos.add(logVo);
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "getLog e:" + e.getMessage()); Log.e(TAG, "getLog e:" + e.getMessage());

View File

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder.utils; package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
@ -11,13 +12,15 @@ public class NetUtil {
//移动网络 //移动网络
private static final int NETWORK_MOBILE = 1; private static final int NETWORK_MOBILE = 1;
//无线网络 //无线网络
private static final int NETWORW_WIFI = 2; private static final int NETWORK_WIFI = 2;
static Boolean hasInit = false; static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")
static Context context; static Context context;
public static void init(Context context1) { public static void init(Context context1) {
//noinspection SynchronizeOnNonFinalField
synchronized (hasInit) { synchronized (hasInit) {
if (hasInit) return; if (hasInit) return;
hasInit = true; hasInit = true;
@ -37,7 +40,7 @@ public class NetUtil {
if (activeNetworkInfo.getType() == (ConnectivityManager.TYPE_WIFI)) { if (activeNetworkInfo.getType() == (ConnectivityManager.TYPE_WIFI)) {
//返回无线网络 //返回无线网络
Toast.makeText(context, "当前处于无线网络", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "当前处于无线网络", Toast.LENGTH_SHORT).show();
return NETWORW_WIFI; return NETWORK_WIFI;
//判断是否移动网络 //判断是否移动网络
} else if (activeNetworkInfo.getType() == (ConnectivityManager.TYPE_MOBILE)) { } else if (activeNetworkInfo.getType() == (ConnectivityManager.TYPE_MOBILE)) {
Toast.makeText(context, "当前处于移动网络", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "当前处于移动网络", Toast.LENGTH_SHORT).show();

View File

@ -53,18 +53,16 @@ public class OSUtils {
//EMUI标识 //EMUI标识
private static final String KEY_EMUI_VERSION_CODE = "ro.build.version.emui"; private static final String KEY_EMUI_VERSION_CODE = "ro.build.version.emui";
//Flyme标识 //Flyme标识
private static final String KEY_FLYME_ID_FALG_KEY = "ro.build.display.id"; private static final String KEY_FLYME_ID_FLAG_KEY = "ro.build.display.id";
private static final String KEY_FLYME_ID_FALG_VALUE_KEYWORD = "Flyme"; private static final String KEY_FLYME_ID_FLAG_VALUE_KEYWORD = "Flyme";
private static final String KEY_FLYME_ICON_FALG = "persist.sys.use.flyme.icon"; private static final String KEY_FLYME_ICON_FLAG = "persist.sys.use.flyme.icon";
private static final String KEY_FLYME_SETUP_FALG = "ro.meizu.setupwizard.flyme"; private static final String KEY_FLYME_SETUP_FLAG = "ro.meizu.setupwizard.flyme";
private static final String KEY_FLYME_PUBLISH_FALG = "ro.flyme.published"; private static final String KEY_FLYME_PUBLISH_FLAG = "ro.flyme.published";
/** /**
* @param * 获取ROM类型MIUI_ROM, *FLYME_ROM, * EMUI_ROM, * OTHER_ROM
*
* @return ROM_TYPE ROM类型的枚举 * @return ROM_TYPE ROM类型的枚举
* @datecreate at 2016/5/11 0011 9:46
* @mehtodgetRomType
* @description获取ROM类型MIUI_ROM, *FLYME_ROM, * EMUI_ROM, * OTHER_ROM
*/ */
public static ROM_TYPE getRomType() { public static ROM_TYPE getRomType() {
ROM_TYPE rom_type = ROM_TYPE.OTHER_ROM; ROM_TYPE rom_type = ROM_TYPE.OTHER_ROM;
@ -76,12 +74,12 @@ public class OSUtils {
if (buildProperties.containsKey(KEY_MIUI_VERSION_CODE) || buildProperties.containsKey(KEY_MIUI_VERSION_NAME)) { if (buildProperties.containsKey(KEY_MIUI_VERSION_CODE) || buildProperties.containsKey(KEY_MIUI_VERSION_NAME)) {
return ROM_TYPE.MIUI_ROM; return ROM_TYPE.MIUI_ROM;
} }
if (buildProperties.containsKey(KEY_FLYME_ICON_FALG) || buildProperties.containsKey(KEY_FLYME_SETUP_FALG) || buildProperties.containsKey(KEY_FLYME_PUBLISH_FALG)) { if (buildProperties.containsKey(KEY_FLYME_ICON_FLAG) || buildProperties.containsKey(KEY_FLYME_SETUP_FLAG) || buildProperties.containsKey(KEY_FLYME_PUBLISH_FLAG)) {
return ROM_TYPE.FLYME_ROM; return ROM_TYPE.FLYME_ROM;
} }
if (buildProperties.containsKey(KEY_FLYME_ID_FALG_KEY)) { if (buildProperties.containsKey(KEY_FLYME_ID_FLAG_KEY)) {
String romName = buildProperties.getProperty(KEY_FLYME_ID_FALG_KEY); String romName = buildProperties.getProperty(KEY_FLYME_ID_FLAG_KEY);
if (!TextUtils.isEmpty(romName) && romName.contains(KEY_FLYME_ID_FALG_VALUE_KEYWORD)) { if (!TextUtils.isEmpty(romName) && romName.contains(KEY_FLYME_ID_FLAG_VALUE_KEYWORD)) {
return ROM_TYPE.FLYME_ROM; return ROM_TYPE.FLYME_ROM;
} }
} }

View File

@ -24,15 +24,17 @@ import java.io.File;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
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"})
public class PhoneUtils { public class PhoneUtils {
static Boolean hasInit = false; static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")
static Context context; static Context context;
private static String TAG = "PhoneUtils"; private static final String TAG = "PhoneUtils";
/** /**
* 构造类 * 构造类
@ -109,7 +111,7 @@ public class PhoneUtils {
} catch (Exception ignored) { } catch (Exception ignored) {
} }
return getUniquePsuedoID(); return getUniquePseudoID();
} }
/** /**
@ -118,7 +120,7 @@ public class PhoneUtils {
* *
* @return 伪唯一ID * @return 伪唯一ID
*/ */
public static String getUniquePsuedoID() { public static String getUniquePseudoID() {
String m_szDevIDShort = "35" + String m_szDevIDShort = "35" +
Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.BOARD.length() % 10 + Build.BRAND.length() % 10 +
Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 +
@ -130,7 +132,7 @@ public class PhoneUtils {
String serial; String serial;
try { try {
serial = android.os.Build.class.getField("SERIAL").get(null).toString(); serial = Objects.requireNonNull(Build.class.getField("SERIAL").get(null)).toString();
return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString(); return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
} catch (Exception e) { } catch (Exception e) {
//获取失败使用AndroidId //获取失败使用AndroidId
@ -217,10 +219,10 @@ public class PhoneUtils {
public static String getSimSerialNumber() { public static String getSimSerialNumber() {
try { try {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String serialNumber = tm != null ? tm.getSimSerialNumber() : null; @SuppressLint("HardwareIds") String serialNumber = tm != null ? tm.getSimSerialNumber() : null;
return serialNumber != null ? serialNumber : ""; return serialNumber != null ? serialNumber : "";
} catch (Exception e) { } catch (Exception ignored) {
} }
return ""; return "";
@ -247,7 +249,7 @@ public class PhoneUtils {
* *
* @return 电话号码 * @return 电话号码
*/ */
@SuppressLint("MissingPermission") @SuppressLint({"MissingPermission", "HardwareIds"})
public static String getPhoneNumber() { public static String getPhoneNumber() {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
try { try {
@ -280,7 +282,7 @@ public class PhoneUtils {
} }
} }
try { try {
count = Integer.parseInt(getReflexMethod(context, "getPhoneCount")); count = Integer.parseInt(getReflexMethod(context));
} catch (MethodNotFoundException ignored) { } catch (MethodNotFoundException ignored) {
} }
return count; return count;
@ -334,9 +336,7 @@ public class PhoneUtils {
List<SubscriptionInfo> activeSubscriptionInfoList = null; List<SubscriptionInfo> activeSubscriptionInfoList = null;
if (mSubscriptionManager != null) { if (mSubscriptionManager != null) {
try { try {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE);
//TODO
}
activeSubscriptionInfoList = mSubscriptionManager.getActiveSubscriptionInfoList(); activeSubscriptionInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
} catch (Exception ignored) { } catch (Exception ignored) {
} }
@ -414,10 +414,10 @@ public class PhoneUtils {
String imsi = null; String imsi = null;
try { try {
imsi = getReflexMethodWithId(context, "getSubscriberId", String.valueOf(i)); imsi = getReflexMethodWithId(context, "getSubscriberId", String.valueOf(i));
} catch (MethodNotFoundException ignored) { } catch (MethodNotFoundException e) {
Log.d(TAG, String.valueOf(ignored)); Log.d(TAG, String.valueOf(e));
} }
if (!TextUtils.isEmpty(imsi) && !imsi.equals(getIMSI())) { if (!TextUtils.isEmpty(imsi) && !Objects.equals(imsi, getIMSI())) {
return imsi; return imsi;
} }
} }
@ -456,23 +456,22 @@ public class PhoneUtils {
/** /**
* 通过反射调取@hide的方法 * 通过反射调取@hide的方法
* *
* @param predictedMethodName 方法名
* @return 返回方法调用的结果 * @return 返回方法调用的结果
* @throws MethodNotFoundException 方法没有找到 * @throws MethodNotFoundException 方法没有找到
*/ */
private static String getReflexMethod(Context context, String predictedMethodName) throws MethodNotFoundException { private static String getReflexMethod(Context context) throws MethodNotFoundException {
String result = null; String result = null;
TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
try { try {
Class<?> telephonyClass = Class.forName(telephony.getClass().getName()); Class<?> telephonyClass = Class.forName(telephony.getClass().getName());
Method getSimID = telephonyClass.getMethod(predictedMethodName); Method getSimID = telephonyClass.getMethod("getPhoneCount");
Object ob_phone = getSimID.invoke(telephony); Object ob_phone = getSimID.invoke(telephony);
if (ob_phone != null) { if (ob_phone != null) {
result = ob_phone.toString(); result = ob_phone.toString();
} }
} catch (Exception e) { } catch (Exception e) {
Log.d(TAG, String.valueOf(e.fillInStackTrace())); Log.d(TAG, String.valueOf(e.fillInStackTrace()));
throw new MethodNotFoundException(predictedMethodName); throw new MethodNotFoundException("getPhoneCount");
} }
return result; return result;
} }
@ -517,8 +516,7 @@ public class PhoneUtils {
public static List removeDuplicateWithOrder(List list) { public static List removeDuplicateWithOrder(List list) {
Set set = new HashSet(); Set set = new HashSet();
List newList = new ArrayList(); List newList = new ArrayList();
for (Iterator iter = list.iterator(); iter.hasNext(); ) { for (Object element : list) {
Object element = iter.next();
if (set.add(element)) if (set.add(element))
newList.add(element); newList.add(element);
} }
@ -601,15 +599,13 @@ public class PhoneUtils {
/** /**
* 通过 IMEI 判断是否相等 * 通过 IMEI 判断是否相等
*
* @param obj
* @return
*/ */
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return obj != null && obj instanceof SimInfo && (TextUtils.isEmpty(((SimInfo) obj).mImei) || ((SimInfo) obj).mImei.equals(mImei)); return obj instanceof SimInfo && (TextUtils.isEmpty(((SimInfo) obj).mImei) || ((SimInfo) obj).mImei.equals(mImei));
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return "SimInfo{" + return "SimInfo{" +

View File

@ -3,6 +3,8 @@ package com.idormy.sms.forwarder.utils;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import com.idormy.sms.forwarder.model.vo.SmsVo; import com.idormy.sms.forwarder.model.vo.SmsVo;
import java.util.ArrayList; import java.util.ArrayList;
@ -10,6 +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")
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 = "或者";
@ -23,11 +26,11 @@ class RuleLine {
public static final String CHECK_START_WITH = "开头"; public static final String CHECK_START_WITH = "开头";
public static final String CHECK_END_WITH = "结尾"; public static final String CHECK_END_WITH = "结尾";
public static final String CHECK_REGEX = "正则"; public static final String CHECK_REGEX = "正则";
public static List<String> CONJUNCTION_LIST = new ArrayList<String>(); public static final List<String> CONJUNCTION_LIST = new ArrayList<>();
public static List<String> FILED_LIST = new ArrayList<String>(); public static final List<String> FILED_LIST = new ArrayList<>();
public static List<String> SURE_LIST = new ArrayList<String>(); public static final List<String> SURE_LIST = new ArrayList<>();
public static List<String> CHECK_LIST = new ArrayList<String>(); public static final List<String> CHECK_LIST = new ArrayList<>();
static String TAG = "RuleLine"; static final String TAG = "RuleLine";
static Boolean STARTLOG = true; static Boolean STARTLOG = true;
static { static {
@ -71,8 +74,8 @@ class RuleLine {
String check; String check;
String value; String value;
public RuleLine(String line, int linenum, RuleLine beforeRuleLine) throws Exception { public RuleLine(String line, int lineNum, RuleLine beforeRuleLine) throws Exception {
logg("----------" + linenum + "-----------------"); logg("----------" + lineNum + "-----------------");
logg(line); logg(line);
//规则检验 //规则检验
//并且 手机号 相等 10086 //并且 手机号 相等 10086
@ -85,7 +88,7 @@ class RuleLine {
//标记3个阶段 //标记3个阶段
boolean isCountHeading = false; boolean isCountHeading = false;
boolean isDealMiddel = false; boolean isDealMiddle = false;
boolean isDealValue = false; boolean isDealValue = false;
//用于保存4个中间体 并且, , 内容, 包含 //用于保存4个中间体 并且, , 内容, 包含
@ -107,44 +110,41 @@ class RuleLine {
isCountHeading = true; isCountHeading = true;
} else { } else {
//直接进入处理中间体阶段 //直接进入处理中间体阶段
isCountHeading = false; isDealMiddle = true;
isDealMiddel = true; logg("start to isDealMiddle:");
logg("start to isDealMiddel:");
} }
} }
//正在数空格头但是遇到非空格阶段变更:由处理空头阶段 变为 处理 中间体阶段 //正在数空格头但是遇到非空格阶段变更:由处理空头阶段 变为 处理 中间体阶段
if (isCountHeading && (!" ".equals(w))) { if (isCountHeading && (!" ".equals(w))) {
logg("isCountHeading to isDealMiddel:"); logg("isCountHeading to isDealMiddle:");
isCountHeading = false; isCountHeading = false;
isDealMiddel = true; isDealMiddle = true;
} }
//正在处理中间体中间体数量够了阶段变更由处理中间体 变为 处理 value //正在处理中间体中间体数量够了阶段变更由处理中间体 变为 处理 value
if (isDealMiddel && middleList.size() == 4) { if (isDealMiddle && middleList.size() == 4) {
logg("isDealMiddel done middleList:" + middleList); logg("isDealMiddle done middleList:" + middleList);
logg("isDealMiddel to isDealValue:"); logg("isDealMiddle to isDealValue:");
isDealMiddel = false; isDealMiddle = false;
isDealValue = true; isDealValue = true;
} }
logg("isCountHeading:" + isCountHeading); logg("isCountHeading:" + isCountHeading);
logg("isDealMiddel:" + isDealMiddel); logg("isDealMiddle:" + isDealMiddle);
logg("isDealValue:" + isDealValue); logg("isDealValue:" + isDealValue);
if (isCountHeading) { if (isCountHeading) {
if (" ".equals(w)) {
logg("headSpaceNum++:" + headSpaceNum); logg("headSpaceNum++:" + headSpaceNum);
headSpaceNum++; headSpaceNum++;
} }
}
if (isDealMiddel) { if (isDealMiddle) {
//遇到空格 //遇到空格
if (" ".equals(w)) { if (" ".equals(w)) {
if (buildMiddleWord.length() == 0) { if (buildMiddleWord.length() == 0) {
throw new Exception(linenum + "行:语法错误不允许出现连续空格!"); throw new Exception(lineNum + "行:语法错误不允许出现连续空格!");
} else { } else {
//生成了一个中间体 //生成了一个中间体
middleList.add(buildMiddleWord.toString()); middleList.add(buildMiddleWord.toString());
@ -170,7 +170,7 @@ class RuleLine {
if (middleList.size() != 4) { if (middleList.size() != 4) {
throw new Exception(linenum + "行配置错误每行必须有4段组成例如 并且 手机号 是 相等 "); throw new Exception(lineNum + "行配置错误每行必须有4段组成例如 并且 手机号 是 相等 ");
} }
@ -232,19 +232,19 @@ class RuleLine {
this.value = valueBuilder.toString(); this.value = valueBuilder.toString();
if (!CONJUNCTION_LIST.contains(this.conjunction)) { if (!CONJUNCTION_LIST.contains(this.conjunction)) {
throw new Exception(linenum + "行配置错误:连接词只支持:" + CONJUNCTION_LIST + " 但提供了" + this.conjunction); throw new Exception(lineNum + "行配置错误:连接词只支持:" + CONJUNCTION_LIST + " 但提供了" + this.conjunction);
} }
if (!FILED_LIST.contains(this.field)) { if (!FILED_LIST.contains(this.field)) {
throw new Exception(linenum + "行配置错误:字段只支持:" + FILED_LIST + " 但提供了" + this.field); throw new Exception(lineNum + "行配置错误:字段只支持:" + FILED_LIST + " 但提供了" + this.field);
} }
if (!SURE_LIST.contains(this.sure)) { if (!SURE_LIST.contains(this.sure)) {
throw new Exception(linenum + "行配置错误 " + this.sure + " 确认词只支持:" + SURE_LIST + " 但提供了" + this.sure); throw new Exception(lineNum + "行配置错误 " + this.sure + " 确认词只支持:" + SURE_LIST + " 但提供了" + this.sure);
} }
if (!CHECK_LIST.contains(this.check)) { if (!CHECK_LIST.contains(this.check)) {
throw new Exception(linenum + "行配置错误:比较词只支持:" + CHECK_LIST + " 但提供了" + this.check); throw new Exception(lineNum + "行配置错误:比较词只支持:" + CHECK_LIST + " 但提供了" + this.check);
} }
logg("----------" + linenum + "==" + this); logg("----------" + lineNum + "==" + this);
} }
@ -282,7 +282,6 @@ class RuleLine {
//整合肯定词 //整合肯定词
switch (this.sure) { switch (this.sure) {
case SURE_YES: case SURE_YES:
mixChecked = mixChecked;
break; break;
case SURE_NOT: case SURE_NOT:
mixChecked = !mixChecked; mixChecked = !mixChecked;
@ -311,6 +310,11 @@ class RuleLine {
checked = msgValue.contains(this.value); checked = msgValue.contains(this.value);
} }
break; break;
case CHECK_NOT_CONTAIN:
if (msgValue != null) {
checked = !msgValue.contains(this.value);
}
break;
case CHECK_START_WITH: case CHECK_START_WITH:
if (msgValue != null) { if (msgValue != null) {
checked = msgValue.startsWith(this.value); checked = msgValue.startsWith(this.value);
@ -326,7 +330,6 @@ class RuleLine {
try { try {
checked = Pattern.matches(this.value, msgValue); checked = Pattern.matches(this.value, msgValue);
} catch (PatternSyntaxException e) { } catch (PatternSyntaxException e) {
checked = false;
logg("PatternSyntaxException: "); logg("PatternSyntaxException: ");
logg("Description: " + e.getDescription()); logg("Description: " + e.getDescription());
logg("Index: " + e.getIndex()); logg("Index: " + e.getIndex());
@ -344,6 +347,7 @@ class RuleLine {
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return "RuleLine{" + return "RuleLine{" +

View File

@ -1,5 +1,8 @@
package com.idormy.sms.forwarder.utils; package com.idormy.sms.forwarder.utils;
import static com.idormy.sms.forwarder.utils.RuleLine.CONJUNCTION_AND;
import static com.idormy.sms.forwarder.utils.RuleLine.CONJUNCTION_OR;
import android.util.Log; import android.util.Log;
import com.idormy.sms.forwarder.model.vo.SmsVo; import com.idormy.sms.forwarder.model.vo.SmsVo;
@ -7,11 +10,9 @@ import com.idormy.sms.forwarder.model.vo.SmsVo;
import java.util.Date; import java.util.Date;
import java.util.Scanner; import java.util.Scanner;
import static com.idormy.sms.forwarder.utils.RuleLine.CONJUNCTION_AND; @SuppressWarnings("unused")
import static com.idormy.sms.forwarder.utils.RuleLine.CONJUNCTION_OR;
public class RuleLineUtils { public class RuleLineUtils {
static String TAG = "RuleLineUtils"; static final String TAG = "RuleLineUtils";
static Boolean STARTLOG = false; static Boolean STARTLOG = false;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
@ -41,16 +42,16 @@ public class RuleLineUtils {
Scanner scanner = new Scanner(RuleLines); Scanner scanner = new Scanner(RuleLines);
int linenum = 0; int lineNum = 0;
RuleLine headRuleLine = null; RuleLine headRuleLine = null;
RuleLine beforeRuleLine = null; RuleLine beforeRuleLine = null;
while (scanner.hasNextLine()) { while (scanner.hasNextLine()) {
String line = scanner.nextLine(); String line = scanner.nextLine();
logg(linenum + " : " + line); logg(lineNum + " : " + line);
//第一行 //第一行
if (linenum == 0) { if (lineNum == 0) {
//第一行不允许缩进 //第一行不允许缩进
if (line.startsWith(" ")) { if (line.startsWith(" ")) {
throw new Exception("第一行不允许缩进"); throw new Exception("第一行不允许缩进");
@ -60,14 +61,15 @@ public class RuleLineUtils {
// process the line // process the line
beforeRuleLine = RuleLineUtils.generateRuleTree(line, linenum, beforeRuleLine); beforeRuleLine = RuleLineUtils.generateRuleTree(line, lineNum, beforeRuleLine);
if (linenum == 0) { if (lineNum == 0) {
headRuleLine = beforeRuleLine; headRuleLine = beforeRuleLine;
} }
linenum++; lineNum++;
} }
assert headRuleLine != null;
return checkRuleTree(msg, headRuleLine); return checkRuleTree(msg, headRuleLine);
} }

View File

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder.utils; package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
@ -13,9 +14,11 @@ import com.idormy.sms.forwarder.model.RuleTable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@SuppressWarnings({"UnusedReturnValue", "SynchronizeOnNonFinalField"})
public class RuleUtil { public class RuleUtil {
static String TAG = "RuleUtil"; static final String TAG = "RuleUtil";
static Boolean hasInit = false; static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")
static Context context; static Context context;
static DbHelper dbHelper; static DbHelper dbHelper;
static SQLiteDatabase db; static SQLiteDatabase db;
@ -75,7 +78,7 @@ public class RuleUtil {
selectionArgList.add(String.valueOf(id)); selectionArgList.add(String.valueOf(id));
} }
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]); String[] selectionArgs = selectionArgList.toArray(new String[0]);
// Issue SQL statement. // Issue SQL statement.
return db.delete(RuleTable.RuleEntry.TABLE_NAME, selection, selectionArgs); return db.delete(RuleTable.RuleEntry.TABLE_NAME, selection, selectionArgs);
@ -114,7 +117,7 @@ public class RuleUtil {
// Specify arguments in placeholder order. // Specify arguments in placeholder order.
selectionArgList.add(key); selectionArgList.add(key);
} }
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]); String[] selectionArgs = selectionArgList.toArray(new String[0]);
// How you want the results sorted in the resulting Cursor // How you want the results sorted in the resulting Cursor
String sortOrder = String sortOrder =

View File

@ -5,10 +5,12 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
@SuppressWarnings({"SynchronizeOnNonFinalField", "unused"})
public class SettingUtil { public class SettingUtil {
static Boolean hasInit = false; static Boolean hasInit = false;
private static String TAG = "SettingUtil"; private static final String TAG = "SettingUtil";
private static SharedPreferences sp_setting = null; private static SharedPreferences sp_setting = null;
@SuppressWarnings("FieldCanBeLocal")
private static Context context = null; private static Context context = null;
public static void init(Context context1) { public static void init(Context context1) {
@ -32,6 +34,27 @@ public class SettingUtil {
return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, false); return sp_setting.getBoolean(Define.SP_MSG_KEY_SWITCH_ADD_EXTRA, false);
} }
public static void switchAddDeviceName(Boolean switchAddDeviceName) {
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) { public static void switchSmsTemplate(Boolean switchSmsTemplate) {
Log.d(TAG, "switchSmsTemplate :" + switchSmsTemplate); Log.d(TAG, "switchSmsTemplate :" + switchSmsTemplate);
sp_setting.edit() sp_setting.edit()
@ -100,8 +123,7 @@ public class SettingUtil {
} }
public static String getBatteryLevelAlarm() { public static String getBatteryLevelAlarm() {
String res = sp_setting.getString(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, ""); return sp_setting.getString(Define.SP_MSG_KEY_STRING_BATTERY_LEVEL_ALARM, "");
return res;
} }
public static void setBatteryLevelAlarm(String battery_level) { public static void setBatteryLevelAlarm(String battery_level) {
@ -112,7 +134,7 @@ public class SettingUtil {
} }
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);
} }
//接口请求失败重试 //接口请求失败重试

View File

@ -6,8 +6,9 @@ import android.util.Log;
import com.idormy.sms.forwarder.MyApplication; import com.idormy.sms.forwarder.MyApplication;
@SuppressWarnings("unused")
public class SimUtil { public class SimUtil {
private static String TAG = "SimUtil"; private static final String TAG = "SimUtil";
//获取卡槽信息ID //获取卡槽信息ID
public static int getSimId(Bundle bundle) { public static int getSimId(Bundle bundle) {

View File

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder.utils; package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -7,10 +8,13 @@ import android.telephony.SmsManager;
import android.util.Log; import android.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects;
@SuppressWarnings("SynchronizeOnNonFinalField")
public class SmsUtil { public class SmsUtil {
static String TAG = "SmsUtil"; static final String TAG = "SmsUtil";
static Boolean hasInit = false; static Boolean hasInit = false;
@SuppressLint("StaticFieldLeak")
static Context context; static Context context;
@ -28,11 +32,11 @@ public class SmsUtil {
try { try {
SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId); SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId);
PendingIntent sendPI = PendingIntent.getBroadcast(context, 0, new Intent(Context.TELEPHONY_SUBSCRIPTION_SERVICE), PendingIntent.FLAG_ONE_SHOT); @SuppressLint("UnspecifiedImmutableFlag") PendingIntent sendPI = PendingIntent.getBroadcast(context, 0, new Intent(Context.TELEPHONY_SUBSCRIPTION_SERVICE), PendingIntent.FLAG_ONE_SHOT);
PendingIntent deliverPI = PendingIntent.getBroadcast(context, 0, new Intent("DELIVERED_SMS_ACTION"), 0); @SuppressLint("UnspecifiedImmutableFlag") PendingIntent deliverPI = PendingIntent.getBroadcast(context, 0, new Intent("DELIVERED_SMS_ACTION"), 0);
ArrayList<PendingIntent> sentPendingIntents = new ArrayList<PendingIntent>(); ArrayList<PendingIntent> sentPendingIntents = new ArrayList<>();
ArrayList<PendingIntent> deliveredPendingIntents = new ArrayList<PendingIntent>(); ArrayList<PendingIntent> deliveredPendingIntents = new ArrayList<>();
ArrayList<String> divideContents = smsManager.divideMessage(message); ArrayList<String> divideContents = smsManager.divideMessage(message);
for (int i = 0; i < divideContents.size(); i++) { for (int i = 0; i < divideContents.size(); i++) {
@ -43,7 +47,7 @@ public class SmsUtil {
return null; return null;
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, e.getMessage()); Log.e(TAG, Objects.requireNonNull(e.getMessage()));
return e.getMessage(); return e.getMessage();
} }
} }

View File

@ -1,5 +1,6 @@
package com.idormy.sms.forwarder.utils; package com.idormy.sms.forwarder.utils;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -15,15 +16,13 @@ import java.util.Properties;
import java.util.TimeZone; import java.util.TimeZone;
public class aUtil { public class aUtil {
private static String TAG = "aUtil";
private static Context context = null;
/** /**
* 判断是否为MIUI系统参考http://blog.csdn.net/xx326664162/article/details/52438706 * 判断是否为MIUI系统参考http://blog.csdn.net/xx326664162/article/details/52438706
* *
* @return * @return 返回结果
*/ */
@SuppressWarnings("unused")
public static boolean isMIUI() { public static boolean isMIUI() {
try { try {
String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code"; String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
@ -45,8 +44,7 @@ public class aUtil {
PackageManager packageManager = context.getPackageManager(); PackageManager packageManager = context.getPackageManager();
// getPackageName()是你当前类的包名0代表是获取版本信息 // getPackageName()是你当前类的包名0代表是获取版本信息
PackageInfo packInfo = packageManager.getPackageInfo(context.getPackageName(), 0); PackageInfo packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
String version = packInfo.versionName; return packInfo.versionName;
return version;
} }
public static Integer getVersionCode(Context context) throws Exception { public static Integer getVersionCode(Context context) throws Exception {
@ -54,15 +52,14 @@ public class aUtil {
PackageManager packageManager = context.getPackageManager(); PackageManager packageManager = context.getPackageManager();
// getPackageName()是你当前类的包名0代表是获取版本信息 // getPackageName()是你当前类的包名0代表是获取版本信息
PackageInfo packInfo = packageManager.getPackageInfo(context.getPackageName(), 0); PackageInfo packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
Integer versionCode = packInfo.versionCode; return packInfo.versionCode;
return versionCode;
} }
//友好时间显示 //友好时间显示
public static String friendlyTime(String utcTime) { public static String friendlyTime(String utcTime) {
SimpleDateFormat utcFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @SuppressLint("SimpleDateFormat") SimpleDateFormat utcFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
utcFormater.setTimeZone(TimeZone.getTimeZone("UTC"));//时区定义并进行时间获取 utcFormater.setTimeZone(TimeZone.getTimeZone("UTC"));//时区定义并进行时间获取
Date utcDate = null; Date utcDate;
try { try {
utcDate = utcFormater.parse(utcTime); utcDate = utcFormater.parse(utcTime);
} catch (ParseException e) { } catch (ParseException e) {
@ -71,6 +68,7 @@ public class aUtil {
} }
//获取utcDate距离当前的秒数 //获取utcDate距离当前的秒数
assert utcDate != null;
int ct = (int) ((System.currentTimeMillis() - utcDate.getTime()) / 1000); int ct = (int) ((System.currentTimeMillis() - utcDate.getTime()) / 1000);
if (ct == 0) { if (ct == 0) {
@ -107,10 +105,10 @@ public class aUtil {
public static String utc2Local(String utcTime) { public static String utc2Local(String utcTime) {
String utcTimePatten = "yyyy-MM-dd HH:mm:ss"; String utcTimePatten = "yyyy-MM-dd HH:mm:ss";
String localTimePatten = "yyyy-MM-dd HH:mm:ss"; String localTimePatten = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat utcFormater = new SimpleDateFormat(utcTimePatten); @SuppressLint("SimpleDateFormat") SimpleDateFormat utcFormater = new SimpleDateFormat(utcTimePatten);
utcFormater.setTimeZone(TimeZone.getTimeZone("UTC"));//时区定义并进行时间获取 utcFormater.setTimeZone(TimeZone.getTimeZone("UTC"));//时区定义并进行时间获取
Date utcDate = null; Date utcDate;
try { try {
utcDate = utcFormater.parse(utcTime); utcDate = utcFormater.parse(utcTime);
} catch (ParseException e) { } catch (ParseException e) {
@ -118,10 +116,10 @@ public class aUtil {
return utcTime; return utcTime;
} }
SimpleDateFormat localFormater = new SimpleDateFormat(localTimePatten); @SuppressLint("SimpleDateFormat") SimpleDateFormat localFormater = new SimpleDateFormat(localTimePatten);
localFormater.setTimeZone(TimeZone.getDefault()); localFormater.setTimeZone(TimeZone.getDefault());
String localTime = localFormater.format(utcDate.getTime()); assert utcDate != null;
return localTime; return localFormater.format(utcDate.getTime());
} }
} }

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -18,7 +19,7 @@
android:padding="15dp"> android:padding="15dp">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
@ -67,7 +68,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="3" android:layout_weight="3"
android:gravity="end" android:gravity="end"
android:textSize="18sp" /> android:textSize="18sp"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout> </LinearLayout>
@ -93,7 +95,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="3" android:layout_weight="3"
android:gravity="end" android:gravity="end"
android:textSize="18sp" /> android:textSize="18sp"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout> </LinearLayout>
@ -119,7 +122,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="3" android:layout_weight="3"
android:autoLink="web" android:autoLink="web"
android:gravity="right" android:gravity="end"
android:text="https://github.com/pppscn/SmsForwarder/releases" android:text="https://github.com/pppscn/SmsForwarder/releases"
android:textSize="14sp" /> android:textSize="14sp" />
</LinearLayout> </LinearLayout>
@ -135,7 +138,7 @@
android:padding="15dp"> android:padding="15dp">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
@ -171,7 +174,7 @@
android:padding="15dp"> android:padding="15dp">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">

View File

@ -34,7 +34,7 @@
android:id="@+id/bt_refresh_log" android:id="@+id/bt_refresh_log"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_marginLeft="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:layout_weight="1" android:layout_weight="1"
@ -47,7 +47,7 @@
android:id="@+id/bt_rule_set" android:id="@+id/bt_rule_set"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_marginLeft="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:layout_weight="1" android:layout_weight="1"

View File

@ -25,7 +25,7 @@
android:textColor="@color/colorPrimary" /> android:textColor="@color/colorPrimary" />
<Button <Button
android:id="@+id/btaddrule" android:id="@+id/bt_add_rule"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_margin="10dp" android:layout_margin="10dp"

View File

@ -28,11 +28,13 @@
android:id="@+id/et_add_extra_device_mark" android:id="@+id/et_add_extra_device_mark"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:ems="16" android:ems="16"
android:inputType="" android:inputType="text"
android:maxLines="1" android:maxLines="1"
android:text="" /> android:text=""
tools:ignore="LabelFor"
android:autofillHints="" />
</LinearLayout> </LinearLayout>
@ -61,18 +63,19 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="end" android:gravity="end"
android:text="运营商_手机号" android:text="运营商_手机号"
android:textSize="9dp" /> android:textSize="9sp" />
</LinearLayout> </LinearLayout>
<EditText <EditText
android:id="@+id/et_add_extra_sim1" android:id="@+id/et_add_extra_sim1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:ems="16" android:ems="16"
android:inputType="" android:inputType="text"
android:maxLines="1" android:maxLines="1"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
@ -101,18 +104,19 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="end" android:gravity="end"
android:text="运营商_手机号" android:text="运营商_手机号"
android:textSize="9dp" /> android:textSize="9sp" />
</LinearLayout> </LinearLayout>
<EditText <EditText
android:id="@+id/et_add_extra_sim2" android:id="@+id/et_add_extra_sim2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:ems="16" android:ems="16"
android:inputType="" android:inputType="text"
android:maxLines="1" android:maxLines="1"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
@ -141,18 +145,19 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="end" android:gravity="end"
android:text="取值范围0-100留空或0禁用" android:text="取值范围0-100留空或0禁用"
android:textSize="9dp" /> android:textSize="9sp" />
</LinearLayout> </LinearLayout>
<EditText <EditText
android:id="@+id/et_battery_level_alarm" android:id="@+id/et_battery_level_alarm"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:ems="16" android:ems="16"
android:inputType="number" android:inputType="number"
android:maxLines="1" android:maxLines="1"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
@ -181,7 +186,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="end" android:gravity="end"
android:text="接口请求失败后将重试5次" android:text="接口请求失败后将重试5次"
android:textSize="9dp" /> android:textSize="9sp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -193,56 +198,61 @@
android:id="@+id/et_retry_delay_time1" android:id="@+id/et_retry_delay_time1"
android:layout_width="42dp" android:layout_width="42dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:ems="16" android:ems="16"
android:inputType="number" android:inputType="number"
android:maxLines="1" android:maxLines="1"
android:textAlignment="center" android:textAlignment="center"
android:text="" /> android:text=""
android:autofillHints="" />
<EditText <EditText
android:id="@+id/et_retry_delay_time2" android:id="@+id/et_retry_delay_time2"
android:layout_width="42dp" android:layout_width="42dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:ems="16" android:ems="16"
android:inputType="number" android:inputType="number"
android:maxLines="1" android:maxLines="1"
android:textAlignment="center" android:textAlignment="center"
android:text="" /> android:text=""
android:autofillHints="" />
<EditText <EditText
android:id="@+id/et_retry_delay_time3" android:id="@+id/et_retry_delay_time3"
android:layout_width="42dp" android:layout_width="42dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:ems="16" android:ems="16"
android:inputType="number" android:inputType="number"
android:maxLines="1" android:maxLines="1"
android:textAlignment="center" android:textAlignment="center"
android:text="" /> android:text=""
android:autofillHints="" />
<EditText <EditText
android:id="@+id/et_retry_delay_time4" android:id="@+id/et_retry_delay_time4"
android:layout_width="42dp" android:layout_width="42dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:ems="16" android:ems="16"
android:inputType="number" android:inputType="number"
android:maxLines="1" android:maxLines="1"
android:textAlignment="center" android:textAlignment="center"
android:text="" /> android:text=""
android:autofillHints="" />
<EditText <EditText
android:id="@+id/et_retry_delay_time5" android:id="@+id/et_retry_delay_time5"
android:layout_width="42dp" android:layout_width="42dp"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:ems="16" android:ems="16"
android:inputType="number" android:inputType="number"
android:maxLines="1" android:maxLines="1"
android:textAlignment="center" android:textAlignment="center"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
@ -267,10 +277,62 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="3" android:layout_weight="3"
android:gravity="end" android:gravity="end"
android:textSize="18sp" /> android:textSize="18sp"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="15dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="转发时附加设备名称"
android:textStyle="bold" />
<Switch
android:id="@+id/switch_add_device_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:gravity="end"
android:textSize="18sp"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:padding="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="转发来电"
android:textStyle="bold" />
<Switch
android:id="@+id/switch_enable_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:checked="true"
android:gravity="end"
android:textSize="18sp"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</RelativeLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -293,7 +355,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="3" android:layout_weight="3"
android:gravity="end" android:gravity="end"
android:textSize="18sp" /> android:textSize="18sp"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout> </LinearLayout>
@ -322,17 +385,18 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:text="Tip按需插入内容标签留空使用默认模版" android:text="Tip按需插入内容标签留空使用默认模版"
android:textSize="11dp" /> android:textSize="11sp" />
</LinearLayout> </LinearLayout>
<EditText <EditText
android:id="@+id/text_sms_template" android:id="@+id/text_sms_template"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -368,7 +432,7 @@
android:id="@+id/bt_insert_content" android:id="@+id/bt_insert_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="25dp" android:layout_height="25dp"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:layout_weight="1" android:layout_weight="1"
@ -380,7 +444,7 @@
android:id="@+id/bt_insert_extra" android:id="@+id/bt_insert_extra"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="25dp" android:layout_height="25dp"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:layout_weight="1" android:layout_weight="1"
@ -392,7 +456,7 @@
android:id="@+id/bt_insert_time" android:id="@+id/bt_insert_time"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="25dp" android:layout_height="25dp"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:layout_weight="1" android:layout_weight="1"
@ -404,7 +468,7 @@
android:id="@+id/bt_insert_device_name" android:id="@+id/bt_insert_device_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="25dp" android:layout_height="25dp"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:layout_weight="1" android:layout_weight="1"

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -24,10 +25,12 @@
android:id="@+id/editTextBarkName" android:id="@+id/editTextBarkName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="11" android:ems="11"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
tools:ignore="LabelFor"
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -47,8 +50,10 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints=""
tools:ignore="LabelFor" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -68,7 +73,7 @@
android:id="@+id/buttonBarkDel" android:id="@+id/buttonBarkDel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/del" /> android:text="@string/del" />
@ -76,7 +81,7 @@
android:id="@+id/buttonBarkTest" android:id="@+id/buttonBarkTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/test" /> android:text="@string/test" />

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -24,10 +25,11 @@
android:id="@+id/editTextDingdingName" android:id="@+id/editTextDingdingName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="11" android:ems="11"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -48,7 +50,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="textPassword" android:inputType="textPassword"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
@ -70,7 +73,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="textPassword" android:inputType="textPassword"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -90,8 +94,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -111,7 +116,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:checked="false" android:checked="false"
android:ems="14" /> android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -121,25 +127,25 @@
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button
android:id="@+id/buttondingdingok" android:id="@+id/buttonDingdingOk"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/ok" /> android:text="@string/ok" />
<Button <Button
android:id="@+id/buttondingdingdel" android:id="@+id/buttonDingdingDel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/del" /> android:text="@string/del" />
<Button <Button
android:id="@+id/buttondingdingtest" android:id="@+id/buttonDingdingTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/test" /> android:text="@string/test" />

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -24,10 +25,11 @@
android:id="@+id/editTextEmailName" android:id="@+id/editTextEmailName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="11" android:ems="11"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -46,10 +48,11 @@
android:id="@+id/editTextEmailHost" android:id="@+id/editTextEmailHost"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="14" android:ems="14"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -68,10 +71,11 @@
android:id="@+id/editTextEmailPort" android:id="@+id/editTextEmailPort"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="5" android:ems="5"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -82,7 +86,8 @@
android:id="@+id/switchEmailSSl" android:id="@+id/switchEmailSSl"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:checked="true" /> android:checked="true"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -101,10 +106,11 @@
android:id="@+id/editTextEmailFromAdd" android:id="@+id/editTextEmailFromAdd"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="14" android:ems="14"
android:inputType="textEmailAddress" android:inputType="textEmailAddress"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -123,10 +129,11 @@
android:id="@+id/editTextEmailNickname" android:id="@+id/editTextEmailNickname"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="14" android:ems="14"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -145,10 +152,11 @@
android:id="@+id/editTextEmailPsw" android:id="@+id/editTextEmailPsw"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="14" android:ems="14"
android:inputType="textPassword" android:inputType="textPassword"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -167,10 +175,11 @@
android:id="@+id/editTextEmailToAdd" android:id="@+id/editTextEmailToAdd"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="14" android:ems="14"
android:inputType="textEmailAddress" android:inputType="textEmailAddress"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -180,25 +189,25 @@
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button
android:id="@+id/buttonemailok" android:id="@+id/buttonEmailOk"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/ok" /> android:text="@string/ok" />
<Button <Button
android:id="@+id/buttonemaildel" android:id="@+id/buttonEmailDel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/del" /> android:text="@string/del" />
<Button <Button
android:id="@+id/buttonemailtest" android:id="@+id/buttonEmailTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/test" /> android:text="@string/test" />

View File

@ -24,10 +24,11 @@
android:id="@+id/editTextFeishuName" android:id="@+id/editTextFeishuName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="11" android:ems="11"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -47,8 +48,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
@ -70,7 +72,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="textPassword" android:inputType="textPassword"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -80,25 +83,25 @@
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button
android:id="@+id/buttonfeishuok" android:id="@+id/buttonFeishuOk"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/ok" /> android:text="@string/ok" />
<Button <Button
android:id="@+id/buttonfeishudel" android:id="@+id/buttonFeishuDel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/del" /> android:text="@string/del" />
<Button <Button
android:id="@+id/buttonfeishutest" android:id="@+id/buttonFeishuTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/test" /> android:text="@string/test" />

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -18,7 +19,7 @@
<TextView <TextView
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="right" android:gravity="end"
android:text="设置名称" android:text="设置名称"
android:textStyle="bold" /> android:textStyle="bold" />
@ -26,9 +27,10 @@
android:id="@+id/editTextQYWXAppName" android:id="@+id/editTextQYWXAppName"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -41,7 +43,7 @@
<TextView <TextView
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="right" android:gravity="end"
android:text="企业ID" android:text="企业ID"
android:textStyle="bold" /> android:textStyle="bold" />
@ -49,9 +51,10 @@
android:id="@+id/editTextQYWXAppCorpID" android:id="@+id/editTextQYWXAppCorpID"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:inputType="" android:inputType="text"
android:text="" /> android:text="@string/wechat_id"
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -64,7 +67,7 @@
<TextView <TextView
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="right" android:gravity="end"
android:text="AgentID" android:text="AgentID"
android:textStyle="bold" /> android:textStyle="bold" />
@ -72,9 +75,10 @@
android:id="@+id/editTextQYWXAppAgentID" android:id="@+id/editTextQYWXAppAgentID"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:inputType="" android:inputType="text"
android:text="" /> android:text="@string/Agent_ID"
android:autofillHints="" />
</LinearLayout> </LinearLayout>
@ -88,7 +92,7 @@
<TextView <TextView
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="right" android:gravity="end"
android:text="Secret" android:text="Secret"
android:textStyle="bold" /> android:textStyle="bold" />
@ -96,9 +100,10 @@
android:id="@+id/editTextQYWXAppSecret" android:id="@+id/editTextQYWXAppSecret"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:inputType="textPassword" android:inputType="textPassword"
android:text="" /> android:text="@string/App_Secret"
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -111,7 +116,7 @@
<TextView <TextView
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="right" android:gravity="end"
android:text="是否@all" android:text="是否@all"
android:textStyle="bold" /> android:textStyle="bold" />
@ -119,7 +124,8 @@
android:id="@+id/switchQYWXAppAtAll" android:id="@+id/switchQYWXAppAtAll"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:checked="false" /> android:checked="false"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -138,7 +144,7 @@
<TextView <TextView
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="right" android:gravity="end"
android:text="指定成员" android:text="指定成员"
android:textStyle="bold" /> android:textStyle="bold" />
@ -146,9 +152,10 @@
android:id="@+id/editTextQYWXAppToUser" android:id="@+id/editTextQYWXAppToUser"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<TextView <TextView
@ -176,7 +183,7 @@
android:id="@+id/buttonQYWXAppDel" android:id="@+id/buttonQYWXAppDel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/del" /> android:text="@string/del" />
@ -184,7 +191,7 @@
android:id="@+id/buttonQYWXAppTest" android:id="@+id/buttonQYWXAppTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/test" /> android:text="@string/test" />

View File

@ -24,10 +24,11 @@
android:id="@+id/editTextQYWXGroupRobotName" android:id="@+id/editTextQYWXGroupRobotName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="11" android:ems="11"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -47,8 +48,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -68,7 +70,7 @@
android:id="@+id/buttonQyWxGroupRobotDel" android:id="@+id/buttonQyWxGroupRobotDel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/del" /> android:text="@string/del" />
@ -76,7 +78,7 @@
android:id="@+id/buttonQyWxGroupRobotTest" android:id="@+id/buttonQyWxGroupRobotTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/test" /> android:text="@string/test" />

View File

@ -11,14 +11,14 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:text="设置匹配的卡槽" android:text="设置匹配的卡槽"
android:textStyle="bold" /> android:textStyle="bold" />
@ -49,14 +49,14 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:text="设置匹配的字段" android:text="设置匹配的字段"
android:textStyle="bold" /> android:textStyle="bold" />
@ -93,14 +93,14 @@
android:id="@+id/matchTypeLayout" android:id="@+id/matchTypeLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:text="设置匹配的模式" android:text="设置匹配的模式"
android:textStyle="bold" /> android:textStyle="bold" />
@ -152,7 +152,7 @@
android:id="@+id/matchValueLayout" android:id="@+id/matchValueLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:orientation="vertical"> android:orientation="vertical">
@ -168,8 +168,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
<TextView <TextView
android:id="@+id/tv_mu_rule_tips" android:id="@+id/tv_mu_rule_tips"
@ -191,7 +192,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:orientation="vertical"> android:orientation="vertical">
@ -219,7 +220,7 @@
android:id="@+id/ruleSenderTv" android:id="@+id/ruleSenderTv"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:text="" /> android:text="" />
</LinearLayout> </LinearLayout>
@ -233,25 +234,25 @@
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button
android:id="@+id/buttonruleok" android:id="@+id/buttonRuleOk"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/ok" /> android:text="@string/ok" />
<Button <Button
android:id="@+id/buttonruledel" android:id="@+id/buttonRuleDel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/del" /> android:text="@string/del" />
<Button <Button
android:id="@+id/buttonruletest" android:id="@+id/buttonRuleTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/test" /> android:text="@string/test" />

View File

@ -26,7 +26,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="3dp" android:layout_margin="3dp"
android:gravity="left|center_vertical" android:gravity="start|center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
<RadioButton <RadioButton
@ -56,8 +56,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="3dp" android:layout_margin="3dp"
android:ems="10" android:ems="10"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -72,14 +73,15 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="3dp" android:layout_margin="3dp"
android:ems="10" android:ems="10"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<Button <Button
android:id="@+id/buttonruletest" android:id="@+id/buttonRuleTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="0dp"
android:layout_margin="3dp" android:layout_margin="3dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/test" /> android:text="@string/test" />

View File

@ -24,10 +24,11 @@
android:id="@+id/editTextServerChanName" android:id="@+id/editTextServerChanName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="11" android:ems="11"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -48,7 +49,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="textPassword" android:inputType="textPassword"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -68,7 +70,7 @@
android:id="@+id/buttonServerChanDel" android:id="@+id/buttonServerChanDel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/del" /> android:text="@string/del" />
@ -76,7 +78,7 @@
android:id="@+id/buttonServerChanTest" android:id="@+id/buttonServerChanTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/test" /> android:text="@string/test" />

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -24,10 +25,11 @@
android:id="@+id/editTextSmsName" android:id="@+id/editTextSmsName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="14" android:ems="14"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -47,7 +49,7 @@
<RadioGroup <RadioGroup
android:id="@+id/radioGroupSmsSimSlot" android:id="@+id/radioGroupSmsSimSlot"
style="@style/rg_style" style="@style/rg_style"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:orientation="horizontal"> android:orientation="horizontal">
<RadioButton <RadioButton
@ -86,9 +88,10 @@
android:id="@+id/editTextSmsMobiles" android:id="@+id/editTextSmsMobiles"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="14" android:ems="14"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -108,7 +111,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:checked="false" android:checked="false"
android:ems="14" /> android:ems="14"
tools:ignore="UseSwitchCompatOrMaterialXml" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -128,7 +132,7 @@
android:id="@+id/buttonSmsDel" android:id="@+id/buttonSmsDel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/del" /> android:text="@string/del" />
@ -136,7 +140,7 @@
android:id="@+id/buttonSmsTest" android:id="@+id/buttonSmsTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/test" /> android:text="@string/test" />

View File

@ -24,10 +24,11 @@
android:id="@+id/editTextTelegramName" android:id="@+id/editTextTelegramName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="11" android:ems="11"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -48,7 +49,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="textPassword" android:inputType="textPassword"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -68,8 +70,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -89,7 +92,7 @@
android:id="@+id/buttonTelegramDel" android:id="@+id/buttonTelegramDel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/del" /> android:text="@string/del" />
@ -97,7 +100,7 @@
android:id="@+id/buttonTelegramTest" android:id="@+id/buttonTelegramTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/test" /> android:text="@string/test" />

View File

@ -24,10 +24,11 @@
android:id="@+id/editTextWebNotifyName" android:id="@+id/editTextWebNotifyName"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:ems="11" android:ems="11"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -47,7 +48,7 @@
android:id="@+id/radioGroupWebNotifyMethod" android:id="@+id/radioGroupWebNotifyMethod"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginStart="3dp"
android:orientation="horizontal"> android:orientation="horizontal">
<RadioButton <RadioButton
@ -84,8 +85,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -105,8 +107,9 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="" android:inputType="text"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -127,7 +130,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="14" android:ems="14"
android:inputType="textPassword" android:inputType="textPassword"
android:text="" /> android:text=""
android:autofillHints="" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -137,25 +141,25 @@
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button
android:id="@+id/buttonbebnotifyok" android:id="@+id/buttonWebNotifyOk"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/ok" /> android:text="@string/ok" />
<Button <Button
android:id="@+id/buttonbebnotifydel" android:id="@+id/buttonWebNotifyDel"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/del" /> android:text="@string/del" />
<Button <Button
android:id="@+id/buttonbebnotifytest" android:id="@+id/buttonWebNotifyTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/test" /> android:text="@string/test" />

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
@ -25,7 +26,7 @@
android:text="下拉可以刷新!" /> android:text="下拉可以刷新!" />
<TextView <TextView
android:id="@+id/lastupdate_time" android:id="@+id/lastUpdateTime"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
@ -34,17 +35,18 @@
android:id="@+id/arrow" android:id="@+id/arrow"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="20dip" android:layout_marginEnd="20dip"
android:layout_toLeftOf="@id/layout" android:layout_toStartOf="@id/layout"
android:src="@android:drawable/ic_popup_sync" /> android:src="@android:drawable/ic_popup_sync"
tools:ignore="ContentDescription" />
<ProgressBar <ProgressBar
android:id="@+id/progress" android:id="@+id/progress"
style="?android:attr/progressBarStyleSmall" style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="20dip" android:layout_marginEnd="20dip"
android:layout_toLeftOf="@id/layout" android:layout_toStartOf="@id/layout"
android:visibility="gone" /> android:visibility="gone" />
</RelativeLayout> </RelativeLayout>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -7,27 +8,29 @@
android:layout_width="34dp" android:layout_width="34dp"
android:layout_height="34dp" android:layout_height="34dp"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_marginLeft="5dp" android:layout_marginStart="5dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/tlog_sender_image" android:id="@+id/tlog_sender_image"
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="32dp" /> android:layout_height="32dp"
tools:ignore="ContentDescription" />
<ImageView <ImageView
android:id="@+id/tlog_status_image" android:id="@+id/tlog_status_image"
android:layout_width="16dp" android:layout_width="16dp"
android:layout_height="16dp" android:layout_height="16dp"
android:layout_marginLeft="18dp" android:layout_marginStart="18dp"
android:layout_marginTop="-14dp" /> android:layout_marginTop="-14dp"
tools:ignore="ContentDescription" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
android:orientation="vertical"> android:orientation="vertical">
<RelativeLayout <RelativeLayout
@ -54,13 +57,14 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_marginRight="24dp" /> android:layout_marginEnd="24dp" />
<ImageView <ImageView
android:id="@+id/tlog_sim_image" android:id="@+id/tlog_sim_image"
android:layout_width="16dp" android:layout_width="16dp"
android:layout_height="16dp" android:layout_height="16dp"
android:layout_alignParentEnd="true" /> android:layout_alignParentEnd="true"
tools:ignore="ContentDescription" />
</RelativeLayout> </RelativeLayout>
<TextView <TextView

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -8,19 +9,20 @@
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_margin="5dp" /> android:layout_margin="5dp"
tools:ignore="ContentDescription" />
<TextView <TextView
android:id="@+id/rule_match" android:id="@+id/rule_match"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp" /> android:layout_marginStart="5dp" />
<TextView <TextView
android:id="@+id/rule_sender" android:id="@+id/rule_sender"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp" /> android:layout_marginStart="5dp" />
</LinearLayout> </LinearLayout>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -7,12 +8,13 @@
android:id="@+id/sender_image" android:id="@+id/sender_image"
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_margin="5dp" /> android:layout_margin="5dp"
tools:ignore="ContentDescription" />
<TextView <TextView
android:id="@+id/sender_name" android:id="@+id/sender_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp" /> android:layout_marginStart="10dp" />
</LinearLayout> </LinearLayout>

View File

@ -1,7 +1,8 @@
<resources> <resources>
<string name="app_name">短信转发器</string> <string name="app_name">短信转发器</string>
<string name="dingdingok">确认</string> <string name="notification_content">根据规则转发到钉钉/微信/邮箱/bark/Server酱/Telegram/webhook等</string>
<string name="ok">确认</string> <string name="ok">确认</string>
<string name="cancel">取消</string>
<string name="del">删除</string> <string name="del">删除</string>
<string name="test">测试</string> <string name="test">测试</string>
<string name="setdingdingtitle">设置钉钉机器人</string> <string name="setdingdingtitle">设置钉钉机器人</string>
@ -22,6 +23,11 @@
<string name="log_tips">提示:置顶下拉刷新,长按删除单条记录</string> <string name="log_tips">提示:置顶下拉刷新,长按删除单条记录</string>
<string name="rule_tips">提示:新建规则点击“添加”,长按删除/点击编辑已有</string> <string name="rule_tips">提示:新建规则点击“添加”,长按删除/点击编辑已有</string>
<string name="sender_tips">提示:新建发送方点击“添加”,长按删除/点击编辑已有</string> <string name="sender_tips">提示:新建发送方点击“添加”,长按删除/点击编辑已有</string>
<string name="unknown_number">未知号码</string>
<string name="calling">来电</string>
<string name="unsupport">您的手机不支持此设置</string> <string name="unsupport">您的手机不支持此设置</string>
<string name="isIgnored">已设置成功!</string> <string name="isIgnored">已设置成功!</string>
<string name="wechat_id" />
<string name="Agent_ID" />
<string name="App_Secret" />
</resources> </resources>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<!-- TODO Remove the following "exclude" elements to make them a part of the auto backup -->
<exclude
domain="database"
path="sms_forwarder.db" />
<!-- Exclude the shared preferences file that contains the GCM registrationId -->
<exclude
domain="sharedpref"
path="forwarder_config.xml" />
<exclude
domain="sharedpref"
path="forwarder_msg.xml" />
</full-backup-content>

View File

@ -1,18 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.4.30'
repositories { repositories {
google() google()
jcenter() jcenter()
// maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://repo1.maven.org/maven2/' }
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.0.2' classpath 'com.android.tools.build:gradle:7.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.chenenyu:img-optimizer:1.2.0' //
} }
} }
@ -20,8 +15,6 @@ allprojects {
repositories { repositories {
google() google()
jcenter() jcenter()
// maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://repo1.maven.org/maven2/' }
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
} }
} }

3
version.properties Normal file
View File

@ -0,0 +1,3 @@
#Fri Jul 16 10:33:23 CST 2021
versionName=2.0.0
versionCode=26