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

Update #22

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
}
}

dataBinding {
enabled = true
buildFeatures {
viewBinding true
}
}

Expand All @@ -23,12 +23,12 @@ dependencies {
implementation project(':views')
implementation project(':sql')

//noinspection GradleDependency
implementation "ca.allanwang.kau:core:${KAU}"
//noinspection GradleDependency
implementation "ca.allanwang.kau:core-ui:${KAU}"
//noinspection GradleDependency
implementation "ca.allanwang.kau:adapter:${KAU}"
implementation kau.Dependencies.kauCore(KAU)
implementation kau.Dependencies.kauCoreUi(KAU)
implementation kau.Dependencies.kauAdapter(KAU)
implementation kau.Dependencies.kauFastAdapter(KAU)
implementation kau.Dependencies.kauFastAdapterViewBinding(KAU)

implementation kau.Dependencies.coreKtx
implementation "androidx.browser:browser:${Versions.browser}"
implementation "com.squareup.retrofit2:retrofit:${Versions.retrofit}"
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.GitDroid.Light"
android:theme="@style/Theme.GitDroid"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".StartActivity"
android:label="@string/app_name"
android:noHistory="true"
android:theme="@style/Theme.GitDroid.Light.Splash">
android:theme="@style/Theme.GitDroid.Splash.DayNight">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -27,7 +27,7 @@
</activity>
<activity
android:name=".activity.LoginActivity"
android:theme="@style/Theme.GitDroid.Light.Splash"
android:theme="@style/Theme.GitDroid.Splash.DayNight"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand All @@ -44,7 +44,7 @@
<activity android:name=".activity.UserActivity" />
<activity
android:name=".activity.BlobActivity"
android:theme="@style/Theme.GitDroid.Light" />
android:theme="@style/Theme.GitDroid" />
<activity android:name=".activity.RepoActivity" />
<activity android:name=".activity.IssueCommentActivity" />
</application>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/ca/allanwang/gitdroid/GitDroidApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GitDroidApp : Application() {
androidContext(this@GitDroidApp)
modules(
listOf(
Prefs.module(this@GitDroidApp, "${BuildConfig.APPLICATION_ID}.prefs"),
Prefs.module(),
GitDroidData.module(this@GitDroidApp),
GitDb.module(AndroidSqliteDriver(Database.Schema, this@GitDroidApp, "gitdroid.db"))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BlobActivity : ToolbarActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = bindContent(R.layout.view_blob)
binding = ViewBlobBinding.inflate(layoutInflater, contentRoot, true)
supportActionBar?.also {
it.title = fileName
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ca.allanwang.gitdroid.utils.addAppBarView
import ca.allanwang.gitdroid.views.item.IssueCommentVhBinding
import ca.allanwang.gitdroid.views.item.PlaceholderVhBinding
import ca.allanwang.gitdroid.views.item.vh
import ca.allanwang.gitdroid.views.utils.FastBindingAdapter
import ca.allanwang.kau.adapters.SingleFastAdapter
import ca.allanwang.kau.utils.startActivity
import ca.allanwang.kau.utils.string
import ca.allanwang.kau.utils.withSceneTransitionAnimation
Expand All @@ -31,12 +31,12 @@ class IssueCommentActivity : ToolbarActivity() {

private val issueName by stringExtra { name }

private val fastAdapter: FastBindingAdapter =
FastBindingAdapter()
private val fastAdapter: SingleFastAdapter =
SingleFastAdapter()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = bindContent(R.layout.view_refresh_recycler)
binding = ViewRefreshRecyclerBinding.inflate(layoutInflater, contentRoot, true)

binding.recycler.also {
it.adapter = fastAdapter
Expand All @@ -49,7 +49,7 @@ class IssueCommentActivity : ToolbarActivity() {
it.subtitle = repo.nameWithOwner
}
val headerBinding: HeaderIssueCommentBinding =
toolbarBinding.viewToolbar.addAppBarView(R.layout.header_issue_comment)
toolbarBinding.viewToolbar.addAppBarView(HeaderIssueCommentBinding::inflate)
headerBinding.title.text = issueName
binding.refresh.setOnRefreshListener {
fastAdapter.clear()
Expand Down
51 changes: 31 additions & 20 deletions app/src/main/kotlin/ca/allanwang/gitdroid/activity/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import android.content.res.ColorStateList
import android.net.Uri
import android.os.Bundle
import androidx.cardview.widget.CardView
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.core.view.get
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
import androidx.transition.*
import androidx.transition.TransitionSet.ORDERING_SEQUENTIAL
import androidx.transition.TransitionSet.ORDERING_TOGETHER
import androidx.viewbinding.ViewBinding
import ca.allanwang.gitdroid.R
import ca.allanwang.gitdroid.activity.base.BaseActivity
import ca.allanwang.gitdroid.data.GitDroidData
Expand All @@ -27,6 +27,8 @@ import ca.allanwang.gitdroid.utils.Prefs
import ca.allanwang.gitdroid.views.databinding.ViewLoginBinding
import ca.allanwang.gitdroid.views.databinding.ViewLoginContainerBinding
import ca.allanwang.gitdroid.views.databinding.ViewLoginSelectionBinding
import ca.allanwang.gitdroid.views.item.ViewBindingBind
import ca.allanwang.gitdroid.views.item.ViewBindingInflate
import ca.allanwang.kau.utils.resolveColor
import ca.allanwang.kau.utils.snackbar
import ca.allanwang.kau.utils.startActivity
Expand All @@ -43,7 +45,7 @@ class LoginActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
gitState = null
sceneRoot = bindContentView(R.layout.view_login_container)
sceneRoot = bindContentView(ViewLoginContainerBinding::inflate)
showSelectorScene(false)
}

Expand Down Expand Up @@ -122,23 +124,20 @@ class LoginActivity : BaseActivity() {
* ------------------------------------------------------------
*/

private fun <T : ViewDataBinding> currentSubBinding(): T? {
private fun <T : ViewBinding> inflateSubBinding(inflater: ViewBindingInflate<T>): T =
inflater(layoutInflater, sceneRoot.loginContainerScene, false)

private fun <T : ViewBinding> bindSubBinding(binder: ViewBindingBind<T>): T? {
if (sceneRoot.loginContainerScene.childCount == 0) {
return null
}
return DataBindingUtil.getBinding(sceneRoot.loginContainerScene.getChildAt(0))
}

private fun <T : ViewDataBinding> inflateSubBinding(layoutRes: Int): T {
return DataBindingUtil.inflate(
layoutInflater,
layoutRes, sceneRoot.loginContainerScene, false
)
return binder(sceneRoot.loginContainerScene[0])
}

private fun showSelectorScene(animate: Boolean = true) {
loginPasswordPage = false
val view: ViewLoginSelectionBinding = inflateSubBinding(R.layout.view_login_selection)
inflateSubBinding(ViewLoginSelectionBinding::inflate)
val view: ViewLoginSelectionBinding = inflateSubBinding(ViewLoginSelectionBinding::inflate)
view.loginSelectPassword.setOnClickListener {
showPasswordScene()
}
Expand All @@ -147,21 +146,29 @@ class LoginActivity : BaseActivity() {
gitState = request.state
launchUrl(Uri.parse(request.url))
}
val oldView: ViewLoginBinding? = currentSubBinding()
val oldView: ViewLoginBinding? = bindSubBinding(ViewLoginBinding::bind)
val scene = Scene(sceneRoot.loginContainerScene, view.root)
val transition = if (animate) selectorSceneTransition(oldView, view) else null
TransitionManager.go(scene, transition)
}

private fun selectorSceneTransition(oldView: ViewLoginBinding?, view: ViewLoginSelectionBinding): Transition =
private fun selectorSceneTransition(
oldView: ViewLoginBinding?,
view: ViewLoginSelectionBinding
): Transition =
transitionSet {
val fosi = FastOutSlowInInterpolator()
add(Fade(Visibility.MODE_IN), R.id.login_select_oauth) {
duration = 200L
startDelay = 300L
}
add(TransitionSet()) {
add(Fade(Visibility.MODE_OUT), R.id.login_user, R.id.login_password, R.id.login_send) {
add(
Fade(Visibility.MODE_OUT),
R.id.login_user,
R.id.login_password,
R.id.login_send
) {
duration = 100L
}
add(TransitionSet()) {
Expand All @@ -177,7 +184,8 @@ class LoginActivity : BaseActivity() {
startColor = cardColor,
endColor = accentColor,
setter = { v, c ->
(v as? MaterialButton)?.backgroundTintList = ColorStateList.valueOf(c)
(v as? MaterialButton)?.backgroundTintList =
ColorStateList.valueOf(c)
}),
R.id.login_select_password
) {
Expand Down Expand Up @@ -211,17 +219,20 @@ class LoginActivity : BaseActivity() {

private fun showPasswordScene(animate: Boolean = true) {
loginPasswordPage = true
val view: ViewLoginBinding = inflateSubBinding(R.layout.view_login)
val view: ViewLoginBinding = inflateSubBinding(ViewLoginBinding::inflate)
view.loginSend.setOnClickListener {
showSelectorScene()
}
val oldView: ViewLoginSelectionBinding? = currentSubBinding()
val oldView: ViewLoginSelectionBinding? = bindSubBinding(ViewLoginSelectionBinding::bind)
val scene = Scene(sceneRoot.loginContainerScene, view.root)
val transition = if (animate) passwordSceneTransition(oldView, view) else null
TransitionManager.go(scene, transition)
}

private fun passwordSceneTransition(oldView: ViewLoginSelectionBinding?, view: ViewLoginBinding): Transition =
private fun passwordSceneTransition(
oldView: ViewLoginSelectionBinding?,
view: ViewLoginBinding
): Transition =
transitionSet {
val fosi = FastOutSlowInInterpolator()
add(Fade(Visibility.MODE_OUT), R.id.login_select_oauth) {
Expand Down
Loading