Skip to content

Commit

Permalink
Merge pull request #23 from vojta-horanek/develop
Browse files Browse the repository at this point in the history
First release candidat
  • Loading branch information
vojta-horanek authored Mar 27, 2021
2 parents 7153178 + c608a58 commit c2bea3a
Show file tree
Hide file tree
Showing 155 changed files with 3,797 additions and 59,381 deletions.
41 changes: 16 additions & 25 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'androidx.navigation.safeargs.kotlin'
id 'com.mikepenz.aboutlibraries.plugin'
}

android {
Expand All @@ -15,8 +14,8 @@ android {
applicationId "eu.vojtechh.takeyourpill"
minSdkVersion 23
targetSdkVersion 30
versionCode 20210306
versionName "v1.0 stable, build $versionCode"
versionCode 20210328
versionName "v1.5.rc1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand All @@ -39,7 +38,6 @@ android {

buildFeatures {
viewBinding true
dataBinding true
}

kapt {
Expand All @@ -50,7 +48,8 @@ android {

buildTypes {
release {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
}
Expand All @@ -61,22 +60,15 @@ kapt {
}

dependencies {
implementation "androidx.legacy:legacy-support-v4:1.0.0"
def nav_version = '2.3.3'
def fragment_version = '1.2.5' // FIXME Cant upgrade to 1.3.0 bcs BottomSheetDialogFragment acts weird
def lifecycle_version = '2.3.0'
def nav_version = '2.3.4'
def fragment_version = '1.3.2'
def lifecycle_version = '2.3.1'
def preference_version = "1.1.1"
def room_version = '2.2.6'

implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "androidx.core:core-ktx:1.3.2"
implementation "androidx.appcompat:appcompat:1.2.0"
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation "androidx.test.ext:junit:1.1.2"
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0"

implementation "androidx.constraintlayout:constraintlayout:2.0.4"
implementation "androidx.fragment:fragment-ktx:$fragment_version"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.preference:preference-ktx:$preference_version"
Expand All @@ -97,18 +89,13 @@ dependencies {
// Hilt
implementation 'com.google.dagger:hilt-android:2.33-beta'
kapt 'com.google.dagger:hilt-android-compiler:2.33-beta'
//noinspection GradleDependency
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha03'
kapt 'androidx.hilt:hilt-compiler:1.0.0-beta01'

// LifeCycle
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
// optional - helpers for implementing LifecycleOwner in a Service
implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version"

// Permissions
implementation "pub.devrel:easypermissions:3.0.0"
Expand All @@ -130,10 +117,14 @@ dependencies {
//charts
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'

//Custom image picker
// Custom image picker
implementation project(path: ':imagepicker')

implementation "com.mikepenz:aboutlibraries-core:${latestAboutLibsRelease}"
implementation "com.mikepenz:aboutlibraries:${latestAboutLibsRelease}"
// Licences dialog
implementation 'de.psdev.licensesdialog:licensesdialog:2.1.0'

// ViewBinding delegate
implementation 'com.github.Zhuinden:fragmentviewbindingdelegate-kt:1.0.0'

implementation 'com.faltenreich:skeletonlayout:4.0.0'
}
18 changes: 0 additions & 18 deletions app/release/output-metadata.json

This file was deleted.

2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@
<receiver android:name=".receiver.ConfirmReceiver" />
<receiver
android:name=".receiver.BootReceiver"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package eu.vojtechh.takeyourpill.activity

//import com.mikepenz.aboutlibraries.LibsBuilder

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import com.mikepenz.aboutlibraries.LibsBuilder
import de.psdev.licensesdialog.LicensesDialogFragment
import eu.vojtechh.takeyourpill.BuildConfig
import eu.vojtechh.takeyourpill.R
import eu.vojtechh.takeyourpill.databinding.ActivityAboutBinding
import eu.vojtechh.takeyourpill.klass.onClick
import eu.vojtechh.takeyourpill.klass.viewBinding


Expand All @@ -18,48 +20,38 @@ class AboutActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
binding.buttonClose.setOnClickListener {
finish()
}
binding.buttonGithub.setOnClickListener {
val browserIntent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://github.com/vojta-horanek/take-your-pill")
)
startActivity(browserIntent)
}
binding.run {
buttonClose.onClick { finish() }

binding.buttonIcons.setOnClickListener {
val browserIntent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://github.com/ShimonHoranek/material-icons")
)
startActivity(browserIntent)
}
buttonGithub.onClick {
openUrl("https://github.com/vojta-horanek/take-your-pill")
}

binding.buttonLicence.setOnClickListener {
val isVisible = binding.fragmentLibs.isVisible
binding.fragmentLibs.isVisible = !isVisible
val drawable = if (isVisible) R.drawable.ic_expand_more else R.drawable.ic_expand_less
binding.buttonLicence.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.ic_article,
0,
drawable,
0
)
buttonIcons.onClick {
openUrl("https://github.com/ShimonHoranek/material-icons")
}

buttonLicence.onClick { openLicencesDialog() }

textVersion.text = getString(R.string.version, BuildConfig.VERSION_NAME)
}

binding.textVersion.text = getString(R.string.version, BuildConfig.VERSION_NAME)
}

val fragment = LibsBuilder()
.withAboutIconShown(false)
.withVersionShown(false)
.withShowLoadingProgress(true)
.supportFragment()
private fun openUrl(url: String) {
val browserIntent = Intent(
Intent.ACTION_VIEW,
Uri.parse(url)
)
startActivity(browserIntent)
}

supportFragmentManager
.beginTransaction()
.add(R.id.fragmentLibs, fragment, "fragment_libs")
.commit()
private fun openLicencesDialog() {
LicensesDialogFragment.Builder(this)
.setNotices(R.raw.notices)
.setShowFullLicenseText(false)
.setIncludeOwnLicense(true)
.build()
.show(supportFragmentManager, null)
}
}
40 changes: 22 additions & 18 deletions app/src/main/java/eu/vojtechh/takeyourpill/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package eu.vojtechh.takeyourpill.activity

import android.content.Intent
import android.os.Bundle
import androidx.activity.result.ActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
Expand All @@ -19,8 +21,6 @@ import eu.vojtechh.takeyourpill.viewmodel.MainViewModel
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {

private val requestCodeIntro = 22

private val binding by viewBinding(ActivityMainBinding::inflate)
private val model: MainViewModel by viewModels()

Expand All @@ -29,10 +29,10 @@ class MainActivity : AppCompatActivity() {

if (Pref.firstRun) {
val intent = Intent(this, AppIntroActivity::class.java)
startActivityForResult(intent, requestCodeIntro)
introResult.launch(intent)
}

setTheme(R.style.AppTheme)
setTheme(R.style.AppTheme) // Switch from splash theme
setContentView(binding.root)

Utils.setTheme(Pref.theme)
Expand All @@ -42,32 +42,36 @@ class MainActivity : AppCompatActivity() {
val navController = navHostFragment.navController

navController.addOnDestinationChangedListener { _, destination, _ ->
binding.bottomNavigation.isVisible = when (destination.id) {
R.id.homescreen, R.id.history, R.id.settings -> true
else -> false
}
showBottomBar(
when (destination.id) {
R.id.homescreen, R.id.history, R.id.settings -> true
else -> false
}
)
}

binding.bottomNavigation.setOnNavigationItemReselectedListener { }
binding.bottomNavigation.setOnNavigationItemReselectedListener { model.scrollUp() }
NavigationUI.setupWithNavController(binding.bottomNavigation, navController)

model.planReminders(this)
model.planReminders(applicationContext)
}

private fun showBottomBar(visible: Boolean) {
if (binding.bottomNavigation.isVisible == visible) return
binding.bottomNavigation.isVisible = visible
}

override fun onSupportNavigateUp(): Boolean {
val navController = findNavController(R.id.navHostFragment)
return navController.navigateUp() || super.onSupportNavigateUp()
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == requestCodeIntro) {
if (resultCode == RESULT_OK) {
Pref.firstRun = false
} else {
finish()
private val introResult =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
when (result.resultCode) {
RESULT_OK -> Pref.firstRun = false
else -> finish()
}
}
}

}
Loading

0 comments on commit c2bea3a

Please sign in to comment.