Fix #441
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<include layout="@layout/toolbar_light_dark" />
|
||||
<android.support.v7.widget.RecyclerView android:id="@+id/profilesList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
<android.support.design.widget.CoordinatorLayout android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
<android.support.v7.widget.RecyclerView android:id="@+id/profilesList"
|
||||
app:layout_behavior="com.github.shadowsocks.widget.AutoPaddingBehavior"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -153,7 +153,7 @@ class ProfileManagerActivity extends AppCompatActivity with OnMenuItemClickListe
|
||||
profilesList.setLayoutManager(new LinearLayoutManager(this))
|
||||
profilesList.setItemAnimator(new DefaultItemAnimator)
|
||||
profilesList.setAdapter(profilesAdapter)
|
||||
removedSnackbar = Snackbar.make(findViewById(android.R.id.content), R.string.removed, Snackbar.LENGTH_LONG)
|
||||
removedSnackbar = Snackbar.make(profilesList, R.string.removed, Snackbar.LENGTH_LONG)
|
||||
.setAction(R.string.undo, ((v: View) => profilesAdapter.undoRemoves): OnClickListener)
|
||||
removedSnackbar.getView.addOnAttachStateChangeListener(new OnAttachStateChangeListener {
|
||||
def onViewDetachedFromWindow(v: View) = profilesAdapter.commitRemoves
|
||||
|
||||
@@ -293,12 +293,6 @@ class Shadowsocks
|
||||
}
|
||||
}
|
||||
|
||||
def isTextEmpty(s: String, msg: String): Boolean = {
|
||||
if (s != null && s.length > 0) return false
|
||||
Snackbar.make(getWindow.getDecorView.findViewById(android.R.id.content), msg, Snackbar.LENGTH_LONG).show
|
||||
true
|
||||
}
|
||||
|
||||
def cancelStart() {
|
||||
clearDialog()
|
||||
changeSwitch(checked = false)
|
||||
@@ -554,7 +548,9 @@ class Shadowsocks
|
||||
|
||||
def checkText(key: String): Boolean = {
|
||||
val text = ShadowsocksApplication.settings.getString(key, "")
|
||||
!isTextEmpty(text, getString(R.string.proxy_empty))
|
||||
if (text != null && text.length > 0) return true
|
||||
Snackbar.make(findViewById(android.R.id.content), getString(R.string.proxy_empty), Snackbar.LENGTH_LONG).show
|
||||
false
|
||||
}
|
||||
|
||||
/** Called when connect button is clicked. */
|
||||
@@ -598,7 +594,7 @@ class Shadowsocks
|
||||
handler.postDelayed(() => fabProgressCircle.hide(), 1000)
|
||||
fab.setEnabled(true)
|
||||
changeSwitch(checked = false)
|
||||
if (m != null) Snackbar.make(getWindow.getDecorView.findViewById(android.R.id.content),
|
||||
if (m != null) Snackbar.make(findViewById(android.R.id.content),
|
||||
getString(R.string.vpn_error).formatLocal(Locale.ENGLISH, m), Snackbar.LENGTH_LONG).show
|
||||
setPreferenceEnabled(enabled = true)
|
||||
case State.STOPPING =>
|
||||
|
||||
@@ -5,9 +5,9 @@ import java.util.Locale
|
||||
import android.content.{DialogInterface, Intent}
|
||||
import android.net.Uri
|
||||
import android.os.{Build, Bundle}
|
||||
import android.preference.{SwitchPreference, Preference, PreferenceFragment}
|
||||
import android.preference.{Preference, PreferenceFragment, SwitchPreference}
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.webkit.{WebViewClient, WebView}
|
||||
import android.webkit.{WebView, WebViewClient}
|
||||
import com.github.shadowsocks.utils.Key
|
||||
|
||||
// TODO: Move related logic here
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.github.shadowsocks.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.support.design.widget.CoordinatorLayout
|
||||
import android.support.design.widget.CoordinatorLayout.Behavior
|
||||
import android.support.design.widget.Snackbar.SnackbarLayout
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
|
||||
/**
|
||||
* @author Mygod
|
||||
*/
|
||||
class AutoPaddingBehavior(context: Context, attrs: AttributeSet) extends Behavior[View] {
|
||||
override def layoutDependsOn(parent: CoordinatorLayout, child: View, dependency: View) =
|
||||
dependency.isInstanceOf[SnackbarLayout]
|
||||
|
||||
override def onDependentViewChanged(parent: CoordinatorLayout, child: View, dependency: View) =
|
||||
dependency match {
|
||||
case sl: SnackbarLayout =>
|
||||
child.setPadding(0, 0, 0, dependency.getHeight)
|
||||
true
|
||||
case _ => super.onDependentViewChanged(parent, child, dependency)
|
||||
}
|
||||
|
||||
override def onDependentViewRemoved(parent: CoordinatorLayout, child: View, dependency: View) =
|
||||
dependency match {
|
||||
case sl: SnackbarLayout => child.setPadding(0, 0, 0, 0)
|
||||
case _ => super.onDependentViewRemoved(parent, child, dependency)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user