diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cbcc9b2..32155f7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -94,9 +94,6 @@ android:name=".act.ChangePwdActivity" android:process=":background" android:screenOrientation="portrait" /> - - - - - - = mutableListOf() - -// var clash: ClashManager? = null - } - - private lateinit var swipeLayout: SwipeRefreshLayout - private lateinit var changeNodeVM: ChangeNodeVM - private lateinit var nodeListRv: RecyclerView - private var names: List? = null - private lateinit var aiBack: AppCompatImageView - private var broadcastReceiver: BroadcastReceiver? = null - private var cacheNodeStr: String? = "" - - // private var checkedNode: ClashNodebBean? = null - private var uuid: UUID? = null - - private var testRuning = false - // var cprofile: ProfileManager? = null - // private var currentNode: Profile? = null - - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_change_node) - setMoreBar("线路测速", this) - changeNodeVM = ViewModelProvider(this).get(ChangeNodeVM::class.java) - initData() - initViews() - -// cprofile = ProfileManager(this) - } - - override fun onBackPressed() { - intent.putExtra(BZYConstants.EXTRA_KEY_IS_RUNING, is_runing) - setResult(HomeFragment.CHECK_NODE_RESULT_CODE, intent) - super.onBackPressed() - } - - private fun initData() { -// clash = MainApplication.getApp()?.let { ClashManager(it) } - cacheNodeStr = MMKV.defaultMMKV().decodeString(BZYConstants.NODE_All_ITEM_NAME_KEY, ""); - - val intentFilter = IntentFilter(Intents.ACTION_NODE_LIST) - broadcastReceiver = NodeListBR() - if (Build.VERSION.SDK_INT >= 34 && applicationInfo.targetSdkVersion >= 34) { - registerReceiver( - broadcastReceiver, - intentFilter, - Context.RECEIVER_EXPORTED - ) - } else { - registerReceiver( - broadcastReceiver, - intentFilter - ) - } -// registerReceiver( -// broadcastReceiver, -// intentFilter -// ) - } - - @SuppressLint("SetTextI18n") - private fun initViews() { - aiBack = findViewById(R.id.aiBack) - aiBack.setOnClickListener { - onBackPressed() - } - swipeLayout = findViewById(R.id.swipeLayout) - initRefreshLayout() - nodeListRv = findViewById(R.id.rv_node_list) - var userTrafficTv: TextView = findViewById(R.id.node_user_traffic) - - findViewById(R.id.iv_back).setOnClickListener { - onBackPressed() - } - initAdapter() -// Log.d("initViews cacheNodeStr==>${cacheNodeStr}") - if (!TextUtils.isEmpty(cacheNodeStr)) { - currentNode = getNodesInfo(cacheNodeStr!!) - setNewData(currentNode) - } - -// if (!TextUtils.isEmpty(serStore.userTraffic)) { -// userTrafficTv.visibility=View.VISIBLE -// var jo = JsonParser.parseString(serStore.userTraffic).asJsonObject -// var t = jo.get("total") -// var d = jo.get("download").asLong -// var u = jo.get("upload").asLong -// val trafficUsedInGB = String.format("%.2f", (d + u) / 1024.0 / 1024.0 / 1024.0) -// userTrafficTv.text="已用流量:${trafficUsedInGB}GB" -// } - } - - private fun getNodesInfo(json: String): MutableList { - var mList: MutableList = mutableListOf() - if (TextUtils.isEmpty(json)) { - return mList - } - val gson = Gson() - var ja = JsonParser.parseString(json).asJsonArray - - var cnb = ClashNodebBean("自动选择", "", "", 1, "", "", 0, true); - mList.add(cnb) - for (i in 0 until ja.size()) { - var bean = gson.fromJson(ja.get(i).asString, ClashNodebBean::class.java) - bean.delay = Utils.generateRandomTwoDigitNumber(10, 60) - mList.add(bean) - } - return mList - } - - inner class NodeListBR : BroadcastReceiver() { - override fun onReceive(context: Context?, intent: Intent?) { - when (intent?.action) { - Intents.ACTION_NODE_LIST -> { - Log.d("ACTION_NODE_LIST ACTION_NODE_LIST") -// val parcelableArrayListExtra = intent.getParcelableArrayListExtra>("") - hideLoading() -// stopTimer() - timerJob?.cancel() - dialogDoMainChoose?.dismiss() -// var json = intent.getStringExtra("node_list") -// Log.d("onReceive: $json") -// currNodeJsonA = json - var json = serStore.nodes -// Log.d("serStore.nodes: $json") - if (TextUtils.isEmpty(json)) { - return - } - //缓存订阅地址 - UIMainActivity.subUrl = nowSubUrl - MMKV.defaultMMKV().encode(BZYConstants.PROFILE_SUB_URL, nowSubUrl) - //缓存节点 - MMKV.defaultMMKV().encode(BZYConstants.NODE_All_ITEM_NAME_KEY, json) - currentNode = getNodesInfo(json) -// val listType = object : TypeToken>() {}.type -// currentNode = gson.fromJson(json, listType) - setNewData(currentNode) - swipeLayout.isRefreshing = false - } - - else -> { - - } - } - } - } - - override fun onDestroy() { - super.onDestroy() - broadcastReceiver?.let { - unregisterReceiver(it) - } - } - - override fun onResume() { - super.onResume() -// uuid = intent.getStringExtra(BZYConstants.MMKV_KEY_CURRENT_NODE) -// com.cncat.vpn.common.log.Log.d("ChangeNode uuid==>$uuid") - is_runing = intent.getBooleanExtra(BZYConstants.EXTRA_KEY_IS_RUNING, false) - } - - val remote = Resource() - var GetNodeTimeOutNum = 5; - var is_runing = false - private var timer: Timer? = null - private var timerTask: TimerTask? = null - var nowSubUrl: String = "" - private fun updateProfile(isDelete: Boolean) { -// showLoading("正在获取...", this@ChangeNodeActivity) - - try { - - - launch(Dispatchers.IO) { - UIMainActivity.profileBinder?.let { profileManager -> - var mProfile = profileManager.queryAll().find { - it.name == Conf.getClashConfName(this@ChangeNodeTzActivity.applicationContext) - } - - if (mProfile == null) { - //为空的情况下选择第一个 - profileManager.queryAll().forEach { profile -> - mProfile = profile - return@forEach - } - } - - mProfile?.let { profile -> - uuid = profile.uuid - Log.d("ChangeNode22 uuid==>${profile.uuid}") - if (isDelete) { - Log.d("gogogogogo isDelete") - profileManager.delete(profile.uuid) - MMKV.defaultMMKV() - .removeValueForKey(BZYConstants.NODE_All_ITEM_NAME_KEY) - setSub2(profileManager, nowSubUrl) - } else { - Log.d("gogogogogo update") - profileManager.setActive(profile) - delay(500) - if (!TextUtils.isEmpty(profile.source)) { -// Log.d("updateProfile pro.source==>${profile.source}, url==>${nowSubUrl}") - if (profile.source != nowSubUrl) { - Log.d("updateProfile patch") - profileManager.patch( - profile.uuid, - profile.name, - nowSubUrl, - 1800000L - ) - Log.d("updateProfile patch 1") - profileManager.commit(profile.uuid) { status -> - Log.d("updateProfile updateStatus: " + Gson().toJson(status.args) + ", pro==>" + status.progress) - } - Log.d("updateProfile patch 2") - } - } - Log.d("updateProfile go update") - profileManager.update(profile.uuid) - } - Log.d("gogogogogo end") - } - } - } - } catch (e: Exception) { - e.printStackTrace() - } - } - - private fun initRefreshLayout() { - swipeLayout.setColorSchemeColors(Color.rgb(47, 223, 189)) - swipeLayout.setOnRefreshListener(object : OnRefreshListener { - override fun onRefresh() { - if (testRuning) { - RxToast.info("正在测速中."); - swipeLayout.isRefreshing = false - return - } - com.cncat.vpn.common.log.Log.d("onRefresh") -// getNodesStatus(); -// changeNodeVM.getAirNodes() - swipeLayout.isRefreshing = true - updateProfile(false) - com.cncat.vpn.common.log.Log.d("onRefresh end") - swipeLayout.isRefreshing = false - } - }) - } - - override fun onStart() { - super.onStart() - UIMainActivity.subUrl?.let { - nowSubUrl = it - } - doProfile() - - } - - fun doProfile() { - if (TextUtils.isEmpty(cacheNodeStr)) { - - } - showLoading("正在获取...", this@ChangeNodeTzActivity) - startTimer() - updateProfile(false) - - } - - private fun changeSubUrl(originalUrl: String, newUrl: String) { - if(!originalUrl.isNullOrEmpty()&&!newUrl.isNullOrEmpty()){ - nowSubUrl = originalUrl.replace(Regex("https://[^/]+/"), "$newUrl/") - MMKV.defaultMMKV().encode(BZYConstants.PROFILE_SUB_URL, nowSubUrl) - } - } - - val reloadLock = Semaphore(10) - private fun setPing() { - if (!HomeFragment.clashRunning) { - RxToast.info("请先开启加速后,再进行测试."); - return - } - if (testRuning) { - RxToast.info("正在测速中."); - return - } - testRuning = true - updateMoreBar("测速中") - launch(Dispatchers.IO) { - var group = reloadLock.withPermit { - UIMainActivity.clashBinder?.let { cb -> - var names = cb.queryProxyGroupNames(false) - if (names.isNotEmpty()) { - cb.healthCheck(names[0]) - } - delay(1000) - cb.queryProxyGroup(names[0], uiStore.proxySort); - } - } - testRuning = false - runOnUiThread { updateMoreBar("线路测速") } - var newDatas = mutableListOf(); - group?.proxies?.forEach { proxy -> - Log.d("node==>${proxy}") - if (currentNode?.isNotEmpty() == true) { - for (nodeItem: ClashNodebBean in currentNode!!) { - if (nodeItem.name == proxy.name) { - if (proxy.name != "自动选择") { - nodeItem.delay = proxy.delay; - } - Log.d("nodeItem==>${nodeItem}") - newDatas.add(nodeItem) - return@forEach - } - } - } - } - if (newDatas.isNotEmpty()) { - setNewData(newDatas) - } - } - } - - - private fun setNewData(nodes: MutableList?) { - runOnUiThread { - if (nodes != null) { - nodeListAdapter.setNewInstance(nodes) - var selected_name = - MMKV.defaultMMKV().decodeString(BZYConstants.NODE_SELECTED_NAME_KEY, ""); - for ((index, node) in nodes.withIndex()) { - if (node.name == selected_name) { - nodeListAdapter.selectedPosition = index -// checkedNode = node - } - } - nodeListAdapter.notifyDataSetChanged() - } - } - } - - var nodeListAdapter: NodeTzListAdapter = NodeTzListAdapter(R.layout.node_tz_list_item_layout) - private fun initAdapter() { - nodeListRv.layoutManager = LinearLayoutManager(this) - nodeListRv.adapter = nodeListAdapter - nodeListAdapter.selectedPosition - nodeListAdapter.setOnItemClickListener { baseQuickAdapter: BaseQuickAdapter<*, *>, view: View, position: Int -> - (baseQuickAdapter.getItem(position) as ClashNodebBean).let { profile -> - com.cncat.vpn.common.log.Log.i("select_node : ${profile.name}") -// checkedNode = profile - MMKV.defaultMMKV().encode(BZYConstants.NODE_SELECTED_NAME_KEY, profile.name) - nodeListAdapter.notifyItemChanged(nodeListAdapter.selectedPosition) - nodeListAdapter.selectedPosition = - if (nodeListAdapter.selectedPosition == position) -1 else position - nodeListAdapter.notifyItemChanged(position) -// launch { -// withClash { -// val names = queryProxyGroupNames(false) -// val mode = queryOverride(Clash.OverrideSlot.Session).mode -// com.cncat.vpn.common.log.Log.d("names 222==>${names}, mode==>$mode") -// names?.let { ns -> -// if (ns.isNotEmpty()) { -// patchSelector(ns[0], profile.name) -// } -// } -// } -// } - launch(Dispatchers.IO) { - val intent = Intent() - intent.putExtra(BZYConstants.MMKV_KEY_SELECT_NODE_NAME, "自动选择") - intent.putExtra(BZYConstants.EXTRA_KEY_IS_RUNING, is_runing) - setResult(HomeFragment.CHECK_NODE_RESULT_CODE, intent) - finish() - } - } - } - } - - private fun createProfile() { - launch(Dispatchers.IO) { - UIMainActivity.profileBinder?.let { pro -> - uuid?.let { uu -> - pro.delete(uu) - delay(500) - setSub2(pro, UIMainActivity.subUrl) - } - } - } - } - - public suspend fun setSub2(pm: IProfileManager, url: String?) { -// com.cncat.vpn.common.log.Log.d("setSub2.... url==>$url") - if (TextUtils.isEmpty(url)) { - com.cncat.vpn.common.log.Log.d("setSub2 url isEmpty") - return - } - - com.cncat.vpn.common.log.Log.d("setSub2 2") - - - com.cncat.vpn.common.log.Log.d("setSub2 3") - val pro = pm.queryAll().find { - it.name == Conf.getClashConfName(this@ChangeNodeTzActivity.applicationContext) - } - com.cncat.vpn.common.log.Log.d("setSub2 4") - pro?.let { - com.cncat.vpn.common.log.Log.d("setSub2 pro 已存在 ==>") -// pm.setActive(it) - - com.cncat.vpn.common.log.Log.d("setSub2 setActive end") - } ?: run { - var uuid: UUID = pm.create( - Profile.Type.Url, - Conf.getClashConfName(this@ChangeNodeTzActivity.applicationContext) - ) - delay(500) - pm.queryByUUID(uuid)?.let { qPro -> - pm.setActive(qPro) - pm.patch( - qPro.uuid, qPro.name, -// "https://mojie0201.xn--8stx8olrwkucjq3b.com/api/v1/client/subscribe?token=169110d2674c49604b7e5b5cea341579", -// "https://www.otcopusapp.cc/lx3af288h5i8pz380/api/v1/client/subscribe?token=d6bc98c7ea53099fa5bd1a3ea415ebb6", - url!!, - 1800000L - ) -// coroutineScope { - pm.commit(qPro.uuid) { status -> - android.util.Log.d( - Conf.TAG, - "new updateStatus: " + Gson().toJson(status.args) + ", pro==>" + status.progress - ) - } -// } - } - } - } - - var isCreate: Boolean = false - private var timerJob: Job? = null - private fun startTimer() { - GetNodeTimeOutNum = 15 - timerJob = launch { - repeat(16) { - Log.d("GetNodeTimeOutNum==>$GetNodeTimeOutNum") - if (GetNodeTimeOutNum == 0) { - hideLoading() - Log.d("stopTimer...") - RxToast.error("获取节点失败...请尝试切换其他地址") - showDomainList() - timerJob?.cancel() -// delay(1000) -// this@ChangeNodeActivity.finish() - - } - GetNodeTimeOutNum-- - delay(1000) - } - } - } - - var dialogDoMainChoose: DialogDoMainChoose? = null - private fun showDomainList() { - try { - SplashHelper(changeNodeVM).getHostWithFallback { success -> - MainScope().launch { - - if (success) { - if (dialogDoMainChoose == null) { - dialogDoMainChoose = DialogDoMainChoose(this@ChangeNodeTzActivity) - } - if (dialogDoMainChoose?.isShowing == false) { - dialogDoMainChoose?.setOnTryButtonListener(object : - DialogDoMainChoose.OnTryButtonListener { - override fun tryButton() { - saveSubUrl() - doProfile() - dialogDoMainChoose?.dismiss() - } - - override fun cancel() { - com.cncat.vpn.common.log.Log.d("tryButton CHECK_LOGIN cancel") - - dialogDoMainChoose?.dismiss() - } - }) - dialogDoMainChoose?.setOnListItemListener(object : - DialogDoMainChoose.OnListItemListener { - override fun listItemClick() { - saveSubUrl() - MainApplication.restartApp(this@ChangeNodeTzActivity, object : - MainApplication.OnRestartButtonListener { - - override fun enterButton() { - - } - - override fun cancelButton() { - doProfile() - dialogDoMainChoose?.dismiss() - } - - }) - } - }) - dialogDoMainChoose?.show() - } - } - } - } - - } catch (e: Exception) { - e.printStackTrace() - } - } - - private fun saveSubUrl() { - var currentHost = MMKV.defaultMMKV() - .decodeString(BZYConstants.MMKV_KEY_CURRENT_HOST, "") -// com.cncat.vpn.common.log.Log.d("tryButton currentHost==>${currentHost}") - var oldUrl = nowSubUrl - currentHost?.let { changeSubUrl(oldUrl, it) } - } - - private fun stopTimer() { - timerTask?.cancel() - timer?.purge() - timer?.cancel() - timerTask = null - timer = null - } - - override fun onClick(p0: View?) { - when (p0?.id) { - R.id.tv_more -> { - setPing() - } - - else -> { - - } - } - } - - -} diff --git a/app/src/main/java/com/yingmao/clash/act/ChangePwdActivity.kt b/app/src/main/java/com/yingmao/clash/act/ChangePwdActivity.kt index 6e4ee51..602a7f3 100644 --- a/app/src/main/java/com/yingmao/clash/act/ChangePwdActivity.kt +++ b/app/src/main/java/com/yingmao/clash/act/ChangePwdActivity.kt @@ -78,8 +78,6 @@ class ChangePwdActivity : BaseActivity() { } if(newPassword == originalPassword){ RxToast.error(resources.getString(R.string.PasswordSame)) -// getFocusAndShowSoftInput(newPasswordEt) -// newPasswordEt.text.clear() return@setOnClickListener } diff --git a/app/src/main/java/com/yingmao/clash/act/ConnectionModeActivity.kt b/app/src/main/java/com/yingmao/clash/act/ConnectionModeActivity.kt deleted file mode 100644 index 112f68b..0000000 --- a/app/src/main/java/com/yingmao/clash/act/ConnectionModeActivity.kt +++ /dev/null @@ -1,206 +0,0 @@ -package com.yingmao.clash.act - -import android.app.Activity -import android.content.Intent -import android.os.Bundle -import android.view.ViewGroup.LayoutParams -import android.widget.LinearLayout -import android.widget.TextView -import androidx.appcompat.widget.AppCompatImageView -import androidx.constraintlayout.widget.ConstraintLayout -import androidx.lifecycle.ViewModelProvider -import com.cncat.vpn.common.constants.Intents -import com.cncat.vpn.service.model.AccessControlMode -import com.tencent.mmkv.MMKV -import com.yingmao.clash.R -import com.yingmao.clash.base.BaseActivity -import com.yingmao.clash.conf.BZYConstants -import com.yingmao.clash.fragment.home.HomeFragment -import com.yingmao.clash.view.RxToast -import com.yingmao.clash.view.popwindow.CommonPopupWindow - -class ConnectionModeActivity : BaseActivity() { - private var proxyModeAtyVM: ProxyModeAtyVM? = null - private lateinit var cardIntelligentModeSelect: ConstraintLayout - private lateinit var clGlobalMode: ConstraintLayout - private lateinit var clApplicationMode:ConstraintLayout - private lateinit var clAccessControlApplication:ConstraintLayout - private lateinit var tbApplicationMode:TextView - private var popupWindow: CommonPopupWindow? = null - private var layoutGravity: CommonPopupWindow.LayoutGravity? = null - private lateinit var aiIntelligentModeSelect: AppCompatImageView - private lateinit var aiGlobalMode: AppCompatImageView - private lateinit var aiBack:AppCompatImageView - - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.connection_mode_layout) - proxyModeAtyVM = ViewModelProvider(this)[ProxyModeAtyVM::class.java] - initView() - } - - private fun initView() { - cardIntelligentModeSelect=findViewById(R.id.cardIntelligentModeSelect) - clGlobalMode=findViewById(R.id.clGlobalMode) - aiIntelligentModeSelect=findViewById(R.id.aiIntelligentModeSelect) - aiGlobalMode=findViewById(R.id.aiGlobalMode) - clApplicationMode=findViewById(R.id.clApplicationMode) - clAccessControlApplication=findViewById(R.id.clAccessControlApplication) - tbApplicationMode=findViewById(R.id.tbApplicationMode) - aiBack=findViewById(R.id.aiBack) - aiBack.setOnClickListener { - finish() - } - val isGlobal = MMKV.defaultMMKV().decodeBool(BZYConstants.MMKV_KEY_GLOBAL_MODEL, false) - val px: ProxyMode = if (isGlobal) { - ProxyMode.GLOBAL - } else { - ProxyMode.PAC - } - setBackground(px) - - clGlobalMode.setOnClickListener { - MMKV.defaultMMKV().encode(BZYConstants.MMKV_KEY_GLOBAL_MODEL, true) - setBackground(ProxyMode.GLOBAL) - goFinish() - } - cardIntelligentModeSelect.setOnClickListener { - setBackground(ProxyMode.PAC) - MMKV.defaultMMKV().encode(BZYConstants.MMKV_KEY_GLOBAL_MODEL, false) - goFinish() - } - clApplicationMode.setOnClickListener { - if (HomeFragment.clashRunning) { - RxToast.info("请关闭加速后再选择.") - return@setOnClickListener - } - - popupWindow = object : CommonPopupWindow( - this, - R.layout.applicationmode_popwindow_item, - 500, - LayoutParams.WRAP_CONTENT - ) { - override fun initView() { - - val view = getContentView() - val allApp = view.findViewById(R.id.LLAll) - val tvAllApp = view.findViewById(R.id.TVAllApp) - - val chooseApp = view.findViewById(R.id.LLChoose) - val tvChooseApp = view.findViewById(R.id.TVChoose) - - val noChooseApp = view.findViewById(R.id.LLNoChoose) - val tvNoChooseApp = view.findViewById(R.id.TVNoChoose) - - val applicationModeStr = - MMKV.defaultMMKV().decodeString(BZYConstants.applicationMode) - if (applicationModeStr.isNullOrEmpty()) { - allApp.setBackgroundResource(R.color.color_clash) - tvAllApp.setTextColor(resources.getColor(R.color.white)) - } else if (applicationModeStr == "AllApp") { - allApp.setBackgroundResource(R.color.color_clash) - tvAllApp.setTextColor(resources.getColor(R.color.white)) - } else if (applicationModeStr == "ChooseApp") { - chooseApp.setBackgroundResource(R.color.color_clash) - tvChooseApp.setTextColor(resources.getColor(R.color.white)) - } else if (applicationModeStr == "noChooseApp") { - noChooseApp.setBackgroundResource(R.color.color_clash) - tvNoChooseApp.setTextColor(resources.getColor(R.color.white)) - } - allApp.setOnClickListener { - serStore.accessControlMode = AccessControlMode.AcceptAll - MMKV.defaultMMKV().encode(BZYConstants.applicationMode, "AllApp") - tbApplicationMode.setText(R.string.allow_all_apps) - popupWindow.dismiss() - } - chooseApp.setOnClickListener { - serStore.accessControlMode = AccessControlMode.AcceptSelected - MMKV.defaultMMKV().encode(BZYConstants.applicationMode, "ChooseApp") - tbApplicationMode.setText(R.string.allow_selected_apps) - popupWindow.dismiss() - } - noChooseApp.setOnClickListener { - serStore.accessControlMode = AccessControlMode.DenySelected - MMKV.defaultMMKV().encode(BZYConstants.applicationMode, "noChooseApp") - tbApplicationMode.setText(R.string.deny_selected_apps) - popupWindow.dismiss() - } - } - - override fun initEvent() {} - } - layoutGravity = - CommonPopupWindow.LayoutGravity(CommonPopupWindow.LayoutGravity.ALIGN_LEFT or CommonPopupWindow.LayoutGravity.TO_BOTTOM) - (popupWindow as CommonPopupWindow).showBashOfAnchor( - tbApplicationMode, - layoutGravity, - 0, - 0 - ) - } - - clAccessControlApplication.setOnClickListener { - startActivity(Intent(this, InstallApplicationActivity::class.java)) - } - - - val amStr = MMKV.defaultMMKV().decodeString(BZYConstants.applicationMode, "") - if (!amStr.isNullOrEmpty()) { - when (amStr) { - "" -> { - tbApplicationMode.setText(R.string.allow_all_apps) - } - - "AllApp" -> { - tbApplicationMode.setText(R.string.allow_all_apps) - } - - "ChooseApp" -> { - tbApplicationMode.setText(R.string.allow_selected_apps) - } - - "noChooseApp" -> { - tbApplicationMode.setText(R.string.deny_selected_apps) - } - } - } - - } - private fun setBackground(proxyMode: ProxyMode) { - when (proxyMode) { - ProxyMode.PAC -> { - HomeFragment.isGlo = false - aiIntelligentModeSelect.isSelected = true - aiGlobalMode.isSelected = false - sendMode(false) - } - - ProxyMode.GLOBAL -> { - HomeFragment.isGlo = true - aiIntelligentModeSelect.isSelected = false - aiGlobalMode.isSelected = true - sendMode(true) - } - else->{ - - } - } - } - private fun sendMode(type: Boolean) { - val intent = Intent(Intents.ACTION_Glo_Mode) - intent.putExtra("mode", type) - sendBroadcast( - intent.setPackage(this.packageName) - ) - } - enum class ProxyMode { - PAC, GLOBAL, PACKAGE - } - private fun goFinish() { - val intent = Intent() - setResult(Activity.RESULT_OK, intent) - finish() - } -} \ No newline at end of file diff --git a/app/src/main/java/com/yingmao/clash/act/ExpensesRecordActivity.kt b/app/src/main/java/com/yingmao/clash/act/ExpensesRecordActivity.kt index 2ce1d24..0d14bdf 100644 --- a/app/src/main/java/com/yingmao/clash/act/ExpensesRecordActivity.kt +++ b/app/src/main/java/com/yingmao/clash/act/ExpensesRecordActivity.kt @@ -149,18 +149,17 @@ class ExpensesRecordActivity : BaseActivity() { expensesRecordAdapter.loadMoreModule.loadMoreFail() } } + class PageInfo { + var page = 1 + fun nextPage() { + page++ + } + + fun reset() { + page = 1 + } + + val isFirstPage: Boolean + get() = page == 1 + } } - -class PageInfo { - var page = 1 - fun nextPage() { - page++ - } - - fun reset() { - page = 1 - } - - val isFirstPage: Boolean - get() = page == 1 -} \ No newline at end of file diff --git a/app/src/main/java/com/yingmao/clash/act/ExpensesRecordVM.kt b/app/src/main/java/com/yingmao/clash/act/ExpensesRecordVM.kt index aeba095..8a2fddf 100644 --- a/app/src/main/java/com/yingmao/clash/act/ExpensesRecordVM.kt +++ b/app/src/main/java/com/yingmao/clash/act/ExpensesRecordVM.kt @@ -9,7 +9,7 @@ import com.yingmao.clash.net.http.HttpReqType import com.yingmao.clash.net.http.NetService class ExpensesRecordVM: BaseViewMode() { - fun getExpensesRecord(page :PageInfo){ + fun getExpensesRecord(page : ExpensesRecordActivity.PageInfo){ val httpApi = NetService.instances.createHttps(HttpApi::class.java) val username = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_REMEMBER_USERNAME,"")!! val phToken = MMKV.defaultMMKV().decodeString(BZYConstants.MMKV_KEY_PH_TOKEN,"")!! diff --git a/app/src/main/java/com/yingmao/clash/act/LoginActivity.kt b/app/src/main/java/com/yingmao/clash/act/LoginActivity.kt index 7a08dbf..66d3220 100644 --- a/app/src/main/java/com/yingmao/clash/act/LoginActivity.kt +++ b/app/src/main/java/com/yingmao/clash/act/LoginActivity.kt @@ -71,7 +71,6 @@ class LoginActivity : BaseActivity(), View.OnClickListener { companion object { private const val LOGIN_TO_REGISTER_REQUEST_CODE = 1 - const val REGISTER_TO_LOGIN_RESULT_CODE = 2 } override fun onCreate(savedInstanceState: Bundle?) { @@ -79,8 +78,8 @@ class LoginActivity : BaseActivity(), View.OnClickListener { setContentView(R.layout.layout_activity_login) //点击输入框外边隐藏输入法 必须在setContentView之后调用 setupUI(findViewById(android.R.id.content).getChildAt(0)) - loginViewMode = ViewModelProvider(this).get(LoginAtyVM::class.java) - splashAtyVM = ViewModelProvider(this).get(SplashAtyVM::class.java) + loginViewMode = ViewModelProvider(this)[LoginAtyVM::class.java] + splashAtyVM = ViewModelProvider(this)[SplashAtyVM::class.java] observe(this, loginViewMode) initViews() loginViewMode.upgradeVersion() @@ -114,7 +113,6 @@ class LoginActivity : BaseActivity(), View.OnClickListener { override fun httpSuccess(httpStatus: HttpStatus.Success) { super.httpSuccess(httpStatus) if (httpStatus.reqType == HttpReqType.LOGIN) { - //LoginRsp(isPointCard=2, code=1000, data=Data(password=123456, phoneNumber=123456, phToken=1351418999069523968, vpnToken=ve3f/wy8iql72kmt1ptuvguh/stk1frhbxqbd7nvk/y=, userId=080743151296), phLogin=PhLogin(needBuy=false, vpn=, mobile=123456), message=登录成功) val rsp = httpStatus.rsp com.cncat.vpn.common.log.Log.d("HttpReqType.LOGIN rsp==>${rsp}") if (rsp is LoginRsp) { diff --git a/app/src/main/java/com/yingmao/clash/act/MainActivity.kt b/app/src/main/java/com/yingmao/clash/act/MainActivity.kt deleted file mode 100644 index aee5faf..0000000 --- a/app/src/main/java/com/yingmao/clash/act/MainActivity.kt +++ /dev/null @@ -1,499 +0,0 @@ -package com.yingmao.clash.act - -import android.content.BroadcastReceiver -import android.content.Context -import android.content.Intent -import android.content.IntentFilter -import android.os.Build -import android.os.Bundle -import android.text.TextUtils -import android.util.Log -import android.view.View -import android.widget.Button -import androidx.activity.result.contract.ActivityResultContract -import androidx.activity.result.contract.ActivityResultContracts -import androidx.appcompat.app.AppCompatActivity -import androidx.lifecycle.ViewModelProvider -import androidx.lifecycle.lifecycleScope -import com.afollestad.materialdialogs.MaterialDialog -import com.yingmao.clash.R - -import com.google.gson.Gson -import com.google.gson.JsonArray -import com.tencent.mmkv.MMKV -import com.yingmao.clash.act.ChangeNodeActivity.Companion -import com.yingmao.clash.act.NewMainActivity.Companion.newUuid -import com.yingmao.clash.app.MainApplication -import com.yingmao.clash.base.BaseActivity - -import com.cncat.vpn.common.constants.Intents -import com.cncat.vpn.core.Clash -import com.cncat.vpn.core.model.ProviderList -import com.cncat.vpn.core.model.TunnelState -import com.yingmao.clash.conf.BZYConstants -import com.yingmao.clash.conf.Conf - -import com.yingmao.clash.listener.BaseCallBack -import com.yingmao.clash.remote.Remote -import com.cncat.vpn.service.ClashManager -import com.cncat.vpn.service.ProfileManager - -import com.cncat.vpn.service.model.Profile -import com.cncat.vpn.service.remote.IClashManager -import com.cncat.vpn.service.remote.IProfileManager -import com.cncat.vpn.service.remote.wrap -import com.cncat.vpn.service.store.ServiceStore -import com.yingmao.clash.util.ActivityResultLifecycle -import com.yingmao.clash.util.Utils -import com.yingmao.clash.util.startClashService -import com.yingmao.clash.util.stopClashService -import com.yingmao.clash.util.withClash -import com.yingmao.clash.util.withProfile - -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.coroutineScope -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch -import kotlinx.coroutines.selects.select -import kotlinx.coroutines.sync.Semaphore -import kotlinx.coroutines.withContext -import okhttp3.Response -import java.util.* -import java.util.concurrent.atomic.AtomicInteger -import kotlin.collections.HashMap -import kotlin.coroutines.resume -import kotlin.coroutines.suspendCoroutine - -class MainActivity : BaseActivity() { - private val TAG: String = "GG" - - -// private lateinit var mainActVM: MainActVM - private lateinit var username: String - - enum class Event { - ServiceRecreated, - ActivityStart, - ActivityStop, - ClashStop, - ClashStart, - ProfileLoaded, - ProfileChanged, - ProfileUpdateCompleted, - ProfileUpdateFailed, - } - - enum class Request { - ToggleStatus, - OpenProxy, - OpenProfiles, - OpenProviders, - OpenLogs, - OpenSettings, - OpenHelp, - OpenAbout, - } - - - protected val clashRunning: Boolean - get() = Remote.broadcasts.clashRunning - var clash: ClashManager? = null -// private var clashBinder: IClashManager? = null - - var profile: ProfileManager? = null - val reloadLock = Semaphore(10) - private var clashBinder: IClashManager? = null - private var profileBinder: IProfileManager? = null - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.main_act) - username = Utils.getUniqueID(this) -// mainActVM = ViewModelProvider(this)[MainActVM::class.java] -// GlobalScope.launch { - clash = ClashManager(this@MainActivity) - profile = ProfileManager(this@MainActivity) - - clashBinder = clash?.wrap() as IClashManager? - profileBinder = profile?.wrap() as IProfileManager? -// } - - findViewById - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c1a0f59..1abdbc8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -416,4 +416,5 @@ 检测到当前账号在其他设备登录,如非本人操作,请立即修改密码并退出陌生设备。 应用初始化中,请等待1~2秒后重试 启动中 + 一键连 \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 50eb23e..cbafc0d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,13 +62,6 @@ subprojects { applicationId = "com.jsq.wufu" namespace = "com.yingmao.clash" } -// if (isTZ){ -// applicationId = "com.taizi.clash" -// namespace = "com.yingmao.clash" -// } -// minSdk = 21 - //noinspection ExpiredTargetSdkVersion -// targetSdk = 32 minSdk = 21 targetSdk = 34 versionName = "1.0.4.7" @@ -100,7 +93,7 @@ subprojects { } productFlavors { flavorDimensions("feature") - create("6666") { + create("66666") { isDefault = true dimension = flavorDimensionList[0] buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")") @@ -111,7 +104,7 @@ subprojects { buildConfigField("String", "applicationId", "\"com.jsq.wufu\"") buildConfigField("String", "service_url", "\"https://api.yijianlianjsq.com/\"") buildConfigField("boolean", "is_free", "false") - buildConfigField("String", "productId", "\"6666\"") + buildConfigField("String", "productId", "\"66666\"") manifestPlaceholders( mapOf( "APP_NAME" to "@string/wf",