Skip to content

Commit

Permalink
Prepare for release
Browse files Browse the repository at this point in the history
  • Loading branch information
manununhez committed Oct 12, 2020
1 parent 04f7fff commit 62c71f9
Show file tree
Hide file tree
Showing 22 changed files with 266 additions and 100 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.iml
.gradle
/local.properties
/keystore.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
Expand Down
72 changes: 59 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,35 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
apply plugin: 'androidx.navigation.safeargs.kotlin' //To pass data safety in nav components
apply plugin: 'androidx.navigation.safeargs.kotlin'//To pass data safety in nav components
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("keystore.properties")

// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()

// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
signingConfigs {
release {
// storeFile file('/Users/Manuel/MyDocuments/kinema - keys/kinema.keystore')
// storePassword 'keystoreforKinema2020$'
// keyPassword 'pA$$w0rD$#kinema'
// keyAlias 'kinemaKeystore'
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
applicationId "today.kinema"
Expand All @@ -23,9 +47,25 @@ android {

buildTypes {
release {
minifyEnabled false
ext.enableCrashlytics = true

minifyEnabled true // Enables code shrinking for the release build type.

// Enables resource shrinking, which is performed by the
// Android Gradle plugin.
shrinkResources true
signingConfig signingConfigs.release
debuggable false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
// Disable fabric build ID generation for debug builds
debuggable true
ext.enableCrashlytics = false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -49,26 +89,33 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.arch.core:core-testing:2.1.0'
implementation "androidx.fragment:fragment-ktx:1.2.0"

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

// GLIDE
implementation "com.github.bumptech.glide:glide:4.10.0"
implementation 'com.github.bumptech.glide:glide:4.11.0'

implementation 'androidx.legacy:legacy-support-v4:1.0.0'

//Firebase
implementation 'com.google.firebase:firebase-crashlytics-ktx:17.2.2'
implementation 'com.google.firebase:firebase-analytics-ktx:17.6.0'

//Hilt
implementation 'com.google.dagger:hilt-android:2.28.3-alpha'
implementation 'com.google.dagger:hilt-android:2.29.1-alpha'
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
kapt 'com.google.dagger:hilt-android-compiler:2.28.3-alpha'
kapt 'com.google.dagger:hilt-android-compiler:2.29.1-alpha'
kapt "androidx.hilt:hilt-compiler:1.0.0-alpha02"

//Material Design
implementation 'com.google.android.material:material:1.2.1'

//Timber - logging
implementation 'com.jakewharton.timber:timber:4.7.1'

// RETROFIT -- keep this version to work with sdk >= 19
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
Expand All @@ -78,7 +125,6 @@ dependencies {
//Fused location requires the use of the Google Play SDK
implementation "com.google.android.gms:play-services-location:17.1.0"


//Multidex
implementation 'com.android.support:multidex:1.0.3'

Expand All @@ -88,4 +134,4 @@ dependencies {
testImplementation 'junit:junit:4.13'
// Mockito framework
testImplementation 'org.mockito:mockito-core:2.28.2'
}
}
9 changes: 8 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile


#https://stackoverflow.com/questions/50378810/proguard-causing-runtime-exception-with-android-navigation-component/50378828#50378828
-keep class * extends androidx.fragment.app.Fragment{}

-keepnames class * extends android.os.Parcelable
-keepnames class * extends java.io.Serializable
12 changes: 7 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!--networkSecurityConfig fix error: "HTTP FAILED: java.net.UnknownServiceException: CLEARTEXT communication to 192.168.1.10 not permitted by network security policy"-->
<application
android:name=".CinemaPLApplication"
android:allowBackup="true"
Expand All @@ -15,15 +15,17 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/CinePL.Metropolis">
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity android:name=".SplashScreenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"/>
<activity android:name=".MainActivity" />

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/today/kinema/CinemaPLApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ package today.kinema

import androidx.multidex.MultiDexApplication
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber

@HiltAndroidApp
class CinemaPLApplication: MultiDexApplication()
class CinemaPLApplication: MultiDexApplication(){
override fun onCreate() {
super.onCreate()

if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
}
}
14 changes: 6 additions & 8 deletions app/src/main/java/today/kinema/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ import android.Manifest
import android.annotation.SuppressLint
import android.content.pm.PackageManager
import android.os.Bundle
import android.util.Log
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import com.google.android.gms.location.FusedLocationProviderClient
import com.google.android.gms.location.LocationServices
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber
import today.kinema.ui.SharedMovieViewModel
import today.kinema.vo.Coordinate
import dagger.hilt.android.AndroidEntryPoint


@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
companion object{
private val TAG: String? = MainActivity::class.java.simpleName
private const val REQUEST_PERMISSIONS_REQUEST_CODE = 34
}
/**
Expand All @@ -35,7 +34,6 @@ class MainActivity : AppCompatActivity() {
setSupportActionBar(findViewById(R.id.toolbar))

fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)

}

override fun onStart() {
Expand Down Expand Up @@ -96,15 +94,15 @@ class MainActivity : AppCompatActivity() {
)) {
// Provide an additional rationale to the user. This would happen if the user denied the
// request previously, but didn't check the "Don't ask again" checkbox.
Log.i(TAG, "Displaying permission rationale to provide additional context.")
Timber.i("Displaying permission rationale to provide additional context.")
// Request permission
startLocationPermissionRequest()

} else {
// Request permission. It's possible this can be auto answered if device policy
// sets the permission in a given state or the user denied the permission
// previously and checked "Never ask again".
Log.i(TAG, "Requesting permission")
Timber.i( "Requesting permission")
startLocationPermissionRequest()
}
}
Expand All @@ -117,12 +115,12 @@ class MainActivity : AppCompatActivity() {
permissions: Array<String>,
grantResults: IntArray
) {
Log.i(TAG, "onRequestPermissionResult")
Timber.i( "onRequestPermissionResult")
if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE) {
when {
// If user interaction was interrupted, the permission request is cancelled and you
// receive empty arrays.
grantResults.isEmpty() -> Log.i(TAG, "User interaction was cancelled.")
grantResults.isEmpty() -> Timber.i("User interaction was cancelled.")

// Permission granted.
(grantResults[0] == PackageManager.PERMISSION_GRANTED) -> getLastLocation()
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/today/kinema/SplashScreenActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import androidx.appcompat.app.AppCompatActivity


class SplashScreenActivity : AppCompatActivity() {
private val SPLASH_TIME_OUT = 1000L
companion object{
private const val SPLASH_TIME_OUT = 1000L
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
41 changes: 33 additions & 8 deletions app/src/main/java/today/kinema/db/LocalStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,35 @@ class LocalStorage @Inject constructor(
private const val SHARED_PREFS_WATCHLIST_MOVIES = "Watchlist Movies"
private const val SHARED_PREFS_ATTRIBUTES = "Attributes"
private const val SHARED_PREFS_SELECTED_ATTRIBUTES = "Selected attributes"
private const val DEFAULT_CITY = "Warszawa"
private const val DEFAULT_CITY_CODE = "Warszawa"
private val DEFAULT_CURRENT_DATE = DateUtils.dateFormat(Date())
}


fun getMovies(filterAttribute: FilterAttribute): LiveData<List<Movies>> {
val prefsMovies = sharedPreferences.getString(SHARED_PREFS_MOVIES, "")!!
val prefsAttrs = getFilteredAttributes() == filterAttribute
return if (prefsMovies.isNotEmpty() && prefsAttrs) {

if (prefsMovies.isNotEmpty() && prefsAttrs) {
val type = object : TypeToken<List<Movies>>() {}.type
val moviesList: List<Movies> = gson.fromJson(prefsMovies, type)

val moviesLiveData = MutableLiveData<List<Movies>>()
moviesLiveData.value = moviesList
if (moviesList.isEmpty())
return AbsentLiveData.create()

val formattedDay = DateUtils.dateParse(moviesList[0].movie.dateTitle)
val today = DateUtils.today()

return if (formattedDay.before(today)) {//if we have a date saved older than today, we update to today's date
AbsentLiveData.create()
} else {
val moviesLiveData = MutableLiveData<List<Movies>>()
moviesLiveData.value = moviesList

moviesLiveData
return moviesLiveData
}
} else {
AbsentLiveData.create()
return AbsentLiveData.create()
}
}

Expand Down Expand Up @@ -93,15 +104,29 @@ class LocalStorage @Inject constructor(

fun getFilteredAttributes(): FilterAttribute {
val filterAttrDefault =
FilterAttribute(DEFAULT_CITY, DEFAULT_CURRENT_DATE, listOf(), listOf())
FilterAttribute(DEFAULT_CITY_CODE, DEFAULT_CURRENT_DATE, listOf(), listOf())
val prefsAttributes =
sharedPreferences.getString(
SHARED_PREFS_SELECTED_ATTRIBUTES,
gson.toJson(filterAttrDefault)
)

val type = object : TypeToken<FilterAttribute>() {}.type
return gson.fromJson(prefsAttributes, type)
val filterAttribute: FilterAttribute = gson.fromJson(prefsAttributes, type)

val formattedDay = DateUtils.dateParse(filterAttribute.date)
val today = DateUtils.today()

return if (formattedDay.before(today)) { //if we have a date saved older than today, we update to today's date
FilterAttribute(
filterAttribute.city,
DEFAULT_CURRENT_DATE,
filterAttribute.cinema,
filterAttribute.language
)
} else {
filterAttribute
}
}

fun setFilteredAttributes(item: FilterAttribute) {
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/java/today/kinema/repository/MovieRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ class MovieRepository @Inject constructor(
setFilteredAttributes(filterAttribute)
//order list based on distance
localStorage.setMovies(
orderCinemasByDistance(
getCurrentLocation(),
item
)
orderCinemasByDistance(getCurrentLocation(), item)
)
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/today/kinema/ui/filter/FilterFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class FilterFragment : Fragment() {
)
}

//scroll rv to select city
//scroll rv to selected city
viewModelShared.currentFilterAttribute.observe(viewLifecycleOwner, {
binding.rvFilterCitiesList.scrollToPosition(attributes.cities.indexOf(it.city))
})
Expand Down
Loading

0 comments on commit 62c71f9

Please sign in to comment.