整理:code review
This commit is contained in:
parent
3430dbbe8e
commit
668847c91f
|
@ -35,3 +35,4 @@
|
|||
/app/seeds.txt
|
||||
/app/unused.txt
|
||||
/pic/*.bkp
|
||||
/*.txt
|
||||
|
|
|
@ -203,11 +203,11 @@ dependencies {
|
|||
implementation 'com.github.xuexiangjys.AgentWeb:agentweb-core:1.0.0'
|
||||
implementation 'com.github.xuexiangjys.AgentWeb:agentweb-download:1.0.0'//选填
|
||||
//腾讯的键值对存储mmkv:https://github.com/Tencent/MMKV
|
||||
implementation 'com.tencent:mmkv:1.2.13'
|
||||
implementation 'com.tencent:mmkv:1.2.14'
|
||||
//屏幕适配AutoSize:https://github.com/JessYanCoding/AndroidAutoSize
|
||||
implementation 'me.jessyan:autosize:1.2.1'
|
||||
//umeng统计
|
||||
implementation 'com.umeng.umsdk:common:9.5.0'
|
||||
implementation 'com.umeng.umsdk:common:9.5.2'
|
||||
implementation 'com.umeng.umsdk:asms:1.6.3'
|
||||
|
||||
//预加载占位控件
|
||||
|
|
|
@ -166,8 +166,6 @@
|
|||
-dontwarn com.squareup.okhttp3.**
|
||||
-keep class com.squareup.okhttp3.** { *;}
|
||||
-dontwarn okio.**
|
||||
-dontwarn javax.annotation.Nullable
|
||||
-dontwarn javax.annotation.ParametersAreNonnullByDefault
|
||||
-dontwarn javax.annotation.**
|
||||
|
||||
#如果用到Gson解析包的,直接添加下面这几行就能成功混淆,不然会报错
|
||||
|
@ -208,8 +206,6 @@
|
|||
#}
|
||||
|
||||
-dontwarn okio.**
|
||||
-dontwarn javax.annotation.Nullable
|
||||
-dontwarn javax.annotation.ParametersAreNonnullByDefault
|
||||
-dontwarn javax.annotation.**
|
||||
|
||||
# fastjson
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" />
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_SMS" />
|
||||
<uses-permission android:name="android.permission.READ_SMS" />
|
||||
|
|
|
@ -44,7 +44,14 @@ import com.xuexiang.xutil.net.JsonUtil
|
|||
* @author xuexiang
|
||||
* @since 2019/1/4 下午11:13
|
||||
*/
|
||||
@Suppress("unused", "MemberVisibilityCanBePrivate", "ProtectedInFinal", "NAME_SHADOWING", "UNUSED_PARAMETER", "OVERRIDE_DEPRECATION")
|
||||
@Suppress(
|
||||
"unused",
|
||||
"MemberVisibilityCanBePrivate",
|
||||
"ProtectedInFinal",
|
||||
"NAME_SHADOWING",
|
||||
"UNUSED_PARAMETER",
|
||||
"OVERRIDE_DEPRECATION"
|
||||
)
|
||||
class AgentWebFragment : Fragment(), FragmentKeyDown {
|
||||
private var mBackImageView: ImageView? = null
|
||||
private var mLineView: View? = null
|
||||
|
@ -372,11 +379,11 @@ class AgentWebFragment : Fragment(), FragmentKeyDown {
|
|||
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
|
||||
Log.i(TAG, "mUrl:$url onPageStarted target:$url")
|
||||
timer[url] = System.currentTimeMillis()
|
||||
if (url == url) {
|
||||
pageNavigator(View.GONE)
|
||||
} else {
|
||||
pageNavigator(View.VISIBLE)
|
||||
}
|
||||
//if (url == url) {
|
||||
// pageNavigator(View.GONE)
|
||||
//} else {
|
||||
pageNavigator(View.VISIBLE)
|
||||
//}
|
||||
}
|
||||
|
||||
override fun onPageFinished(view: WebView, url: String) {
|
||||
|
@ -495,7 +502,8 @@ class AgentWebFragment : Fragment(), FragmentKeyDown {
|
|||
* @param text
|
||||
*/
|
||||
private fun toCopy(context: Context?, text: String) {
|
||||
val manager = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val manager =
|
||||
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
manager.setPrimaryClip(ClipData.newPlainText(null, text))
|
||||
}
|
||||
|
||||
|
|
|
@ -360,11 +360,11 @@ class XPageWebViewFragment : BaseFragment<FragmentAgentwebBinding?>(), View.OnCl
|
|||
|
||||
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap) {
|
||||
mTimer[url] = System.currentTimeMillis()
|
||||
if (url == url) {
|
||||
pageNavigator(View.GONE)
|
||||
} else {
|
||||
pageNavigator(View.VISIBLE)
|
||||
}
|
||||
//if (url == url) {
|
||||
// pageNavigator(View.GONE)
|
||||
//} else {
|
||||
pageNavigator(View.VISIBLE)
|
||||
//}
|
||||
}
|
||||
|
||||
override fun onPageFinished(view: WebView, url: String) {
|
||||
|
@ -480,7 +480,8 @@ class XPageWebViewFragment : BaseFragment<FragmentAgentwebBinding?>(), View.OnCl
|
|||
* @param text
|
||||
*/
|
||||
private fun toCopy(context: Context?, text: String) {
|
||||
val manager = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val manager =
|
||||
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
manager.setPrimaryClip(ClipData.newPlainText(null, text))
|
||||
}
|
||||
|
||||
|
|
|
@ -44,13 +44,13 @@ abstract class AppDatabase : RoomDatabase() {
|
|||
}
|
||||
|
||||
private fun buildDatabase(context: Context): AppDatabase {
|
||||
var builder = Room.databaseBuilder(
|
||||
val builder = Room.databaseBuilder(
|
||||
context.applicationContext,
|
||||
AppDatabase::class.java,
|
||||
DATABASE_NAME
|
||||
)
|
||||
.allowMainThreadQueries() //TODO:允许主线程访问,后面再优化
|
||||
.addCallback(object : RoomDatabase.Callback() {
|
||||
.addCallback(object : Callback() {
|
||||
override fun onCreate(db: SupportSQLiteDatabase) {
|
||||
//fillInDb(context.applicationContext)
|
||||
db.execSQL(
|
||||
|
|
|
@ -635,7 +635,7 @@ class SettingsFragment : BaseFragment<FragmentSettingsBinding?>(), View.OnClickL
|
|||
KeepAliveUtils.ignoreBatteryOptimization(requireActivity())
|
||||
} else if (isChecked) {
|
||||
XToastUtils.info(R.string.isIgnored)
|
||||
sbBatterySetting.isChecked = isIgnoreBatteryOptimization
|
||||
sbBatterySetting.isChecked = true
|
||||
} else {
|
||||
XToastUtils.info(R.string.isIgnored2)
|
||||
sbBatterySetting.isChecked = isIgnoreBatteryOptimization
|
||||
|
|
|
@ -75,7 +75,8 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
.request(object : OnPermissionCallback {
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onGranted(permissions: List<String>, all: Boolean) {
|
||||
backupPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).path
|
||||
backupPath =
|
||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).path
|
||||
binding!!.tvBackupPath.text = backupPath + File.separator + backupFile
|
||||
}
|
||||
|
||||
|
@ -105,7 +106,8 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
|
||||
//按钮增加倒计时,避免重复点击
|
||||
pushCountDownHelper = CountDownButtonHelper(binding!!.btnPush, SettingUtils.requestTimeout)
|
||||
pushCountDownHelper!!.setOnCountDownListener(object : CountDownButtonHelper.OnCountDownListener {
|
||||
pushCountDownHelper!!.setOnCountDownListener(object :
|
||||
CountDownButtonHelper.OnCountDownListener {
|
||||
override fun onCountDown(time: Int) {
|
||||
binding!!.btnPush.text = String.format(getString(R.string.seconds_n), time)
|
||||
}
|
||||
|
@ -115,7 +117,8 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
}
|
||||
})
|
||||
pullCountDownHelper = CountDownButtonHelper(binding!!.btnPull, SettingUtils.requestTimeout)
|
||||
pullCountDownHelper!!.setOnCountDownListener(object : CountDownButtonHelper.OnCountDownListener {
|
||||
pullCountDownHelper!!.setOnCountDownListener(object :
|
||||
CountDownButtonHelper.OnCountDownListener {
|
||||
override fun onCountDown(time: Int) {
|
||||
binding!!.btnPull.text = String.format(getString(R.string.seconds_n), time)
|
||||
}
|
||||
|
@ -125,7 +128,8 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
}
|
||||
})
|
||||
exportCountDownHelper = CountDownButtonHelper(binding!!.btnExport, 3)
|
||||
exportCountDownHelper!!.setOnCountDownListener(object : CountDownButtonHelper.OnCountDownListener {
|
||||
exportCountDownHelper!!.setOnCountDownListener(object :
|
||||
CountDownButtonHelper.OnCountDownListener {
|
||||
override fun onCountDown(time: Int) {
|
||||
binding!!.btnExport.text = String.format(getString(R.string.seconds_n), time)
|
||||
}
|
||||
|
@ -135,7 +139,8 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
}
|
||||
})
|
||||
importCountDownHelper = CountDownButtonHelper(binding!!.btnImport, 3)
|
||||
importCountDownHelper!!.setOnCountDownListener(object : CountDownButtonHelper.OnCountDownListener {
|
||||
importCountDownHelper!!.setOnCountDownListener(object :
|
||||
CountDownButtonHelper.OnCountDownListener {
|
||||
override fun onCountDown(time: Int) {
|
||||
binding!!.btnImport.text = String.format(getString(R.string.seconds_n), time)
|
||||
}
|
||||
|
@ -176,7 +181,12 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
XToastUtils.error(getString(R.string.export_failed))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
XToastUtils.error(String.format(getString(R.string.export_failed_tips), e.message))
|
||||
XToastUtils.error(
|
||||
String.format(
|
||||
getString(R.string.export_failed_tips),
|
||||
e.message
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
//导入配置
|
||||
|
@ -199,7 +209,9 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
|
||||
//替换Date字段为当前时间
|
||||
val builder = GsonBuilder()
|
||||
builder.registerTypeAdapter(Date::class.java, JsonDeserializer<Any?> { _, _, _ -> Date() })
|
||||
builder.registerTypeAdapter(
|
||||
Date::class.java,
|
||||
JsonDeserializer<Any?> { _, _, _ -> Date() })
|
||||
val gson = builder.create()
|
||||
val cloneInfo = gson.fromJson(jsonStr, CloneInfo::class.java)
|
||||
Log.d(TAG, "cloneInfo = $cloneInfo")
|
||||
|
@ -213,7 +225,12 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
XToastUtils.error(getString(R.string.import_failed))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
XToastUtils.error(String.format(getString(R.string.import_failed_tips), e.message))
|
||||
XToastUtils.error(
|
||||
String.format(
|
||||
getString(R.string.import_failed_tips),
|
||||
e.message
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +253,8 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
msgMap["timestamp"] = timestamp
|
||||
val clientSignKey = HttpServerUtils.clientSignKey
|
||||
if (!TextUtils.isEmpty(clientSignKey)) {
|
||||
msgMap["sign"] = HttpServerUtils.calcSign(timestamp.toString(), clientSignKey.toString())
|
||||
msgMap["sign"] =
|
||||
HttpServerUtils.calcSign(timestamp.toString(), clientSignKey.toString())
|
||||
}
|
||||
msgMap["data"] = HttpServerUtils.exportSettings()
|
||||
|
||||
|
@ -261,7 +279,10 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
override fun onSuccess(response: String) {
|
||||
Log.i(TAG, response)
|
||||
try {
|
||||
val resp: BaseResponse<String> = Gson().fromJson(response, object : TypeToken<BaseResponse<String>>() {}.type)
|
||||
val resp: BaseResponse<String> = Gson().fromJson(
|
||||
response,
|
||||
object : TypeToken<BaseResponse<String>>() {}.type
|
||||
)
|
||||
if (resp.code == 200) {
|
||||
XToastUtils.success(ResUtils.getString(R.string.request_succeeded))
|
||||
} else {
|
||||
|
@ -283,7 +304,7 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
XToastUtils.error(getString(R.string.invalid_service_address))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
exportCountDownHelper?.start()
|
||||
|
||||
val requestUrl: String = HttpServerUtils.serverAddress + "/clone/pull"
|
||||
|
@ -294,7 +315,8 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
msgMap["timestamp"] = timestamp
|
||||
val clientSignKey = HttpServerUtils.clientSignKey
|
||||
if (!TextUtils.isEmpty(clientSignKey)) {
|
||||
msgMap["sign"] = HttpServerUtils.calcSign(timestamp.toString(), clientSignKey.toString())
|
||||
msgMap["sign"] =
|
||||
HttpServerUtils.calcSign(timestamp.toString(), clientSignKey.toString())
|
||||
}
|
||||
|
||||
val dataMap: MutableMap<String, Any> = mutableMapOf()
|
||||
|
@ -324,15 +346,20 @@ class CloneFragment : BaseFragment<FragmentClientCloneBinding?>(), View.OnClickL
|
|||
try {
|
||||
//替换Date字段为当前时间
|
||||
val builder = GsonBuilder()
|
||||
builder.registerTypeAdapter(Date::class.java, JsonDeserializer<Any?> { _, _, _ -> Date() })
|
||||
builder.registerTypeAdapter(
|
||||
Date::class.java,
|
||||
JsonDeserializer<Any?> { _, _, _ -> Date() })
|
||||
val gson = builder.create()
|
||||
val resp: BaseResponse<CloneInfo> = gson.fromJson(response, object : TypeToken<BaseResponse<CloneInfo>>() {}.type)
|
||||
val resp: BaseResponse<CloneInfo> = gson.fromJson(
|
||||
response,
|
||||
object : TypeToken<BaseResponse<CloneInfo>>() {}.type
|
||||
)
|
||||
if (resp.code == 200) {
|
||||
val cloneInfo = resp.data
|
||||
Log.d(TAG, "cloneInfo = $cloneInfo")
|
||||
|
||||
if (cloneInfo == null) {
|
||||
XToastUtils.error(ResUtils.getString(R.string.request_failed) + cloneInfo)
|
||||
XToastUtils.error(ResUtils.getString(R.string.request_failed))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,8 @@ class WolSendFragment : BaseFragment<FragmentClientWolSendBinding?>(), View.OnCl
|
|||
override fun initViews() {
|
||||
//发送按钮增加倒计时,避免重复点击
|
||||
mCountDownHelper = CountDownButtonHelper(binding!!.btnSubmit, SettingUtils.requestTimeout)
|
||||
mCountDownHelper!!.setOnCountDownListener(object : CountDownButtonHelper.OnCountDownListener {
|
||||
mCountDownHelper!!.setOnCountDownListener(object :
|
||||
CountDownButtonHelper.OnCountDownListener {
|
||||
override fun onCountDown(time: Int) {
|
||||
binding!!.btnSubmit.text = String.format(getString(R.string.seconds_n), time)
|
||||
}
|
||||
|
@ -64,7 +65,8 @@ class WolSendFragment : BaseFragment<FragmentClientWolSendBinding?>(), View.OnCl
|
|||
//取出历史记录
|
||||
val history = HttpServerUtils.wolHistory
|
||||
if (!TextUtils.isEmpty(history)) {
|
||||
wolHistory = Gson().fromJson(history, object : TypeToken<MutableMap<String, String>>() {}.type)
|
||||
wolHistory =
|
||||
Gson().fromJson(history, object : TypeToken<MutableMap<String, String>>() {}.type)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +85,7 @@ class WolSendFragment : BaseFragment<FragmentClientWolSendBinding?>(), View.OnCl
|
|||
}
|
||||
Log.d(TAG, "wolHistory = $wolHistory")
|
||||
|
||||
MaterialDialog.Builder(context!!)
|
||||
MaterialDialog.Builder(requireContext())
|
||||
.title(R.string.server_history)
|
||||
.items(wolHistory.keys)
|
||||
.itemsCallbackSingleChoice(0) { _: MaterialDialog?, _: View?, _: Int, text: CharSequence ->
|
||||
|
@ -111,7 +113,8 @@ class WolSendFragment : BaseFragment<FragmentClientWolSendBinding?>(), View.OnCl
|
|||
msgMap["timestamp"] = timestamp
|
||||
val clientSignKey = HttpServerUtils.clientSignKey
|
||||
if (!TextUtils.isEmpty(clientSignKey)) {
|
||||
msgMap["sign"] = HttpServerUtils.calcSign(timestamp.toString(), clientSignKey.toString())
|
||||
msgMap["sign"] =
|
||||
HttpServerUtils.calcSign(timestamp.toString(), clientSignKey.toString())
|
||||
}
|
||||
|
||||
val mac = binding!!.etMac.text.toString()
|
||||
|
@ -161,7 +164,10 @@ class WolSendFragment : BaseFragment<FragmentClientWolSendBinding?>(), View.OnCl
|
|||
override fun onSuccess(response: String) {
|
||||
Log.i(TAG, response)
|
||||
try {
|
||||
val resp: BaseResponse<String> = Gson().fromJson(response, object : TypeToken<BaseResponse<String>>() {}.type)
|
||||
val resp: BaseResponse<String> = Gson().fromJson(
|
||||
response,
|
||||
object : TypeToken<BaseResponse<String>>() {}.type
|
||||
)
|
||||
if (resp.code == 200) {
|
||||
XToastUtils.success(ResUtils.getString(R.string.request_succeeded))
|
||||
//添加到历史记录
|
||||
|
|
|
@ -21,7 +21,6 @@ import com.idormy.sms.forwarder.utils.PhoneUtils
|
|||
import com.idormy.sms.forwarder.utils.SettingUtils
|
||||
import com.idormy.sms.forwarder.utils.Worker
|
||||
import com.idormy.sms.forwarder.workers.SendWorker
|
||||
import com.xuexiang.xutil.resource.ResUtils
|
||||
import com.xuexiang.xutil.resource.ResUtils.getString
|
||||
import java.util.*
|
||||
|
||||
|
@ -40,7 +39,11 @@ class PhoneStateReceiver : BroadcastReceiver() {
|
|||
if (TelephonyManager.ACTION_PHONE_STATE_CHANGED != intent.action) return
|
||||
|
||||
//权限判断
|
||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) return
|
||||
if (ActivityCompat.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.READ_PHONE_STATE
|
||||
) != PackageManager.PERMISSION_GRANTED
|
||||
) return
|
||||
|
||||
//获取来电号码
|
||||
val number = intent.extras!!.getString(TelephonyManager.EXTRA_INCOMING_NUMBER)
|
||||
|
@ -80,11 +83,12 @@ class PhoneStateReceiver : BroadcastReceiver() {
|
|||
//来电提醒
|
||||
if (!TextUtils.isEmpty(number) && SettingUtils.enableCallType4) {
|
||||
val contacts = PhoneUtils.getContactByNumber(number)
|
||||
val contactName = if (contacts.isNotEmpty()) contacts[0].name else getString(R.string.unknown_number)
|
||||
val contactName =
|
||||
if (contacts.isNotEmpty()) contacts[0].name else getString(R.string.unknown_number)
|
||||
|
||||
val sb = StringBuilder()
|
||||
sb.append(getString(R.string.linkman)).append(contactName).append("\n")
|
||||
sb.append(ResUtils.getString(R.string.mandatory_type))
|
||||
sb.append(getString(R.string.mandatory_type))
|
||||
sb.append(getString(R.string.incoming_call))
|
||||
|
||||
val msgInfo = MsgInfo("call", number.toString(), sb.toString(), Date(), "", -1)
|
||||
|
@ -117,15 +121,27 @@ class PhoneStateReceiver : BroadcastReceiver() {
|
|||
when {
|
||||
lastState == TelephonyManager.CALL_STATE_RINGING -> {
|
||||
Log.d(TAG, "来电未接")
|
||||
sendReceiveCallMsg(context, 3, MMKVUtils.getString("CALL_SAVED_NUMBER", null))
|
||||
sendReceiveCallMsg(
|
||||
context,
|
||||
3,
|
||||
MMKVUtils.getString("CALL_SAVED_NUMBER", null)
|
||||
)
|
||||
}
|
||||
MMKVUtils.getBoolean("CALL_IS_INCOMING", false) -> {
|
||||
Log.d(TAG, "来电挂机")
|
||||
sendReceiveCallMsg(context, 1, MMKVUtils.getString("CALL_SAVED_NUMBER", null))
|
||||
sendReceiveCallMsg(
|
||||
context,
|
||||
1,
|
||||
MMKVUtils.getString("CALL_SAVED_NUMBER", null)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
Log.d(TAG, "去电挂机")
|
||||
sendReceiveCallMsg(context, 2, MMKVUtils.getString("CALL_SAVED_NUMBER", null))
|
||||
sendReceiveCallMsg(
|
||||
context,
|
||||
2,
|
||||
MMKVUtils.getString("CALL_SAVED_NUMBER", null)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,10 +177,18 @@ class PhoneStateReceiver : BroadcastReceiver() {
|
|||
//获取联系人姓名
|
||||
if (TextUtils.isEmpty(callInfo.name)) {
|
||||
val contacts = PhoneUtils.getContactByNumber(phoneNumber)
|
||||
callInfo.name = if (contacts.isNotEmpty()) contacts[0].name else getString(R.string.unknown_number)
|
||||
callInfo.name =
|
||||
if (contacts.isNotEmpty()) contacts[0].name else getString(R.string.unknown_number)
|
||||
}
|
||||
|
||||
val msgInfo = MsgInfo("call", callInfo.number, PhoneUtils.getCallMsg(callInfo), Date(), simInfo, simSlot)
|
||||
val msgInfo = MsgInfo(
|
||||
"call",
|
||||
callInfo.number,
|
||||
PhoneUtils.getCallMsg(callInfo),
|
||||
Date(),
|
||||
simInfo,
|
||||
simSlot
|
||||
)
|
||||
val request = OneTimeWorkRequestBuilder<SendWorker>()
|
||||
.setInputData(
|
||||
workDataOf(
|
||||
|
|
|
@ -230,7 +230,10 @@ class PhoneUtils private constructor() {
|
|||
Log.i(TAG, "cursor count:" + cursor.count)
|
||||
|
||||
// 避免超过总数后循环取出
|
||||
if (cursor.count == 0 || offset >= cursor.count) return callInfoList
|
||||
if (cursor.count == 0 || offset >= cursor.count) {
|
||||
cursor.close()
|
||||
return callInfoList
|
||||
}
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
Log.d(TAG, "Call ColumnNames=${cursor.columnNames.contentToString()}")
|
||||
|
@ -328,7 +331,10 @@ class PhoneUtils private constructor() {
|
|||
Log.i(TAG, "cursor count:" + cursor.count)
|
||||
|
||||
// 避免超过总数后循环取出
|
||||
if (cursor.count == 0 || offset >= cursor.count) return contactInfoList
|
||||
if (cursor.count == 0 || offset >= cursor.count) {
|
||||
cursor.close()
|
||||
return contactInfoList
|
||||
}
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
val displayNameIndex =
|
||||
|
@ -424,7 +430,10 @@ class PhoneUtils private constructor() {
|
|||
selectionArgs.toTypedArray(),
|
||||
"date desc"
|
||||
) ?: return smsInfoList
|
||||
if (offset >= cursorTotal.count) return smsInfoList
|
||||
if (offset >= cursorTotal.count) {
|
||||
cursorTotal.close()
|
||||
return smsInfoList
|
||||
}
|
||||
|
||||
val cursor = Core.app.contentResolver.query(
|
||||
Uri.parse("content://sms/"),
|
||||
|
@ -435,7 +444,10 @@ class PhoneUtils private constructor() {
|
|||
) ?: return smsInfoList
|
||||
|
||||
Log.i(TAG, "cursor count:" + cursor.count)
|
||||
if (cursor.count == 0) return smsInfoList
|
||||
if (cursor.count == 0) {
|
||||
cursor.close()
|
||||
return smsInfoList
|
||||
}
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
Log.d(TAG, "SMS ColumnNames=${cursor.columnNames.contentToString()}")
|
||||
|
@ -474,6 +486,8 @@ class PhoneUtils private constructor() {
|
|||
) else -1
|
||||
smsInfoList.add(smsInfo)
|
||||
} while (cursor.moveToNext())
|
||||
|
||||
if (!cursorTotal.isClosed) cursorTotal.close()
|
||||
if (!cursor.isClosed) cursor.close()
|
||||
}
|
||||
} catch (e: java.lang.Exception) {
|
||||
|
|
|
@ -34,7 +34,7 @@ object MailUtil {
|
|||
properties["mail.smtp.auth"] = "true"
|
||||
properties["mail.smtp.ssl.enable"] = mail.openSSL
|
||||
if (mail.startTls) {
|
||||
properties["mail.smtp.starttls.enable"] = mail.startTls
|
||||
properties["mail.smtp.starttls.enable"] = true
|
||||
}
|
||||
if (mail.openSSL) {
|
||||
properties["mail.smtp.socketFactory.class"] = mail.sslFactory
|
||||
|
@ -94,7 +94,10 @@ object MailUtil {
|
|||
// 邮件正文
|
||||
val textBodyPart = MimeBodyPart()
|
||||
if (mail.content is Spanned) {
|
||||
textBodyPart.setContent(Html.toHtml(mail.content as Spanned), "text/html;charset=UTF-8")
|
||||
textBodyPart.setContent(
|
||||
Html.toHtml(mail.content as Spanned),
|
||||
"text/html;charset=UTF-8"
|
||||
)
|
||||
} else {
|
||||
textBodyPart.setContent(mail.content, "text/html;charset=UTF-8")
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class UMengInit private constructor() {
|
|||
* @param context
|
||||
* @return
|
||||
*/
|
||||
private fun getChannel(context: Context?): String? {
|
||||
private fun getChannel(context: Context?): String {
|
||||
//return WalleChannelReader.getChannel(context!!, DEFAULT_CHANNEL_ID)
|
||||
return DEFAULT_CHANNEL_ID
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class GuideTipsDialog(context: Context?, tips: List<TipInfo>) :
|
|||
*/
|
||||
private fun updateTips(tips: List<TipInfo>) {
|
||||
mTips = tips
|
||||
if (mTips != null && mTips!!.isNotEmpty() && mTvContent != null) {
|
||||
if (mTips!!.isNotEmpty() && mTvContent != null) {
|
||||
mIndex = 0
|
||||
showRichText(mTips!![mIndex])
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.idormy.sms.forwarder.workers
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.work.CoroutineWorker
|
||||
|
@ -23,6 +24,7 @@ class SendWorker(
|
|||
workerParams: WorkerParameters,
|
||||
) : CoroutineWorker(context, workerParams) {
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
override suspend fun doWork(): Result {
|
||||
|
||||
return withContext(Dispatchers.IO) {
|
||||
|
@ -41,8 +43,10 @@ class SendWorker(
|
|||
|
||||
val dateFmt = SimpleDateFormat("yyyy-MM-dd")
|
||||
val mTimeOption = DataProvider.timePeriodOption
|
||||
val periodStartStr = dateFmt.format(periodStartDay) + " " + mTimeOption[SettingUtils.silentPeriodStart] + ":00"
|
||||
val periodEndStr = dateFmt.format(periodStartEnd) + " " + mTimeOption[SettingUtils.silentPeriodEnd] + ":00"
|
||||
val periodStartStr =
|
||||
dateFmt.format(periodStartDay) + " " + mTimeOption[SettingUtils.silentPeriodStart] + ":00"
|
||||
val periodEndStr =
|
||||
dateFmt.format(periodStartEnd) + " " + mTimeOption[SettingUtils.silentPeriodEnd] + ":00"
|
||||
|
||||
val timeFmt = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
val periodStart = timeFmt.parse(periodStartStr, ParsePosition(0)).time
|
||||
|
@ -75,14 +79,22 @@ class SendWorker(
|
|||
|
||||
//【注意】卡槽id:-1=获取失败、0=卡槽1、1=卡槽2,但是 Rule 表里存的是 SIM1/SIM2
|
||||
val simSlot = "SIM" + (msgInfo.simSlot + 1)
|
||||
val ruleList: List<RuleAndSender> = Core.rule.getRuleAndSender(msgInfo.type, 1, simSlot)
|
||||
val ruleList: List<RuleAndSender> =
|
||||
Core.rule.getRuleAndSender(msgInfo.type, 1, simSlot)
|
||||
if (ruleList.isEmpty()) {
|
||||
return@withContext Result.failure(workDataOf("send" to "failed"))
|
||||
}
|
||||
|
||||
for (rule in ruleList) {
|
||||
if (!rule.rule.checkMsg(msgInfo)) continue
|
||||
val log = Logs(0, msgInfo.type, msgInfo.from, msgInfo.content, rule.rule.id, msgInfo.simInfo)
|
||||
val log = Logs(
|
||||
0,
|
||||
msgInfo.type,
|
||||
msgInfo.from,
|
||||
msgInfo.content,
|
||||
rule.rule.id,
|
||||
msgInfo.simInfo
|
||||
)
|
||||
val logId = Core.logs.insert(log)
|
||||
SendUtils.sendMsgSender(msgInfo, rule.rule, rule.sender, logId)
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<!--有公司logo-->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:opacity="opaque">
|
||||
<item android:drawable="@color/xui_config_color_white" />
|
||||
|
||||
<item android:bottom="@dimen/xui_config_app_logo_bottom">
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@drawable/ic_splash_app_logo" />
|
||||
</item>
|
||||
|
||||
<item android:bottom="@dimen/xui_config_company_logo_bottom">
|
||||
<bitmap
|
||||
android:gravity="bottom"
|
||||
android:src="@drawable/ic_splash_company_logo" />
|
||||
</item>
|
||||
</layer-list>
|
|
@ -65,7 +65,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
android:layout_width="280dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="72dp"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
tools:ignore="UselessParent">
|
||||
|
||||
<com.xuexiang.xui.widget.alpha.XUIAlphaImageView
|
||||
android:id="@+id/iv_close"
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/xui_config_color_background"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
tools:ignore="Overdraw">
|
||||
|
||||
<androidx.core.widget.NestedScrollView style="@style/ScrollViewStyle">
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/xui_config_color_background"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
tools:ignore="Overdraw">
|
||||
|
||||
<androidx.core.widget.NestedScrollView style="@style/ScrollViewStyle">
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/xui_config_color_background"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
tools:ignore="Overdraw">
|
||||
|
||||
<androidx.core.widget.NestedScrollView style="@style/ScrollViewStyle">
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@
|
|||
android:inputType="number"
|
||||
android:maxLength="1"
|
||||
android:singleLine="true"
|
||||
android:text="1"
|
||||
android:text="@string/_1"
|
||||
app:met_clearButton="true" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -123,7 +123,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/missed_call"
|
||||
android:textSize="10sp" />
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
<com.xuexiang.xui.widget.button.SmoothCheckBox
|
||||
android:id="@+id/scb_call_type1"
|
||||
|
@ -137,7 +138,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/received_call"
|
||||
android:textSize="10sp" />
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
<com.xuexiang.xui.widget.button.SmoothCheckBox
|
||||
android:id="@+id/scb_call_type2"
|
||||
|
@ -151,7 +153,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/local_outgoing_call"
|
||||
android:textSize="10sp" />
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
<com.xuexiang.xui.widget.button.SmoothCheckBox
|
||||
android:id="@+id/scb_call_type4"
|
||||
|
@ -165,7 +168,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="@string/incoming_call"
|
||||
android:textSize="10sp" />
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -230,7 +234,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/cancel_app_notify"
|
||||
android:textSize="10sp" />
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
<com.xuexiang.xui.widget.button.SmoothCheckBox
|
||||
android:id="@+id/scb_not_user_present"
|
||||
|
@ -243,7 +248,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/not_user_present"
|
||||
android:textSize="10sp" />
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -307,7 +313,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/user_app"
|
||||
android:textSize="10sp" />
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
<com.xuexiang.xui.widget.button.SmoothCheckBox
|
||||
android:id="@+id/scb_load_system_app"
|
||||
|
@ -320,7 +327,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/system_app"
|
||||
android:textSize="10sp" />
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -589,7 +597,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/keep_reminding"
|
||||
android:textSize="10sp" />
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -861,7 +870,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/play_silence_music"
|
||||
android:textSize="10sp" />
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_one_pixel_activity"
|
||||
|
@ -880,7 +890,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/one_pixel_activity"
|
||||
android:textSize="10sp" />
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -17,8 +17,12 @@
|
|||
|
||||
<style name="AppTheme.Launch">
|
||||
<item name="xui_config_color_splash_bg">@color/xui_config_color_white</item>
|
||||
<item name="xui_config_app_logo_bottom" tools:ignore="PrivateResource">@dimen/xui_config_app_logo_bottom</item>
|
||||
<item name="xui_config_company_logo_bottom" tools:ignore="PrivateResource">@dimen/xui_config_company_logo_bottom</item>
|
||||
<item name="xui_config_app_logo_bottom" tools:ignore="PrivateResource">
|
||||
@dimen/xui_config_app_logo_bottom
|
||||
</item>
|
||||
<item name="xui_config_company_logo_bottom" tools:ignore="PrivateResource">
|
||||
@dimen/xui_config_company_logo_bottom
|
||||
</item>
|
||||
<item name="android:windowBackground">@drawable/xui_config_bg_splash</item>
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
</style>
|
||||
|
@ -43,7 +47,7 @@
|
|||
<!--无标题-->
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<!--是否浮现在activity之上-->
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
<item name="android:windowIsFloating" tools:ignore="TranslucentOrientation">true</item>
|
||||
<!--是否半透明-->
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<!--是否有覆盖-->
|
||||
|
|
Loading…
Reference in New Issue