初始化
@ -0,0 +1,12 @@
|
||||
.idea/
|
||||
.gradle
|
||||
.git
|
||||
build
|
||||
local.properties
|
||||
*.iml
|
||||
*.project
|
||||
*/*.project
|
||||
*.classpath
|
||||
*/*.classpath
|
||||
.settings/*
|
||||
*/.settings/*
|
@ -0,0 +1 @@
|
||||
theme: jekyll-theme-cayman
|
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
@ -0,0 +1,19 @@
|
||||
[
|
||||
{
|
||||
"outputType": {
|
||||
"type": "APK"
|
||||
},
|
||||
"apkInfo": {
|
||||
"type": "MAIN",
|
||||
"splits": [],
|
||||
"versionCode": 35,
|
||||
"versionName": "3.5.0",
|
||||
"enabled": true,
|
||||
"outputFile": "TSMS_release_20210126_3.5.0.apk",
|
||||
"fullName": "release",
|
||||
"baseName": "release"
|
||||
},
|
||||
"path": "TSMS_release_20210126_3.5.0.apk",
|
||||
"properties": {}
|
||||
}
|
||||
]
|
@ -0,0 +1,22 @@
|
||||
package com.idormy.sms.forwarder
|
||||
|
||||
import android.support.test.InstrumentationRegistry
|
||||
import android.support.test.runner.AndroidJUnit4
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getTargetContext()
|
||||
assertEquals("com.idormy.sms.forwarder", appContext.packageName)
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 105 KiB |
@ -0,0 +1,26 @@
|
||||
package com.idormy.sms.forwarder.BroadCastReceiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
public class MessageBroadcastReceiver extends BroadcastReceiver {
|
||||
public static String EXTRA_DATA = "data";
|
||||
public static String ACTION_DINGDING = "com.idormy.sms.forwarder.action_dingding";
|
||||
private String TAG = "MessageBroadcastReceiver";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context arg0, Intent intent) {
|
||||
Log.d(TAG, "onReceive intent " + intent.getAction());
|
||||
String action = intent.getAction();
|
||||
if (action.equals(ACTION_DINGDING)) {
|
||||
String sendStatus = intent.getStringExtra(EXTRA_DATA);
|
||||
Toast.makeText(arg0, "dingding sendStatus: " + sendStatus, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.idormy.sms.forwarder.BroadCastReceiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.idormy.sms.forwarder.FrontService;
|
||||
import com.idormy.sms.forwarder.utils.InitUtil;
|
||||
|
||||
public class RebootBroadcastReceiver extends BroadcastReceiver {
|
||||
private String TAG = "RebootBroadcastReceiver";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String receiveAction = intent.getAction();
|
||||
Log.d(TAG, "onReceive intent " + receiveAction);
|
||||
if (receiveAction.equals("android.intent.action.BOOT_COMPLETED")) {
|
||||
Log.d(TAG, "BOOT_COMPLETED");
|
||||
|
||||
InitUtil.init(context);
|
||||
Intent frontServiceIntent = new Intent(context, FrontService.class);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
context.startForegroundService(frontServiceIntent);
|
||||
} else {
|
||||
context.startService(frontServiceIntent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.idormy.sms.forwarder.BroadCastReceiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.telephony.SmsMessage;
|
||||
import android.util.Log;
|
||||
|
||||
import com.idormy.sms.forwarder.model.vo.SmsVo;
|
||||
import com.idormy.sms.forwarder.utils.SendUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TSMSBroadcastReceiver extends BroadcastReceiver {
|
||||
private String TAG = "TSMSBroadcastReceiver";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String receiveAction = intent.getAction();
|
||||
Log.d(TAG, "onReceive intent " + receiveAction);
|
||||
if (receiveAction.equals("android.provider.Telephony.SMS_RECEIVED")) {
|
||||
try {
|
||||
|
||||
Object[] object = (Object[]) Objects.requireNonNull(intent.getExtras()).get("pdus");
|
||||
if (object != null) {
|
||||
List<SmsVo> smsVoList = new ArrayList<>();
|
||||
String format = intent.getStringExtra("format");
|
||||
Map<String, String> mobileToContent = new HashMap<>();
|
||||
Date date = new Date();
|
||||
for (Object pdus : object) {
|
||||
byte[] pdusMsg = (byte[]) pdus;
|
||||
SmsMessage sms = SmsMessage.createFromPdu(pdusMsg, format);
|
||||
String mobile = sms.getOriginatingAddress();//发送短信的手机号
|
||||
if (mobile == null) {
|
||||
continue;
|
||||
}
|
||||
//下面是获取短信的发送时间
|
||||
date = new Date(sms.getTimestampMillis());
|
||||
|
||||
String content = mobileToContent.get(mobile);
|
||||
if (content == null) content = "";
|
||||
|
||||
content += sms.getMessageBody();//短信内容
|
||||
mobileToContent.put(mobile, content);
|
||||
|
||||
}
|
||||
for (String mobile : mobileToContent.keySet()) {
|
||||
smsVoList.add(new SmsVo(mobile, mobileToContent.get(mobile), date));
|
||||
}
|
||||
Log.d(TAG, "短信:" + smsVoList);
|
||||
SendUtil.send_msg_list(context, smsVoList);
|
||||
|
||||
}
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
Log.e(TAG, "解析短信失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.idormy.sms.forwarder;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
public class FrontService extends Service {
|
||||
private static final String TAG = "FrontService";
|
||||
private static final String CHANNEL_ONE_ID = "com.idormy.sms.forwarder";
|
||||
private static final String CHANNEL_ONE_NAME = "com.idormy.sms.forwarderName";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.i(TAG, "onCreate");
|
||||
Notification.Builder builder = new Notification.Builder(this);
|
||||
builder.setSmallIcon(R.mipmap.ic_launchert);
|
||||
builder.setContentTitle("短信转发器");
|
||||
builder.setContentText("根据规则转发到钉钉/微信/邮箱/bark/webhook等");
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity
|
||||
(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
//修改安卓8.1以上系统报错
|
||||
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ONE_ID, CHANNEL_ONE_NAME, NotificationManager.IMPORTANCE_MIN);
|
||||
notificationChannel.enableLights(false);//如果使用中的设备支持通知灯,则说明此通知通道是否应显示灯
|
||||
notificationChannel.setShowBadge(false);//是否显示角标
|
||||
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
|
||||
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
manager.createNotificationChannel(notificationChannel);
|
||||
builder.setChannelId(CHANNEL_ONE_ID);
|
||||
}
|
||||
|
||||
Notification notification = builder.build();
|
||||
startForeground(1, notification);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.i(TAG, "flags: " + flags + " startId: " + startId);
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
package com.idormy.sms.forwarder;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.idormy.sms.forwarder.BroadCastReceiver.RebootBroadcastReceiver;
|
||||
import com.idormy.sms.forwarder.model.vo.FeedBackResult;
|
||||
import com.idormy.sms.forwarder.utils.HttpI;
|
||||
import com.idormy.sms.forwarder.utils.HttpUtil;
|
||||
import com.idormy.sms.forwarder.utils.UpdateAppHttpUtil;
|
||||
import com.idormy.sms.forwarder.utils.aUtil;
|
||||
import com.vector.update_app.UpdateAppManager;
|
||||
import com.vector.update_app.UpdateCallback;
|
||||
import com.vector.update_app.listener.ExceptionHandler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class SettingActivity extends AppCompatActivity {
|
||||
private String TAG = "SettingActivity";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
Log.d(TAG, "oncreate");
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_setting);
|
||||
Log.d(TAG, "onCreate: " + RebootBroadcastReceiver.class.getName());
|
||||
|
||||
Switch check_with_reboot = (Switch) findViewById(R.id.switch_with_reboot);
|
||||
checkWithReboot(check_with_reboot);
|
||||
|
||||
TextView version_now = (TextView) findViewById(R.id.version_now);
|
||||
Button check_version_now = (Button) findViewById(R.id.check_version_now);
|
||||
try {
|
||||
version_now.setText(aUtil.getVersionName(SettingActivity.this));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
check_version_now.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
checkNewVersion();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//检查重启广播接受器状态并设置
|
||||
private void checkWithReboot(Switch withrebootSwitch) {
|
||||
//获取组件
|
||||
final ComponentName cm = new ComponentName(this.getPackageName(), RebootBroadcastReceiver.class.getName());
|
||||
|
||||
final PackageManager pm = getPackageManager();
|
||||
int state = pm.getComponentEnabledSetting(cm);
|
||||
if (state != PackageManager.COMPONENT_ENABLED_STATE_DISABLED
|
||||
&& state != PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) {
|
||||
|
||||
withrebootSwitch.setChecked(true);
|
||||
} else {
|
||||
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;
|
||||
pm.setComponentEnabledSetting(cm, newState, PackageManager.DONT_KILL_APP);
|
||||
Log.d(TAG, "onCheckedChanged:" + isChecked);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkNewVersion() {
|
||||
String geturl = "http://api.allmything.com/api/version/hasnew?versioncode=";
|
||||
|
||||
try {
|
||||
geturl += aUtil.getVersionCode(SettingActivity.this);
|
||||
|
||||
Log.i("SettingActivity", geturl);
|
||||
new UpdateAppManager
|
||||
.Builder()
|
||||
//当前Activity
|
||||
.setActivity(SettingActivity.this)
|
||||
//更新地址
|
||||
.setUpdateUrl(geturl)
|
||||
//全局异常捕获
|
||||
.handleException(new ExceptionHandler() {
|
||||
@Override
|
||||
public void onException(Exception e) {
|
||||
Log.e(TAG, "onException: ", e);
|
||||
Toast.makeText(SettingActivity.this, "更新失败:" + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
})
|
||||
//实现httpManager接口的对象
|
||||
.setHttpManager(new UpdateAppHttpUtil())
|
||||
.build()
|
||||
.checkNewApp(new UpdateCallback() {
|
||||
/**
|
||||
* 没有新版本
|
||||
*/
|
||||
protected void noNewApp(String error) {
|
||||
Toast.makeText(SettingActivity.this, "没有新版本", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
// .update();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void feedbackcommit(View view) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(SettingActivity.this);
|
||||
View view1 = View.inflate(SettingActivity.this, R.layout.dialog_feedback, null);
|
||||
|
||||
final EditText feedback_et_email = view1.findViewById(R.id.feedback_et_email);
|
||||
final EditText feedback_et_text = view1.findViewById(R.id.feedback_et_text);
|
||||
|
||||
builder
|
||||
.setTitle(R.string.feedback_input_text)
|
||||
.setView(view1)
|
||||
.create();
|
||||
builder.setPositiveButton("提交反馈", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
try {
|
||||
Map<String, String> feedBackData = new HashMap<>();
|
||||
feedBackData.put("email", feedback_et_email.getText().toString());
|
||||
feedBackData.put("text", feedback_et_text.getText().toString());
|
||||
new HttpUtil().asyncPost("https://api.sl.willanddo.com/api/tsms/feedBack", feedBackData, new HttpI.Callback() {
|
||||
@Override
|
||||
public void onResponse(String result) {
|
||||
Log.i(TAG, "onResponse: " + result);
|
||||
if (result != null) {
|
||||
FeedBackResult feedBackResult = JSON.parseObject(result, FeedBackResult.class);
|
||||
Log.i(TAG, "feedBackResult: " + feedBackResult);
|
||||
|
||||
if (feedBackResult != null) {
|
||||
JSONObject feedBackResultObject = JSON.parseObject(result);
|
||||
Toast.makeText(SettingActivity.this, feedBackResultObject.getString("message"), Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(SettingActivity.this, "感谢您的反馈,我们将尽快处理!", Toast.LENGTH_LONG).show();
|
||||
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(SettingActivity.this, "感谢您的反馈,我们将尽快处理!", Toast.LENGTH_LONG).show();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
Log.i(TAG, "onError: " + error);
|
||||
Toast.makeText(SettingActivity.this, error, Toast.LENGTH_LONG).show();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(SettingActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
|
||||
Log.d(TAG, "feedback e: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.idormy.sms.forwarder.model;
|
||||
|
||||
public class LogModel {
|
||||
private String from;
|
||||
private String content;
|
||||
private Long ruleId;
|
||||
private Long time;
|
||||
|
||||
public LogModel(String from, String content, Long ruleId) {
|
||||
this.from = from;
|
||||
this.content = content;
|
||||
this.ruleId = ruleId;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Long getRuleId() {
|
||||
return ruleId;
|
||||
}
|
||||
|
||||
public void setRuleId(Long ruleId) {
|
||||
this.ruleId = ruleId;
|
||||
}
|
||||
|
||||
public Long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogModel{" +
|
||||
"from='" + from + '\'' +
|
||||
", content='" + content + '\'' +
|
||||
", ruleId=" + ruleId +
|
||||
", time=" + time +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.idormy.sms.forwarder.model;
|
||||
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
public final class LogTable {
|
||||
// To prevent someone from accidentally instantiating the contract class,
|
||||
// make the constructor private.
|
||||
private LogTable() {
|
||||
}
|
||||
|
||||
/* Inner class that defines the table contents */
|
||||
public static class LogEntry implements BaseColumns {
|
||||
public static final String TABLE_NAME = "log";
|
||||
public static final String COLUMN_NAME_FROM = "l_from";
|
||||
public static final String COLUMN_NAME_CONTENT = "content";
|
||||
public static final String COLUMN_NAME_RULE_ID = "rule_id";
|
||||
public static final String COLUMN_NAME_TIME = "time";
|
||||
}
|
||||
}
|
@ -0,0 +1,179 @@
|
||||
package com.idormy.sms.forwarder.model;
|
||||
|
||||
import com.idormy.sms.forwarder.R;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class RuleModel {
|
||||
public static final String FILED_TRANSPOND_ALL = "transpond_all";
|
||||
public static final String FILED_PHONE_NUM = "phone_num";
|
||||
public static final String FILED_MSG_CONTENT = "msg_content";
|
||||
public static final Map<String, String> FILED_MAP = new HashMap<String, String>();
|
||||
public static final String CHECK_IS = "is";
|
||||
public static final String CHECK_CONTAIN = "contain";
|
||||
public static final String CHECK_START_WITH = "startwith";
|
||||
public static final String CHECK_END_WITH = "endwith";
|
||||
public static final String CHECK_NOT_IS = "notis";
|
||||
public static final Map<String, String> CHECK_MAP = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
FILED_MAP.put("transpond_all", "转发全部");
|
||||
FILED_MAP.put("phone_num", "手机号");
|
||||
FILED_MAP.put("msg_content", "内容");
|
||||
}
|
||||
|
||||
static {
|
||||
CHECK_MAP.put("is", "是");
|
||||
CHECK_MAP.put("contain", "包含");
|
||||
CHECK_MAP.put("startwith", "开头是");
|
||||
CHECK_MAP.put("endwith", "结尾是");
|
||||
CHECK_MAP.put("notis", "不是");
|
||||
}
|
||||
|
||||
private Long id;
|
||||
private String filed;
|
||||
private String check;
|
||||
|
||||
private String value;
|
||||
|
||||
private Long senderId;
|
||||
private Long time;
|
||||
|
||||
public static String getRuleMatch(String filed, String check, String value) {
|
||||
switch (filed) {
|
||||
case FILED_TRANSPOND_ALL:
|
||||
return "全部转发到 ";
|
||||
default:
|
||||
return "当 " + FILED_MAP.get(filed) + " " + CHECK_MAP.get(check) + " " + value;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String getRuleFiledFromCheckId(int id) {
|
||||
switch (id) {
|
||||
case R.id.btnContent:
|
||||
return FILED_MSG_CONTENT;
|
||||
case R.id.btnPhone:
|
||||
return FILED_PHONE_NUM;
|
||||
default:
|
||||
return FILED_TRANSPOND_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getRuleCheckFromCheckId(int id) {
|
||||
switch (id) {
|
||||
case R.id.btnContain:
|
||||
return CHECK_CONTAIN;
|
||||
case R.id.btnStartWith:
|
||||
return CHECK_START_WITH;
|
||||
case R.id.btnEndWith:
|
||||
return CHECK_END_WITH;
|
||||
case R.id.btnNotIs:
|
||||
return CHECK_NOT_IS;
|
||||
default:
|
||||
return CHECK_IS;
|
||||
}
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getSenderId() {
|
||||
return senderId;
|
||||
}
|
||||
|
||||
public void setSenderId(Long senderId) {
|
||||
this.senderId = senderId;
|
||||
}
|
||||
|
||||
public Long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(Long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getFiled() {
|
||||
return filed;
|
||||
}
|
||||
|
||||
public void setFiled(String filed) {
|
||||
this.filed = filed;
|
||||
}
|
||||
|
||||
public String getCheck() {
|
||||
return check;
|
||||
}
|
||||
|
||||
public void setCheck(String check) {
|
||||
this.check = check;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getRuleMatch() {
|
||||
switch (filed) {
|
||||
case FILED_TRANSPOND_ALL:
|
||||
return "全部转发到 ";
|
||||
default:
|
||||
return "当 " + FILED_MAP.get(filed) + " " + CHECK_MAP.get(check) + " " + value + " 转发到 ";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Long getRuleSenderId() {
|
||||
return senderId;
|
||||
}
|
||||
|
||||
public int getRuleFiledCheckId() {
|
||||
switch (filed) {
|
||||
case FILED_MSG_CONTENT:
|
||||
return R.id.btnContent;
|
||||
case FILED_PHONE_NUM:
|
||||
return R.id.btnPhone;
|
||||
default:
|
||||
return R.id.btnTranspondAll;
|
||||
}
|
||||
}
|
||||
|
||||
public int getRuleCheckCheckId() {
|
||||
switch (check) {
|
||||
case CHECK_CONTAIN:
|
||||
return R.id.btnContain;
|
||||
case CHECK_START_WITH:
|
||||
return R.id.btnStartWith;
|
||||
case CHECK_END_WITH:
|
||||
return R.id.btnEndWith;
|
||||
case CHECK_NOT_IS:
|
||||
return R.id.btnNotIs;
|
||||
default:
|
||||
return R.id.btnIs;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RuleModel{" +
|
||||
"id=" + id +
|
||||
", filed='" + filed + '\'' +
|
||||
", check='" + check + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
", senderId=" + senderId +
|
||||
", time=" + time +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.idormy.sms.forwarder.model;
|
||||
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
public final class RuleTable {
|
||||
// To prevent someone from accidentally instantiating the contract class,
|
||||
// make the constructor private.
|
||||
private RuleTable() {
|
||||
}
|
||||
|
||||
/* Inner class that defines the table contents */
|
||||
public static class RuleEntry implements BaseColumns {
|
||||
public static final String TABLE_NAME = "rule";
|
||||
public static final String COLUMN_NAME_FILED = "filed";
|
||||
public static final String COLUMN_NAME_CHECK = "tcheck";
|
||||
public static final String COLUMN_NAME_VALUE = "value";
|
||||
public static final String COLUMN_NAME_SENDER_ID = "sender_id";
|
||||
public static final String COLUMN_NAME_TIME = "time";
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
package com.idormy.sms.forwarder.model;
|
||||
|
||||
import com.idormy.sms.forwarder.R;
|
||||
|
||||
|
||||
public class SenderModel {
|
||||
public static final int STATUS_ON = 1;
|
||||
public static final int STATUS_OFF = 0;
|
||||
public static final int TYPE_DINGDING = 0;
|
||||
public static final int TYPE_EMAIL = 1;
|
||||
public static final int TYPE_MESSAGE = 2;
|
||||
public static final int TYPE_WEB_NOTIFY = 3;
|
||||
public static final int TYPE_QYWX_GROUP_ROBOT = 4;
|
||||
public static final int TYPE_BARK = 5;
|
||||
private Long id;
|
||||
private String name;
|
||||
private int status;
|
||||
private int type;
|
||||
|
||||
private String jsonSetting;
|
||||
|
||||
private long time;
|
||||
|
||||
public SenderModel() {
|
||||
}
|
||||
|
||||
public SenderModel(String name, int status, int type, String jsonSetting) {
|
||||
this.name = name;
|
||||
this.status = status == STATUS_ON ? STATUS_ON : STATUS_OFF;
|
||||
this.type = type;
|
||||
this.jsonSetting = jsonSetting;
|
||||
}
|
||||
|
||||
public static int getImageId(int type) {
|
||||
switch (type) {
|
||||
case (TYPE_DINGDING):
|
||||
return R.mipmap.dingding;
|
||||
case (TYPE_EMAIL):
|
||||
return R.drawable.ic_baseline_email_24;
|
||||
case (TYPE_QYWX_GROUP_ROBOT):
|
||||
return R.mipmap.qywx;
|
||||
case (TYPE_BARK):
|
||||
return R.mipmap.qywx;
|
||||
default:
|
||||
return R.mipmap.ic_launcher_round;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status == STATUS_ON ? STATUS_ON : STATUS_OFF;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getJsonSetting() {
|
||||
return jsonSetting;
|
||||
}
|
||||
|
||||
public void setJsonSetting(String jsonSetting) {
|
||||
this.jsonSetting = jsonSetting;
|
||||
}
|
||||
|
||||
public int getImageId() {
|
||||
switch (type) {
|
||||
case (TYPE_DINGDING):
|
||||
return R.mipmap.dingding;
|
||||
case (TYPE_EMAIL):
|
||||
return R.drawable.ic_baseline_email_24;
|
||||
case (TYPE_QYWX_GROUP_ROBOT):
|
||||
return R.mipmap.qywx;
|
||||
case (TYPE_BARK):
|
||||
return R.mipmap.qywx;
|
||||
default:
|
||||
return R.mipmap.ic_launcher_round;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SenderModel{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", status=" + status +
|
||||
", type=" + type +
|
||||
", jsonSetting='" + jsonSetting + '\'' +
|
||||
", time=" + time +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.idormy.sms.forwarder.model;
|
||||
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
public final class SenderTable {
|
||||
// To prevent someone from accidentally instantiating the contract class,
|
||||
// make the constructor private.
|
||||
private SenderTable() {
|
||||
}
|
||||
|
||||
/* Inner class that defines the table contents */
|
||||
public static class SenderEntry implements BaseColumns {
|
||||
public static final String TABLE_NAME = "sender";
|
||||
public static final String COLUMN_NAME_NAME = "name";
|
||||
public static final String COLUMN_NAME_STATUS = "status";
|
||||
public static final String COLUMN_NAME_TYPE = "type";
|
||||
public static final String COLUMN_NAME_JSON_SETTING = "json_setting";
|
||||
public static final String COLUMN_NAME_TIME = "time";
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.idormy.sms.forwarder.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class BarkSettingVo implements Serializable {
|
||||
private String server;
|
||||
|
||||
public BarkSettingVo() {
|
||||
}
|
||||
|
||||
public BarkSettingVo(String server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public void setServer(String server) {
|
||||
this.server = server;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.idormy.sms.forwarder.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class DingDingSettingVo implements Serializable {
|
||||
private String token;
|
||||
private String secret;
|
||||
private String atMobils;
|
||||
private Boolean atAll;
|
||||
|
||||
public DingDingSettingVo() {
|
||||
}
|
||||
|
||||
public DingDingSettingVo(String token, String secret, String atMobils, Boolean atAll) {
|
||||
this.token = token;
|
||||
this.secret = secret;
|
||||
this.atMobils = atMobils;
|
||||
this.atAll = atAll;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getSecret() {
|
||||
return secret;
|
||||
}
|
||||
|
||||
public void setSecret(String secret) {
|
||||
this.secret = secret;
|
||||
}
|
||||
|
||||
public String getAtMobils() {
|
||||
return atMobils;
|
||||
}
|
||||
|
||||
public void setAtMobils(String atMobils) {
|
||||
this.atMobils = atMobils;
|
||||
}
|
||||
|
||||
public Boolean getAtAll() {
|
||||
return atAll;
|
||||
}
|
||||
|
||||
public void setAtAll(Boolean atAll) {
|
||||
this.atAll = atAll;
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.idormy.sms.forwarder.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class EmailSettingVo implements Serializable {
|
||||
private String host;
|
||||
private String port;
|
||||
private Boolean ssl = true;
|
||||
private String fromEmail;
|
||||
private String pwd;
|
||||
private String toEmail;
|
||||
|
||||
public EmailSettingVo() {
|
||||
}
|
||||
|
||||
public EmailSettingVo(String host, String port, Boolean ssl, String fromEmail, String pwd, String toEmail) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.ssl = ssl;
|
||||
this.fromEmail = fromEmail;
|
||||
this.pwd = pwd;
|
||||
this.toEmail = toEmail;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public Boolean getSsl() {
|
||||
return ssl;
|
||||
}
|
||||
|
||||
public void setSsl(Boolean ssl) {
|
||||
this.ssl = ssl;
|
||||
}
|
||||
|
||||
public String getFromEmail() {
|
||||
return fromEmail;
|
||||
}
|
||||
|
||||
public void setFromEmail(String fromEmail) {
|
||||
this.fromEmail = fromEmail;
|
||||
}
|
||||
|
||||
public String getPwd() {
|
||||
return pwd;
|
||||
}
|
||||
|
||||
public void setPwd(String pwd) {
|
||||
this.pwd = pwd;
|
||||
}
|
||||
|
||||
public String getToEmail() {
|
||||
return toEmail;
|
||||
}
|
||||
|
||||
public void setToEmail(String toEmail) {
|
||||
this.toEmail = toEmail;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.idormy.sms.forwarder.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class FeedBackResult implements Serializable {
|
||||
Integer code;
|
||||
String message;
|
||||
Object result;
|
||||
|
||||
public FeedBackResult() {
|
||||
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return 1 == code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FeedBackResult{" +
|
||||
"code=" + code +
|
||||
", message='" + message + '\'' +
|
||||
", result=" + result +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.idormy.sms.forwarder.model.vo;
|
||||
|
||||
public class LogVo {
|
||||
private String from;
|
||||
private String content;
|
||||
private String rule;
|
||||
private int senderImageId;
|
||||
private String time;
|
||||
|
||||
public LogVo(String from, String content, String time, String rule, int senderImageId) {
|
||||
this.from = from;
|
||||
this.content = content;
|
||||
this.time = time;
|
||||
this.rule = rule;
|
||||
this.senderImageId = senderImageId;
|
||||
}
|
||||
|
||||
public LogVo() {
|
||||
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getRule() {
|
||||
return rule;
|
||||
}
|
||||
|
||||
public void setRule(String rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public int getSenderImageId() {
|
||||
return senderImageId;
|
||||
}
|
||||
|
||||
public void setSenderImageId(int senderImageId) {
|
||||
this.senderImageId = senderImageId;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.idormy.sms.forwarder.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class QYWXGroupRobotSettingVo implements Serializable {
|
||||
private String webHook;
|
||||
|
||||
public QYWXGroupRobotSettingVo() {
|
||||
}
|
||||
|
||||
public QYWXGroupRobotSettingVo(String webHook) {
|
||||
this.webHook = webHook;
|
||||
}
|
||||
|
||||
public String getWebHook() {
|
||||
return webHook;
|
||||
}
|
||||
|
||||
public void setWebHook(String webHook) {
|
||||
this.webHook = webHook;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.idormy.sms.forwarder.model.vo;
|
||||
|
||||
public class RuleVo {
|
||||
private String matchStr;
|
||||
private String senderStr;
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.idormy.sms.forwarder.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class SmsVo implements Serializable {
|
||||
String mobile;
|
||||
String content;
|
||||
Date date;
|
||||
|
||||
public SmsVo() {
|
||||
}
|
||||
|
||||
public SmsVo(String mobile, String content, Date date) {
|
||||
this.mobile = mobile;
|
||||
this.content = content;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getSmsVoForSend() {
|
||||
return mobile + "\n" +
|
||||
content + "\n" +
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SmsVo{" +
|
||||
"mobile='" + mobile + '\'' +
|
||||
", content='" + content + '\'' +
|
||||
", date=" + date +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.idormy.sms.forwarder.model.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class WebNotifySettingVo implements Serializable {
|
||||
private String token;
|
||||
private String secret;
|
||||
|
||||
public WebNotifySettingVo() {
|
||||
}
|
||||
|
||||
public WebNotifySettingVo(String token, String secret) {
|
||||
this.token = token;
|
||||
this.secret = secret;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getSecret() {
|
||||
return secret;
|
||||
}
|
||||
|
||||
public void setSecret(String secret) {
|
||||
this.secret = secret;
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.idormy.sms.forwarder.model.LogTable;
|
||||
import com.idormy.sms.forwarder.model.RuleTable;
|
||||
import com.idormy.sms.forwarder.model.SenderTable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class DbHelper extends SQLiteOpenHelper {
|
||||
// If you change the database schema, you must increment the database version.
|
||||
public static final String TAG = "DbHelper";
|
||||
public static final int DATABASE_VERSION = 1;
|
||||
public static final String DATABASE_NAME = "sms_forwarder.db";
|
||||
|
||||
private static final List<String> SQL_CREATE_ENTRIES =
|
||||
Arrays.asList(
|
||||
"CREATE TABLE " + LogTable.LogEntry.TABLE_NAME + " (" +
|
||||
LogTable.LogEntry._ID + " INTEGER PRIMARY KEY," +
|
||||
LogTable.LogEntry.COLUMN_NAME_FROM + " TEXT," +
|
||||
LogTable.LogEntry.COLUMN_NAME_CONTENT + " TEXT," +
|
||||
LogTable.LogEntry.COLUMN_NAME_RULE_ID + " INTEGER," +
|
||||
LogTable.LogEntry.COLUMN_NAME_TIME + " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)"
|
||||
, "CREATE TABLE " + RuleTable.RuleEntry.TABLE_NAME + " (" +
|
||||
RuleTable.RuleEntry._ID + " INTEGER PRIMARY KEY," +
|
||||
RuleTable.RuleEntry.COLUMN_NAME_FILED + " TEXT," +
|
||||
RuleTable.RuleEntry.COLUMN_NAME_CHECK + " TEXT," +
|
||||
RuleTable.RuleEntry.COLUMN_NAME_VALUE + " TEXT," +
|
||||
RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID + " INTEGER," +
|
||||
RuleTable.RuleEntry.COLUMN_NAME_TIME + " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)"
|
||||
, "CREATE TABLE " + SenderTable.SenderEntry.TABLE_NAME + " (" +
|
||||
SenderTable.SenderEntry._ID + " INTEGER PRIMARY KEY," +
|
||||
SenderTable.SenderEntry.COLUMN_NAME_NAME + " TEXT," +
|
||||
SenderTable.SenderEntry.COLUMN_NAME_STATUS + " INTEGER," +
|
||||
SenderTable.SenderEntry.COLUMN_NAME_TYPE + " INTEGER," +
|
||||
SenderTable.SenderEntry.COLUMN_NAME_JSON_SETTING + " TEXT," +
|
||||
SenderTable.SenderEntry.COLUMN_NAME_TIME + " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)"
|
||||
);
|
||||
|
||||
private static final List<String> SQL_DELETE_ENTRIES =
|
||||
Arrays.asList(
|
||||
"DROP TABLE IF EXISTS " + LogTable.LogEntry.TABLE_NAME + " ; "
|
||||
, "DROP TABLE IF EXISTS " + RuleTable.RuleEntry.TABLE_NAME + " ; "
|
||||
, "DROP TABLE IF EXISTS " + SenderTable.SenderEntry.TABLE_NAME + " ; "
|
||||
|
||||
);
|
||||
|
||||
|
||||
public DbHelper(Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
}
|
||||
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
for (String createEntries : SQL_CREATE_ENTRIES
|
||||
) {
|
||||
Log.d(TAG, "onCreate:createEntries " + createEntries);
|
||||
db.execSQL(createEntries);
|
||||
}
|
||||
}
|
||||
|
||||
public void delCreateTable(SQLiteDatabase db) {
|
||||
for (String delCreateEntries : SQL_DELETE_ENTRIES
|
||||
) {
|
||||
Log.d(TAG, "delCreateTable:delCreateEntries " + delCreateEntries);
|
||||
db.execSQL(delCreateEntries);
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
// This database is only a cache for online data, so its upgrade policy is
|
||||
// to simply to discard the data and start over
|
||||
delCreateTable(db);
|
||||
onCreate(db);
|
||||
}
|
||||
|
||||
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
onUpgrade(db, oldVersion, newVersion);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
public class Define {
|
||||
public static String SP_MSG = "tsms_msg";
|
||||
public static String SP_MSG_SET_KEY = "tsms_msg_set_key";
|
||||
public static String SP_MSG_SEND_UTIL_EMAIL_HOST_KEY = "tsms_msg_send_util_email_host_key";
|
||||
public static String SP_MSG_SEND_UTIL_EMAIL_PORT_KEY = "tsms_msg_send_util_email_port_key";
|
||||
public static String SP_MSG_SEND_UTIL_EMAIL_FROMADD_KEY = "tsms_msg_send_util_email_fromadd_key";
|
||||
public static String SP_MSG_SEND_UTIL_EMAIL_PSW_KEY = "tsms_msg_send_util_email_psw_key";
|
||||
public static String SP_MSG_SEND_UTIL_EMAIL_TOADD_KEY = "tsms_msg_send_util_email_toadd_key";
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* app版本更新接口
|
||||
*/
|
||||
public interface HttpI extends Serializable {
|
||||
/**
|
||||
* 异步get
|
||||
*
|
||||
* @param url get请求地址
|
||||
* @param params get参数
|
||||
* @param callBack 回调
|
||||
*/
|
||||
void asyncGet(@NonNull String url, @NonNull Map<String, String> params, @NonNull Callback callBack);
|
||||
|
||||
|
||||
/**
|
||||
* 异步post
|
||||
*
|
||||
* @param url post请求地址
|
||||
* @param params post请求参数
|
||||
* @param callBack 回调
|
||||
*/
|
||||
void asyncPost(@NonNull String url, @NonNull Map<String, String> params, @NonNull Callback callBack);
|
||||
|
||||
/**
|
||||
* 下载
|
||||
*
|
||||
* @param url 下载地址
|
||||
* @param path 文件保存路径
|
||||
* @param fileName 文件名称
|
||||
* @param callback 回调
|
||||
*/
|
||||
void download(@NonNull String url, @NonNull String path, @NonNull String fileName, @NonNull FileCallback callback);
|
||||
|
||||
/**
|
||||
* 下载回调
|
||||
*/
|
||||
interface FileCallback {
|
||||
/**
|
||||
* 进度
|
||||
*
|
||||
* @param progress 进度0.00 - 0.50 - 1.00
|
||||
* @param total 文件总大小 单位字节
|
||||
*/
|
||||
void onProgress(float progress, long total);
|
||||
|
||||
/**
|
||||
* 错误回调
|
||||
*
|
||||
* @param error 错误提示
|
||||
*/
|
||||
void onError(String error);
|
||||
|
||||
/**
|
||||
* 结果回调
|
||||
*
|
||||
* @param file 下载好的文件
|
||||
*/
|
||||
void onResponse(File file);
|
||||
|
||||
/**
|
||||
* 请求之前
|
||||
*/
|
||||
void onBefore();
|
||||
}
|
||||
|
||||
/**
|
||||
* 网络请求回调
|
||||
*/
|
||||
interface Callback {
|
||||
/**
|
||||
* 结果回调
|
||||
*
|
||||
* @param result 结果
|
||||
*/
|
||||
void onResponse(String result);
|
||||
|
||||
/**
|
||||
* 错误回调
|
||||
*
|
||||
* @param error 错误提示
|
||||
*/
|
||||
void onError(String error);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,117 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.zhy.http.okhttp.OkHttpUtils;
|
||||
import com.zhy.http.okhttp.callback.FileCallBack;
|
||||
import com.zhy.http.okhttp.callback.StringCallback;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
|
||||
public class HttpUtil implements HttpI {
|
||||
/**
|
||||
* 异步get
|
||||
*
|
||||
* @param url get请求地址
|
||||
* @param params get参数
|
||||
* @param callBack 回调
|
||||
*/
|
||||
public void asyncGet(@NonNull String url, @NonNull Map<String, String> params, @NonNull final Callback callBack) {
|
||||
params.put("aaa", "bbbbb");
|
||||
params.put("ccc", "ddd");
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
OkHttpUtils.get()
|
||||
.url(url)
|
||||
.headers(headers)
|
||||
.params(params)
|
||||
.build()
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e, int id) {
|
||||
callBack.onError(validateError(e, response));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(String response, int id) {
|
||||
callBack.onResponse(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步post
|
||||
*
|
||||
* @param url post请求地址
|
||||
* @param params post请求参数
|
||||
* @param callBack 回调
|
||||
*/
|
||||
public void asyncPost(@NonNull String url, @NonNull Map<String, String> params, @NonNull final Callback callBack) {
|
||||
params.put("eeee", "fff");
|
||||
params.put("gggg", "hhhh");
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("heada", "bb");
|
||||
OkHttpUtils.post()
|
||||
.url(url)
|
||||
.headers(headers)
|
||||
.params(params)
|
||||
.build()
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e, int id) {
|
||||
callBack.onError(validateError(e, response));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(String response, int id) {
|
||||
callBack.onResponse(response);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载
|
||||
*
|
||||
* @param url 下载地址
|
||||
* @param path 文件保存路径
|
||||
* @param fileName 文件名称
|
||||
* @param callback 回调
|
||||
*/
|
||||
public void download(@NonNull String url, @NonNull String path, @NonNull String fileName, @NonNull final FileCallback callback) {
|
||||
OkHttpUtils.get()
|
||||
.url(url)
|
||||
.build()
|
||||
.execute(new FileCallBack(path, fileName) {
|
||||
@Override
|
||||
public void inProgress(float progress, long total, int id) {
|
||||
callback.onProgress(progress, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e, int id) {
|
||||
callback.onError(validateError(e, response));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(File response, int id) {
|
||||
callback.onResponse(response);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBefore(Request request, int id) {
|
||||
super.onBefore(request, id);
|
||||
callback.onBefore();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
public class InitUtil {
|
||||
static Boolean hasInit = false;
|
||||
private static String TAG = "InitUtil";
|
||||
private static Context context = null;
|
||||
|
||||
public static void init(Context context1) {
|
||||
Log.d(TAG, "TMSG init");
|
||||
synchronized (hasInit) {
|
||||
if (hasInit) return;
|
||||
hasInit = true;
|
||||
context = context1;
|
||||
Log.d(TAG, "init context");
|
||||
SettingUtil.init(context);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.provider.BaseColumns;
|
||||
import android.util.Log;
|
||||
|
||||
import com.idormy.sms.forwarder.model.LogModel;
|
||||
import com.idormy.sms.forwarder.model.LogTable;
|
||||
import com.idormy.sms.forwarder.model.RuleModel;
|
||||
import com.idormy.sms.forwarder.model.RuleTable;
|
||||
import com.idormy.sms.forwarder.model.SenderModel;
|
||||
import com.idormy.sms.forwarder.model.SenderTable;
|
||||
import com.idormy.sms.forwarder.model.vo.LogVo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class LogUtil {
|
||||
static String TAG = "LogUtil";
|
||||
static Boolean hasInit = false;
|
||||
|
||||
static Context context;
|
||||
static DbHelper dbHelper;
|
||||
static SQLiteDatabase db;
|
||||
|
||||
public static void init(Context context1) {
|
||||
synchronized (hasInit) {
|
||||
if (hasInit) return;
|
||||
hasInit = true;
|
||||
context = context1;
|
||||
dbHelper = new DbHelper(context);
|
||||
// Gets the data repository in write mode
|
||||
db = dbHelper.getReadableDatabase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static long addLog(LogModel logModel) {
|
||||
Log.i(TAG, "addLog logModel: " + logModel);
|
||||
//不保存转发消息
|
||||
if (logModel == null) return 0;
|
||||
|
||||
// Create a new map of values, where column names are the keys
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(LogTable.LogEntry.COLUMN_NAME_FROM, logModel.getFrom());
|
||||
values.put(LogTable.LogEntry.COLUMN_NAME_CONTENT, logModel.getContent());
|
||||
values.put(LogTable.LogEntry.COLUMN_NAME_RULE_ID, logModel.getRuleId());
|
||||
|
||||
// Insert the new row, returning the primary key value of the new row
|
||||
|
||||
return db.insert(LogTable.LogEntry.TABLE_NAME, null, values);
|
||||
}
|
||||
|
||||
public static int delLog(Long id, String key) {
|
||||
// Define 'where' part of query.
|
||||
String selection = " 1 ";
|
||||
// Specify arguments in placeholder order.
|
||||
List<String> selectionArgList = new ArrayList<>();
|
||||
if (id != null) {
|
||||
// Define 'where' part of query.
|
||||
selection += " and " + LogTable.LogEntry._ID + " = ? ";
|
||||
// Specify arguments in placeholder order.
|
||||
selectionArgList.add(String.valueOf(id));
|
||||
|
||||
}
|
||||
|
||||
if (key != null) {
|
||||
// Define 'where' part of query.
|
||||
selection = " and (" + LogTable.LogEntry.COLUMN_NAME_FROM + " LIKE ? or " + LogTable.LogEntry.COLUMN_NAME_CONTENT + " LIKE ? ) ";
|
||||
// Specify arguments in placeholder order.
|
||||
selectionArgList.add(key);
|
||||
selectionArgList.add(key);
|
||||
}
|
||||
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]);
|
||||
// Issue SQL statement.
|
||||
return db.delete(LogTable.LogEntry.TABLE_NAME, selection, selectionArgs);
|
||||
|
||||
}
|
||||
|
||||
public static List<LogVo> getLog(Long id, String key) {
|
||||
// Define a projection that specifies which columns from the database
|
||||
// you will actually use after this query.
|
||||
String[] projection = {
|
||||
LogTable.LogEntry.TABLE_NAME + "." + BaseColumns._ID,
|
||||
LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_FROM,
|
||||
LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_TIME,
|
||||
LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_CONTENT,
|
||||
RuleTable.RuleEntry.TABLE_NAME + "." + RuleTable.RuleEntry.COLUMN_NAME_FILED,
|
||||
RuleTable.RuleEntry.TABLE_NAME + "." + RuleTable.RuleEntry.COLUMN_NAME_CHECK,
|
||||
RuleTable.RuleEntry.TABLE_NAME + "." + RuleTable.RuleEntry.COLUMN_NAME_VALUE,
|
||||
SenderTable.SenderEntry.TABLE_NAME + "." + SenderTable.SenderEntry.COLUMN_NAME_NAME,
|
||||
SenderTable.SenderEntry.TABLE_NAME + "." + SenderTable.SenderEntry.COLUMN_NAME_TYPE
|
||||
};
|
||||
// Define 'where' part of query.
|
||||
String selection = " 1 ";
|
||||
// Specify arguments in placeholder order.
|
||||
List<String> selectionArgList = new ArrayList<>();
|
||||
if (id != null) {
|
||||
// Define 'where' part of query.
|
||||
selection += " and " + LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry._ID + " = ? ";
|
||||
// Specify arguments in placeholder order.
|
||||
selectionArgList.add(String.valueOf(id));
|
||||
}
|
||||
|
||||
if (key != null) {
|
||||
// Define 'where' part of query.
|
||||
selection = " and (" + LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_FROM + " LIKE ? or " + LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_CONTENT + " LIKE ? ) ";
|
||||
// Specify arguments in placeholder order.
|
||||
selectionArgList.add(key);
|
||||
selectionArgList.add(key);
|
||||
}
|
||||
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]);
|
||||
|
||||
// How you want the results sorted in the resulting Cursor
|
||||
String sortOrder =
|
||||
LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry._ID + " DESC";
|
||||
|
||||
Cursor cursor = db.query(
|
||||
// The table to query
|
||||
LogTable.LogEntry.TABLE_NAME
|
||||
+ " LEFT JOIN " + RuleTable.RuleEntry.TABLE_NAME + " ON " + LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_RULE_ID + "=" + RuleTable.RuleEntry.TABLE_NAME + "." + RuleTable.RuleEntry._ID
|
||||
+ " LEFT JOIN " + SenderTable.SenderEntry.TABLE_NAME + " ON " + SenderTable.SenderEntry.TABLE_NAME + "." + SenderTable.SenderEntry._ID + "=" + RuleTable.RuleEntry.TABLE_NAME + "." + RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID,
|
||||
projection, // The array of columns to return (pass null to get all)
|
||||
selection, // The columns for the WHERE clause
|
||||
selectionArgs, // The values for the WHERE clause
|
||||
null, // don't group the rows
|
||||
null, // don't filter by row groups
|
||||
sortOrder // The sort order
|
||||
);
|
||||
|
||||
|
||||
Log.d(TAG, "getLog: " + db.getPath());
|
||||
List<LogVo> LogVos = new ArrayList<>();
|
||||
|
||||
Log.d(TAG, "getLog: itemId cursor" + Arrays.toString(cursor.getColumnNames()));
|
||||
while (cursor.moveToNext()) {
|
||||
try {
|
||||
String itemfrom = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_FROM));
|
||||
String content = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_CONTENT));
|
||||
String time = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(LogTable.LogEntry.TABLE_NAME + "." + LogTable.LogEntry.COLUMN_NAME_TIME));
|
||||
String ruleFiled = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.TABLE_NAME + "." + RuleTable.RuleEntry.COLUMN_NAME_FILED));
|
||||
String ruleCheck = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.TABLE_NAME + "." + RuleTable.RuleEntry.COLUMN_NAME_CHECK));
|
||||
String ruleValue = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.TABLE_NAME + "." + RuleTable.RuleEntry.COLUMN_NAME_VALUE));
|
||||
String senderName = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(SenderTable.SenderEntry.TABLE_NAME + "." + SenderTable.SenderEntry.COLUMN_NAME_NAME));
|
||||
Integer senderType = cursor.getInt(
|
||||
cursor.getColumnIndexOrThrow(SenderTable.SenderEntry.TABLE_NAME + "." + SenderTable.SenderEntry.COLUMN_NAME_TYPE));
|
||||
|
||||
Log.d(TAG, "getLog: time" + time);
|
||||
String rule = RuleModel.getRuleMatch(ruleFiled, ruleCheck, ruleValue) + " 转发到 " + senderName;
|
||||
// String rule = time+" 转发到 "+senderName;
|
||||
int senderImageId = SenderModel.getImageId(senderType);
|
||||
LogVo logVo = new LogVo(itemfrom, content, time, rule, senderImageId);
|
||||
|
||||
LogVos.add(logVo);
|
||||
} catch (Exception e) {
|
||||
Log.i(TAG, "getLog e:" + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
cursor.close();
|
||||
|
||||
return LogVos;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.sun.mail.util.MailSSLSocketFactory;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MailSenderInfo {
|
||||
private static String TAG = "MailSenderInfo";
|
||||
// 发送邮件的服务器的IP和端口
|
||||
private String mailServerHost;
|
||||
private String mailServerPort = "25";
|
||||
|
||||
// 邮件发送者的地址
|
||||
private String fromAddress;
|
||||
// 邮件接收者的地址
|
||||
private String toAddress;
|
||||
// 登陆邮件发送服务器的用户名和密码
|
||||
private String userName;
|
||||
private String password;
|
||||
// 是否需要身份验证
|
||||
private boolean validate = true;
|
||||
//开启ssl
|
||||
private boolean ssl = true;
|
||||
// 邮件主题
|
||||
private String subject;
|
||||
// 邮件的文本内容
|
||||
private String content;
|
||||
// 邮件附件的文件名
|
||||
private String[] attachFileNames;
|
||||
|
||||
/**
|
||||
* 获得邮件会话属性
|
||||
*/
|
||||
public Properties getProperties() {
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.host", this.mailServerHost);
|
||||
props.put("mail.smtp.port", this.mailServerPort);
|
||||
props.put("mail.smtp.auth", validate ? "true" : "false");
|
||||
|
||||
if (ssl) {
|
||||
try {
|
||||
MailSSLSocketFactory sf = new MailSSLSocketFactory();
|
||||
sf.setTrustAllHosts(true);
|
||||
props.put("mail.smtp.ssl.enable", "true");
|
||||
props.put("mail.smtp.ssl.socketFactory", sf);
|
||||
Log.i(TAG, "set ssl success");
|
||||
} catch (GeneralSecurityException e) {
|
||||
Log.e(TAG, "set ssl fail: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
public String getMailServerHost() {
|
||||
return mailServerHost;
|
||||
}
|
||||
|
||||
public void setMailServerHost(String mailServerHost) {
|
||||
this.mailServerHost = mailServerHost;
|
||||
}
|
||||
|
||||
public String getMailServerPort() {
|
||||
return mailServerPort;
|
||||
}
|
||||
|
||||
public void setMailServerPort(String mailServerPort) {
|
||||
this.mailServerPort = mailServerPort;
|
||||
}
|
||||
|
||||
public boolean isValidate() {
|
||||
return validate;
|
||||
}
|
||||
|
||||
public void setValidate(boolean validate) {
|
||||
this.validate = validate;
|
||||
}
|
||||
|
||||
public String[] getAttachFileNames() {
|
||||
return attachFileNames;
|
||||
}
|
||||
|
||||
public void setAttachFileNames(String[] fileNames) {
|
||||
this.attachFileNames = fileNames;
|
||||
}
|
||||
|
||||
public String getFromAddress() {
|
||||
return fromAddress;
|
||||
}
|
||||
|
||||
public void setFromAddress(String fromAddress) {
|
||||
this.fromAddress = fromAddress;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getToAddress() {
|
||||
return toAddress;
|
||||
}
|
||||
|
||||
public void setToAddress(String toAddress) {
|
||||
this.toAddress = toAddress;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String textContent) {
|
||||
this.content = textContent;
|
||||
}
|
||||
|
||||
public boolean isSsl() {
|
||||
return ssl;
|
||||
}
|
||||
|
||||
public void setSsl(boolean ssl) {
|
||||
this.ssl = ssl;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import javax.mail.Authenticator;
|
||||
import javax.mail.PasswordAuthentication;
|
||||
|
||||
public class MyAuthenticator extends Authenticator {
|
||||
String userName = null;
|
||||
String password = null;
|
||||
|
||||
public MyAuthenticator() {
|
||||
}
|
||||
|
||||
public MyAuthenticator(String username, String password) {
|
||||
this.userName = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(userName, password);
|
||||
}
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.provider.BaseColumns;
|
||||
import android.util.Log;
|
||||
|
||||
import com.idormy.sms.forwarder.model.RuleModel;
|
||||
import com.idormy.sms.forwarder.model.RuleTable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RuleUtil {
|
||||
static String TAG = "RuleUtil";
|
||||
static Boolean hasInit = false;
|
||||
static Context context;
|
||||
static DbHelper dbHelper;
|
||||
static SQLiteDatabase db;
|
||||
|
||||
public static void init(Context context1) {
|
||||
synchronized (hasInit) {
|
||||
if (hasInit) return;
|
||||
hasInit = true;
|
||||
context = context1;
|
||||
dbHelper = new DbHelper(context);
|
||||
// Gets the data repository in write mode
|
||||
db = dbHelper.getReadableDatabase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static long addRule(RuleModel ruleModel) {
|
||||
|
||||
// Create a new map of values, where column names are the keys
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_FILED, ruleModel.getFiled());
|
||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_CHECK, ruleModel.getCheck());
|
||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_VALUE, ruleModel.getValue());
|
||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID, ruleModel.getSenderId());
|
||||
|
||||
// Insert the new row, returning the primary key value of the new row
|
||||
|
||||
return db.insert(RuleTable.RuleEntry.TABLE_NAME, null, values);
|
||||
}
|
||||
|
||||
public static long updateRule(RuleModel ruleModel) {
|
||||
if (ruleModel == null) return 0;
|
||||
|
||||
// Create a new map of values, where column names are the keys
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_FILED, ruleModel.getFiled());
|
||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_CHECK, ruleModel.getCheck());
|
||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_VALUE, ruleModel.getValue());
|
||||
values.put(RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID, ruleModel.getSenderId());
|
||||
|
||||
String selection = RuleTable.RuleEntry._ID + " = ? ";
|
||||
String[] whereArgs = {String.valueOf(ruleModel.getId())};
|
||||
|
||||
return db.update(RuleTable.RuleEntry.TABLE_NAME, values, selection, whereArgs);
|
||||
}
|
||||
|
||||
public static int delRule(Long id) {
|
||||
// Define 'where' part of query.
|
||||
String selection = " 1 ";
|
||||
// Specify arguments in placeholder order.
|
||||
List<String> selectionArgList = new ArrayList<>();
|
||||
if (id != null) {
|
||||
// Define 'where' part of query.
|
||||
selection += " and " + RuleTable.RuleEntry._ID + " = ? ";
|
||||
// Specify arguments in placeholder order.
|
||||
selectionArgList.add(String.valueOf(id));
|
||||
|
||||
}
|
||||
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]);
|
||||
// Issue SQL statement.
|
||||
return db.delete(RuleTable.RuleEntry.TABLE_NAME, selection, selectionArgs);
|
||||
|
||||
}
|
||||
|
||||
public static List<RuleModel> getRule(Long id, String key) {
|
||||
// Define a projection that specifies which columns from the database
|
||||
// you will actually use after this query.
|
||||
String[] projection = {
|
||||
BaseColumns._ID,
|
||||
RuleTable.RuleEntry.COLUMN_NAME_FILED,
|
||||
RuleTable.RuleEntry.COLUMN_NAME_CHECK,
|
||||
RuleTable.RuleEntry.COLUMN_NAME_VALUE,
|
||||
RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID,
|
||||
RuleTable.RuleEntry.COLUMN_NAME_TIME
|
||||
};
|
||||
// Define 'where' part of query.
|
||||
String selection = " 1 ";
|
||||
// Specify arguments in placeholder order.
|
||||
List<String> selectionArgList = new ArrayList<>();
|
||||
if (id != null) {
|
||||
// Define 'where' part of query.
|
||||
selection += " and " + RuleTable.RuleEntry._ID + " = ? ";
|
||||
// Specify arguments in placeholder order.
|
||||
selectionArgList.add(String.valueOf(id));
|
||||
}
|
||||
|
||||
if (key != null) {
|
||||
// Define 'where' part of query.
|
||||
selection = " and (" + RuleTable.RuleEntry.COLUMN_NAME_VALUE + " LIKE ? ";
|
||||
// Specify arguments in placeholder order.
|
||||
selectionArgList.add(key);
|
||||
}
|
||||
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]);
|
||||
|
||||
// How you want the results sorted in the resulting Cursor
|
||||
String sortOrder =
|
||||
RuleTable.RuleEntry._ID + " DESC";
|
||||
|
||||
Cursor cursor = db.query(
|
||||
RuleTable.RuleEntry.TABLE_NAME, // The table to query
|
||||
projection, // The array of columns to return (pass null to get all)
|
||||
selection, // The columns for the WHERE clause
|
||||
selectionArgs, // The values for the WHERE clause
|
||||
null, // don't group the rows
|
||||
null, // don't filter by row groups
|
||||
sortOrder // The sort order
|
||||
);
|
||||
List<RuleModel> tRules = new ArrayList<>();
|
||||
while (cursor.moveToNext()) {
|
||||
|
||||
long itemId = cursor.getLong(
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry._ID));
|
||||
String itemFiled = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_FILED));
|
||||
String itemCheck = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_CHECK));
|
||||
String itemValue = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_VALUE));
|
||||
long itemSenderId = cursor.getLong(
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_SENDER_ID));
|
||||
long itemTime = cursor.getLong(
|
||||
cursor.getColumnIndexOrThrow(RuleTable.RuleEntry.COLUMN_NAME_TIME));
|
||||
|
||||
Log.d(TAG, "getRule: itemId" + itemId);
|
||||
RuleModel ruleModel = new RuleModel();
|
||||
ruleModel.setId(itemId);
|
||||
ruleModel.setFiled(itemFiled);
|
||||
ruleModel.setCheck(itemCheck);
|
||||
ruleModel.setValue(itemValue);
|
||||
ruleModel.setSenderId(itemSenderId);
|
||||
ruleModel.setTime(itemTime);
|
||||
|
||||
tRules.add(ruleModel);
|
||||
}
|
||||
cursor.close();
|
||||
return tRules;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public class SendMailUtil {
|
||||
private static String TAG = "SendMailUtil";
|
||||
//qq
|
||||
// private static final String HOST = "smtp.qq.com";
|
||||
// private static final String PORT = "587";
|
||||
// private static final String FROM_ADD = "teprinciple@foxmail.com"; //发送方邮箱
|
||||
// private static final String FROM_PSW = "lfrlpganzjrwbeci";//发送方邮箱授权码
|
||||
|
||||
// //163
|
||||
// private static final String HOST = "smtp.163.com";
|
||||
// private static final String PORT = "465"; //nossl 25或者ssl465 994
|
||||
// private static final String FROM_ADD = "xxxxxx@163.com";
|
||||
// private static final String FROM_PSW = "xx";
|
||||
|
||||
public static void send(final File file, String toAdd, String title, String content) {
|
||||
Log.d(TAG, "send file to " + toAdd);
|
||||
final MailInfo mailInfo = creatMail(toAdd, title, content);
|
||||
final MailSender sms = new MailSender();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sms.sendFileMail(mailInfo, file);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public static void send(String toAdd, String title, String content) {
|
||||
Log.d(TAG, "send to " + toAdd);
|
||||
final MailInfo mailInfo = creatMail(toAdd, title, content);
|
||||
final MailSender sms = new MailSender();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sms.sendTextMail(mailInfo);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private static MailInfo creatMail(String toAdd, String title, String content) {
|
||||
Log.d(TAG, "creatMail to " + toAdd);
|
||||
final MailInfo mailInfo = new MailInfo();
|
||||
mailInfo.setMailServerHost(SettingUtil.get_send_util_email(Define.SP_MSG_SEND_UTIL_EMAIL_HOST_KEY));
|
||||
mailInfo.setMailServerPort(SettingUtil.get_send_util_email(Define.SP_MSG_SEND_UTIL_EMAIL_PORT_KEY));
|
||||
mailInfo.setValidate(true);
|
||||
mailInfo.ssl(true);
|
||||
mailInfo.setUserName(SettingUtil.get_send_util_email(Define.SP_MSG_SEND_UTIL_EMAIL_FROMADD_KEY)); // 你的邮箱地址
|
||||
mailInfo.setPassword(SettingUtil.get_send_util_email(Define.SP_MSG_SEND_UTIL_EMAIL_PSW_KEY));// 您的邮箱密码
|
||||
mailInfo.setFromAddress(SettingUtil.get_send_util_email(Define.SP_MSG_SEND_UTIL_EMAIL_FROMADD_KEY)); // 发送的邮箱
|
||||
mailInfo.setToAddress(SettingUtil.get_send_util_email(Define.SP_MSG_SEND_UTIL_EMAIL_TOADD_KEY)); // 发到哪个邮件去
|
||||
mailInfo.setSubject(title); // 邮件主题
|
||||
mailInfo.setContent(content); // 邮件文本
|
||||
return mailInfo;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* public void sendFileMail(View view) {
|
||||
* <p>
|
||||
* File file = new File(Environment.getExternalStorageDirectory()+File.separator+"test.txt");
|
||||
* OutputStream os = null;
|
||||
* try {
|
||||
* os = new FileOutputStream(file);
|
||||
* String str = "hello world";
|
||||
* byte[] data = str.getBytes();
|
||||
* os.write(data);
|
||||
* } catch (FileNotFoundException e) {
|
||||
* e.printStackTrace();
|
||||
* } catch (IOException e) {
|
||||
* e.printStackTrace();
|
||||
* }finally{
|
||||
* try {
|
||||
* if (os != null)os.close();
|
||||
* } catch (IOException e) {
|
||||
* }
|
||||
* }
|
||||
* SendMailUtil.send(file,editText.getText().toString());
|
||||
* }
|
||||
*/
|
@ -0,0 +1,234 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.idormy.sms.forwarder.model.LogModel;
|
||||
import com.idormy.sms.forwarder.model.RuleModel;
|
||||
import com.idormy.sms.forwarder.model.SenderModel;
|
||||
import com.idormy.sms.forwarder.model.vo.BarkSettingVo;
|
||||
import com.idormy.sms.forwarder.model.vo.DingDingSettingVo;
|
||||
import com.idormy.sms.forwarder.model.vo.EmailSettingVo;
|
||||
import com.idormy.sms.forwarder.model.vo.QYWXGroupRobotSettingVo;
|
||||
import com.idormy.sms.forwarder.model.vo.SmsVo;
|
||||
import com.idormy.sms.forwarder.model.vo.WebNotifySettingVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.idormy.sms.forwarder.model.RuleModel.CHECK_CONTAIN;
|
||||
import static com.idormy.sms.forwarder.model.RuleModel.CHECK_END_WITH;
|
||||
import static com.idormy.sms.forwarder.model.RuleModel.CHECK_IS;
|
||||
import static com.idormy.sms.forwarder.model.RuleModel.CHECK_NOT_IS;
|
||||
import static com.idormy.sms.forwarder.model.RuleModel.CHECK_START_WITH;
|
||||
import static com.idormy.sms.forwarder.model.RuleModel.FILED_MSG_CONTENT;
|
||||
import static com.idormy.sms.forwarder.model.RuleModel.FILED_PHONE_NUM;
|
||||
import static com.idormy.sms.forwarder.model.RuleModel.FILED_TRANSPOND_ALL;
|
||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_BARK;
|
||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_DINGDING;
|
||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_EMAIL;
|
||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_QYWX_GROUP_ROBOT;
|
||||
import static com.idormy.sms.forwarder.model.SenderModel.TYPE_WEB_NOTIFY;
|
||||
|
||||
public class SendUtil {
|
||||
private static String TAG = "SendUtil";
|
||||
|
||||
public static void send_msg(String msg) {
|
||||
if (SettingUtil.using_dingding()) {
|
||||
try {
|
||||
SenderDingdingMsg.sendMsg(msg);
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "发送出错:" + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
if (SettingUtil.using_email()) {
|
||||
// SenderMailMsg.send(SettingUtil.get_send_util_email(Define.SP_MSG_SEND_UTIL_EMAIL_TOADD_KEY),"转发",msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void send_msg_list(Context context, List<SmsVo> smsVoList) {
|
||||
Log.i(TAG, "send_msg_list size: " + smsVoList.size());
|
||||
for (SmsVo smsVo : smsVoList) {
|
||||
SendUtil.send_msg(context, smsVo);
|
||||
}
|
||||
}
|
||||
|
||||
public static void send_msg(Context context, SmsVo smsVo) {
|
||||
Log.i(TAG, "send_msg smsVo:" + smsVo);
|
||||
RuleUtil.init(context);
|
||||
LogUtil.init(context);
|
||||
|
||||
List<RuleModel> rulelist = RuleUtil.getRule(null, null);
|
||||
if (!rulelist.isEmpty()) {
|
||||
SenderUtil.init(context);
|
||||
for (RuleModel ruleModel : rulelist
|
||||
) {
|
||||
boolean canSend = false;
|
||||
//使用转发规则制定的字段 匹配
|
||||
switch (ruleModel.getFiled()) {
|
||||
case FILED_TRANSPOND_ALL:
|
||||
canSend = true;
|
||||
break;
|
||||
case FILED_PHONE_NUM:
|
||||
switch (ruleModel.getCheck()) {
|
||||
case CHECK_IS:
|
||||
if (smsVo.getMobile() != null && smsVo.getMobile().equals(ruleModel.getValue())) {
|
||||
canSend = true;
|
||||
}
|
||||
break;
|
||||
case CHECK_NOT_IS:
|
||||
if (smsVo.getMobile() != null && !smsVo.getMobile().equals(ruleModel.getValue())) {
|
||||
canSend = true;
|
||||
}
|
||||
break;
|
||||
case CHECK_START_WITH:
|
||||
if (smsVo.getMobile() != null && smsVo.getMobile().startsWith(ruleModel.getValue())) {
|
||||
canSend = true;
|
||||
}
|
||||
break;
|
||||
case CHECK_END_WITH:
|
||||
if (smsVo.getMobile() != null && smsVo.getMobile().endsWith(ruleModel.getValue())) {
|
||||
canSend = true;
|
||||
}
|
||||
break;
|
||||
case CHECK_CONTAIN:
|
||||
if (smsVo.getMobile() != null && smsVo.getMobile().contains(ruleModel.getValue())) {
|
||||
canSend = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case FILED_MSG_CONTENT:
|
||||
switch (ruleModel.getCheck()) {
|
||||
case CHECK_IS:
|
||||
if (smsVo.getContent() != null && smsVo.getContent().equals(ruleModel.getValue())) {
|
||||
canSend = true;
|
||||
}
|
||||
break;
|
||||
case CHECK_NOT_IS:
|
||||
if (smsVo.getContent() != null && !smsVo.getContent().equals(ruleModel.getValue())) {
|
||||
canSend = true;
|
||||
}
|
||||
break;
|
||||
case CHECK_START_WITH:
|
||||
if (smsVo.getContent() != null && smsVo.getContent().startsWith(ruleModel.getValue())) {
|
||||
canSend = true;
|
||||
}
|
||||
break;
|
||||
case CHECK_END_WITH:
|
||||
if (smsVo.getContent() != null && smsVo.getContent().endsWith(ruleModel.getValue())) {
|
||||
canSend = true;
|
||||
}
|
||||
break;
|
||||
case CHECK_CONTAIN:
|
||||
if (smsVo.getContent() != null && smsVo.getContent().contains(ruleModel.getValue())) {
|
||||
canSend = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
//规则匹配发现需要发送
|
||||
if (canSend) {
|
||||
List<SenderModel> senderModels = SenderUtil.getSender(ruleModel.getSenderId(), null);
|
||||
for (SenderModel senderModel : senderModels
|
||||
) {
|
||||
LogUtil.addLog(new LogModel(smsVo.getMobile(), smsVo.getContent(), senderModel.getId()));
|
||||
SendUtil.senderSendMsg(smsVo, senderModel);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void senderSendMsg(SmsVo smsVo, SenderModel senderModel) {
|
||||
|
||||
Log.i(TAG, "senderSendMsg smsVo:" + smsVo + "senderModel:" + senderModel);
|
||||
switch (senderModel.getType()) {
|
||||
case TYPE_DINGDING:
|
||||
//try phrase json setting
|
||||
if (senderModel.getJsonSetting() != null) {
|
||||
DingDingSettingVo dingDingSettingVo = JSON.parseObject(senderModel.getJsonSetting(), DingDingSettingVo.class);
|
||||
if (dingDingSettingVo != null) {
|
||||
try {
|
||||
SenderDingdingMsg.sendMsg(null, dingDingSettingVo.getToken(), dingDingSettingVo.getSecret(), dingDingSettingVo.getAtMobils(), dingDingSettingVo.getAtAll(), smsVo.getSmsVoForSend());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "senderSendMsg: dingding error " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case TYPE_EMAIL:
|
||||
//try phrase json setting
|
||||
if (senderModel.getJsonSetting() != null) {
|
||||
EmailSettingVo emailSettingVo = JSON.parseObject(senderModel.getJsonSetting(), EmailSettingVo.class);
|
||||
if (emailSettingVo != null) {
|
||||
try {
|
||||
SenderMailMsg.sendEmail(null, emailSettingVo.getHost(), emailSettingVo.getPort(), emailSettingVo.getSsl(), emailSettingVo.getFromEmail(),
|
||||
emailSettingVo.getPwd(), emailSettingVo.getToEmail(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "senderSendMsg: SenderMailMsg error " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case TYPE_WEB_NOTIFY:
|
||||
//try phrase json setting
|
||||
if (senderModel.getJsonSetting() != null) {
|
||||
WebNotifySettingVo webNotifySettingVo = JSON.parseObject(senderModel.getJsonSetting(), WebNotifySettingVo.class);
|
||||
if (webNotifySettingVo != null) {
|
||||
try {
|
||||
SenderWebNotifyMsg.sendMsg(null, webNotifySettingVo.getToken(), webNotifySettingVo.getSecret(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "senderSendMsg: SenderWebNotifyMsg error " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case TYPE_QYWX_GROUP_ROBOT:
|
||||
//try phrase json setting
|
||||
if (senderModel.getJsonSetting() != null) {
|
||||
QYWXGroupRobotSettingVo qywxGroupRobotSettingVo = JSON.parseObject(senderModel.getJsonSetting(), QYWXGroupRobotSettingVo.class);
|
||||
if (qywxGroupRobotSettingVo != null) {
|
||||
try {
|
||||
SenderQyWxGroupRobotMsg.sendMsg(null, qywxGroupRobotSettingVo.getWebHook(), smsVo.getMobile(), smsVo.getSmsVoForSend());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "senderSendMsg: SenderQyWxGroupRobotMsg error " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case TYPE_BARK:
|
||||
//try phrase json setting
|
||||
if (senderModel.getJsonSetting() != null) {
|
||||
BarkSettingVo barkSettingVo = JSON.parseObject(senderModel.getJsonSetting(), BarkSettingVo.class);
|
||||
if (barkSettingVo != null) {
|
||||
try {
|
||||
SenderBarkMsg.sendMsg(null, barkSettingVo.getServer(), smsVo.getMobile(), smsVo.getContent());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "senderSendMsg: SenderBarkMsg error " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,148 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.mail.Address;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import static com.idormy.sms.forwarder.SenderActivity.NOTIFY;
|
||||
|
||||
|
||||
public class SenderMailMsg {
|
||||
private static String TAG = "SenderMailMsg";
|
||||
//qq
|
||||
// private static final String HOST = "smtp.qq.com";
|
||||
// private static final String PORT = "587";
|
||||
// private static final String FROM_ADD = "teprinciple@foxmail.com"; //发送方邮箱
|
||||
// private static final String FROM_PSW = "lfrlpganzjrwbeci";//发送方邮箱授权码
|
||||
|
||||
// //163
|
||||
// private static final String HOST = "smtp.163.com";
|
||||
// private static final String PORT = "465"; //nossl 25或者ssl465 994
|
||||
// private static final String FROM_ADD = "xxxxxx@163.com";
|
||||
// private static final String FROM_PSW = "xx";
|
||||
|
||||
public static void sendEmail(final Handler handError, final String host, final String port, final boolean ssl, final String fromemail, final String pwd, final String toAdd, final String title, final String content) {
|
||||
|
||||
Log.d(TAG, "sendEmail: host:" + host + " port:" + port + " ssl:" + ssl + " fromemail:" + fromemail + " pwd:" + pwd + " toAdd:" + toAdd);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
final MailSenderInfo mailInfo = new MailSenderInfo();
|
||||
mailInfo.setMailServerHost(host);
|
||||
mailInfo.setMailServerPort(port);
|
||||
mailInfo.setValidate(true);
|
||||
mailInfo.setUserName(fromemail); //你的邮箱地址
|
||||
mailInfo.setPassword(pwd);//您的邮箱密码
|
||||
mailInfo.setFromAddress(fromemail);//和上面username的邮箱地址一致
|
||||
mailInfo.setToAddress(toAdd);
|
||||
mailInfo.setSubject(title);
|
||||
mailInfo.setContent(content);
|
||||
mailInfo.setSsl(ssl);
|
||||
|
||||
//这个类主要来发送邮件
|
||||
// 判断是否需要身份认证
|
||||
MyAuthenticator authenticator = null;
|
||||
Properties pro = mailInfo.getProperties();
|
||||
if (mailInfo.isValidate()) {
|
||||
// 如果需要身份认证,则创建一个密码验证器
|
||||
authenticator = new MyAuthenticator(mailInfo.getUserName(), mailInfo.getPassword());
|
||||
}
|
||||
// 根据邮件会话属性和密码验证器构造一个发送邮件的session
|
||||
Session sendMailSession = Session.getDefaultInstance(pro, authenticator);
|
||||
try {
|
||||
// 根据session创建一个邮件消息
|
||||
final Message mailMessage = new MimeMessage(sendMailSession);
|
||||
// 创建邮件发送者地址
|
||||
Address from = new InternetAddress(mailInfo.getFromAddress());
|
||||
// 设置邮件消息的发送者
|
||||
mailMessage.setFrom(from);
|
||||
// 创建邮件的接收者地址,并设置到邮件消息中
|
||||
Address to = new InternetAddress(mailInfo.getToAddress());
|
||||
mailMessage.setRecipient(Message.RecipientType.TO, to);
|
||||
// 设置邮件消息的主题
|
||||
mailMessage.setSubject(mailInfo.getSubject());
|
||||
// 设置邮件消息发送的时间
|
||||
mailMessage.setSentDate(new Date());
|
||||
// 设置邮件消息的主要内容
|
||||
String mailContent = mailInfo.getContent();
|
||||
mailMessage.setText(mailContent);
|
||||
// 发送邮件
|
||||
Transport.send(mailMessage);
|
||||
|
||||
} catch (MessagingException ex) {
|
||||
ex.printStackTrace();
|
||||
Log.e(TAG, "error" + ex.getMessage());
|
||||
if (handError != null) {
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = NOTIFY;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("DATA", ex.getMessage());
|
||||
msg.setData(bundle);
|
||||
handError.sendMessage(msg);
|
||||
}
|
||||
|
||||
}
|
||||
if (handError != null) {
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = NOTIFY;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("DATA", "发送成功");
|
||||
msg.setData(bundle);
|
||||
handError.sendMessage(msg);
|
||||
}
|
||||
|
||||
Log.e(TAG, "sendEmail success");//sms.sendHtmlMail(mailInfo);//发送html格式
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, e.getMessage(), e);
|
||||
if (handError != null) {
|
||||
android.os.Message msg = new android.os.Message();
|
||||
msg.what = NOTIFY;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("DATA", e.getMessage());
|
||||
msg.setData(bundle);
|
||||
handError.sendMessage(msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* public void sendFileMail(View view) {
|
||||
* <p>
|
||||
* File file = new File(Environment.getExternalStorageDirectory()+File.separator+"test.txt");
|
||||
* OutputStream os = null;
|
||||
* try {
|
||||
* os = new FileOutputStream(file);
|
||||
* String str = "hello world";
|
||||
* byte[] data = str.getBytes();
|
||||
* os.write(data);
|
||||
* } catch (FileNotFoundException e) {
|
||||
* e.printStackTrace();
|
||||
* } catch (IOException e) {
|
||||
* e.printStackTrace();
|
||||
* }finally{
|
||||
* try {
|
||||
* if (os != null)os.close();
|
||||
* } catch (IOException e) {
|
||||
* }
|
||||
* }
|
||||
* SenderMailMsg.send(file,editText.getText().toString());
|
||||
* }
|
||||
*/
|
@ -0,0 +1,194 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.provider.BaseColumns;
|
||||
import android.util.Log;
|
||||
|
||||
import com.idormy.sms.forwarder.model.SenderModel;
|
||||
import com.idormy.sms.forwarder.model.SenderTable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SenderUtil {
|
||||
static String TAG = "SenderUtil";
|
||||
static Boolean hasInit = false;
|
||||
|
||||
static Context context;
|
||||
static DbHelper dbHelper;
|
||||
static SQLiteDatabase db;
|
||||
|
||||
public static void init(Context context1) {
|
||||
synchronized (hasInit) {
|
||||
if (hasInit) return;
|
||||
hasInit = true;
|
||||
context = context1;
|
||||
dbHelper = new DbHelper(context);
|
||||
// Gets the data repository in write mode
|
||||
db = dbHelper.getReadableDatabase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static long addSender(SenderModel senderModel) {
|
||||
|
||||
// Create a new map of values, where column names are the keys
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(SenderTable.SenderEntry.COLUMN_NAME_NAME, senderModel.getName());
|
||||
values.put(SenderTable.SenderEntry.COLUMN_NAME_TYPE, senderModel.getType());
|
||||
values.put(SenderTable.SenderEntry.COLUMN_NAME_STATUS, senderModel.getStatus());
|
||||
values.put(SenderTable.SenderEntry.COLUMN_NAME_JSON_SETTING, senderModel.getJsonSetting());
|
||||
|
||||
// Insert the new row, returning the primary key value of the new row
|
||||
|
||||
return db.insert(SenderTable.SenderEntry.TABLE_NAME, null, values);
|
||||
}
|
||||
|
||||
public static long updateSender(SenderModel senderModel) {
|
||||
if (senderModel == null) return 0;
|
||||
|
||||
// Create a new map of values, where column names are the keys
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(SenderTable.SenderEntry.COLUMN_NAME_NAME, senderModel.getName());
|
||||
values.put(SenderTable.SenderEntry.COLUMN_NAME_TYPE, senderModel.getType());
|
||||
values.put(SenderTable.SenderEntry.COLUMN_NAME_STATUS, senderModel.getStatus());
|
||||
values.put(SenderTable.SenderEntry.COLUMN_NAME_JSON_SETTING, senderModel.getJsonSetting());
|
||||
|
||||
String selection = SenderTable.SenderEntry._ID + " = ? ";
|
||||
String[] whereArgs = {String.valueOf(senderModel.getId())};
|
||||
|
||||
return db.update(SenderTable.SenderEntry.TABLE_NAME, values, selection, whereArgs);
|
||||
}
|
||||
|
||||
public static int delSender(Long id) {
|
||||
// Define 'where' part of query.
|
||||
String selection = " 1 ";
|
||||
// Specify arguments in placeholder order.
|
||||
List<String> selectionArgList = new ArrayList<>();
|
||||
if (id != null) {
|
||||
// Define 'where' part of query.
|
||||
selection += " and " + SenderTable.SenderEntry._ID + " = ? ";
|
||||
// Specify arguments in placeholder order.
|
||||
selectionArgList.add(String.valueOf(id));
|
||||
|
||||
}
|
||||
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]);
|
||||
// Issue SQL statement.
|
||||
return db.delete(SenderTable.SenderEntry.TABLE_NAME, selection, selectionArgs);
|
||||
|
||||
}
|
||||
|
||||
public static List<SenderModel> getSender(Long id, String key) {
|
||||
// Define a projection that specifies which columns from the database
|
||||
// you will actually use after this query.
|
||||
String[] projection = {
|
||||
BaseColumns._ID,
|
||||
SenderTable.SenderEntry.COLUMN_NAME_NAME,
|
||||
SenderTable.SenderEntry.COLUMN_NAME_TYPE,
|
||||
SenderTable.SenderEntry.COLUMN_NAME_STATUS,
|
||||
SenderTable.SenderEntry.COLUMN_NAME_JSON_SETTING,
|
||||
SenderTable.SenderEntry.COLUMN_NAME_TIME
|
||||
};
|
||||
// Define 'where' part of query.
|
||||
String selection = " 1 ";
|
||||
// Specify arguments in placeholder order.
|
||||
List<String> selectionArgList = new ArrayList<>();
|
||||
if (id != null) {
|
||||
// Define 'where' part of query.
|
||||
selection += " and " + SenderTable.SenderEntry._ID + " = ? ";
|
||||
// Specify arguments in placeholder order.
|
||||
selectionArgList.add(String.valueOf(id));
|
||||
}
|
||||
|
||||
if (key != null) {
|
||||
// Define 'where' part of query.
|
||||
selection = " and (" + SenderTable.SenderEntry.COLUMN_NAME_NAME + " LIKE ? or " + SenderTable.SenderEntry.COLUMN_NAME_JSON_SETTING + " LIKE ? ) ";
|
||||
// Specify arguments in placeholder order.
|
||||
selectionArgList.add(key);
|
||||
selectionArgList.add(key);
|
||||
}
|
||||
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]);
|
||||
|
||||
// How you want the results sorted in the resulting Cursor
|
||||
String sortOrder =
|
||||
SenderTable.SenderEntry._ID + " DESC";
|
||||
|
||||
Cursor cursor = db.query(
|
||||
SenderTable.SenderEntry.TABLE_NAME, // The table to query
|
||||
projection, // The array of columns to return (pass null to get all)
|
||||
selection, // The columns for the WHERE clause
|
||||
selectionArgs, // The values for the WHERE clause
|
||||
null, // don't group the rows
|
||||
null, // don't filter by row groups
|
||||
sortOrder // The sort order
|
||||
);
|
||||
List<SenderModel> tSenders = new ArrayList<>();
|
||||
while (cursor.moveToNext()) {
|
||||
|
||||
long itemId = cursor.getLong(
|
||||
cursor.getColumnIndexOrThrow(SenderTable.SenderEntry._ID));
|
||||
String itemName = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(SenderTable.SenderEntry.COLUMN_NAME_NAME));
|
||||
int itemStatus = cursor.getInt(
|
||||
cursor.getColumnIndexOrThrow(SenderTable.SenderEntry.COLUMN_NAME_STATUS));
|
||||
int itemType = cursor.getInt(
|
||||
cursor.getColumnIndexOrThrow(SenderTable.SenderEntry.COLUMN_NAME_TYPE));
|
||||
String itemJsonSetting = cursor.getString(
|
||||
cursor.getColumnIndexOrThrow(SenderTable.SenderEntry.COLUMN_NAME_JSON_SETTING));
|
||||
long itemTime = cursor.getLong(
|
||||
cursor.getColumnIndexOrThrow(SenderTable.SenderEntry.COLUMN_NAME_TIME));
|
||||
Log.d(TAG, "getSender: itemId" + itemId);
|
||||
|
||||
SenderModel senderModel = new SenderModel();
|
||||
senderModel.setId(itemId);
|
||||
senderModel.setName(itemName);
|
||||
senderModel.setStatus(itemStatus);
|
||||
senderModel.setType(itemType);
|
||||
senderModel.setJsonSetting(itemJsonSetting);
|
||||
senderModel.setTime(itemTime);
|
||||
|
||||
tSenders.add(senderModel);
|
||||
}
|
||||
cursor.close();
|
||||
return tSenders;
|
||||
}
|
||||
|
||||
public static int countSender(String key) {
|
||||
// Define a projection that specifies which columns from the database
|
||||
// you will actually use after this query.
|
||||
String[] projection = {
|
||||
};
|
||||
// Define 'where' part of query.
|
||||
String selection = " 1 ";
|
||||
// Specify arguments in placeholder order.
|
||||
List<String> selectionArgList = new ArrayList<>();
|
||||
|
||||
if (key != null) {
|
||||
// Define 'where' part of query.
|
||||
selection = " and (" + SenderTable.SenderEntry.COLUMN_NAME_NAME + " LIKE ? or " + SenderTable.SenderEntry.COLUMN_NAME_JSON_SETTING + " LIKE ? ) ";
|
||||
// Specify arguments in placeholder order.
|
||||
selectionArgList.add(key);
|
||||
selectionArgList.add(key);
|
||||
}
|
||||
String[] selectionArgs = selectionArgList.toArray(new String[selectionArgList.size()]);
|
||||
|
||||
// How you want the results sorted in the resulting Cursor
|
||||
|
||||
Cursor cursor = db.query(
|
||||
SenderTable.SenderEntry.TABLE_NAME, // The table to query
|
||||
projection, // The array of columns to return (pass null to get all)
|
||||
selection, // The columns for the WHERE clause
|
||||
selectionArgs, // The values for the WHERE clause
|
||||
null, // don't group the rows
|
||||
null, // don't filter by row groups
|
||||
null // The sort order
|
||||
);
|
||||
int count = cursor.getCount();
|
||||
cursor.close();
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class SettingUtil {
|
||||
static Boolean hasInit = false;
|
||||
private static String TAG = "SettingUtil";
|
||||
private static SharedPreferences sp_setting = null;
|
||||
private static Context context = null;
|
||||
|
||||
public static void init(Context context1) {
|
||||
synchronized (hasInit) {
|
||||
if (hasInit) return;
|
||||
hasInit = true;
|
||||
context = context1;
|
||||
Log.d(TAG, "init ");
|
||||
sp_setting = PreferenceManager.getDefaultSharedPreferences(context1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean option_withreboot() {
|
||||
return sp_setting.getBoolean("option_withreboot", false);
|
||||
}
|
||||
|
||||
public static boolean using_dingding() {
|
||||
return sp_setting.getBoolean("option_dingding_on", false);
|
||||
}
|
||||
|
||||
public static String get_using_dingding_token() {
|
||||
return sp_setting.getString("option_dingding_token", "");
|
||||
}
|
||||
|
||||
public static String get_using_dingding_secret() {
|
||||
return sp_setting.getString("option_dingding_secret", "");
|
||||
}
|
||||
|
||||
public static boolean using_email() {
|
||||
return sp_setting.getBoolean("option_email_on", false);
|
||||
}
|
||||
|
||||
public static void set_send_util_email(String host, String port, String from_add, String psw, String to_add) {
|
||||
Log.d(TAG, "set_send_util_email host:" + host + "port" + port + "from_add" + from_add + "psw" + psw + "to_add" + to_add);
|
||||
//验证
|
||||
if (host.equals("") || port.equals("") || from_add.equals("") || psw.equals("") || to_add.equals("")) {
|
||||
return;
|
||||
}
|
||||
sp_setting.edit()
|
||||
.putString(Define.SP_MSG_SEND_UTIL_EMAIL_HOST_KEY, host)
|
||||
.putString(Define.SP_MSG_SEND_UTIL_EMAIL_PORT_KEY, port)
|
||||
.putString(Define.SP_MSG_SEND_UTIL_EMAIL_FROMADD_KEY, from_add)
|
||||
.putString(Define.SP_MSG_SEND_UTIL_EMAIL_PSW_KEY, psw)
|
||||
.putString(Define.SP_MSG_SEND_UTIL_EMAIL_TOADD_KEY, to_add)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public static String get_send_util_email(String key) {
|
||||
Log.d(TAG, "get_send_util_email key" + key);
|
||||
String defaultstt = "";
|
||||
if (key.equals(Define.SP_MSG_SEND_UTIL_EMAIL_HOST_KEY)) defaultstt = "stmp服务器";
|
||||
if (key.equals(Define.SP_MSG_SEND_UTIL_EMAIL_PORT_KEY)) defaultstt = "端口";
|
||||
if (key.equals(Define.SP_MSG_SEND_UTIL_EMAIL_FROMADD_KEY)) defaultstt = "发送邮箱";
|
||||
if (key.equals(Define.SP_MSG_SEND_UTIL_EMAIL_PSW_KEY)) defaultstt = "密码";
|
||||
if (key.equals(Define.SP_MSG_SEND_UTIL_EMAIL_TOADD_KEY)) defaultstt = "接收邮箱";
|
||||
return sp_setting.getString(key, defaultstt);
|
||||
}
|
||||
|
||||
public static boolean saveMsgHistory() {
|
||||
return sp_setting.getBoolean("option_save_history_on", false);
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package com.idormy.sms.forwarder.utils;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.vector.update_app.HttpManager;
|
||||
import com.zhy.http.okhttp.OkHttpUtils;
|
||||
import com.zhy.http.okhttp.callback.FileCallBack;
|
||||
import com.zhy.http.okhttp.callback.StringCallback;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
|
||||
public class UpdateAppHttpUtil implements HttpManager {
|
||||
/**
|
||||
* 异步get
|
||||
*
|
||||
* @param url get请求地址
|
||||
* @param params get参数
|
||||
* @param callBack 回调
|
||||
*/
|
||||
@Override
|
||||
public void asyncGet(@NonNull String url, @NonNull Map<String, String> params, @NonNull final HttpManager.Callback callBack) {
|
||||
Log.i("UpdateAppHttpUtil", "asyncGet" + url);
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("heada", "bb");
|
||||
OkHttpUtils.get()
|
||||
.url(url)
|
||||
.headers(headers)
|
||||
.params(params)
|
||||
.build()
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e, int id) {
|
||||
Log.i("UpdateAppHttpUtil", "err response" + response);
|
||||
callBack.onError(validateError(e, response));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(String response, int id) {
|
||||
Log.i("UpdateAppHttpUtil", "response" + response);
|
||||
callBack.onResponse(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步post
|
||||
*
|
||||
* @param url post请求地址
|
||||
* @param params post请求参数
|
||||
* @param callBack 回调
|
||||
*/
|
||||
@Override
|
||||
public void asyncPost(@NonNull String url, @NonNull Map<String, String> params, @NonNull final HttpManager.Callback callBack) {
|
||||
Log.i("UpdateAppHttpUtil", "asyncPost" + url);
|
||||
|
||||
// params.put("gggg","hhhh");
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("heada", "bb");
|
||||
OkHttpUtils.post()
|
||||
.url(url)
|
||||
.headers(headers)
|
||||
.params(params)
|
||||
.build()
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e, int id) {
|
||||
callBack.onError(validateError(e, response));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(String response, int id) {
|
||||
callBack.onResponse(response);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载
|
||||
*
|
||||
* @param url 下载地址
|
||||
* @param path 文件保存路径
|
||||
* @param fileName 文件名称
|
||||
* @param callback 回调
|
||||
*/
|
||||
@Override
|
||||
public void download(@NonNull String url, @NonNull String path, @NonNull String fileName, @NonNull final HttpManager.FileCallback callback) {
|
||||
OkHttpUtils.get()
|
||||
.url(url)
|
||||
.build()
|
||||
.execute(new FileCallBack(path, fileName) {
|
||||
@Override
|
||||
public void inProgress(float progress, long total, int id) {
|
||||
callback.onProgress(progress, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e, int id) {
|
||||
callback.onError(validateError(e, response));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(File response, int id) {
|
||||
callback.onResponse(response);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBefore(Request request, int id) {
|
||||
super.onBefore(request, id);
|
||||
callback.onBefore();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 123 KiB |
@ -0,0 +1,34 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="78.5885"
|
||||
android:endY="90.9159"
|
||||
android:startX="48.7653"
|
||||
android:startY="61.0927"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z" />
|
||||
</vector>
|
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
@ -0,0 +1,184 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:text="设置名称" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextEmailName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:ems="10"
|
||||
android:inputType=""
|
||||
android:text="" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:text="stmp服务器" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextEmailHost"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:ems="10"
|
||||
android:inputType=""
|
||||
android:text="" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:text="端口" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextEmailPort"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:ems="10"
|
||||
android:inputType=""
|
||||
android:text="" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:text="是否开启ssl" />
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switchEmailSSl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:checked="true"
|
||||
android:ems="10" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:text="用哪个邮箱发送" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextEmailFromAdd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:ems="10"
|
||||
android:inputType="textEmailAddress"
|
||||
android:text="" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:text="密码" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextEmailPsw"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:ems="10"
|
||||
android:inputType=""
|
||||
android:text="" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:text="发到哪个邮件去" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextEmailToAdd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:ems="10"
|
||||
android:inputType="textEmailAddress"
|
||||
android:text="" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonemailok"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:text="@string/ok" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonemaildel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/del" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonemailtest"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="2dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/test" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,168 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="3dp"
|
||||
android:text="设置匹配的字段:选择全部转发后不再匹配下方的模式值直接使用发送方发送" />
|
||||
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/radioGroupRuleFiled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnTranspondAll"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="转发全部" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnPhone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="手机号" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="内容" />
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="3dp"
|
||||
android:text="设置匹配的模式" />
|
||||
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/radioGroupRuleCheck"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnIs"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="是" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnNotIs"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="不是" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnContain"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="包含" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnStartWith"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="开头" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/btnEndWith"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="结尾" />
|
||||
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="3dp"
|
||||
android:text="设置匹配的值" />
|
||||
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextRuleValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="3dp"
|
||||
android:ems="10"
|
||||
android:inputType=""
|
||||
android:text="" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ruleSenderTv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="3dp"
|
||||
android:text="" />
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btSetRuleSender"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="设置发送方">
|
||||
|
||||
</Button>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonruleok"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="3dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/ok" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonruledel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="3dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/del" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.idormy.sms.forwarder.ReFlashListView
|
||||
android:id="@+id/list_view_log"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<!-- <ListView-->
|
||||
<!-- android:id="@+id/list_view_log"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent"-->
|
||||
<!-- android:layout_margin="8dp"-->
|
||||
<!-- android:layout_weight="1" />-->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="9"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/bt_refresh_log"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/holo_blue_dark"
|
||||
android:onClick="cleanLog"
|
||||
android:text="清空记录"
|
||||
tools:ignore="NestedWeights" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bt_rule_set"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/holo_blue_dark"
|
||||
android:onClick="toRuleSetting"
|
||||
android:text="设置转发规则"
|
||||
tools:ignore="NestedWeights" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bt_send_set"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/holo_blue_dark"
|
||||
android:onClick="toSendSetting"
|
||||
android:text="设置发送方" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/list_view_rule"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="4dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btaddrule"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="10px"
|
||||
android:layout_weight="9"
|
||||
android:background="@android:color/holo_blue_dark"
|
||||
android:text="添加转发规则"
|
||||
tools:ignore="NestedWeights" />
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/list_view_sender"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="9"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button22"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/holo_blue_dark"
|
||||
android:onClick="addSender"
|
||||
android:text="添加"
|
||||
tools:ignore="NestedWeights" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,162 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:background="@android:color/white"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="20dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="当前版本" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/version_now"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end"
|
||||
android:text="v1.0" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/check_version_now"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="检查新版本" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/auto_reboot"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:background="@android:color/white"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="3"
|
||||
android:text="开机启动" />
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switch_with_reboot"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="3"
|
||||
android:gravity="end"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/about_web"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:background="@android:color/white"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="官网" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/linkweb"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="3"
|
||||
android:autoLink="web"
|
||||
android:gravity="right"
|
||||
android:text="idormy.com"
|
||||
android:textSize="18sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_wait_open_time"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:background="@android:color/white"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="用户交流群" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_wait_open_time"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:text="562854376"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/feedback"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:background="@android:color/white"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="3"
|
||||
android:text="建议反馈" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/feedback_commit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:onClick="feedbackcommit"
|
||||
android:text="提交反馈"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,28 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/xxxxxx"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/feedback_et_email"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:hint="邮箱"
|
||||
android:inputType="textEmailAddress" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/feedback_et_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:hint="内容" />
|
||||
</LinearLayout>
|
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dip"
|
||||
android:paddingBottom="10dip">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="下拉可以刷新!" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lastupdate_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/arrow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="20dip"
|
||||
android:layout_toLeftOf="@id/layout"
|
||||
android:src="@android:drawable/ic_popup_sync" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
style="?android:attr/progressBarStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="20dip"
|
||||
android:layout_toLeftOf="@id/layout"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rule_match"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_margin="10dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rule_sender"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_margin="10dp" />
|
||||
</LinearLayout>
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sender_image"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sender_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp" />
|
||||
</LinearLayout>
|
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dip"
|
||||
android:paddingBottom="10dip">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tlog_from"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:textColor="@android:color/black"
|
||||
android:textColorHighlight="@android:color/holo_red_dark" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tlog_rule"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginStart="10dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/tlog_sender_image"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tlog_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp" />
|
||||
</LinearLayout>
|
@ -0,0 +1,11 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.allmything.linkhelper.MainActivity">
|
||||
<item
|
||||
android:id="@+id/to_setting"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/to_setting"
|
||||
app:showAsAction="never" />
|
||||
|
||||
</menu>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@mipmap/ic_launcher_background" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@mipmap/ic_launcher_background" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/qywx_background" />
|
||||
<foreground android:drawable="@mipmap/qywx_foreground" />
|
||||
</adaptive-icon>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/qywx_background" />
|
||||
<foreground android:drawable="@mipmap/qywx_foreground" />
|
||||
</adaptive-icon>
|
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 9.2 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 14 KiB |