Add basic transitions/animations

Add animations to all LoadingFragment & a transition from LoadingFragment to MainFragment.
This commit is contained in:
OxygenCobalt 2020-09-04 14:39:51 -06:00
parent e59009a0fa
commit 139cf3c089
8 changed files with 22 additions and 9 deletions

View file

@ -66,6 +66,7 @@ dependencies {
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
// --- THIRD PARTY ---
// Image loading
implementation 'io.coil-kt:coil:0.12.0'

View file

@ -3,6 +3,7 @@ package org.oxycblt.auxio.loading
import android.Manifest
import android.content.pm.PackageManager
import android.os.Bundle
import android.transition.TransitionInflater
import android.util.Log
import android.view.LayoutInflater
import android.view.View
@ -67,8 +68,9 @@ class LoadingFragment : Fragment(R.layout.fragment_loading) {
// Set up the permission launcher, as its disallowed outside of onCreate.
permLauncher =
registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted: Boolean ->
registerForActivityResult(
ActivityResultContracts.RequestPermission()
) { granted: Boolean ->
// If its actually granted, restart the loading process again.
if (granted) {
wipeViews()
@ -92,8 +94,8 @@ class LoadingFragment : Fragment(R.layout.fragment_loading) {
}
// Check for two things:
// - If Auxio needs to show the rationale for getting the READ_EXTERNAL_STORAGE perm
// - If Auxio straight up doesnt have the permission
// - If Auxio needs to show the rationale for getting the READ_EXTERNAL_STORAGE permission.
// - If Auxio straight up doesn't have the READ_EXTERNAL_STORAGE permission.
private fun checkPerms(): Boolean {
return shouldShowRequestPermissionRationale(
Manifest.permission.READ_EXTERNAL_STORAGE
@ -108,6 +110,9 @@ class LoadingFragment : Fragment(R.layout.fragment_loading) {
repoResponse?.let { response ->
if (response == MusicLoaderResponse.DONE) {
val inflater = TransitionInflater.from(requireContext())
exitTransition = inflater.inflateTransition(R.transition.transition_to_main)
this.findNavController().navigate(
LoadingFragmentDirections.actionToMain()
)

View file

@ -34,9 +34,9 @@ class MusicRepository {
loader.albums,
loader.songs,
app.applicationContext.getString(R.string.placeholder_unknown_genre),
app.applicationContext.getString(R.string.placeholder_unknown_artist),
app.applicationContext.getString(R.string.placeholder_unknown_album)
app.getString(R.string.placeholder_unknown_genre),
app.getString(R.string.placeholder_unknown_artist),
app.getString(R.string.placeholder_unknown_album)
)
songs = sorter.songs.toList()

View file

@ -13,6 +13,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="@drawable/ripple"
android:clickable="true"
android:focusable="true"

View file

@ -14,7 +14,8 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<ProgressBar
android:id="@+id/loading_bar"

View file

@ -13,6 +13,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="@drawable/ripple"
android:clickable="true"
android:focusable="true"

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<fade xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime">
</fade>

View file

@ -7,7 +7,7 @@
<string name="error_no_music">No music found.</string>
<string name="error_music_load_failed">Music loading failed.</string>
<string name="error_no_perms">Auxio needs access to your music library.</string>
<string name="error_no_perms">Auxio needs permission to access to your music library.</string>
<string name="label_retry">Retry</string>
<string name="label_grant">Grant</string>