Use an AppBarLayout scrolling RecyclerView Activities to give the user

more screen real estate -- except for EditPlaylistActivity where we
never want to hide the `save` button.
This commit is contained in:
casey langen 2019-02-11 23:48:41 -08:00
parent 7695a5abda
commit d3fdd9ba33
17 changed files with 105 additions and 34 deletions

View File

@ -30,7 +30,8 @@
<activity android:name=".ui.albums.activity.AlbumBrowseActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppThemeNoActionBar" />
<activity android:name=".ui.browse.activity.BrowseActivity"
android:screenOrientation="portrait"
@ -39,7 +40,8 @@
<activity android:name=".ui.category.activity.CategoryBrowseActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppThemeNoActionBar" />
<activity android:name=".ui.settings.activity.SettingsActivity"
android:screenOrientation="portrait"
@ -47,11 +49,13 @@
<activity android:name=".ui.playqueue.activity.PlayQueueActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppThemeNoActionBar" />
<activity android:name=".ui.tracks.activity.TrackListActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppThemeNoActionBar" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
@ -65,7 +69,8 @@
<activity android:name=".ui.tracks.activity.EditPlaylistActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppThemeNoActionBar" />
<activity android:name=".ui.settings.activity.RemoteSettingsActivity"
android:screenOrientation="portrait"
@ -78,12 +83,14 @@
<activity
android:name=".ui.category.activity.AllCategoriesActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppThemeNoActionBar" />
<activity
android:name=".ui.settings.activity.ConnectionsActivity"
android:label="@string/connections_title"
android:windowSoftInputMode="adjustResize" />
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppThemeNoActionBar" />
<service
android:name="io.casey.musikcube.remote.service.system.SystemService"

View File

