-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
715 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 0 additions & 114 deletions
114
app/src/main/java/com/jeanbarrossilva/orca/app/OrcaActivity.kt
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/jeanbarrossilva/orca/app/activity/OrcaActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright © 2023-2024 Orca | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If | ||
* not, see https://www.gnu.org/licenses. | ||
*/ | ||
|
||
package com.jeanbarrossilva.orca.app.activity | ||
|
||
import android.os.Bundle | ||
import androidx.constraintlayout.widget.ConstraintSet | ||
import androidx.core.view.WindowCompat | ||
import com.jeanbarrossilva.orca.app.activity.delegate.BottomNavigation | ||
import com.jeanbarrossilva.orca.app.activity.delegate.BottomNavigationViewAvailability | ||
import com.jeanbarrossilva.orca.app.activity.delegate.Injection | ||
import com.jeanbarrossilva.orca.app.databinding.ActivityOrcaBinding | ||
import com.jeanbarrossilva.orca.app.module.core.MainMastodonCoreModule | ||
import com.jeanbarrossilva.orca.core.module.CoreModule | ||
import com.jeanbarrossilva.orca.platform.ui.core.navigation.NavigationActivity | ||
|
||
open class OrcaActivity : | ||
NavigationActivity(), BottomNavigationViewAvailability, Injection, BottomNavigation { | ||
protected open val coreModule: CoreModule = MainMastodonCoreModule | ||
|
||
override var binding: ActivityOrcaBinding? = null | ||
override var constraintSet: ConstraintSet? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
WindowCompat.setDecorFitsSystemWindows(window, false) | ||
bindView(this) | ||
offsetOnChange(this) | ||
setContentView(binding?.root) | ||
inject(this, coreModule) | ||
navigateOnItemSelection(this) | ||
selectDefaultItem() | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
app/src/main/java/com/jeanbarrossilva/orca/app/activity/delegate/Binding.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright © 2024 Orca | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If | ||
* not, see https://www.gnu.org/licenses. | ||
*/ | ||
|
||
package com.jeanbarrossilva.orca.app.activity.delegate | ||
|
||
import androidx.activity.ComponentActivity | ||
import androidx.lifecycle.DefaultLifecycleObserver | ||
import androidx.lifecycle.LifecycleOwner | ||
import com.jeanbarrossilva.orca.app.databinding.ActivityOrcaBinding | ||
|
||
internal interface Binding { | ||
var binding: ActivityOrcaBinding? | ||
|
||
fun bindView(activity: ComponentActivity) { | ||
binding = ActivityOrcaBinding.inflate(activity.layoutInflater) | ||
unbindOnDestroy(activity) | ||
} | ||
|
||
private fun unbindOnDestroy(activity: ComponentActivity) { | ||
activity.lifecycle.addObserver( | ||
object : DefaultLifecycleObserver { | ||
override fun onDestroy(owner: LifecycleOwner) { | ||
binding = null | ||
} | ||
} | ||
) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/jeanbarrossilva/orca/app/activity/delegate/BottomNavigation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright © 2024 Orca | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If | ||
* not, see https://www.gnu.org/licenses. | ||
*/ | ||
|
||
package com.jeanbarrossilva.orca.app.activity.delegate | ||
|
||
import androidx.annotation.IdRes | ||
import androidx.lifecycle.lifecycleScope | ||
import com.jeanbarrossilva.orca.app.R | ||
import com.jeanbarrossilva.orca.app.navigation.BottomDestinationProvider | ||
import com.jeanbarrossilva.orca.platform.ui.core.navigation.NavigationActivity | ||
import kotlinx.coroutines.launch | ||
|
||
internal interface BottomNavigation : Binding { | ||
fun navigateOnItemSelection(activity: NavigationActivity) { | ||
binding?.bottomNavigationView?.setOnItemSelectedListener { | ||
navigate(activity, it.itemId) | ||
true | ||
} | ||
} | ||
|
||
fun selectDefaultItem() { | ||
binding?.bottomNavigationView?.selectedItemId = R.id.feed | ||
} | ||
|
||
private fun navigate(activity: NavigationActivity, @IdRes itemID: Int) { | ||
activity.lifecycleScope.launch { | ||
BottomDestinationProvider.provideAndNavigate(activity.navigator, itemID) | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...n/java/com/jeanbarrossilva/orca/app/activity/delegate/BottomNavigationViewAvailability.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright © 2024 Orca | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If | ||
* not, see https://www.gnu.org/licenses. | ||
*/ | ||
|
||
package com.jeanbarrossilva.orca.app.activity.delegate | ||
|
||
import androidx.activity.ComponentActivity | ||
import androidx.constraintlayout.widget.ConstraintSet | ||
import androidx.lifecycle.DefaultLifecycleObserver | ||
import androidx.lifecycle.LifecycleOwner | ||
import com.jeanbarrossilva.orca.app.R | ||
import com.jeanbarrossilva.orca.platform.autos.reactivity.OnBottomAreaAvailabilityChangeListener | ||
|
||
internal interface BottomNavigationViewAvailability : | ||
OnBottomAreaAvailabilityChangeListener, Binding { | ||
var constraintSet: ConstraintSet? | ||
|
||
override val height | ||
get() = binding?.bottomNavigationView?.height ?: 0 | ||
|
||
override fun getCurrentOffsetY(): Float { | ||
return constraintSet?.getConstraint(R.id.bottom_navigation_view)?.transform?.translationY ?: 0f | ||
} | ||
|
||
override fun onBottomAreaAvailabilityChange(offsetY: Float) { | ||
constraintSet?.apply { | ||
getConstraint(R.id.container).layout.bottomMargin = -offsetY.toInt() | ||
getConstraint(R.id.bottom_navigation_view).transform.translationY = offsetY | ||
applyTo(binding?.root) | ||
} | ||
} | ||
|
||
fun offsetOnChange(activity: ComponentActivity) { | ||
constraintSet = ConstraintSet().apply { clone(binding?.root) } | ||
dereferenceConstraintSetOnDestroy(activity) | ||
} | ||
|
||
private fun dereferenceConstraintSetOnDestroy(activity: ComponentActivity) { | ||
activity.lifecycle.addObserver( | ||
object : DefaultLifecycleObserver { | ||
override fun onDestroy(owner: LifecycleOwner) { | ||
constraintSet = null | ||
} | ||
} | ||
) | ||
} | ||
} |
Oops, something went wrong.