Add basic transitions/animations
Add animations to all LoadingFragment & a transition from LoadingFragment to MainFragment.
This commit is contained in:
parent
e59009a0fa
commit
139cf3c089
8 changed files with 22 additions and 9 deletions
|
@ -66,6 +66,7 @@ dependencies {
|
||||||
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
|
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
|
||||||
|
|
||||||
// --- THIRD PARTY ---
|
// --- THIRD PARTY ---
|
||||||
|
|
||||||
// Image loading
|
// Image loading
|
||||||
implementation 'io.coil-kt:coil:0.12.0'
|
implementation 'io.coil-kt:coil:0.12.0'
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.oxycblt.auxio.loading
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.transition.TransitionInflater
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
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.
|
// Set up the permission launcher, as its disallowed outside of onCreate.
|
||||||
permLauncher =
|
permLauncher =
|
||||||
registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted: Boolean ->
|
registerForActivityResult(
|
||||||
|
ActivityResultContracts.RequestPermission()
|
||||||
|
) { granted: Boolean ->
|
||||||
// If its actually granted, restart the loading process again.
|
// If its actually granted, restart the loading process again.
|
||||||
if (granted) {
|
if (granted) {
|
||||||
wipeViews()
|
wipeViews()
|
||||||
|
@ -92,8 +94,8 @@ class LoadingFragment : Fragment(R.layout.fragment_loading) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for two things:
|
// Check for two things:
|
||||||
// - If Auxio needs to show the rationale for getting the READ_EXTERNAL_STORAGE perm
|
// - If Auxio needs to show the rationale for getting the READ_EXTERNAL_STORAGE permission.
|
||||||
// - If Auxio straight up doesnt have the permission
|
// - If Auxio straight up doesn't have the READ_EXTERNAL_STORAGE permission.
|
||||||
private fun checkPerms(): Boolean {
|
private fun checkPerms(): Boolean {
|
||||||
return shouldShowRequestPermissionRationale(
|
return shouldShowRequestPermissionRationale(
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||||
|
@ -108,6 +110,9 @@ class LoadingFragment : Fragment(R.layout.fragment_loading) {
|
||||||
repoResponse?.let { response ->
|
repoResponse?.let { response ->
|
||||||
|
|
||||||
if (response == MusicLoaderResponse.DONE) {
|
if (response == MusicLoaderResponse.DONE) {
|
||||||
|
val inflater = TransitionInflater.from(requireContext())
|
||||||
|
exitTransition = inflater.inflateTransition(R.transition.transition_to_main)
|
||||||
|
|
||||||
this.findNavController().navigate(
|
this.findNavController().navigate(
|
||||||
LoadingFragmentDirections.actionToMain()
|
LoadingFragmentDirections.actionToMain()
|
||||||
)
|
)
|
||||||
|
|
|
@ -34,9 +34,9 @@ class MusicRepository {
|
||||||
loader.albums,
|
loader.albums,
|
||||||
loader.songs,
|
loader.songs,
|
||||||
|
|
||||||
app.applicationContext.getString(R.string.placeholder_unknown_genre),
|
app.getString(R.string.placeholder_unknown_genre),
|
||||||
app.applicationContext.getString(R.string.placeholder_unknown_artist),
|
app.getString(R.string.placeholder_unknown_artist),
|
||||||
app.applicationContext.getString(R.string.placeholder_unknown_album)
|
app.getString(R.string.placeholder_unknown_album)
|
||||||
)
|
)
|
||||||
|
|
||||||
songs = sorter.songs.toList()
|
songs = sorter.songs.toList()
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
android:background="@drawable/ripple"
|
android:background="@drawable/ripple"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:animateLayoutChanges="true">
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/loading_bar"
|
android:id="@+id/loading_bar"
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
android:background="@drawable/ripple"
|
android:background="@drawable/ripple"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
|
|
4
app/src/main/res/transition/transition_to_main.xml
Normal file
4
app/src/main/res/transition/transition_to_main.xml
Normal 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>
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<string name="error_no_music">No music found.</string>
|
<string name="error_no_music">No music found.</string>
|
||||||
<string name="error_music_load_failed">Music loading failed.</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_retry">Retry</string>
|
||||||
<string name="label_grant">Grant</string>
|
<string name="label_grant">Grant</string>
|
||||||
|
|
Loading…
Reference in a new issue