Skip to content

Commit

Permalink
Merge pull request #98 from odaridavid/pr96-cleanup
Browse files Browse the repository at this point in the history
Codebase optimizations
  • Loading branch information
odaridavid authored Jun 8, 2020
2 parents 9366a48 + ff2fdff commit e53ac71
Show file tree
Hide file tree
Showing 137 changed files with 908 additions and 157 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ keystore.properties

If you encounter any error check [this site](https://docs.travis-ci.com/user/encrypting-files/) out.

To setup the Travis CLI tools see [this](https://github.com/travis-ci/travis.rb#installation)

## Architecture

The Application is split into a three layer architecture:
Expand Down
35 changes: 21 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
*
* Copyright 2020 David Odari
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
**/
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
Expand All @@ -8,10 +21,10 @@ apply plugin: 'kotlin-kapt'

apply plugin: 'jacoco-android'

apply plugin: 'io.fabric'

apply plugin: 'com.mikepenz.aboutlibraries.plugin'

apply plugin: 'com.google.firebase.crashlytics'

jacoco {
toolVersion = "0.8.4"
}
Expand Down Expand Up @@ -53,24 +66,18 @@ android {
buildTypes {

release {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
manifestPlaceholders = [
crashlyticsEnabled: true,
appIcon : "@mipmap/ic_launcher",
appIconRound : "@mipmap/ic_launcher_round"
]
manifestPlaceholders = [crashlyticsEnabled: true]
signingConfig signingConfigs.release
}

debug {
minifyEnabled false
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
manifestPlaceholders = [
crashlyticsEnabled: false,
appIcon : "@mipmap/ic_debug_launcher",
appIconRound : "@mipmap/ic_debug_launcher_round"
]
manifestPlaceholders = [crashlyticsEnabled: false]
testCoverageEnabled true
}
}
Expand Down Expand Up @@ -121,7 +128,7 @@ dependencies {

//Firebase
implementation appDependencies.firebaseAnalytics
implementation appDependencies.crashlytics
implementation appDependencies.firebaseCrashlytics

//Stetho
implementation appDependencies.stetho
Expand Down
9 changes: 9 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

#Exclude R from ProGuard to enable the libraries auto detection[AboutLibraries]
-keep class **.R$* {
<fields>;
}

-printusage build/outputs/mapping/release/usage.txt

-keep class com.k0d4black.theforce.** { *; }
18 changes: 15 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
~ Copyright 2020 David Odari
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied. See the License for the specific language governing permissions and limitations under
~ the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.k0d4black.theforce">

<application
android:name=".TheForceApplication"
android:allowBackup="true"
android:icon="${appIcon}"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="${appIconRound}"
android:supportsRtl="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">
<activity android:name=".base.BaseActivity" />
<activity
Expand Down
Binary file removed app/src/main/ic_debug_launcher-playstore.png
Binary file not shown.
13 changes: 13 additions & 0 deletions app/src/main/kotlin/com/k0d4black/theforce/TheForceApplication.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
*
* Copyright 2020 David Odari
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
**/
package com.k0d4black.theforce

import android.app.Application
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
*
* Copyright 2020 David Odari
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
**/
package com.k0d4black.theforce.activities

import android.os.Bundle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
*
* Copyright 2020 David Odari
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
**/
package com.k0d4black.theforce.activities

import android.os.Bundle
Expand All @@ -16,7 +29,7 @@ import com.k0d4black.theforce.models.states.CharacterDetailsViewState
import com.k0d4black.theforce.viewmodel.CharacterDetailViewModel
import org.koin.androidx.viewmodel.ext.android.viewModel

//TODO Disable Saving favs for remote till everything is done
//TODO Disable Saving favs for remote till everything is done and is not error
internal class CharacterDetailActivity : BaseActivity() {

private val characterDetailViewModel by viewModel<CharacterDetailViewModel>()
Expand Down Expand Up @@ -88,9 +101,9 @@ internal class CharacterDetailActivity : BaseActivity() {
menuInflater.inflate(R.menu.details_menu, menu)
val menuItem = menu?.getItem(0)
if (isFavorite)
menuItem?.setIcon(R.drawable.ic_fav_on)
menuItem?.setIcon(R.drawable.ic_favs_24dp)
else
menuItem?.setIcon(R.drawable.ic_fav_off)
menuItem?.setIcon(R.drawable.ic_no_favs_24dp)
return super.onCreateOptionsMenu(menu)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
*
* Copyright 2020 David Odari
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
**/
package com.k0d4black.theforce.activities

import android.os.Bundle
Expand Down Expand Up @@ -138,8 +151,8 @@ internal class DashboardActivity : BaseActivity() {
})
}

private fun handleSearchLoading(stateDashboard: DashboardSearchViewState) {
if (stateDashboard.isLoading) {
private fun handleSearchLoading(state: DashboardSearchViewState) {
if (state.isLoading) {
binding.searchResultsRecyclerView.hide()
binding.searchResultsProgressBar.show()
} else {
Expand All @@ -148,8 +161,8 @@ internal class DashboardActivity : BaseActivity() {
}
}

private fun handleFavoritesLoading(stateDashboard: DashboardFavoritesViewState) {
if (stateDashboard.isLoading) {
private fun handleFavoritesLoading(state: DashboardFavoritesViewState) {
if (state.isLoading) {
binding.favoritesProgressBar.show()
} else {
binding.favoritesProgressBar.hide()
Expand Down Expand Up @@ -187,8 +200,8 @@ internal class DashboardActivity : BaseActivity() {
)
}

private fun handleSearchError(stateDashboard: DashboardSearchViewState) {
stateDashboard.error?.run {
private fun handleSearchError(state: DashboardSearchViewState) {
state.error?.run {
showSnackbar(
binding.searchResultsRecyclerView,
getString(this.message),
Expand All @@ -197,8 +210,8 @@ internal class DashboardActivity : BaseActivity() {
}
}

private fun handleFavoritesError(stateDashboard: DashboardFavoritesViewState) {
stateDashboard.error?.run {
private fun handleFavoritesError(state: DashboardFavoritesViewState) {
state.error?.run {
showSnackbar(
binding.favoritesRecyclerView,
getString(this.message),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
*
* Copyright 2020 David Odari
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
**/
package com.k0d4black.theforce.activities

import android.os.Bundle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
package com.k0d4black.theforce.adapters;

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.k0d4black.theforce.databinding.ItemFavoriteBinding
import com.k0d4black.theforce.models.FavoritePresentation
import kotlinx.android.synthetic.main.item_favorite.view.*

/**
*
* Copyright 2020 David Odari
Expand All @@ -22,6 +11,17 @@ import kotlinx.android.synthetic.main.item_favorite.view.*
* the License.
*
**/
package com.k0d4black.theforce.adapters;

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.k0d4black.theforce.databinding.ItemFavoriteBinding
import com.k0d4black.theforce.models.FavoritePresentation
import kotlinx.android.synthetic.main.item_favorite.view.*

internal class FavoritesAdapter(
val onClick: (FavoritePresentation) -> (Unit)
) : ListAdapter<FavoritePresentation, FavoritesAdapter.FavoriteViewHolder>(DiffUtil) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
*
* Copyright 2020 David Odari
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
**/
package com.k0d4black.theforce.adapters

import android.view.LayoutInflater
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
*
* Copyright 2020 David Odari
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
**/
package com.k0d4black.theforce.adapters;

import android.view.LayoutInflater
Expand All @@ -7,7 +20,6 @@ import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.k0d4black.theforce.databinding.ItemSearchBinding
import com.k0d4black.theforce.models.CharacterPresentation
import kotlinx.android.synthetic.main.item_search.view.*


internal class SearchResultAdapter(
Expand All @@ -31,7 +43,7 @@ internal class SearchResultAdapter(
binding.searchedCharacter = characterPresentation
binding.executePendingBindings()

binding.root.more_info_arrow_image_button.setOnClickListener {
binding.moreInfoArrowImageButton.setOnClickListener {
onClick(characterPresentation)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
*
* Copyright 2020 David Odari
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
**/
package com.k0d4black.theforce.adapters

import android.view.LayoutInflater
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/kotlin/com/k0d4black/theforce/base/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
*
* Copyright 2020 David Odari
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*
**/
package com.k0d4black.theforce.base

import android.os.Build
Expand Down
Loading

0 comments on commit e53ac71

Please sign in to comment.