mirror of
https://github.com/pppscn/SmsForwarder
synced 2025-08-02 17:07:41 +08:00
优化:单 sim 卡槽手机不显示 sim2 设置。
This commit is contained in:
parent
3adfffee4f
commit
dc3726d0de
@ -180,12 +180,18 @@ class SettingsFragment : BaseFragment<FragmentSettingsBinding?>(), View.OnClickL
|
|||||||
editAddExtraDeviceMark(binding!!.etExtraDeviceMark)
|
editAddExtraDeviceMark(binding!!.etExtraDeviceMark)
|
||||||
//SIM1主键
|
//SIM1主键
|
||||||
editAddSubidSim1(binding!!.etSubidSim1)
|
editAddSubidSim1(binding!!.etSubidSim1)
|
||||||
//SIM2主键
|
|
||||||
editAddSubidSim2(binding!!.etSubidSim2)
|
|
||||||
//SIM1备注
|
//SIM1备注
|
||||||
editAddExtraSim1(binding!!.etExtraSim1)
|
editAddExtraSim1(binding!!.etExtraSim1)
|
||||||
//SIM2备注
|
|
||||||
editAddExtraSim2(binding!!.etExtraSim2)
|
// sim 槽只有一个的时候不显示 SIM2 设置
|
||||||
|
if (PhoneUtils.getSimSlotCount() != 1) {
|
||||||
|
//SIM2主键
|
||||||
|
editAddSubidSim2(binding!!.etSubidSim2)
|
||||||
|
//SIM2备注
|
||||||
|
editAddExtraSim2(binding!!.etExtraSim2)
|
||||||
|
} else {
|
||||||
|
binding!!.layoutSim2.visibility = View.GONE
|
||||||
|
}
|
||||||
//通知内容
|
//通知内容
|
||||||
editNotifyContent(binding!!.etNotifyContent)
|
editNotifyContent(binding!!.etNotifyContent)
|
||||||
//启用自定义模版
|
//启用自定义模版
|
||||||
@ -991,7 +997,7 @@ class SettingsFragment : BaseFragment<FragmentSettingsBinding?>(), View.OnClickL
|
|||||||
|
|
||||||
//设置SIM1主键
|
//设置SIM1主键
|
||||||
private fun editAddSubidSim1(etSubidSim1: EditText) {
|
private fun editAddSubidSim1(etSubidSim1: EditText) {
|
||||||
etSubidSim1.setText(SettingUtils.subidSim1.toString())
|
etSubidSim1.setText("${SettingUtils.subidSim1}")
|
||||||
etSubidSim1.addTextChangedListener(object : TextWatcher {
|
etSubidSim1.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
||||||
@ -1008,7 +1014,7 @@ class SettingsFragment : BaseFragment<FragmentSettingsBinding?>(), View.OnClickL
|
|||||||
|
|
||||||
//设置SIM2主键
|
//设置SIM2主键
|
||||||
private fun editAddSubidSim2(etSubidSim2: EditText) {
|
private fun editAddSubidSim2(etSubidSim2: EditText) {
|
||||||
etSubidSim2.setText(SettingUtils.subidSim2.toString())
|
etSubidSim2.setText("${SettingUtils.subidSim2}")
|
||||||
etSubidSim2.addTextChangedListener(object : TextWatcher {
|
etSubidSim2.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
||||||
|
@ -14,6 +14,7 @@ import android.provider.Settings
|
|||||||
import android.telephony.SmsManager
|
import android.telephony.SmsManager
|
||||||
import android.telephony.SubscriptionInfo
|
import android.telephony.SubscriptionInfo
|
||||||
import android.telephony.SubscriptionManager
|
import android.telephony.SubscriptionManager
|
||||||
|
import android.telephony.TelephonyManager
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import androidx.annotation.RequiresPermission
|
import androidx.annotation.RequiresPermission
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
@ -37,6 +38,14 @@ class PhoneUtils private constructor() {
|
|||||||
companion object {
|
companion object {
|
||||||
const val TAG = "PhoneUtils"
|
const val TAG = "PhoneUtils"
|
||||||
|
|
||||||
|
/** 获取 sim 卡槽数量,注意不是 sim 卡的数量。*/
|
||||||
|
fun getSimSlotCount() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
||||||
|
(App.context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager).activeModemCount
|
||||||
|
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||||
|
(App.context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager).phoneCount
|
||||||
|
else
|
||||||
|
-1
|
||||||
|
|
||||||
//获取多卡信息
|
//获取多卡信息
|
||||||
@SuppressLint("Range")
|
@SuppressLint("Range")
|
||||||
fun getSimMultiInfo(): MutableMap<Int, SimInfo> {
|
fun getSimMultiInfo(): MutableMap<Int, SimInfo> {
|
||||||
|
@ -1567,6 +1567,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/layout_sim2"
|
||||||
style="@style/BarStyle"
|
style="@style/BarStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user