This commit is contained in:
Mygod
2015-11-23 21:21:47 +08:00
parent ffdde981fb
commit da3690d18c
5 changed files with 46 additions and 15 deletions
@@ -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)
}
}