proxy activity

This commit is contained in:
Kr328 committed 2019-11-29 00:19:45 +08:00
1 parent 7765d14588
commit 8466662226
7 files changed
+45 -7

No files matched your search

@@ -8,6 +8,7 @@ import android.widget.TextView
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.github.kr328.clash.R
import com.github.kr328.clash.core.utils.Log
import com.github.kr328.clash.model.ListProxyGroup
class ProxyGroupAdapter(private val context: Context) : RecyclerView.Adapter<ProxyGroupAdapter.Holder>() {
@@ -16,6 +17,7 @@ class ProxyGroupAdapter(private val context: Context) : RecyclerView.Adapter<Pro
class Holder(view: View) : RecyclerView.ViewHolder(view) {
val name: TextView = view.findViewById(R.id.adapter_proxy_group_name)
val list: RecyclerView = view.findViewById(R.id.adapter_proxy_group_list)
val expend: View = view.findViewById(R.id.adapter_proxy_group_expand)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
@@ -37,10 +39,18 @@ class ProxyGroupAdapter(private val context: Context) : RecyclerView.Adapter<Pro
val current = data[position]
holder.name.text = current.name
holder.list.visibility = if (current.hide) View.GONE else View.VISIBLE
Log.i("${current.hide}")
(holder.list.adapter as ProxyAdapter).apply {
proxies = current.proxies
now = current.now
holder.expend.setOnClickListener {
current.hide = !current.hide
this@ProxyGroupAdapter.notifyItemChanged(position)
}
}
}
}
@@ -1,5 +1,5 @@
package com.github.kr328.clash.model
data class ListProxyGroup(val name: String, val type: String, val proxies: List<ListProxy>, var now: ListProxy?) {
data class ListProxyGroup(val name: String, val type: String, val proxies: List<ListProxy>, var now: ListProxy?, var hide: Boolean = false) {
data class ListProxy(val name: String, val type: String, val delay: Long)
}
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14z"/>
</vector>
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M7,2v11h3v9l7,-12h-4l4,-8z"/>
</vector>
@@ -9,18 +9,28 @@
android:paddingTop="12dp">
<TextView
android:padding="2dp"
android:layout_marginStart="2dp"
android:textColor="@color/colorAccent"
android:text="@string/app_name"
android:id="@+id/adapter_proxy_group_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content" />
<View
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginEnd="5dp"
android:background="@drawable/ic_url_test"
android:layout_toStartOf="@id/adapter_proxy_group_expand"/>
<View
android:id="@+id/adapter_proxy_group_expand"
android:layout_alignParentEnd="true"
android:layout_width="16dp"
android:layout_height="16dp"
android:background="@drawable/ic_expand"/>
android:layout_marginEnd="5dp"
android:layout_width="22dp"
android:layout_height="22dp"
android:background="@drawable/ic_expand_more"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/adapter_proxy_group_list"
@@ -28,4 +38,4 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
</RelativeLayout>
+1 -1
View File
@@ -6,7 +6,7 @@
<string name="clash_status_started">Running</string>
<string name="clash_status_forwarded_traffic">%s Forwarded</string>
<string name="clash_proxy_manage">Proxies</string>
<string name="clash_proxy_manage">Proxy</string>
<string name="clash_proxy_manage_summary">%d Items</string>
<string name="clash_profiles">Profiles</string>