@@ -24,7 +24,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:id="@+id/container">
|
||||
<TextView android:id="@+id/title"
|
||||
<TextView android:id="@android:id/text1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
@@ -54,27 +54,29 @@
|
||||
android:contentDescription="@string/edit"
|
||||
android:focusable="true"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
<RelativeLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:id="@+id/details">
|
||||
<TextView android:id="@+id/address"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
android:layout_marginTop="4dp">
|
||||
<TextView android:id="@android:id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toStartOf="@+id/traffic"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
<TextView android:id="@+id/traffic"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</com.github.shadowsocks.widget.BoundedCardView>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -142,4 +142,5 @@
|
||||
<string name="plugin_configure">Configure…</string>
|
||||
<string name="plugin_disabled">Disabled</string>
|
||||
<string name="plugin_unknown">Unknown plugin %s</string>
|
||||
<string name="profile_plugin">Plugin: %s</string>
|
||||
</resources>
|
||||
|
||||
@@ -37,11 +37,12 @@ import android.view._
|
||||
import android.widget.{LinearLayout, PopupMenu, TextView, Toast}
|
||||
import com.github.shadowsocks.ShadowsocksApplication.app
|
||||
import com.github.shadowsocks.database.Profile
|
||||
import com.github.shadowsocks.plugin.PluginConfiguration
|
||||
import com.github.shadowsocks.utils._
|
||||
import com.github.shadowsocks.widget.UndoSnackbarManager
|
||||
import com.google.android.gms.ads.{AdRequest, AdSize, NativeExpressAdView}
|
||||
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
|
||||
import scala.util.Random
|
||||
|
||||
object ProfilesFragment {
|
||||
@@ -77,8 +78,8 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
|
||||
|
||||
var item: Profile = _
|
||||
|
||||
private val title = itemView.findViewById(R.id.title).asInstanceOf[TextView]
|
||||
private val address = itemView.findViewById(R.id.address).asInstanceOf[TextView]
|
||||
private val text1 = itemView.findViewById(android.R.id.text1).asInstanceOf[TextView]
|
||||
private val text2 = itemView.findViewById(android.R.id.text2).asInstanceOf[TextView]
|
||||
private val traffic = itemView.findViewById(R.id.traffic).asInstanceOf[TextView]
|
||||
private val edit = itemView.findViewById(R.id.edit)
|
||||
edit.setOnClickListener(_ => startConfig(item.id))
|
||||
@@ -111,10 +112,22 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
|
||||
tx += txTotal
|
||||
rx += rxTotal
|
||||
}
|
||||
title.setText(item.getName)
|
||||
address.setText(if (item.nameIsEmpty) "" else item.formattedAddress)
|
||||
traffic.setText(if (tx <= 0 && rx <= 0) null else getString(R.string.stat_profiles,
|
||||
TrafficMonitor.formatTraffic(tx), TrafficMonitor.formatTraffic(rx)))
|
||||
text1.setText(item.getName)
|
||||
val t2 = new ListBuffer[String]
|
||||
if (!item.nameIsEmpty) t2 += item.formattedAddress
|
||||
new PluginConfiguration(item.plugin).selected match {
|
||||
case "" =>
|
||||
case id => t2 += app.getString(R.string.profile_plugin, id)
|
||||
}
|
||||
if (t2.isEmpty) text2.setVisibility(View.GONE) else {
|
||||
text2.setVisibility(View.VISIBLE)
|
||||
text2.setText(t2.mkString("\n"))
|
||||
}
|
||||
if (tx <= 0 && rx <= 0) traffic.setVisibility(View.GONE) else {
|
||||
traffic.setVisibility(View.VISIBLE)
|
||||
traffic.setText(getString(R.string.stat_profiles,
|
||||
TrafficMonitor.formatTraffic(tx), TrafficMonitor.formatTraffic(rx)))
|
||||
}
|
||||
|
||||
if (item.id == app.profileId) {
|
||||
itemView.setSelected(true)
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.github.shadowsocks.utils.{Commandline, IOUtils}
|
||||
import eu.chainfire.libsuperuser.Shell
|
||||
|
||||
import scala.collection.JavaConversions._
|
||||
import scala.collection.mutable.ListBuffer
|
||||
|
||||
/**
|
||||
* @author Mygod
|
||||
@@ -80,14 +81,14 @@ object PluginManager {
|
||||
IOUtils.deleteRecursively(pluginDir)
|
||||
if (!pluginDir.mkdirs()) throw new FileNotFoundException("Unable to create plugin directory")
|
||||
val pluginDirPath = pluginDir.getAbsolutePath + '/'
|
||||
var list: List[String] = Nil
|
||||
val list = new ListBuffer[String]
|
||||
do {
|
||||
val path = cursor.getString(0)
|
||||
val file = new File(pluginDir, path)
|
||||
assert(file.getAbsolutePath.startsWith(pluginDirPath))
|
||||
autoClose(cr.openInputStream(builder.path(path).build()))(in =>
|
||||
autoClose(new FileOutputStream(file))(out => IOUtils.copy(in, out)))
|
||||
list +:= Commandline.toString(Array("chmod", cursor.getString(1), file.getAbsolutePath))
|
||||
list += Commandline.toString(Array("chmod", cursor.getString(1), file.getAbsolutePath))
|
||||
if (path == id) initialized = true
|
||||
} while (cursor.moveToNext())
|
||||
if (!initialized) entryNotFound()
|
||||
|
||||
Reference in New Issue
Block a user