Skip to content

Commit c2bea3a

Browse files
Merge pull request #23 from vojta-horanek/develop
First release candidat
2 parents 7153178 + c608a58 commit c2bea3a

File tree

155 files changed

+3797
-59381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+3797
-59381
lines changed

app/build.gradle

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ plugins {
44
id 'kotlin-kapt'
55
id 'dagger.hilt.android.plugin'
66
id 'androidx.navigation.safeargs.kotlin'
7-
id 'com.mikepenz.aboutlibraries.plugin'
87
}
98

109
android {
@@ -15,8 +14,8 @@ android {
1514
applicationId "eu.vojtechh.takeyourpill"
1615
minSdkVersion 23
1716
targetSdkVersion 30
18-
versionCode 20210306
19-
versionName "v1.0 stable, build $versionCode"
17+
versionCode 20210328
18+
versionName "v1.5.rc1"
2019

2120
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2221

@@ -39,7 +38,6 @@ android {
3938

4039
buildFeatures {
4140
viewBinding true
42-
dataBinding true
4341
}
4442

4543
kapt {
@@ -50,7 +48,8 @@ android {
5048

5149
buildTypes {
5250
release {
53-
minifyEnabled false
51+
minifyEnabled true
52+
shrinkResources true
5453
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
5554
}
5655
}
@@ -61,22 +60,15 @@ kapt {
6160
}
6261

6362
dependencies {
64-
implementation "androidx.legacy:legacy-support-v4:1.0.0"
65-
def nav_version = '2.3.3'
66-
def fragment_version = '1.2.5' // FIXME Cant upgrade to 1.3.0 bcs BottomSheetDialogFragment acts weird
67-
def lifecycle_version = '2.3.0'
63+
def nav_version = '2.3.4'
64+
def fragment_version = '1.3.2'
65+
def lifecycle_version = '2.3.1'
6866
def preference_version = "1.1.1"
6967
def room_version = '2.2.6'
7068

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

71+
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
8072
implementation "androidx.fragment:fragment-ktx:$fragment_version"
8173
implementation "androidx.recyclerview:recyclerview:1.1.0"
8274
implementation "androidx.preference:preference-ktx:$preference_version"
@@ -97,18 +89,13 @@ dependencies {
9789
// Hilt
9890
implementation 'com.google.dagger:hilt-android:2.33-beta'
9991
kapt 'com.google.dagger:hilt-android-compiler:2.33-beta'
100-
//noinspection GradleDependency
10192
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
102-
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha03'
93+
kapt 'androidx.hilt:hilt-compiler:1.0.0-beta01'
10394

10495
// LifeCycle
10596
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
10697
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
107-
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
10898
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
109-
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
110-
// optional - helpers for implementing LifecycleOwner in a Service
111-
implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version"
11299

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

133-
//Custom image picker
120+
// Custom image picker
134121
implementation project(path: ':imagepicker')
135122

136-
implementation "com.mikepenz:aboutlibraries-core:${latestAboutLibsRelease}"
137-
implementation "com.mikepenz:aboutlibraries:${latestAboutLibsRelease}"
123+
// Licences dialog
124+
implementation 'de.psdev.licensesdialog:licensesdialog:2.1.0'
125+
126+
// ViewBinding delegate
127+
implementation 'com.github.Zhuinden:fragmentviewbindingdelegate-kt:1.0.0'
138128

129+
implementation 'com.faltenreich:skeletonlayout:4.0.0'
139130
}

app/release/output-metadata.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@
4343
<receiver android:name=".receiver.ConfirmReceiver" />
4444
<receiver
4545
android:name=".receiver.BootReceiver"
46+
android:exported="true"
4647
android:enabled="true">
4748
<intent-filter>
4849
<action android:name="android.intent.action.BOOT_COMPLETED" />
50+
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
4951
</intent-filter>
5052
</receiver>
5153

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package eu.vojtechh.takeyourpill.activity
22

3+
//import com.mikepenz.aboutlibraries.LibsBuilder
4+
35
import android.content.Intent
46
import android.net.Uri
57
import android.os.Bundle
68
import androidx.appcompat.app.AppCompatActivity
7-
import androidx.core.view.isVisible
8-
import com.mikepenz.aboutlibraries.LibsBuilder
9+
import de.psdev.licensesdialog.LicensesDialogFragment
910
import eu.vojtechh.takeyourpill.BuildConfig
1011
import eu.vojtechh.takeyourpill.R
1112
import eu.vojtechh.takeyourpill.databinding.ActivityAboutBinding
13+
import eu.vojtechh.takeyourpill.klass.onClick
1214
import eu.vojtechh.takeyourpill.klass.viewBinding
1315

1416

@@ -18,48 +20,38 @@ class AboutActivity : AppCompatActivity() {
1820
override fun onCreate(savedInstanceState: Bundle?) {
1921
super.onCreate(savedInstanceState)
2022
setContentView(binding.root)
21-
binding.buttonClose.setOnClickListener {
22-
finish()
23-
}
24-
binding.buttonGithub.setOnClickListener {
25-
val browserIntent = Intent(
26-
Intent.ACTION_VIEW,
27-
Uri.parse("https://github.com/vojta-horanek/take-your-pill")
28-
)
29-
startActivity(browserIntent)
30-
}
23+
binding.run {
24+
buttonClose.onClick { finish() }
3125

32-
binding.buttonIcons.setOnClickListener {
33-
val browserIntent = Intent(
34-
Intent.ACTION_VIEW,
35-
Uri.parse("https://github.com/ShimonHoranek/material-icons")
36-
)
37-
startActivity(browserIntent)
38-
}
26+
buttonGithub.onClick {
27+
openUrl("https://github.com/vojta-horanek/take-your-pill")
28+
}
3929

40-
binding.buttonLicence.setOnClickListener {
41-
val isVisible = binding.fragmentLibs.isVisible
42-
binding.fragmentLibs.isVisible = !isVisible
43-
val drawable = if (isVisible) R.drawable.ic_expand_more else R.drawable.ic_expand_less
44-
binding.buttonLicence.setCompoundDrawablesWithIntrinsicBounds(
45-
R.drawable.ic_article,
46-
0,
47-
drawable,
48-
0
49-
)
30+
buttonIcons.onClick {
31+
openUrl("https://github.com/ShimonHoranek/material-icons")
32+
}
33+
34+
buttonLicence.onClick { openLicencesDialog() }
35+
36+
textVersion.text = getString(R.string.version, BuildConfig.VERSION_NAME)
5037
}
5138

52-
binding.textVersion.text = getString(R.string.version, BuildConfig.VERSION_NAME)
39+
}
5340

54-
val fragment = LibsBuilder()
55-
.withAboutIconShown(false)
56-
.withVersionShown(false)
57-
.withShowLoadingProgress(true)
58-
.supportFragment()
41+
private fun openUrl(url: String) {
42+
val browserIntent = Intent(
43+
Intent.ACTION_VIEW,
44+
Uri.parse(url)
45+
)
46+
startActivity(browserIntent)
47+
}
5948

60-
supportFragmentManager
61-
.beginTransaction()
62-
.add(R.id.fragmentLibs, fragment, "fragment_libs")
63-
.commit()
49+
private fun openLicencesDialog() {
50+
LicensesDialogFragment.Builder(this)
51+
.setNotices(R.raw.notices)
52+
.setShowFullLicenseText(false)
53+
.setIncludeOwnLicense(true)
54+
.build()
55+
.show(supportFragmentManager, null)
6456
}
6557
}

app/src/main/java/eu/vojtechh/takeyourpill/activity/MainActivity.kt

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package eu.vojtechh.takeyourpill.activity
22

33
import android.content.Intent
44
import android.os.Bundle
5+
import androidx.activity.result.ActivityResult
6+
import androidx.activity.result.contract.ActivityResultContracts
57
import androidx.activity.viewModels
68
import androidx.appcompat.app.AppCompatActivity
79
import androidx.core.view.isVisible
@@ -19,8 +21,6 @@ import eu.vojtechh.takeyourpill.viewmodel.MainViewModel
1921
@AndroidEntryPoint
2022
class MainActivity : AppCompatActivity() {
2123

22-
private val requestCodeIntro = 22
23-
2424
private val binding by viewBinding(ActivityMainBinding::inflate)
2525
private val model: MainViewModel by viewModels()
2626

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

3030
if (Pref.firstRun) {
3131
val intent = Intent(this, AppIntroActivity::class.java)
32-
startActivityForResult(intent, requestCodeIntro)
32+
introResult.launch(intent)
3333
}
3434

35-
setTheme(R.style.AppTheme)
35+
setTheme(R.style.AppTheme) // Switch from splash theme
3636
setContentView(binding.root)
3737

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

4444
navController.addOnDestinationChangedListener { _, destination, _ ->
45-
binding.bottomNavigation.isVisible = when (destination.id) {
46-
R.id.homescreen, R.id.history, R.id.settings -> true
47-
else -> false
48-
}
45+
showBottomBar(
46+
when (destination.id) {
47+
R.id.homescreen, R.id.history, R.id.settings -> true
48+
else -> false
49+
}
50+
)
4951
}
5052

51-
binding.bottomNavigation.setOnNavigationItemReselectedListener { }
53+
binding.bottomNavigation.setOnNavigationItemReselectedListener { model.scrollUp() }
5254
NavigationUI.setupWithNavController(binding.bottomNavigation, navController)
5355

54-
model.planReminders(this)
56+
model.planReminders(applicationContext)
57+
}
58+
59+
private fun showBottomBar(visible: Boolean) {
60+
if (binding.bottomNavigation.isVisible == visible) return
61+
binding.bottomNavigation.isVisible = visible
5562
}
5663

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

62-
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
63-
super.onActivityResult(requestCode, resultCode, data)
64-
if (requestCode == requestCodeIntro) {
65-
if (resultCode == RESULT_OK) {
66-
Pref.firstRun = false
67-
} else {
68-
finish()
69+
private val introResult =
70+
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
71+
when (result.resultCode) {
72+
RESULT_OK -> Pref.firstRun = false
73+
else -> finish()
6974
}
7075
}
71-
}
7276

7377
}

0 commit comments

Comments
 (0)