diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index af5f5c8..ed13ca2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,20 +10,24 @@ - + + - - - - - + + + + + + + { -// var a=0 -// var c=1/a - checkPermission() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + if (Environment.isExternalStorageManager()) { + showLoading( + resources.getString(R.string.UploadingInProgress), + requireActivity() + ) + // 已授予权限 + val directory: File? = requireActivity().getExternalFilesDir("CrashLog") + if (directory != null) { + val allFilePath = getAllFilePath(directory.path) + if (allFilePath.isNotEmpty()) { + mainAtyVM.getUploadParameters() + } else { + android.util.Log.i("checkPermission", "allFilePath is empty") + hideLoading() + RxToast.info(resources.getString(R.string.NoErrorLogs)) + } + } else { + hideLoading() + RxToast.error(resources.getString(R.string.NoErrorLogs)) + } + } else { + // 未授予权限,跳转到设置页面 + val intent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION) + startActivity(intent) + hideLoading() + } + } else { + checkPermission() + } } 8->{ val intent = Intent(requireContext(),AgreementAndPrivacyActivity::class.java) diff --git a/app/src/main/java/com/yingmao/clash/fragment/vip/vipFragment.kt b/app/src/main/java/com/yingmao/clash/fragment/vip/vipFragment.kt index 25e2993..f6d30d8 100644 --- a/app/src/main/java/com/yingmao/clash/fragment/vip/vipFragment.kt +++ b/app/src/main/java/com/yingmao/clash/fragment/vip/vipFragment.kt @@ -4,12 +4,14 @@ import android.annotation.SuppressLint import android.content.Context import android.content.Intent import android.graphics.Color +import android.os.Build import android.text.TextUtils import android.view.View import android.widget.FrameLayout import android.widget.ImageView import android.widget.RelativeLayout import android.widget.TextView +import androidx.annotation.RequiresApi import androidx.appcompat.widget.AppCompatImageView import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.net.toUri @@ -65,6 +67,8 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import java.text.DecimalFormat +import java.text.SimpleDateFormat +import java.util.Locale class vipFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatchers.IO) { @@ -78,6 +82,9 @@ class vipFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatchers private var selectedGrade: Grade? = null private lateinit var rxDialogShapeLoading: RxDialogShapeLoading + private lateinit var tvUserName: TextView + private lateinit var tvUserTimeEnd: TextView + private lateinit var tvTxtShowLink:TextView private var outTradeNo = "" private var selectedGradeID :Int=0 //stripePay 支付 @@ -113,6 +120,11 @@ class vipFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatchers mainAtyVM = ViewModelProvider(this)[MainAtyVM::class.java] viewModel = ViewModelProvider(this)[RechargeViewModel::class.java] observe(this, viewModel) + val userName = + MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_REMEMBER_USERNAME) + + tvUserName.text=userName + setExpireDate() //获取充值列表 val username = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_REMEMBER_USERNAME,"")!! val phToken = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_PH_TOKEN,"")!! @@ -127,7 +139,17 @@ class vipFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatchers tvPay=view.findViewById(R.id.tvPay) tvRechargeRecord=view.findViewById(R.id.tvRechargeRecord) clCustom=view.findViewById(R.id.clCustom) + + tvUserName=view.findViewById(R.id.tvUserName) + tvUserTimeEnd=view.findViewById(R.id.tvUserTimeEnd) + tvTxtShowLink=view.findViewById(R.id.tvTxtShowLink) + + swipeLayout.setColorSchemeColors(Color.rgb(47, 223, 189)) + + tvTxtShowLink.setOnClickListener { + startActivity(Intent(requireActivity(), CustomerServiceWebView::class.java)) + } swipeLayout.setOnRefreshListener { selectedGrade = null val username = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_REMEMBER_USERNAME,"")!! @@ -548,4 +570,75 @@ class vipFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatchers baseLoadingView?.cancel() } } + fun setExpireDate() { + val isExpire = checkExpire() + var endTimeInfo = "--" + if (isExpire) { + if (isAdded) { + endTimeInfo = resources.getString(R.string.AccountExpired) + } + } else { + val validPeriod = MMKV.defaultMMKV().decodeLong(BZYConstants.MMKV_KEY_VPN_VALID_PERIOD) + val decodeString = MMKV.defaultMMKV().decodeString(BZYConstants.languageInfo, "") + if (decodeString.isNullOrEmpty()) { + //获取当前系统语言 + val config = resources.configuration + val language = config.locale.language + if (language.equals("en")) { + val dateFormat = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + val localEN = Locale.ENGLISH + SimpleDateFormat("MM/dd/yyyy HH:mm", localEN) + } else { + val localEN = Locale.ENGLISH + SimpleDateFormat("MM/dd/yyyy HH:mm", localEN) + } + endTimeInfo = dateFormat.format(validPeriod) + } else { + val dateFormat = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + + SimpleDateFormat("yyyy年MM月dd日 HH:mm") + } else { + SimpleDateFormat("yyyy年MM月dd日 HH:mm") + + } + endTimeInfo = dateFormat.format(validPeriod) + } + + } else { + if (decodeString == "English") { + val dateFormat = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + val locale = Locale.ENGLISH + SimpleDateFormat("MM/dd/yyyy HH:mm", locale) + } else { + val locale = Locale.ENGLISH + SimpleDateFormat("MM/dd/yyyy HH:mm", locale) + } + endTimeInfo = dateFormat.format(validPeriod) + } else { + val dateFormat = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + SimpleDateFormat("yyyy年MM月dd日 HH:mm") + } else { + SimpleDateFormat("yyyy年MM月dd日 HH:mm") + } + endTimeInfo = dateFormat.format(validPeriod) + + } + } + } + + tvUserTimeEnd.text =resources.getString(R.string.expire_date)+endTimeInfo + } + + private fun checkExpire(): Boolean { + val validPeriod = MMKV.defaultMMKV().decodeLong(BZYConstants.MMKV_KEY_VPN_VALID_PERIOD) + if (validPeriod > 0) { + val nowTime = System.currentTimeMillis() + Log.d("validPeriod==>$validPeriod, nowTime==>$nowTime") + if (validPeriod >= nowTime) { + return false + } + } + return true + } + } \ No newline at end of file diff --git a/app/src/main/res/drawable/vip_item_nochoose_bg.xml b/app/src/main/res/drawable/vip_item_nochoose_bg.xml new file mode 100644 index 0000000..8cd93f4 --- /dev/null +++ b/app/src/main/res/drawable/vip_item_nochoose_bg.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/vip_item_zs_bg.xml b/app/src/main/res/drawable/vip_item_zs_bg.xml new file mode 100644 index 0000000..2fabcbb --- /dev/null +++ b/app/src/main/res/drawable/vip_item_zs_bg.xml @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/app/src/main/res/drawable/yjl_login_bg.xml b/app/src/main/res/drawable/yjl_login_bg.xml index 115f80d..85343c9 100644 --- a/app/src/main/res/drawable/yjl_login_bg.xml +++ b/app/src/main/res/drawable/yjl_login_bg.xml @@ -7,7 +7,7 @@ android:color="#BFD5D5D5" > android:angle="360" android:endColor="@color/white" android:startColor="@color/white" /> - + \ No newline at end of file diff --git a/app/src/main/res/drawable/yjl_login_bg_icon.xml b/app/src/main/res/drawable/yjl_login_bg_icon.xml new file mode 100644 index 0000000..1257e54 --- /dev/null +++ b/app/src/main/res/drawable/yjl_login_bg_icon.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/member_recharge_layout.xml b/app/src/main/res/layout/member_recharge_layout.xml index e9bc655..119b63d 100644 --- a/app/src/main/res/layout/member_recharge_layout.xml +++ b/app/src/main/res/layout/member_recharge_layout.xml @@ -13,7 +13,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" - android:layout_marginTop="12dp" + android:layout_marginTop="48dp" > - - - - - - - - - - - - - - - - - - - - - - + + android:layout_height="match_parent"> - - - - - - - - - - - - - - - - - - - - - - - + - /> + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/vip_recharge_list_item_layout.xml b/app/src/main/res/layout/vip_recharge_list_item_layout.xml index 58a7c62..ec59f20 100644 --- a/app/src/main/res/layout/vip_recharge_list_item_layout.xml +++ b/app/src/main/res/layout/vip_recharge_list_item_layout.xml @@ -20,7 +20,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" - android:background="@drawable/oc_language_bg" + android:background="@drawable/vip_item_nochoose_bg" android:layout_marginTop="@dimen/dp_10" > 最新通知 你的会员还有$天到期 去完成 + 流量限制 + 不限流量 + 解锁流媒体 + 智能连接 + ¥ \ No newline at end of file