Commit 62e2d636 authored by Max Lv's avatar Max Lv

Avoid overlapping snackbar

parent ed0dba8f
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<include layout="@layout/toolbar_light_dark" /> <include layout="@layout/toolbar_light_dark" />
<android.support.design.widget.CoordinatorLayout
android:id="@+id/snackbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<fragment android:id="@+id/content" <fragment android:id="@+id/content"
class="com.github.shadowsocks.GlobalConfigFragment" class="com.github.shadowsocks.GlobalConfigFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_height="match_parent" android:layout_width="match_parent" android:layout_height="match_parent"
tools:ignore="UnknownIdInLayout" android:clipChildren="false"> tools:ignore="UnknownIdInLayout" android:clipChildren="false">
<FrameLayout android:id="@+id/content" <android.support.design.widget.CoordinatorLayout android:id="@+id/content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/stat"/> android:layout_above="@+id/stat"/>
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<include layout="@layout/toolbar_light_dark" /> <include layout="@layout/toolbar_light_dark" />
<android.support.design.widget.CoordinatorLayout
android:id="@+id/snackbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<fragment android:id="@+id/content" <fragment android:id="@+id/content"
class="com.github.shadowsocks.ProfileConfigFragment" class="com.github.shadowsocks.ProfileConfigFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<include layout="@layout/toolbar_light_dark"/> <include layout="@layout/toolbar_light_dark"/>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/snackbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/profilesList" android:id="@+id/profilesList"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -46,7 +46,7 @@ class GlobalConfigFragment extends PreferenceFragment { ...@@ -46,7 +46,7 @@ class GlobalConfigFragment extends PreferenceFragment {
val value = v.asInstanceOf[Boolean] val value = v.asInstanceOf[Boolean]
val result = TcpFastOpen.enabled(value) val result = TcpFastOpen.enabled(value)
if (result != null && result != "Success.") if (result != null && result != "Success.")
Snackbar.make(getActivity.findViewById(android.R.id.content), result, Snackbar.LENGTH_LONG).show() Snackbar.make(getActivity.findViewById(R.id.snackbar), result, Snackbar.LENGTH_LONG).show()
value == TcpFastOpen.sendEnabled value == TcpFastOpen.sendEnabled
}) })
if (!TcpFastOpen.supported) { if (!TcpFastOpen.supported) {
......
...@@ -105,7 +105,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe ...@@ -105,7 +105,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
fab.setEnabled(true) fab.setEnabled(true)
changeSwitch(checked = false) changeSwitch(checked = false)
if (m != null) { if (m != null) {
val snackbar = Snackbar.make(findViewById(android.R.id.content), val snackbar = Snackbar.make(findViewById(R.id.snackbar),
getString(R.string.vpn_error).formatLocal(Locale.ENGLISH, m), Snackbar.LENGTH_LONG) getString(R.string.vpn_error).formatLocal(Locale.ENGLISH, m), Snackbar.LENGTH_LONG)
if (m == getString(R.string.nat_no_root)) addDisableNatToSnackbar(snackbar) if (m == getString(R.string.nat_no_root)) addDisableNatToSnackbar(snackbar)
snackbar.show() snackbar.show()
...@@ -143,7 +143,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe ...@@ -143,7 +143,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
if (fab != null) fab.setEnabled(true) if (fab != null) fab.setEnabled(true)
updateState() updateState()
if (Build.VERSION.SDK_INT >= 21 && app.isNatEnabled) { if (Build.VERSION.SDK_INT >= 21 && app.isNatEnabled) {
val snackbar = Snackbar.make(findViewById(android.R.id.content), R.string.nat_deprecated, Snackbar.LENGTH_LONG) val snackbar = Snackbar.make(findViewById(R.id.snackbar), R.string.nat_deprecated, Snackbar.LENGTH_LONG)
addDisableNatToSnackbar(snackbar) addDisableNatToSnackbar(snackbar)
snackbar.show() snackbar.show()
} }
...@@ -276,7 +276,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe ...@@ -276,7 +276,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
synchronized(if (serviceStarted && testCount == id && app.isVpnEnabled) handler.post(() => synchronized(if (serviceStarted && testCount == id && app.isVpnEnabled) handler.post(() =>
if (success) statusText.setText(result) else { if (success) statusText.setText(result) else {
statusText.setText(R.string.connection_test_fail) statusText.setText(R.string.connection_test_fail)
Snackbar.make(findViewById(android.R.id.content), result, Snackbar.LENGTH_LONG).show() Snackbar.make(findViewById(R.id.snackbar), result, Snackbar.LENGTH_LONG).show()
})) }))
} }
} }
......
...@@ -252,7 +252,7 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic ...@@ -252,7 +252,7 @@ final class ProfilesFragment extends ToolbarFragment with Toolbar.OnMenuItemClic
layoutManager.scrollToPosition(profilesAdapter.profiles.zipWithIndex.collectFirst { layoutManager.scrollToPosition(profilesAdapter.profiles.zipWithIndex.collectFirst {
case (profile, i) if profile.id == app.profileId => i case (profile, i) if profile.id == app.profileId => i
}.getOrElse(-1)) }.getOrElse(-1))
undoManager = new UndoSnackbarManager[Profile](profilesList, profilesAdapter.undo, profilesAdapter.commit) undoManager = new UndoSnackbarManager[Profile](view.findViewById(R.id.snackbar), profilesAdapter.undo, profilesAdapter.commit)
new ItemTouchHelper(new SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, new ItemTouchHelper(new SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN,
ItemTouchHelper.START | ItemTouchHelper.END) { ItemTouchHelper.START | ItemTouchHelper.END) {
def onSwiped(viewHolder: ViewHolder, direction: Int) { def onSwiped(viewHolder: ViewHolder, direction: Int) {
......
...@@ -22,6 +22,7 @@ package com.github.shadowsocks.widget ...@@ -22,6 +22,7 @@ package com.github.shadowsocks.widget
import android.support.design.widget.Snackbar import android.support.design.widget.Snackbar
import android.view.View import android.view.View
import com.github.shadowsocks.R import com.github.shadowsocks.R
import scala.collection.mutable.ArrayBuffer import scala.collection.mutable.ArrayBuffer
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment