Skip to content

Commit

Permalink
Fix deprecation of kotlin extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Jan 26, 2021
1 parent 7600853 commit b3f2571
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {
id("com.android.library")
id("org.mozilla.rust-android-gradle.rust-android")
kotlin("android")
kotlin("android.extensions")
kotlin("kapt")
id("kotlin-parcelize")
}

setupCore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import com.github.shadowsocks.database.ProfileManager
import com.github.shadowsocks.plugin.AlertDialogFragment
import com.github.shadowsocks.plugin.Empty
import com.github.shadowsocks.plugin.showAllowingStateLoss
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

class UrlImportActivity : AppCompatActivity() {
@Parcelize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
package com.github.shadowsocks.aidl

import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

@Parcelize
data class TrafficStats(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import com.google.gson.JsonPrimitive
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize
import org.json.JSONArray
import org.json.JSONObject
import timber.log.Timber
Expand Down
2 changes: 1 addition & 1 deletion mobile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
kotlin("android")
kotlin("android.extensions")
id("kotlin-parcelize")
}

setupApp()
Expand Down
26 changes: 16 additions & 10 deletions mobile/src/main/java/com/github/shadowsocks/AppManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ import android.graphics.drawable.Drawable
import android.os.Bundle
import android.util.SparseBooleanArray
import android.view.*
import android.widget.Filter
import android.widget.Filterable
import android.widget.SearchView
import android.widget.*
import androidx.annotation.UiThread
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.core.util.set
import androidx.core.view.ViewCompat
import androidx.lifecycle.lifecycleScope
Expand All @@ -52,8 +51,6 @@ import com.github.shadowsocks.utils.listenForPackageChanges
import com.github.shadowsocks.widget.ListHolderListener
import com.github.shadowsocks.widget.ListListener
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.layout_apps.*
import kotlinx.android.synthetic.main.layout_apps_item.view.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.ensureActive
Expand Down Expand Up @@ -110,14 +107,14 @@ class AppManager : AppCompatActivity() {

fun bind(app: ProxiedApp) {
item = app
itemView.itemicon.setImageDrawable(app.icon)
itemView.title.text = app.name
itemView.desc.text = "${app.packageName} (${app.uid})"
itemView.itemcheck.isChecked = isProxiedApp(app)
itemView.findViewById<ImageView>(R.id.itemicon).setImageDrawable(app.icon)
itemView.findViewById<TextView>(R.id.title).text = app.name
itemView.findViewById<TextView>(R.id.desc).text = "${app.packageName} (${app.uid})"
itemView.findViewById<Switch>(R.id.itemcheck).isChecked = isProxiedApp(app)
}

fun handlePayload(payloads: List<String>) {
if (payloads.contains(SWITCH)) itemView.itemcheck.isChecked = isProxiedApp(item)
if (payloads.contains(SWITCH)) itemView.findViewById<Switch>(R.id.itemcheck).isChecked = isProxiedApp(item)
}

override fun onClick(v: View?) {
Expand Down Expand Up @@ -175,6 +172,11 @@ class AppManager : AppCompatActivity() {
override fun getPopupText(position: Int) = filteredApps[position].name.firstOrNull()?.toString() ?: ""
}

private val loading by lazy { findViewById<View>(R.id.loading) }
private lateinit var toolbar: Toolbar
private lateinit var bypassGroup: RadioGroup
private lateinit var list: RecyclerView
private lateinit var search: SearchView
private val proxiedUids = SparseBooleanArray()
private var loader: Job? = null
private var apps = emptyList<ProxiedApp>()
Expand Down Expand Up @@ -219,6 +221,7 @@ class AppManager : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.layout_apps)
ListHolderListener.setup(this)
toolbar = findViewById(R.id.toolbar)
setSupportActionBar(toolbar)
supportActionBar!!.setDisplayHomeAsUpEnabled(true)

Expand All @@ -227,6 +230,7 @@ class AppManager : AppCompatActivity() {
DataStore.dirty = true
}

bypassGroup = findViewById(R.id.bypassGroup)
bypassGroup.check(if (DataStore.bypass) R.id.btn_bypass else R.id.btn_on)
bypassGroup.setOnCheckedChangeListener { _, checkedId ->
DataStore.dirty = true
Expand All @@ -241,12 +245,14 @@ class AppManager : AppCompatActivity() {
}

initProxiedUids()
list = findViewById(R.id.list)
ViewCompat.setOnApplyWindowInsetsListener(list, ListListener)
list.layoutManager = LinearLayoutManager(this, RecyclerView.VERTICAL, false)
list.itemAnimator = DefaultItemAnimator()
list.adapter = appsAdapter
FastScrollerBuilder(list).useMd2Style().build()

search = findViewById(R.id.search)
search.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?) = false
override fun onQueryTextChange(newText: String?) = true.also { appsAdapter.filter.filter(newText) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ import com.github.shadowsocks.preference.*
import com.github.shadowsocks.utils.*
import com.github.shadowsocks.widget.ListListener
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.parcel.Parcelize
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.parcelize.Parcelize

class ProfileConfigFragment : PreferenceFragmentCompat(),
Preference.OnPreferenceChangeListener, OnPreferenceDataStoreChangeListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import com.github.shadowsocks.widget.ListHolderListener
import com.github.shadowsocks.widget.MainListListener
import com.github.shadowsocks.widget.UndoSnackbarManager
import com.google.android.material.textfield.TextInputLayout
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize
import me.zhanghai.android.fastscroll.FastScrollerBuilder
import timber.log.Timber
import java.net.IDN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import com.github.shadowsocks.widget.ListHolderListener
import com.github.shadowsocks.widget.MainListListener
import com.github.shadowsocks.widget.UndoSnackbarManager
import com.google.android.material.textfield.TextInputLayout
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize
import me.zhanghai.android.fastscroll.FastScrollerBuilder
import java.net.MalformedURLException
import java.net.URL
Expand Down
2 changes: 1 addition & 1 deletion plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id("com.android.library")
id("com.vanniktech.maven.publish")
kotlin("android")
kotlin("android.extensions")
id("kotlin-parcelize")
}

setupCommon()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ package com.github.shadowsocks.plugin
import android.os.Parcelable
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

@Parcelize
class Empty : Parcelable
Expand Down

0 comments on commit b3f2571

Please sign in to comment.