From 3968759b2ec63e0edc4b9d9995c894191c180c96 Mon Sep 17 00:00:00 2001 From: pppscn <35696959@qq.com> Date: Fri, 29 Mar 2024 18:14:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A`=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE`=E5=A2=9E=E5=8A=A0=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E8=B7=B3=E8=BD=AC`=E4=B8=80=E9=94=AE?= =?UTF-8?q?=E6=8D=A2=E6=96=B0=E6=9C=BA`=C2=B7`=E7=A6=BB=E7=BA=BF=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../forwarder/fragment/SettingsFragment.kt | 12 ++++++++ .../fragment/client/CloneFragment.kt | 28 +++++++++++++++++-- .../idormy/sms/forwarder/utils/Constants.kt | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/idormy/sms/forwarder/fragment/SettingsFragment.kt b/app/src/main/java/com/idormy/sms/forwarder/fragment/SettingsFragment.kt index e6422ee5..da1afd58 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/fragment/SettingsFragment.kt +++ b/app/src/main/java/com/idormy/sms/forwarder/fragment/SettingsFragment.kt @@ -41,6 +41,7 @@ import com.idormy.sms.forwarder.adapter.spinner.AppListSpinnerAdapter import com.idormy.sms.forwarder.core.BaseFragment import com.idormy.sms.forwarder.databinding.FragmentSettingsBinding import com.idormy.sms.forwarder.entity.SimInfo +import com.idormy.sms.forwarder.fragment.client.CloneFragment import com.idormy.sms.forwarder.receiver.BootCompletedReceiver import com.idormy.sms.forwarder.service.BluetoothScanService import com.idormy.sms.forwarder.service.ForegroundService @@ -55,6 +56,7 @@ import com.idormy.sms.forwarder.utils.CommonUtils import com.idormy.sms.forwarder.utils.DataProvider import com.idormy.sms.forwarder.utils.EVENT_LOAD_APP_LIST import com.idormy.sms.forwarder.utils.EXTRA_UPDATE_NOTIFICATION +import com.idormy.sms.forwarder.utils.KEY_DEFAULT_SELECTION import com.idormy.sms.forwarder.utils.KeepAliveUtils import com.idormy.sms.forwarder.utils.LocationUtils import com.idormy.sms.forwarder.utils.Log @@ -66,6 +68,7 @@ import com.idormy.sms.forwarder.workers.LoadAppListWorker import com.jeremyliao.liveeventbus.LiveEventBus import com.xuexiang.xaop.annotation.SingleClick import com.xuexiang.xpage.annotation.Page +import com.xuexiang.xpage.core.PageOption import com.xuexiang.xui.widget.actionbar.TitleBar import com.xuexiang.xui.widget.button.SmoothCheckBox import com.xuexiang.xui.widget.button.switchbutton.SwitchButton @@ -114,6 +117,15 @@ class SettingsFragment : BaseFragment(), View.OnClickL GuideTipsDialog.showTipsForce(requireContext()) } }) + titleBar!!.addAction(object : TitleBar.ImageAction(R.drawable.ic_restore) { + @SingleClick + override fun performAction(view: View) { + PageOption.to(CloneFragment::class.java) + .putInt(KEY_DEFAULT_SELECTION, 1) //默认离线模式 + .setNewActivity(true) + .open(this@SettingsFragment) + } + }) return titleBar } diff --git a/app/src/main/java/com/idormy/sms/forwarder/fragment/client/CloneFragment.kt b/app/src/main/java/com/idormy/sms/forwarder/fragment/client/CloneFragment.kt index 905db299..dac98b0e 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/fragment/client/CloneFragment.kt +++ b/app/src/main/java/com/idormy/sms/forwarder/fragment/client/CloneFragment.kt @@ -20,14 +20,24 @@ import com.idormy.sms.forwarder.core.BaseFragment import com.idormy.sms.forwarder.databinding.FragmentClientCloneBinding import com.idormy.sms.forwarder.entity.CloneInfo import com.idormy.sms.forwarder.server.model.BaseResponse -import com.idormy.sms.forwarder.utils.* +import com.idormy.sms.forwarder.utils.AppUtils import com.idormy.sms.forwarder.utils.Base64 +import com.idormy.sms.forwarder.utils.CommonUtils +import com.idormy.sms.forwarder.utils.HttpServerUtils +import com.idormy.sms.forwarder.utils.KEY_DEFAULT_SELECTION +import com.idormy.sms.forwarder.utils.Log +import com.idormy.sms.forwarder.utils.RSACrypt +import com.idormy.sms.forwarder.utils.SM4Crypt +import com.idormy.sms.forwarder.utils.SettingUtils +import com.idormy.sms.forwarder.utils.XToastUtils import com.xuexiang.xaop.annotation.SingleClick import com.xuexiang.xhttp2.XHttp import com.xuexiang.xhttp2.cache.model.CacheMode import com.xuexiang.xhttp2.callback.SimpleCallBack import com.xuexiang.xhttp2.exception.ApiException import com.xuexiang.xpage.annotation.Page +import com.xuexiang.xrouter.annotation.AutoWired +import com.xuexiang.xrouter.launcher.XRouter import com.xuexiang.xrouter.utils.TextUtils import com.xuexiang.xui.utils.CountDownButtonHelper import com.xuexiang.xui.widget.actionbar.TitleBar @@ -38,7 +48,7 @@ import com.xuexiang.xutil.file.FileIOUtils import com.xuexiang.xutil.file.FileUtils import com.xuexiang.xutil.resource.ResUtils.getStringArray import java.io.File -import java.util.* +import java.util.Date @Suppress("PrivatePropertyName") @Page(name = "一键换新机") @@ -52,6 +62,14 @@ class CloneFragment : BaseFragment(), View.OnClickL private var exportCountDownHelper: CountDownButtonHelper? = null private var importCountDownHelper: CountDownButtonHelper? = null + @JvmField + @AutoWired(name = KEY_DEFAULT_SELECTION) + var defaultSelection: Int = 0 + + override fun initArgs() { + XRouter.getInstance().inject(this) + } + override fun viewBindingInflate( inflater: LayoutInflater, container: ViewGroup, @@ -102,6 +120,12 @@ class CloneFragment : BaseFragment(), View.OnClickL binding!!.layoutOffline.visibility = View.GONE } } + //通用设置界面跳转时只使用离线模式 + if (defaultSelection == 1) { + binding!!.tabBar.visibility = View.GONE + binding!!.layoutNetwork.visibility = View.GONE + binding!!.layoutOffline.visibility = View.VISIBLE + } //按钮增加倒计时,避免重复点击 pushCountDownHelper = CountDownButtonHelper(binding!!.btnPush, SettingUtils.requestTimeout) diff --git a/app/src/main/java/com/idormy/sms/forwarder/utils/Constants.kt b/app/src/main/java/com/idormy/sms/forwarder/utils/Constants.kt index aa109f8c..91e31036 100644 --- a/app/src/main/java/com/idormy/sms/forwarder/utils/Constants.kt +++ b/app/src/main/java/com/idormy/sms/forwarder/utils/Constants.kt @@ -180,6 +180,7 @@ const val KEY_SENDER_TEST = "key_sender_test" const val KEY_RULE_ID = "key_rule_id" const val KEY_RULE_TYPE = "key_rule_type" const val KEY_RULE_CLONE = "key_rule_clone" +const val KEY_DEFAULT_SELECTION = "key_default_selection" const val KEY_TASK_ID = "key_task_id" const val KEY_TASK_TYPE = "key_task_type"