Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#16: fix incorrect backstack. #23

Merged
merged 1 commit into from
Aug 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 36 additions & 31 deletions app/src/main/java/com/techbeloved/hymnbook/HymnbookActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class HymnbookActivity : AppCompatActivity() {
navController.addOnDestinationChangedListener { _, destination, _ ->
// Hide the bottom navigation in detail view
when (destination.id) {
R.id.detailPagerFragment,
R.id.sheetMusicPagerFragment -> if (binding.bottomNavigationMain.isVisible) {
R.id.detailPagerFragment -> if (binding.bottomNavigationMain.isVisible) {
binding.bottomNavigationMain.visibility = View.INVISIBLE
}
else -> if (!binding.bottomNavigationMain.isVisible) binding.bottomNavigationMain.visibility = View.VISIBLE
else -> if (!binding.bottomNavigationMain.isVisible) binding.bottomNavigationMain.visibility =
View.VISIBLE
}
}

Expand All @@ -73,7 +73,9 @@ class HymnbookActivity : AppCompatActivity() {
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return (navController.currentDestination?.id != item.itemId && item.onNavDestinationSelected(navController))
return (navController.currentDestination?.id != item.itemId && item.onNavDestinationSelected(
navController
))
|| super.onOptionsItemSelected(item)
}

Expand All @@ -82,42 +84,45 @@ class HymnbookActivity : AppCompatActivity() {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
val rxPreferences = RxSharedPreferences.create(sharedPreferences)

val nightModePreference: Preference<Boolean> = rxPreferences.getBoolean(getString(R.string.pref_key_enable_night_mode), false)
val nightModePreference: Preference<Boolean> =
rxPreferences.getBoolean(getString(R.string.pref_key_enable_night_mode), false)
val disposable = nightModePreference.asObservable()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { enable ->

// If already in night mode, do nothing, and otherwise
when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_NO -> {
if (enable) delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_YES
else delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM

}
Configuration.UI_MODE_NIGHT_YES -> {
if (!enable) delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
}
Configuration.UI_MODE_NIGHT_UNDEFINED -> {
if (!enable) delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { enable ->

// If already in night mode, do nothing, and otherwise
when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_NO -> {
if (enable) delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_YES
else delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM

}
Configuration.UI_MODE_NIGHT_YES -> {
if (!enable) delegate.localNightMode =
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
}
Configuration.UI_MODE_NIGHT_UNDEFINED -> {
if (!enable) delegate.localNightMode =
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
}
}
}
disposables.add(disposable)
}

private fun handleDynamicLinks(intent: Intent) {
FirebaseDynamicLinks.getInstance()
.getDynamicLink(intent)
.addOnSuccessListener(this) { pendingDynamicLinkData ->
// Get deep link from result (may be null if no link is found)
val deepLink = pendingDynamicLinkData?.link
if (deepLink != null) {
navController.safeNavigate(deepLink)
}

.getDynamicLink(intent)
.addOnSuccessListener(this) { pendingDynamicLinkData ->
// Get deep link from result (may be null if no link is found)
val deepLink = pendingDynamicLinkData?.link
if (deepLink != null) {
navController.safeNavigate(deepLink)
}
.addOnFailureListener(this) { e -> Timber.w(e, "getDynamicLink:onFailure") }

}
.addOnFailureListener(this) { e -> Timber.w(e, "getDynamicLink:onFailure") }
}

override fun onDestroy() {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

25 changes: 25 additions & 0 deletions app/src/main/res/anim/slide_in_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/res/anim/slide_in_left.xml
**
** Copyright 2007, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="-50%p" android:toXDelta="0"
android:duration="@android:integer/config_shortAnimTime"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@android:integer/config_shortAnimTime" />
</set>
Loading