Improve: Cleanup code

This commit is contained in:
zt515 2017-08-24 23:32:04 +08:00
parent 257427657c
commit bffb7f1dd4
11 changed files with 26 additions and 31 deletions

View File

@ -16,7 +16,7 @@ class CrashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.ui_crash)
setSupportActionBar(findViewById<Toolbar>(R.id.crash_toolbar))
setSupportActionBar(findViewById(R.id.crash_toolbar))
(findViewById<TextView>(R.id.crash_model)).text = getString(R.string.crash_model, collectModelInfo())
(findViewById<TextView>(R.id.crash_app_version)).text = getString(R.string.crash_app, collectAppInfo())
@ -36,7 +36,7 @@ class CrashActivity : AppCompatActivity() {
return "are.you.kidding.me.NoExceptionFoundException: This is a bug, please contact developers!"
}
fun collectAppInfo(): String {
private fun collectAppInfo(): String {
val pm = packageManager
val info = pm.getPackageInfo(packageName, 0)
return "${info.versionName} (${info.versionCode})"

View File

@ -35,10 +35,10 @@ class ColorSchemeActivity : BaseCustomizeActivity() {
.build()
var changed = false
lateinit var editingColorScheme: NeoColorScheme
private lateinit var editingColorScheme: NeoColorScheme
lateinit var adapter: ColorItemAdapter
val colorSchemeComponent = ComponentManager.getComponent<ColorSchemeComponent>()
private val colorSchemeComponent = ComponentManager.getComponent<ColorSchemeComponent>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

View File

@ -58,8 +58,8 @@ class PackageManagerActivity : AppCompatActivity(), SearchView.OnQueryTextListen
setSupportActionBar(toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
progressBar = findViewById<ProgressBar>(R.id.package_loading_progress_bar)
recyclerView = findViewById<RecyclerView>(R.id.package_list)
progressBar = findViewById(R.id.package_loading_progress_bar)
recyclerView = findViewById(R.id.package_list)
recyclerView.setHasFixedSize(true)
adapter = PackageAdapter(this, COMPARATOR, object : PackageAdapter.Listener {
override fun onModelClicked(model: PackageModel) {

View File

@ -10,8 +10,8 @@ import io.neoterm.ui.pm.adapter.PackageAdapter
import io.neoterm.ui.pm.model.PackageModel
class PackageViewHolder(private val rootView: View, private val listener: PackageAdapter.Listener) : SortedListAdapter.ViewHolder<PackageModel>(rootView) {
private val packageNameView: TextView = rootView.findViewById<TextView>(R.id.package_item_name)
private val packageDescView: TextView = rootView.findViewById<TextView>(R.id.package_item_desc)
private val packageNameView: TextView = rootView.findViewById(R.id.package_item_name)
private val packageDescView: TextView = rootView.findViewById(R.id.package_item_desc)
override fun performBind(item: PackageModel) {
rootView.setOnClickListener { listener.onModelClicked(item) }

View File

@ -14,7 +14,7 @@ import io.neoterm.utils.PackageUtils
* @author kiva
*/
class SetupActivity : AppCompatActivity() {
var aptUpdated = false
private var aptUpdated = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

View File

@ -6,7 +6,6 @@ import android.net.Uri
import android.os.Bundle
import android.support.v7.app.AlertDialog
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
import android.view.MenuItem
import android.view.View
import android.widget.TextView
@ -26,7 +25,7 @@ class AboutActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.ui_about)
setSupportActionBar(findViewById<Toolbar>(R.id.about_toolbar))
setSupportActionBar(findViewById(R.id.about_toolbar))
supportActionBar?.setDisplayHomeAsUpEnabled(true)
try {
@ -76,10 +75,10 @@ class AboutActivity : AppCompatActivity() {
AlertDialog.Builder(this)
.setTitle(R.string.support_donate_label)
.setMessage(R.string.support_donate_dialog_text)
.setPositiveButton(R.string.support_donate_alipay, {_, _ ->
.setPositiveButton(R.string.support_donate_alipay, { _, _ ->
Donation.donateByAlipay(this, "FKX025062MBLAG6E90RYBC")
})
.setNegativeButton(R.string.support_donate_qq, {_, _ ->
.setNegativeButton(R.string.support_donate_qq, { _, _ ->
Donation.donateByQQ(this)
})
.setNeutralButton(android.R.string.no, null)

View File

@ -10,9 +10,6 @@ import io.neoterm.R
import java.net.URISyntaxException
object Donation {
// 支付宝包名
private val ALIPAY_PACKAGE_NAME = "com.eg.android.AlipayGphone"
// 旧版支付宝二维码通用 Intent Scheme Url 格式
private val INTENT_URL_FORMAT = "intent://platformapi/startapp?saId=10000007&" +
"clientVersion=3.7.0.0718&qrcode=https%3A%2F%2Fqr.alipay.com%2F{payCode}%3F_s" +
@ -33,19 +30,19 @@ object Donation {
}
private fun startIntentUrl(activity: Activity, intentFullUrl: String): Boolean {
try {
return try {
val intent = Intent.parseUri(
intentFullUrl,
Intent.URI_INTENT_SCHEME
)
activity.startActivity(intent)
return true
true
} catch (e: URISyntaxException) {
e.printStackTrace()
return false
false
} catch (e: ActivityNotFoundException) {
e.printStackTrace()
return false
false
}
}
}

View File

@ -13,7 +13,7 @@ class HelpActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.ui_faq)
setSupportActionBar(findViewById<Toolbar>(R.id.faq_toolbar))
setSupportActionBar(findViewById(R.id.faq_toolbar))
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}

View File

@ -331,9 +331,9 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
forEachTab { it.resetStatus() }
}
private fun floatTabUp(tab: TermTab) {
Toast.makeText(this, "In Progress", Toast.LENGTH_SHORT).show()
}
// private fun floatTabUp(tab: TermTab) {
// Toast.makeText(this, "In Progress", Toast.LENGTH_SHORT).show()
// }
private fun forceAddSystemSession() {
if (!tabSwitcher.isSwitcherShown) {
@ -507,9 +507,9 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
return RevealAnimation.Builder().setX(x).setY(y).create()
}
private fun createPeekAnimation(): Animation {
return PeekAnimation.Builder().setX(tabSwitcher.width / 2f).create()
}
// private fun createPeekAnimation(): Animation {
// return PeekAnimation.Builder().setX(tabSwitcher.width / 2f).create()
// }
private fun getNavigationMenuItem(): View? {
val toolbars = tabSwitcher.toolbars

View File

@ -27,7 +27,7 @@ import java.io.File
* @author kiva
*/
class NeoTermRemoteInterface : AppCompatActivity(), ServiceConnection {
var termService: NeoTermService? = null
private var termService: NeoTermService? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -118,7 +118,7 @@ class NeoTermRemoteInterface : AppCompatActivity(), ServiceConnection {
when (extra) {
is ArrayList<*> -> {
(0..extra.size - 1)
(0 until extra.size)
.map { extra[it] }
.takeWhile { it is Uri }
.mapTo(filesToHandle, { File((it as Uri).path).absolutePath })

View File

@ -55,13 +55,12 @@ class TermTabDecorator(val context: NeoTermActivity) : TabSwitcherDecorator() {
colorSchemeManager.applyColorScheme(view, extraKeysView, colorSchemeManager.getCurrentColorScheme())
if (tab is TermTab) {
val termTab = tab
val termData = tab.termData
TerminalUtils.setupTerminalSession(termData.termSession)
// 复用前一次的 TermSessionCallback 和 TermViewClient
termData.initializeViewWith(termTab, view, extraKeysView)
termData.initializeViewWith(tab, view, extraKeysView)
if (termData.termSession != null) {
termData.viewClient?.updateExtraKeys(termData.termSession?.title, true)