Commit d23be09c authored by Mygod's avatar Mygod

Add snackbars everywhere

parent 4a97ff1d
...@@ -34,6 +34,7 @@ import android.content.pm.PackageManager ...@@ -34,6 +34,7 @@ import android.content.pm.PackageManager
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.support.design.widget.Snackbar
import android.support.v4.app.TaskStackBuilder import android.support.v4.app.TaskStackBuilder
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.DefaultItemAnimator import android.support.v7.widget.DefaultItemAnimator
...@@ -231,14 +232,14 @@ class AppManager : AppCompatActivity(), Toolbar.OnMenuItemClickListener { ...@@ -231,14 +232,14 @@ class AppManager : AppCompatActivity(), Toolbar.OnMenuItemClickListener {
ProfileManager.updateProfile(it) ProfileManager.updateProfile(it)
} }
if (DataStore.directBootAware) DirectBoot.update() if (DataStore.directBootAware) DirectBoot.update()
Toast.makeText(this, R.string.action_apply_all, Toast.LENGTH_SHORT).show() Snackbar.make(appListView, R.string.action_apply_all, Snackbar.LENGTH_LONG).show()
} else Toast.makeText(this, R.string.action_export_err, Toast.LENGTH_SHORT).show() } else Snackbar.make(appListView, R.string.action_export_err, Snackbar.LENGTH_LONG).show()
return true return true
} }
R.id.action_export -> { R.id.action_export -> {
clipboard.primaryClip = ClipData.newPlainText(Key.individual, clipboard.primaryClip = ClipData.newPlainText(Key.individual,
"${DataStore.bypass}\n${DataStore.individual}") "${DataStore.bypass}\n${DataStore.individual}")
Toast.makeText(this, R.string.action_export_msg, Toast.LENGTH_SHORT).show() Snackbar.make(appListView, R.string.action_export_msg, Snackbar.LENGTH_LONG).show()
return true return true
} }
R.id.action_import -> { R.id.action_import -> {
...@@ -251,13 +252,13 @@ class AppManager : AppCompatActivity(), Toolbar.OnMenuItemClickListener { ...@@ -251,13 +252,13 @@ class AppManager : AppCompatActivity(), Toolbar.OnMenuItemClickListener {
bypassSwitch.isChecked = enabled.toBoolean() bypassSwitch.isChecked = enabled.toBoolean()
DataStore.individual = apps DataStore.individual = apps
DataStore.dirty = true DataStore.dirty = true
Toast.makeText(this, R.string.action_import_msg, Toast.LENGTH_SHORT).show() Snackbar.make(appListView, R.string.action_import_msg, Snackbar.LENGTH_LONG).show()
initProxiedApps(apps) initProxiedApps(apps)
reloadApps() reloadApps()
return true return true
} catch (_: IllegalArgumentException) { } } catch (_: IllegalArgumentException) { }
} }
Toast.makeText(this, R.string.action_import_err, Toast.LENGTH_SHORT).show() Snackbar.make(appListView, R.string.action_import_err, Snackbar.LENGTH_LONG).show()
} }
} }
return false return false
......
...@@ -370,7 +370,8 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener { ...@@ -370,7 +370,8 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
val profiles = Profile.findAll(clipboard.primaryClip.getItemAt(0).text).toList() val profiles = Profile.findAll(clipboard.primaryClip.getItemAt(0).text).toList()
if (profiles.isNotEmpty()) { if (profiles.isNotEmpty()) {
profiles.forEach { ProfileManager.createProfile(it) } profiles.forEach { ProfileManager.createProfile(it) }
Toast.makeText(activity, R.string.action_import_msg, Toast.LENGTH_SHORT).show() Snackbar.make(activity!!.findViewById(R.id.snackbar), R.string.action_import_msg,
Snackbar.LENGTH_LONG).show()
return true return true
} }
} catch (exc: Exception) { } catch (exc: Exception) {
...@@ -386,10 +387,10 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener { ...@@ -386,10 +387,10 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
} }
R.id.action_export -> { R.id.action_export -> {
val profiles = ProfileManager.getAllProfiles() val profiles = ProfileManager.getAllProfiles()
if (profiles != null) { Snackbar.make(activity!!.findViewById(R.id.snackbar), if (profiles != null) {
clipboard.primaryClip = ClipData.newPlainText(null, profiles.joinToString("\n")) clipboard.primaryClip = ClipData.newPlainText(null, profiles.joinToString("\n"))
Toast.makeText(activity, R.string.action_export_msg, Toast.LENGTH_SHORT).show() R.string.action_export_msg
} else Toast.makeText(activity, R.string.action_export_err, Toast.LENGTH_SHORT).show() } else R.string.action_export_err, Snackbar.LENGTH_LONG).show()
true true
} }
else -> false else -> false
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent" android:layout_width="match_parent"
android:layout_height="fill_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:duplicateParentState="false"> android:duplicateParentState="false">
<include layout="@layout/toolbar_light_dark"/> <include layout="@layout/toolbar_light_dark"/>
...@@ -41,28 +41,36 @@ ...@@ -41,28 +41,36 @@
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
android:textSize="18sp"/> android:textSize="18sp"/>
</LinearLayout> </LinearLayout>
<FrameLayout android:layout_width="fill_parent" <android.support.design.widget.CoordinatorLayout
android:layout_height="0dp" android:id="@+id/snackbar"
android:layout_weight="1"> android:background="@color/material_primary_700"
<ProgressBar android:id="@+id/loading" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="0dp"
android:layout_height="wrap_content" android:layout_weight="1">
android:layout_gravity="center" /> <FrameLayout android:layout_width="match_parent"
<android.support.v7.widget.RecyclerView android:layout_height="match_parent"
android:layout_width="fill_parent" android:background="?android:attr/windowBackground"
android:layout_height="fill_parent" app:layout_behavior="com.github.shadowsocks.widget.ShrinkUpwardBehavior">
android:id="@+id/list" <ProgressBar android:id="@+id/loading"
tools:listitem="@layout/layout_apps_item"/> android:layout_width="wrap_content"
<com.futuremind.recyclerviewfastscroll.FastScroller android:layout_height="wrap_content"
android:id="@+id/fastscroller" android:layout_gravity="center" />
android:orientation="vertical" <android.support.v7.widget.RecyclerView
android:layout_width="wrap_content" android:layout_width="fill_parent"
android:layout_height="match_parent" android:layout_height="fill_parent"
android:layout_gravity="end" android:id="@+id/list"
android:layout_marginTop="8dp" tools:listitem="@layout/layout_apps_item"/>
android:layout_marginBottom="8dp" <com.futuremind.recyclerviewfastscroll.FastScroller
app:fastscroll__handleColor="@color/material_primary_500" android:id="@+id/fastscroller"
app:fastscroll__bubbleColor="@color/material_primary_500" android:orientation="vertical"
app:fastscroll__bubbleTextAppearance="@style/StyledScrollerTextAppearance"/> android:layout_width="wrap_content"
</FrameLayout> android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:fastscroll__handleColor="@color/material_primary_500"
app:fastscroll__bubbleColor="@color/material_primary_500"
app:fastscroll__bubbleTextAppearance="@style/StyledScrollerTextAppearance"/>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout> </LinearLayout>
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