add auto activity name detect

This commit is contained in:
Kr328 committed 2020-03-19 15:16:50 +08:00
1 parent 4bc40e0663
commit ea8e270df6
15 files changed
+11 -45

No files matched your search

@@ -65,7 +65,4 @@ class ApkBrokenActivity : BaseActivity() {
override fun shouldDisplayHomeAsUpEnabled(): Boolean {
return false
}
override val activityLabel: CharSequence
get() = getText(R.string.application_broken)
}
@@ -109,6 +109,8 @@ abstract class BaseActivity : AppCompatActivity(), CoroutineScope by MainScope()
resetDarkMode()
resetLightNavigationBar()
title = resolveActivityTitle()
}
override fun onStart() {
@@ -148,10 +150,6 @@ abstract class BaseActivity : AppCompatActivity(), CoroutineScope by MainScope()
supportActionBar?.apply {
setDisplayHomeAsUpEnabled(shouldDisplayHomeAsUpEnabled())
activityLabel?.let {
title = it
}
}
}
@@ -159,8 +157,6 @@ abstract class BaseActivity : AppCompatActivity(), CoroutineScope by MainScope()
return true
}
abstract val activityLabel: CharSequence?
override fun onSupportNavigateUp(): Boolean {
this.onBackPressed()
@@ -213,4 +209,13 @@ abstract class BaseActivity : AppCompatActivity(), CoroutineScope by MainScope()
window.navigationBarColor = getColor(R.color.backgroundColor)
}
private fun resolveActivityTitle(): CharSequence {
val info = packageManager.getActivityInfo(componentName, 0)
if ( info.labelRes <= 0 )
return title
return resources.getText(info.labelRes)
}
}
@@ -66,9 +66,6 @@ class CreateProfileActivity : BaseActivity() {
}
}
override val activityLabel: CharSequence
get() = getText(R.string.create_profile)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK)
return finish()
@@ -63,9 +63,6 @@ class LogViewerActivity : BaseActivity() {
}
}
override val activityLabel: CharSequence
get() = getText(R.string.log_viewer)
override fun onStart() {
super.onStart()
@@ -92,9 +92,6 @@ class LogsActivity : BaseActivity() {
refreshList()
}
override val activityLabel: CharSequence
get() = getText(R.string.logs)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
@@ -84,8 +84,6 @@ class MainActivity : BaseActivity() {
stopBandwidthPolling()
}
override val activityLabel: CharSequence? = null
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK)
@@ -15,8 +15,6 @@ import kotlinx.coroutines.channels.Channel
import kotlin.streams.toList
class PackagesActivity : BaseActivity() {
override val activityLabel: CharSequence?
get() = getText(R.string.access_control_packages)
private val activity: PackagesActivity
get() = this
private val adapter: PackagesAdapter?
@@ -178,8 +178,6 @@ class ProfileEditActivity : BaseActivity() {
}
}
override val activityLabel: CharSequence? = null
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == REQUEST_CODE) {
if (resultCode != Activity.RESULT_OK || data == null)
@@ -62,9 +62,6 @@ class ProfilesActivity : BaseActivity(), ProfileAdapter.Callback, ProfilesMenu.C
backgroundJob = null
}
override val activityLabel: CharSequence?
get() = getText(R.string.profiles)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == EDITOR_REQUEST_CODE) {
launch {
@@ -161,9 +161,6 @@ class ProxiesActivity : BaseActivity(), ScrollBinding.Callback {
return true
}
override val activityLabel: CharSequence?
get() = getText(R.string.proxy)
override suspend fun onClashStopped(reason: String?) {
finish()
}
@@ -43,7 +43,4 @@ class SettingsActivity : BaseActivity() {
}
}
}
override val activityLabel: CharSequence?
get() = getText(R.string.settings)
}
@@ -14,7 +14,4 @@ class SettingsBehaviorActivity : BaseActivity() {
.replace(R.id.fragment, BehaviorFragment())
.commit()
}
override val activityLabel: CharSequence?
get() = getText(R.string.behavior)
}
@@ -14,7 +14,4 @@ class SettingsInterfaceActivity : BaseActivity() {
.replace(R.id.fragment, InterfaceFragment())
.commit()
}
override val activityLabel: CharSequence?
get() = getText(R.string.interface_)
}
@@ -26,7 +26,4 @@ class SettingsNetworkActivity : BaseActivity() {
override suspend fun onClashStarted() {
recreate()
}
override val activityLabel: CharSequence?
get() = getText(R.string.network)
}
@@ -10,9 +10,6 @@ import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.activity_support.*
class SupportActivity : BaseActivity() {
override val activityLabel: CharSequence?
get() = getText(R.string.support)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)