Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
Refactoring to more dedicated names with leading "Backdrop-"
Browse files Browse the repository at this point in the history
Updated build files
  • Loading branch information
Str3l0k committed Sep 6, 2019
1 parent d4fc65f commit ccc2e74
Show file tree
Hide file tree
Showing 22 changed files with 235 additions and 193 deletions.
38 changes: 24 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
applicationId "de.si.backdrop"
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"

Expand All @@ -21,6 +21,16 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

kotlinOptions {

}

buildToolsVersion = '29.0.2'
}

dependencies {
Expand All @@ -35,17 +45,17 @@ dependencies {
implementation project(path: ':backdroplibrary')

testImplementation 'junit:junit:4.12'
testImplementation 'androidx.test.espresso:espresso-core:3.1.1'
testImplementation 'androidx.test.espresso:espresso-intents:3.1.1'
testImplementation 'androidx.test.ext:junit:1.1.0'
testImplementation 'androidx.test.ext:junit-ktx:1.1.0'
testImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
testImplementation 'androidx.test.ext:junit:1.1.1'
testImplementation 'androidx.test.ext:junit-ktx:1.1.1'
testImplementation 'org.robolectric:robolectric:4.2.1'
testImplementation 'androidx.test.ext:truth:1.1.0'

androidTestImplementation 'androidx.test:core:1.2.0-beta01'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.1'
testImplementation 'androidx.test.ext:truth:1.2.0'

androidTestImplementation 'androidx.test:core:1.2.1-alpha02'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
}
14 changes: 7 additions & 7 deletions app/src/main/java/de/si/backdrop/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ package de.si.backdrop
import android.os.Bundle
import android.view.View
import android.widget.Button
import de.si.backdrop.children.BaseCardFragment
import de.si.backdrop.children.FullscreenRevealFragment
import de.si.backdrop.children.BaseCardBackdropFragment
import de.si.backdrop.children.FullscreenRevealBackdropFragment
import de.si.backdrop.content.MainMenu
import de.si.backdroplibrary.activity.Activity
import de.si.backdroplibrary.children.CardFragment
import de.si.backdroplibrary.activity.BackdropActivity
import de.si.backdroplibrary.children.CardBackdropFragment
import de.si.kotlinx.globalCenterPoint

class MainActivity : Activity() {
class MainActivity : BackdropActivity() {
private var mainMenu: MainMenu? = null

override val baseCardFragment: CardFragment = BaseCardFragment()
override val baseCardFragment: CardBackdropFragment = BaseCardBackdropFragment()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -28,7 +28,7 @@ class MainActivity : Activity() {
}
R.id.layout_test_content -> {
view.findViewById<Button>(R.id.button_backdrop_content_test).setOnClickListener { button ->
val fragment = FullscreenRevealFragment()
val fragment = FullscreenRevealBackdropFragment()
fragment.revealEpiCenter = button.globalCenterPoint
revealFullscreenFragment(fragment)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import de.si.backdrop.R
import de.si.backdroplibrary.children.CardFragment
import de.si.backdroplibrary.components.ToolbarItem
import de.si.backdroplibrary.children.CardBackdropFragment
import de.si.backdroplibrary.components.BackdropToolbarItem
import kotlin.random.Random

class BaseCardFragment : CardFragment() {
override val toolbarItem: ToolbarItem
get() = ToolbarItem(
class BaseCardBackdropFragment : CardBackdropFragment() {
override val toolbarItem: BackdropToolbarItem
get() = BackdropToolbarItem(
title = "Backdrop",
subtitle = "Demonstration",
primaryAction = R.drawable.ic_add,
Expand All @@ -32,7 +32,7 @@ class BaseCardFragment : CardFragment() {

override fun onPrimaryActionClicked(): Boolean {
changeToolbarItem(
ToolbarItem(
BackdropToolbarItem(
title = "Title ${Random.nextInt(42)}",
primaryAction = toolbarItem.primaryAction,
moreActionEnabled = toolbarItem.moreActionEnabled
Expand All @@ -42,7 +42,7 @@ class BaseCardFragment : CardFragment() {
}

override fun onMoreActionClicked(): Boolean {
addCardFragment(TopCardFragment())
addCardFragment(TopCardBackdropFragment())
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import de.si.backdrop.R
import de.si.backdroplibrary.children.FullscreenFragment
import de.si.backdroplibrary.children.FullscreenBackdropFragment
import kotlinx.android.synthetic.main.fragment_fullscreen.view.*

class FullscreenDialogFragment : FullscreenFragment() {
class FullscreenDialogBackdropFragment : FullscreenBackdropFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_fullscreen, container, false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import de.si.backdrop.R
import de.si.backdroplibrary.children.FullscreenRevealFragment
import de.si.backdroplibrary.children.FullscreenRevealBackdropFragment
import kotlinx.android.synthetic.main.fragment_fullscreen.view.*

class FullscreenRevealFragment : FullscreenRevealFragment() {
class FullscreenRevealBackdropFragment : FullscreenRevealBackdropFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_fullscreen, container, false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import de.si.backdrop.R
import de.si.backdroplibrary.children.CardFragment
import de.si.backdroplibrary.components.ToolbarItem
import de.si.backdroplibrary.children.CardBackdropFragment
import de.si.backdroplibrary.components.BackdropToolbarItem

class TopCardFragment : CardFragment() {
override val toolbarItem: ToolbarItem
get() = ToolbarItem(
class TopCardBackdropFragment : CardBackdropFragment() {
override val toolbarItem: BackdropToolbarItem
get() = BackdropToolbarItem(
title = "Mid card",
moreActionEnabled = false,
primaryAction = R.drawable.ic_add
Expand Down
21 changes: 10 additions & 11 deletions app/src/main/java/de/si/backdrop/content/MainMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ package de.si.backdrop.content

import android.view.View
import de.si.backdrop.R
import de.si.backdrop.children.FullscreenDialogFragment
import de.si.backdrop.children.FullscreenRevealFragment
import de.si.backdroplibrary.Component
import de.si.backdrop.children.FullscreenDialogBackdropFragment
import de.si.backdrop.children.FullscreenRevealBackdropFragment
import de.si.backdroplibrary.BackdropComponent
import de.si.kotlinx.globalCenterPoint
import kotlinx.android.synthetic.main.main_menu.view.*

class MainMenu(
view: View,
private val backdropComponent: Component
) {
class MainMenu(view: View, private val backdropBackdropComponent: BackdropComponent) {
companion object {
internal const val resourceId = R.id.menu_main_layout
}
Expand All @@ -26,19 +23,21 @@ class MainMenu(
buttonFullscreenFragmentReveal.setOnClickListener(this::showFullscreenFragmentReveal)
}

@Suppress("UNUSED_PARAMETER")
private fun changeContent(view: View) {
backdropComponent.showBackdropContent(R.layout.test_content)
backdropBackdropComponent.showBackdropContent(R.layout.test_content)
}

@Suppress("UNUSED_PARAMETER")
private fun showFullscreenFragmentSlide(view: View) {
backdropComponent.showFullscreenFragment(FullscreenDialogFragment())
backdropBackdropComponent.showFullscreenFragment(FullscreenDialogBackdropFragment())
}

private fun showFullscreenFragmentReveal(view: View) {
val centerPoint = view.globalCenterPoint
val fullscreenRevealFragment = FullscreenRevealFragment().apply {
val fullscreenRevealFragment = FullscreenRevealBackdropFragment().apply {
revealEpiCenter = centerPoint
}
backdropComponent.revealFullscreenFragment(fullscreenRevealFragment)
backdropBackdropComponent.revealFullscreenFragment(fullscreenRevealFragment)
}
}
47 changes: 34 additions & 13 deletions backdroplibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'digital.wup.android-maven-publish'

group='com.github.Str3l0k'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"


testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand All @@ -31,6 +31,15 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}

buildToolsVersion = '28.0.3'
}

Expand All @@ -46,18 +55,30 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

testImplementation 'junit:junit:4.12'
testImplementation 'androidx.test.espresso:espresso-core:3.1.1'
testImplementation 'androidx.test.espresso:espresso-intents:3.1.1'
testImplementation 'androidx.test.ext:junit:1.1.0'
testImplementation 'androidx.test.ext:junit-ktx:1.1.0'
testImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
testImplementation 'androidx.test.ext:junit:1.1.1'
testImplementation 'androidx.test.ext:junit-ktx:1.1.1'
testImplementation 'org.robolectric:robolectric:4.2.1'
testImplementation 'androidx.test.ext:truth:1.1.0'
testImplementation 'androidx.test.ext:truth:1.2.0'

androidTestImplementation 'androidx.test:core:1.2.0-beta01'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.0'
androidTestImplementation 'androidx.test:core:1.2.1-alpha02'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.1'
}

publishing {
publications {
maven(MavenPublication) {
groupId = 'de.si.backdrop'
artifactId = 'core'
version = '0.2.1'

from components.android
}
}
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package de.si.backdroplibrary

import android.view.View
import androidx.annotation.LayoutRes
import de.si.backdroplibrary.activity.Activity
import de.si.backdroplibrary.children.CardFragment
import de.si.backdroplibrary.children.FullscreenFragment
import de.si.backdroplibrary.children.FullscreenRevealFragment
import de.si.backdroplibrary.components.ToolbarItem

interface Component {
val activity: Activity
import de.si.backdroplibrary.activity.BackdropActivity
import de.si.backdroplibrary.children.CardBackdropFragment
import de.si.backdroplibrary.children.FullscreenBackdropFragment
import de.si.backdroplibrary.children.FullscreenRevealBackdropFragment
import de.si.backdroplibrary.components.BackdropToolbarItem

interface BackdropComponent {
val backdropActivity: BackdropActivity

val viewModel: BackdropViewModel
get() = BackdropViewModel.registeredInstance(activity)
get() = BackdropViewModel.registeredInstance(backdropActivity)

fun prefetchBackdropContent(@LayoutRes layoutResId: Int) {
viewModel.emit(Event.PREFETCH_BACKDROP_CONTENT_VIEW, layoutResId)
Expand All @@ -25,27 +26,27 @@ interface Component {
viewModel.emit(Event.HIDE_BACKDROP_CONTENT)
}

fun addCardFragment(cardFragment: CardFragment) {
fun addCardFragment(cardFragment: CardBackdropFragment) {
viewModel.emit(Event.ADD_TOP_CARD, cardFragment)
}

fun removeTopCardFragment() {
viewModel.emit(Event.REMOVE_TOP_CARD)
}

fun showFullscreenFragment(fragment: FullscreenFragment) {
fun showFullscreenFragment(fragment: FullscreenBackdropFragment) {
viewModel.emit(Event.SHOW_FULLSCREEN_FRAGMENT, fragment)
}

fun revealFullscreenFragment(parameters: FullscreenRevealFragment) {
fun revealFullscreenFragment(parameters: FullscreenRevealBackdropFragment) {
viewModel.emit(Event.REVEAL_FULLSCREEN_FRAGMENT, parameters)
}

fun hideFullscreenFragment() {
viewModel.emit(Event.HIDE_FULLSCREEN_FRAGMENT)
}

fun changeToolbarItem(toolbarItem: ToolbarItem) {
fun changeToolbarItem(toolbarItem: BackdropToolbarItem) {
viewModel.emit(Event.CHANGE_NAVIGATION_ITEM, toolbarItem)
}

Expand Down
Loading

0 comments on commit ccc2e74

Please sign in to comment.