Skip to content

Commit

Permalink
[FEAT] Add image resources to fragments empty states
Browse files Browse the repository at this point in the history
  • Loading branch information
peterkrauz committed Sep 23, 2020
1 parent a22875c commit 11ec0b1
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 24 deletions.
8 changes: 6 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ plugins {
id 'com.google.firebase.appdistribution'
}

def firebaseBetaGroups = System.getenv("FIREBASE_TESTERS")
def firebaseBetaTesters = System.getenv("TESTER_GROUP_ALIAS")

android {
compileSdkVersion AndroidConfig.compileSdkVersion
buildToolsVersion AndroidConfig.buildToolsVersion
Expand All @@ -21,7 +24,7 @@ android {
versionCode AndroidConfig.versionCode
versionName AndroidConfig.versionName
testInstrumentationRunner AndroidConfig.testInstrumentationRunner
ext.betaDistributionGroupAliases = AndroidConfig.firebaseAppTestersGroupAlias
ext.betaDistributionGroupAliases = firebaseBetaGroups

javaCompileOptions {
annotationProcessorOptions {
Expand All @@ -46,7 +49,8 @@ android {
resValue "string", "app_name", "Grimoire Beta"
firebaseAppDistribution {
releaseNotesFile="releasenotes.txt"
groups=AndroidConfig.firebaseAppTestersGroupAlias
testers=firebaseBetaTesters
groups=firebaseBetaGroups
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package="com.peterkrauz.grimoire">

<application
android:name=".GrimoireApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/peterkrauz/grimoire/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.fragment.findNavController
import androidx.navigation.ui.setupWithNavController
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.android.synthetic.main.activity_main.*

@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -15,7 +17,7 @@ class MainActivity : AppCompatActivity() {

private fun setupView() {
bottomNavigationView.run {
setOnNavigationItemReselectedListener { Unit }
// setOnNavigationItemReselectedListener { Unit }
setupWithNavController(mainNavFragment.findNavController())
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
app:elevation="16dp"
app:itemIconTint="@drawable/selector_bottom_nav_item"
app:itemTextColor="@drawable/selector_bottom_nav_item"
app:itemTextAppearanceActive="@style/TextAppearance.Grimoire.Bold"
app:itemTextAppearanceActive="@style/TextAppearance.Grimoire.BottomNavItem.Bold"
app:labelVisibilityMode="selected"
app:layout_constraintBottom_toBottomOf="parent" />

Expand Down
3 changes: 1 addition & 2 deletions buildSrc/src/main/java/AndroidConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ object AndroidConfig {
const val minSdkVersion = 21
const val targetSdkVersion = 30
const val versionCode = 1
val versionName = System.getenv("VERSION_NAME")
const val versionName = "0.0.2"
const val testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
const val consumerProguardFile = "consumer-rules.pro"
val firebaseAppTestersGroupAlias = System.getenv("TESTER_GROUP_ALIAS")

val javaVersion = JavaVersion.VERSION_1_8
const val jvmTarget = "1.8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.peterkrauz.grimoire.common
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlin.coroutines.CoroutineContext
import kotlin.properties.Delegates
import kotlin.reflect.KProperty

Expand All @@ -14,12 +16,16 @@ abstract class BaseViewModel<out S : BaseViewState, A : BaseViewAction>(state: S
val stateLiveData: LiveData<out S>
get() = _stateLiveData

private val coroutinesErrorHandler by lazy { CoroutineExceptionHandler(::handleError) }

fun performAction(action: A) {
state = reduceState(action)
}

abstract fun loadData()

abstract fun handleError(context: CoroutineContext, error: Throwable)

protected abstract fun reduceState(action: A): S

private fun onStateChanged(property: KProperty<*>, oldState: S, newState: S) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package com.peterkrauz.grimoire.common

interface BaseViewState {
object Loading : BaseViewState
}
interface BaseViewState
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<color name="colorAccent">#9162e4</color>
<color name="colorBackground">#fafafa</color>
<color name="grey64">#868586</color>
<color name="grey82">#636363</color>
</resources>
7 changes: 7 additions & 0 deletions common/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Empty state messages -->
<string name="arcs_empty_state_msg">It seems you haven\'t\ncreated any Arc yet.</string>
<string name="characters_empty_state_msg">It seems you haven\'t\ncreated any Character yet.</string>
<string name="notes_empty_state_msg">It seems you haven\'t\ncreated any Note yet.</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
<item name="contentInsetEnd">0dp</item>
</style>

<style name="TextAppearance.Grimoire.Bold" parent="TextAppearance.AppCompat">
<style name="TextAppearance.Grimoire.BottomNavItem.Bold" parent="TextAppearance.AppCompat">
<item name="android:fontFamily">@font/kumbh_sans_bold</item>
</style>

<style name="TextAppearance.Grimoire.H2" parent="TextAppearance.AppCompat">
<item name="android:fontFamily">@font/kumbh_sans_bold</item>
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/grey82</item>
</style>
</resources>
3 changes: 3 additions & 0 deletions presentation/characters/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}

android {
Expand Down Expand Up @@ -45,4 +46,6 @@ dependencies {
implementation Hilt.viewModel
kapt Hilt.compiler
kapt Hilt.androidXCompiler

implementation project(ModulePaths.common)
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutEmptyState"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
app:layout_constraintVertical_bias="0.4"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" >

<ImageView
android:layout_width="190dp"
android:layout_height="190dp"
android:src="@drawable/img_tree" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/characters_empty_state_msg"
android:textAppearance="@style/TextAppearance.Grimoire.H2"
android:gravity="center"
android:layout_marginTop="64dp"/>

</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 3 additions & 0 deletions presentation/home/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}

android {
Expand Down Expand Up @@ -45,4 +46,6 @@ dependencies {
implementation Hilt.viewModel
kapt Hilt.compiler
kapt Hilt.androidXCompiler

implementation project(ModulePaths.common)
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 31 additions & 3 deletions presentation/home/src/main/res/layout/fragment_arcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutEmptyState"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
app:layout_constraintVertical_bias="0.4"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" >

<ImageView
android:layout_width="190dp"
android:layout_height="190dp"
android:src="@drawable/img_crow" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/arcs_empty_state_msg"
android:textAppearance="@style/TextAppearance.Grimoire.H2"
android:gravity="center"
android:layout_marginTop="64dp"/>

</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 3 additions & 0 deletions presentation/notes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}

android {
Expand Down Expand Up @@ -45,4 +46,6 @@ dependencies {
implementation Hilt.viewModel
kapt Hilt.compiler
kapt Hilt.androidXCompiler

implementation project(ModulePaths.common)
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 31 additions & 3 deletions presentation/notes/src/main/res/layout/fragment_notes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutEmptyState"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
app:layout_constraintVertical_bias="0.4"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" >

<ImageView
android:layout_width="190dp"
android:layout_height="190dp"
android:src="@drawable/img_magic_book" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/notes_empty_state_msg"
android:textAppearance="@style/TextAppearance.Grimoire.H2"
android:gravity="center"
android:layout_marginTop="64dp"/>

</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
6 changes: 1 addition & 5 deletions releasenotes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
Version: 0.0.1

Features:
- Home screen
- App icon
Version: 0.0.2

0 comments on commit 11ec0b1

Please sign in to comment.