Skip to content

Commit

Permalink
Convert ShadowsocksApplication
Browse files Browse the repository at this point in the history
36/40
  • Loading branch information
HMBSbige committed Nov 5, 2019
1 parent 000e624 commit 8b94271
Show file tree
Hide file tree
Showing 12 changed files with 497 additions and 672 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
Expand All @@ -59,7 +59,6 @@ dependencies {
implementation "com.mikepenz:materialdrawer:6.1.2"
implementation "com.twofortyfouram:android-plugin-api-for-locale:1.0.4"
implementation "dnsjava:dnsjava:2.1.9"
implementation "eu.chainfire:libsuperuser:1.1.0.201907261845"
implementation "me.dm7.barcodescanner:zxing:1.9.13"
implementation "net.glxn.qrgen:android:2.0"
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/github/shadowsocks/BootReceiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.content.*
import android.content.pm.*
import android.os.*
import androidx.core.content.*
import com.github.shadowsocks.ShadowsocksApplication.*
import com.github.shadowsocks.ShadowsocksApplication.Companion.app
import com.github.shadowsocks.utils.*

class BootReceiver : BroadcastReceiver()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class ProfileManagerActivity : AppCompatActivity(), View.OnClickListener, Toolba
val subAutoUpdateEnable = view.findViewById<Switch>(R.id.sw_ssr_sub_autoupdate_enable)

// adding listener
ShadowsocksApplication.app.ssrsubManager.addSSRSubAddedListener(this)
ShadowsocksApplication.app.ssrSubManager.addSSRSubAddedListener(this)

val ssrSubsList = view.findViewById<RecyclerView>(R.id.ssrsubList)
val layoutManager = LinearLayoutManager(this)
Expand Down Expand Up @@ -464,7 +464,7 @@ class ProfileManagerActivity : AppCompatActivity(), View.OnClickListener, Toolba
.setNeutralButton(R.string.ssrsub_add) { _, _ -> showAddSSRSubDialog() }
.setOnCancelListener {
// remove listener
ShadowsocksApplication.app.ssrsubManager.removeSSRSubAddedListener(this@ProfileManagerActivity)
ShadowsocksApplication.app.ssrSubManager.removeSSRSubAddedListener(this@ProfileManagerActivity)
}
.setView(view)
.create()
Expand All @@ -478,7 +478,7 @@ class ProfileManagerActivity : AppCompatActivity(), View.OnClickListener, Toolba
.setTitle(getString(R.string.ssrsub_remove_tip_title))
.setPositiveButton(R.string.ssrsub_remove_tip_direct) { dialog, which ->
ssrSubAdapter.remove(index)
ShadowsocksApplication.app.ssrsubManager.delSSRSub((viewHolder as SSRSubViewHolder).item.id)
ShadowsocksApplication.app.ssrSubManager.delSSRSub((viewHolder as SSRSubViewHolder).item.id)
}
.setNegativeButton(android.R.string.no) { _, _ -> ssrSubAdapter.notifyDataSetChanged() }
.setNeutralButton(R.string.ssrsub_remove_tip_delete) { _, _ ->
Expand All @@ -495,7 +495,7 @@ class ProfileManagerActivity : AppCompatActivity(), View.OnClickListener, Toolba

val index1 = viewHolder.getAdapterPosition()
ssrSubAdapter.remove(index1)
ShadowsocksApplication.app.ssrsubManager.delSSRSub(viewHolder.item.id)
ShadowsocksApplication.app.ssrSubManager.delSSRSub(viewHolder.item.id)

finish()
startActivity(Intent(intent))
Expand All @@ -511,7 +511,7 @@ class ProfileManagerActivity : AppCompatActivity(), View.OnClickListener, Toolba
testProgressDialog = ProgressDialog.show(this@ProfileManagerActivity, getString(R.string.ssrsub_progres), getString(R.string.ssrsub_progres_text), false, true)

// start update sub
val subs = ShadowsocksApplication.app.ssrsubManager.allSSRSubs
val subs = ShadowsocksApplication.app.ssrSubManager.allSSRSubs
SubUpdateHelper.instance()
.updateSub(subs, 0, object : SubUpdateCallback()
{
Expand Down Expand Up @@ -567,7 +567,7 @@ class ProfileManagerActivity : AppCompatActivity(), View.OnClickListener, Toolba
override fun onSuccess(code: Int, response: String)
{
val ssrSub = SubUpdateHelper.parseSSRSub(subUrl, response)
ShadowsocksApplication.app.ssrsubManager.createSSRSub(ssrSub)
ShadowsocksApplication.app.ssrSubManager.createSSRSub(ssrSub)
}

override fun onFailed(code: Int, msg: String)
Expand Down Expand Up @@ -1245,7 +1245,7 @@ class ProfileManagerActivity : AppCompatActivity(), View.OnClickListener, Toolba

private inner class SSRSubAdapter : RecyclerView.Adapter<SSRSubViewHolder>()
{
private var profiles = ShadowsocksApplication.app.ssrsubManager.allSSRSubs.toMutableList()
private var profiles = ShadowsocksApplication.app.ssrSubManager.allSSRSubs.toMutableList()

override fun getItemCount(): Int
{
Expand Down
Loading

0 comments on commit 8b94271

Please sign in to comment.