@ -75,7 +75,7 @@ class MainActivity : BaseActivity() {
prefs = this.getSharedPreferences(Prefs.NAME, Context.MODE_PRIVATE)
setContentView(R.layout.activity_main)
setContentView(R.layout.main_activity)
bindEventListeners()

View File

@ -38,7 +38,7 @@ class ConnectionsActivity : BaseActivity() {
super.onCreate(savedInstanceState)
setResult(Activity.RESULT_CANCELED)
setContentView(R.layout.activity_connections)
setContentView(R.layout.connections_activity)
enableUpNavigation()

View File

@ -32,7 +32,7 @@ class RemoteEqActivity: BaseActivity() {
title = getString(R.string.remote_settings_eq_title)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_remote_eq)
setContentView(R.layout.remote_eq_activity)
this.loadingOverlay = findViewById(R.id.loading_overlay)
this.table = findViewById(R.id.eq_table)
this.revertButton = findViewById(R.id.button_revert)

View File

@ -43,7 +43,7 @@ class RemoteSettingsActivity: BaseActivity() {
title = getString(R.string.remote_settings_title)
setContentView(R.layout.activity_remote_settings)
setContentView(R.layout.remote_settings_activity)
loadingOverlay = findViewById(R.id.loading_overlay)
driverSpinner = findViewById(R.id.output_driver_spinner)
deviceSpinner = findViewById(R.id.output_device_spinner)

View File

@ -56,7 +56,7 @@ class SettingsActivity : BaseActivity() {
component.inject(this)
super.onCreate(savedInstanceState)
prefs = this.getSharedPreferences(Prefs.NAME, Context.MODE_PRIVATE)
setContentView(R.layout.activity_settings)
setContentView(R.layout.settings_activity)
setTitle(R.string.settings_title)
cacheViews()
bindListeners()

View File

@ -63,7 +63,7 @@ class EmptyListView : FrameLayout {
fun update(state: WebSocketState, count: Int) { /* TODO REMOVE ME! */
if (count > 0) {
visibility = View.GONE
visibility = View.INVISIBLE
}
else {
visibility = View.VISIBLE
@ -82,7 +82,7 @@ class EmptyListView : FrameLayout {
fun update(state: IDataProvider.State, count: Int) {
if (count > 0) {
visibility = View.GONE
visibility = View.INVISIBLE
}
else {
visibility = View.VISIBLE
@ -96,7 +96,7 @@ class EmptyListView : FrameLayout {
emptyContainer?.setVisible(!showOfflineContainer)
}
alternateView?.visibility = if (visibility == View.GONE) View.VISIBLE else View.GONE
alternateView?.visibility = if (visibility == View.INVISIBLE) View.VISIBLE else View.INVISIBLE
}
private fun initialize() {

View File

@ -35,7 +35,7 @@ class EditPlaylistActivity: BaseActivity() {
super.onCreate(savedInstanceState)
playlistName = extras.getString(EXTRA_PLAYLIST_NAME, "-")
title = getString(R.string.playlist_edit_activity, playlistName)
setContentView(R.layout.recycler_view_activity)
setContentView(R.layout.edit_playlist_activity)
viewModel = getViewModel()!!
viewModel.attach(data.provider)
val recycler = findViewById<RecyclerView>(R.id.recycler_view)
@ -126,19 +126,18 @@ class EditPlaylistActivity: BaseActivity() {
}
class ConfirmDiscardChangesDialog : BaseDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val editActivity = activity as EditPlaylistActivity
return AlertDialog.Builder(editActivity)
.setTitle(R.string.playlist_edit_save_changes_title)
.setMessage(R.string.playlist_edit_save_changes_message)
.setNegativeButton(R.string.button_discard) { _, _ -> editActivity.finish() }
.setPositiveButton(R.string.button_save) { _, _ -> editActivity.saveAndFinish() }
.create()
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
(activity as EditPlaylistActivity).run {
return AlertDialog.Builder(this)
.setTitle(R.string.playlist_edit_save_changes_title)
.setMessage(R.string.playlist_edit_save_changes_message)
.setNegativeButton(R.string.button_discard) { _, _ -> this.finish() }
.setPositiveButton(R.string.button_save) { _, _ -> this.saveAndFinish() }
.create()
}
companion object {
val TAG = "confirm_discard_playlist_changes"
const val TAG = "confirm_discard_playlist_changes"
fun show(activity: AppCompatActivity) {
dismiss(activity, TAG)

View File

@ -0,0 +1,40 @@
<?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" />
<FrameLayout
android:layout_weight="1"
android:layout_height="0dp"
android:layout_width="match_parent">
<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:fastScrollAutoHide="true"
app:fastScrollAutoHideDelay="1500"
app:fastScrollThumbInactiveColor="@color/color_primary_dark"
app:fastScrollThumbColor="@color/color_accent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<io.casey.musikcube.remote.ui.shared.view.EmptyListView
android:id="@+id/empty_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:visibility="invisible"/>
</FrameLayout>
<FrameLayout
android:id="@+id/transport_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"/>
</LinearLayout>

View File

@ -5,15 +5,18 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
<android.support.design.widget.CoordinatorLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp">
<include layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
@ -25,12 +28,13 @@
android:scaleType="center"
android:elevation="6dp"
android:visibility="gone"
app:layout_anchor="@id/content_container"
app:layout_anchorGravity="bottom|right"
app:backgroundTint="@color/color_primary"
app:fabSize="mini"
app:rippleColor="?colorAccent"/>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
<FrameLayout
android:id="@+id/transport_container"

View File

@ -5,11 +5,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
<android.support.design.widget.CoordinatorLayout
android:layout_weight="1"
android:layout_height="0dp"
android:layout_width="match_parent">
<include layout="@layout/toolbar" />
<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
@ -17,13 +19,15 @@
app:fastScrollAutoHide="true"
app:fastScrollAutoHideDelay="1500"
app:fastScrollThumbInactiveColor="@color/color_primary_dark"
app:fastScrollThumbColor="@color/color_accent" />
app:fastScrollThumbColor="@color/color_accent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<io.casey.musikcube.remote.ui.shared.view.EmptyListView
android:id="@+id/empty_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:visibility="invisible"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
@ -35,11 +39,13 @@
android:scaleType="center"
android:elevation="6dp"
android:visibility="gone"
app:layout_anchor="@id/recycler_view"
app:layout_anchorGravity="bottom|right"
app:backgroundTint="@color/color_primary"
app:fabSize="mini"
app:rippleColor="?colorAccent"/>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
<FrameLayout
android:id="@+id/transport_container"

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways|snap" />
</android.support.design.widget.AppBarLayout>