|
@@ -1,15 +1,23 @@
|
|
|
package com.github.kr328.clash
|
|
package com.github.kr328.clash
|
|
|
|
|
|
|
|
|
|
+import android.content.BroadcastReceiver
|
|
|
|
|
+import android.content.Context
|
|
|
|
|
+import android.content.Intent
|
|
|
|
|
+import android.content.IntentFilter
|
|
|
import com.github.kr328.clash.common.util.intent
|
|
import com.github.kr328.clash.common.util.intent
|
|
|
import com.github.kr328.clash.common.util.setUUID
|
|
import com.github.kr328.clash.common.util.setUUID
|
|
|
import com.github.kr328.clash.common.util.ticker
|
|
import com.github.kr328.clash.common.util.ticker
|
|
|
import com.github.kr328.clash.design.ProfilesDesign
|
|
import com.github.kr328.clash.design.ProfilesDesign
|
|
|
|
|
+import com.github.kr328.clash.design.ui.ToastDuration
|
|
|
|
|
+import com.github.kr328.clash.R
|
|
|
import com.github.kr328.clash.service.model.Profile
|
|
import com.github.kr328.clash.service.model.Profile
|
|
|
import com.github.kr328.clash.util.withProfile
|
|
import com.github.kr328.clash.util.withProfile
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
import kotlinx.coroutines.isActive
|
|
import kotlinx.coroutines.isActive
|
|
|
|
|
+import kotlinx.coroutines.launch
|
|
|
import kotlinx.coroutines.selects.select
|
|
import kotlinx.coroutines.selects.select
|
|
|
import kotlinx.coroutines.withContext
|
|
import kotlinx.coroutines.withContext
|
|
|
|
|
+import java.util.*
|
|
|
import java.util.concurrent.TimeUnit
|
|
import java.util.concurrent.TimeUnit
|
|
|
|
|
|
|
|
class ProfilesActivity : BaseActivity<ProfilesDesign>() {
|
|
class ProfilesActivity : BaseActivity<ProfilesDesign>() {
|
|
@@ -83,4 +91,37 @@ class ProfilesActivity : BaseActivity<ProfilesDesign>() {
|
|
|
patchProfiles(queryAll())
|
|
patchProfiles(queryAll())
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ override fun onProfileUpdateCompleted(uuid: UUID?) {
|
|
|
|
|
+ if(uuid == null)
|
|
|
|
|
+ return;
|
|
|
|
|
+ launch {
|
|
|
|
|
+ var name: String? = null;
|
|
|
|
|
+ withProfile {
|
|
|
|
|
+ name = queryByUUID(uuid)?.name
|
|
|
|
|
+ }
|
|
|
|
|
+ design?.showToast(
|
|
|
|
|
+ getString(R.string.toast_profile_updated_complete, name),
|
|
|
|
|
+ ToastDuration.Long
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ override fun onProfileUpdateFailed(uuid: UUID?, reason: String?) {
|
|
|
|
|
+ if(uuid == null)
|
|
|
|
|
+ return;
|
|
|
|
|
+ launch {
|
|
|
|
|
+ var name: String? = null;
|
|
|
|
|
+ withProfile {
|
|
|
|
|
+ name = queryByUUID(uuid)?.name
|
|
|
|
|
+ }
|
|
|
|
|
+ design?.showToast(
|
|
|
|
|
+ getString(R.string.toast_profile_updated_failed, name, reason),
|
|
|
|
|
+ ToastDuration.Long
|
|
|
|
|
+ ){
|
|
|
|
|
+ setAction(R.string.edit) {
|
|
|
|
|
+ startActivity(PropertiesActivity::class.intent.setUUID(uuid))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|