Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
KagayamaKaede committed Nov 14, 2015
1 parent 51f728a commit 66e4ae4
Show file tree
Hide file tree
Showing 12 changed files with 447 additions and 496 deletions.
7 changes: 5 additions & 2 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
##1.1.1 Test

+ Reduce RAM usage.
+ Improve crypt operating speed.
+ Reduce RAM usage.
+ Update tun2socks from shadowsocks/tun2socks repo.
+ Add backupagent, this only worked on android6+
+ Clean code, using some Kotlin language.
+ Clean code, convert many code to Kotlin language.
+ Update http\_simple.
+ Update UI.
+ Change plane fly to North-West.
+ ```May be contains many bug, even not work properly```.

##1.1.0 Test
Expand Down
12 changes: 4 additions & 8 deletions app/src/main/java/com/proxy/shadowsocksr/ProxyAppsActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package com.proxy.shadowsocksr

import android.app.AlertDialog
import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.os.Bundle
import android.support.v7.app.ActionBar
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
Expand All @@ -16,6 +12,7 @@ import android.view.View
import com.orhanobut.hawk.Hawk
import com.proxy.shadowsocksr.adapter.AppsAdapter
import com.proxy.shadowsocksr.adapter.items.AppItem
import com.proxy.shadowsocksr.ui.DialogManager

import java.util.ArrayList

Expand Down Expand Up @@ -43,7 +40,7 @@ class ProxyAppsActivity : AppCompatActivity(), AppsAdapter.OnItemClickListener
rvApps!!.setHasFixedSize(true)
appLst = ArrayList<AppItem>()
appsAdapter = AppsAdapter(appLst!!)
appsAdapter!!.setOnItemClickListener(this)
appsAdapter!!.onItemClickListener = this
rvApps!!.adapter = appsAdapter
//rvApps.setClipToPadding(false);
//rvApps.setPadding(0, 0, 0, ScreenUtil.getNavigationBarSize(this).y);
Expand All @@ -66,8 +63,7 @@ class ProxyAppsActivity : AppCompatActivity(), AppsAdapter.OnItemClickListener
override fun onResume()
{
super.onResume()
val ad = AlertDialog.Builder(this).setCancelable(false).setMessage(
"Please wait load list...").show()
DialogManager.instance.showTipDialog(this, R.string.wait_load_list);
//
Thread(object : Runnable
{
Expand Down Expand Up @@ -97,7 +93,7 @@ class ProxyAppsActivity : AppCompatActivity(), AppsAdapter.OnItemClickListener
override fun run()
{
appsAdapter!!.notifyDataSetChanged()
ad.dismiss()
DialogManager.instance.dismissTipDialog()
}
})
}
Expand Down
14 changes: 4 additions & 10 deletions app/src/main/java/com/proxy/shadowsocksr/adapter/AppsAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ import com.proxy.shadowsocksr.adapter.items.AppItem

class AppsAdapter(private val appLst: List<AppItem>) : RecyclerView.Adapter<AppsAdapter.ViewHolder>()
{
private var onItemClickListener: OnItemClickListener? = null
var onItemClickListener: OnItemClickListener? = null

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder
{
val v = LayoutInflater.from(parent.context).inflate(
R.layout.list_app_item, parent, false)
val v = LayoutInflater.from(parent.context).inflate(R.layout.list_app_item, parent, false)
return ViewHolder(v)
}

Expand All @@ -35,7 +34,7 @@ class AppsAdapter(private val appLst: List<AppItem>) : RecyclerView.Adapter<Apps
return appLst.size
}

internal inner class ViewHolder(v: View) : RecyclerView.ViewHolder(v), View.OnClickListener
public inner class ViewHolder(v: View) : RecyclerView.ViewHolder(v), View.OnClickListener
{
var iv: ImageView
var tv: TextView
Expand All @@ -53,8 +52,8 @@ class AppsAdapter(private val appLst: List<AppItem>) : RecyclerView.Adapter<Apps
{
if (onItemClickListener != null)
{
appLst[adapterPosition].checked = !cb.isChecked
cb.isChecked = !cb.isChecked
appLst[adapterPosition].checked = cb.isChecked
onItemClickListener!!.onItemClick(v, adapterPosition)
}
}
Expand All @@ -64,9 +63,4 @@ class AppsAdapter(private val appLst: List<AppItem>) : RecyclerView.Adapter<Apps
{
fun onItemClick(v: View, pos: Int)
}

fun setOnItemClickListener(onItemClickListener: OnItemClickListener)
{
this.onItemClickListener = onItemClickListener
}
}
40 changes: 20 additions & 20 deletions app/src/main/java/com/proxy/shadowsocksr/fragment/PrefFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class PrefFragment : PreferenceFragment(), SharedPreferences.OnSharedPreferenceC
private var prefUdpDNS: CheckBoxPreference? = null
private var prefAuto: CheckBoxPreference? = null

private var pm: PreferenceManager?=null
private var pm: PreferenceManager? = null

override fun onCreate(savedInstanceState: Bundle?)
{
super.onCreate(savedInstanceState)
addPreferencesFromResource(R.xml.pref)
pm=preferenceManager
pm = preferenceManager
//
prefLbl = findPreference("label") as SummaryEditTextPreference
prefSvr = findPreference("server") as SummaryEditTextPreference
Expand Down Expand Up @@ -87,20 +87,20 @@ class PrefFragment : PreferenceFragment(), SharedPreferences.OnSharedPreferenceC
}
}

// override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
// savedInstanceState: Bundle?): View?
// {
// val v = super.onCreateView(inflater, container, savedInstanceState)
//
// if (v != null)
// {
// val lv = v.findViewById(android.R.id.list) as ListView
// ViewCompat.setNestedScrollingEnabled(lv, true)
// lv.clipToPadding = false
// //lv.setPadding(0, 0, 0, ScreenUtil.getNavigationBarSize(getActivity()).y);
// }
// return super.onCreateView(inflater, container, savedInstanceState)
// }
// override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
// savedInstanceState: Bundle?): View?
// {
// val v = super.onCreateView(inflater, container, savedInstanceState)
//
// if (v != null)
// {
// val lv = v.findViewById(android.R.id.list) as ListView
// ViewCompat.setNestedScrollingEnabled(lv, true)
// lv.clipToPadding = false
// //lv.setPadding(0, 0, 0, ScreenUtil.getNavigationBarSize(getActivity()).y);
// }
// return super.onCreateView(inflater, container, savedInstanceState)
// }

override fun onResume()
{
Expand Down Expand Up @@ -197,10 +197,10 @@ class PrefFragment : PreferenceFragment(), SharedPreferences.OnSharedPreferenceC
}

"server" -> ss.server = sp.getString(key, Consts.defaultIP)
"remote_port" -> ss.remotePort = Integer.valueOf(
sp.getString(key, Consts.defaultRemotePort.toString()))!!
"local_port" -> ss.localPort = Integer.valueOf(
sp.getString(key, Consts.defaultLocalPort.toString()))!!
"remote_port" -> ss.remotePort = Integer.valueOf(sp.getString(
key, Consts.defaultRemotePort.toString()))!!
"local_port" -> ss.localPort = Integer.valueOf(sp.getString(
key, Consts.defaultLocalPort.toString()))!!
"crypt_method" -> ss.cryptMethod = sp.getString(key, Consts.defaultCryptMethod)
"password" -> ss.passwd = sp.getString(key, "")
"protocol_type" -> ss.tcpProtocol = sp.getString(key, Consts.defaultTcpProtocol)
Expand Down
Loading

0 comments on commit 66e4ae4

Please sign in to comment.