Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanbarrossilva committed Jan 10, 2024
2 parents 490cd93 + 8e2f511 commit dc4dfad
Show file tree
Hide file tree
Showing 57 changed files with 715 additions and 299 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ android {
applicationId = project.namespace
minSdk = libs.versions.android.sdk.min.get().toInt()
targetSdk = libs.versions.android.sdk.target.get().toInt()
versionCode = 2
versionName = "0.1.1"
versionCode = 3
versionName = "v0.2"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.jeanbarrossilva.orca.app

import androidx.test.core.app.launchActivity
import com.jeanbarrossilva.orca.app.activity.OrcaActivity
import com.jeanbarrossilva.orca.core.mastodon.auth.authorization.MastodonAuthorizationActivity
import com.jeanbarrossilva.orca.ext.intents.intendStartingOf
import org.junit.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

package com.jeanbarrossilva.orca.app.demo

import com.jeanbarrossilva.orca.app.OrcaActivity
import com.jeanbarrossilva.orca.app.activity.OrcaActivity
import com.jeanbarrossilva.orca.app.demo.module.core.DemoCoreModule

internal open class DemoOrcaActivity : OrcaActivity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package com.jeanbarrossilva.orca.app.demo.module.core
import com.jeanbarrossilva.orca.core.instance.InstanceProvider
import com.jeanbarrossilva.orca.core.module.CoreModule
import com.jeanbarrossilva.orca.core.sample.feed.profile.post.content.SampleTermMuter
import com.jeanbarrossilva.orca.std.injector.module.injection.injectionOf

internal object DemoCoreModule :
CoreModule(
{ InstanceProvider.sample },
{ InstanceProvider.sample.provide().authenticationLock },
{ SampleTermMuter() }
injectionOf { InstanceProvider.sample },
injectionOf { InstanceProvider.sample.provide().authenticationLock },
injectionOf { SampleTermMuter() }
)
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.Autos">
<activity
android:name="com.jeanbarrossilva.orca.app.OrcaActivity"
android:name=".activity.OrcaActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
Expand Down
114 changes: 0 additions & 114 deletions app/src/main/java/com/jeanbarrossilva/orca/app/OrcaActivity.kt

This file was deleted.

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()
}
}
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
}
}
)
}
}
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)
}
}
}
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
}
}
)
}
}
Loading

0 comments on commit dc4dfad

Please sign in to comment.