Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/build.gradle
  • Loading branch information
tyehooney committed Oct 7, 2023
2 parents f6d2be4 + 5ebd384 commit 1b7e4e5
Show file tree
Hide file tree
Showing 40 changed files with 851 additions and 173 deletions.
20 changes: 11 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id 'com.google.gms.google-services'
id 'com.google.dagger.hilt.android'
id 'com.google.firebase.crashlytics'
id 'kotlin-parcelize'
}

def localProperties = new Properties()
Expand All @@ -22,15 +23,15 @@ android {
keyPassword localProperties['signedKeyAliasPassword']
}
}
compileSdkVersion 33
compileSdkVersion 34
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.tyehooney.dgtimer"
minSdkVersion 26
targetSdkVersion 33
versionCode 20
versionName "1.7.3"
targetSdkVersion 34
versionCode 21
versionName "1.8.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -58,19 +59,20 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'com.example.dgtimer'
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.activity:activity-ktx:1.5.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.activity:activity-ktx:1.7.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

def room_version = '2.5.1'
def room_version = '2.5.2'
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
Expand All @@ -82,7 +84,7 @@ dependencies {
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'

implementation 'androidx.recyclerview:recyclerview:1.3.0'
implementation 'androidx.recyclerview:recyclerview:1.3.1'

implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'

Expand All @@ -106,7 +108,7 @@ dependencies {
kapt 'androidx.hilt:hilt-compiler:1.0.0'

// coroutines
def coroutines_version = '1.6.3'
def coroutines_version = '1.7.1'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
}
20 changes: 17 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dgtimer">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
Expand Down Expand Up @@ -29,9 +28,24 @@
android:screenOrientation="portrait" />
<activity
android:name=".activities.timer.TimerActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:configChanges="layoutDirection|locale"
android:parentActivityName=".activities.main.MainActivity" />
<activity
android:name=".activities.main.MainActivity"
android:screenOrientation="portrait"/>
<receiver android:name=".widget.DGTimerWidgetProvider"
android:exported="false">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/dgtimer_appwidget_info" />
</receiver>

<service android:name=".widget.DGTimerWidgetRemoteViewsService"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BIND_REMOTEVIEWS"/>
</application>
</manifest>
3 changes: 1 addition & 2 deletions app/src/main/java/com/example/dgtimer/KakaoBannerAds.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import com.kakao.adfit.ads.AdListener
import com.kakao.adfit.ads.ba.BannerAdView

private const val TAG = "KakaoBannerAds"
fun setAd(bannerAdView: BannerAdView, context: Context,
lifecycle: Lifecycle){
fun setAd(bannerAdView: BannerAdView, context: Context, lifecycle: Lifecycle){

bannerAdView.setClientId(context.getString(R.string.adfit_id))
bannerAdView.setAdListener(object : AdListener{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.dgtimer.activities.main

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
Expand Down Expand Up @@ -31,9 +30,11 @@ import com.example.dgtimer.AppRater
import com.example.dgtimer.R
import com.example.dgtimer.activities.timer.TimerActivity
import com.example.dgtimer.databinding.ActivityMainBinding
import com.example.dgtimer.utils.Extensions.getPackageInfoCompat
import com.example.dgtimer.utils.Extensions.readUpdateNote
import com.example.dgtimer.utils.Extensions.setSearchFocus
import com.example.dgtimer.utils.getPackageInfoCompat
import com.example.dgtimer.utils.readUpdateNote
import com.example.dgtimer.utils.setSearchFocus
import com.example.dgtimer.utils.updateListWithSavingState
import com.example.dgtimer.widget.DGTimerWidgetProvider
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.stateIn
Expand All @@ -43,7 +44,8 @@ import javax.inject.Inject
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {

@Inject lateinit var appRater: AppRater
@Inject
lateinit var appRater: AppRater

private lateinit var binding: ActivityMainBinding
private val viewModel: MainViewModel by viewModels()
Expand Down Expand Up @@ -105,7 +107,10 @@ class MainActivity : AppCompatActivity() {
repeatOnLifecycle(Lifecycle.State.STARTED) {
launch {
viewModel.capsules.collect {
mainCapsulesAdapter.submitList(it)
mainCapsulesAdapter.updateListWithSavingState(
binding.rvCapsules,
it
)
updateNetworkDisconnectedText()
}
}
Expand All @@ -116,7 +121,10 @@ class MainActivity : AppCompatActivity() {
}
launch {
viewModel.searchedCapsules.collectLatest {
searchedCapsulesAdapter.submitList(it)
searchedCapsulesAdapter.updateListWithSavingState(
binding.rvSearchedCapsules,
it
)
}
}
launch {
Expand All @@ -129,6 +137,13 @@ class MainActivity : AppCompatActivity() {
toggleScrollTopFab(it)
}
}
launch {
viewModel.updateCapsuleMajorEvent.collect {
DGTimerWidgetProvider.notifyAppWidgetUpdate(
this@MainActivity
)
}
}
}
}
}
Expand All @@ -155,7 +170,7 @@ class MainActivity : AppCompatActivity() {
rvCapsules.adapter = mainCapsulesAdapter
rvSearchedCapsules.adapter = searchedCapsulesAdapter
rvCapsules.addOnScrollListener(
object: RecyclerView.OnScrollListener() {
object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
viewModel.setScrollYForShowingFab(dy)
}
Expand All @@ -172,7 +187,7 @@ class MainActivity : AppCompatActivity() {
readUpdateNote(packageInfo.versionName)?.let { updateNote ->
updateVersionNoteDialog = AlertDialog.Builder(this)
.setMessage(updateNote)
.setPositiveButton(R.string.check, null)
.setPositiveButton(R.string.ok, null)
.create().apply {
show()
}
Expand Down Expand Up @@ -218,6 +233,7 @@ class MainActivity : AppCompatActivity() {
}

private fun setSearchMode(isOn: Boolean) {
binding.llLogo.isVisible = !isOn
binding.rvCapsules.isVisible = !isOn
binding.rvSearchedCapsules.isVisible = isOn
binding.llSearch.isVisible = isOn
Expand Down Expand Up @@ -258,7 +274,7 @@ class MainActivity : AppCompatActivity() {

companion object {
fun createMainActivityIntent(
callerActivity: Activity
) = Intent(callerActivity, MainActivity::class.java)
context: Context
) = Intent(context, MainActivity::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import com.example.dgtimer.DGTimerPreferences
import com.example.dgtimer.PrefKey
import com.example.dgtimer.db.Capsule
import com.example.dgtimer.repo.CapsuleRepository
import com.example.dgtimer.utils.Extensions.trimAllSpaces
import com.example.dgtimer.utils.trimAllSpaces
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -39,18 +42,18 @@ class MainViewModel @Inject constructor(
MutableStateFlow("")
val searchedCapsules: Flow<List<Capsule>> =
capsules.combine(searchingWord) { capsules, word ->
val trimmedWord = word.trimAllSpaces()
val trimmedWord = word.trimAllSpaces().lowercase()
if (trimmedWord.isEmpty()) {
emptyList()
} else {
capsules?.filter { capsule ->
capsule.name.trimAllSpaces().contains(trimmedWord)
capsule.name.trimAllSpaces().lowercase().contains(trimmedWord)
} ?: emptyList()
}
}

fun updateCapsulesFromServer() {
repository.refreshCapsules() {
repository.refreshCapsules {
_isInitialized.value = true
}
}
Expand Down Expand Up @@ -78,9 +81,12 @@ class MainViewModel @Inject constructor(
}
}

private val _updateCapsuleMajorEvent: MutableSharedFlow<Unit> = MutableSharedFlow()
val updateCapsuleMajorEvent: SharedFlow<Unit> = _updateCapsuleMajorEvent.asSharedFlow()
fun updateCapsuleMajor(capsuleId: Int) {
viewModelScope.launch {
repository.updateCapsuleMajor(capsuleId)
_updateCapsuleMajorEvent.emit(Unit)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.example.dgtimer.AppRater.Companion.launchGooglePlayForRating
import com.example.dgtimer.R
import com.example.dgtimer.databinding.ActivitySettingsBinding
import com.example.dgtimer.utils.AlarmPlayerWrapper
import com.example.dgtimer.utils.Extensions.getPackageInfoCompat
import com.example.dgtimer.utils.getPackageInfoCompat
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -139,12 +139,18 @@ class SettingsActivity : AppCompatActivity() {
launch {
viewModel.volume.collectLatest {
binding.tvVolume.text = it.toString()
if (binding.sbVolume.progress != it) {
binding.sbVolume.progress = it
}
}
}

launch {
viewModel.amplitude.collectLatest {
binding.tvAmplitude.text = it.toString()
if (binding.sbAmplitude.progress != it) {
binding.sbAmplitude.progress = it
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.dgtimer.activities.timer

data class Counter(
val type: String,
val typeStringResId: Int,
val totalTime: Long,
val index: Int,
val isActive: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CounterView(
if (counter.index == 0 && counterViewCount > 1) {
context.getString(R.string.latte)
} else {
counter.type
context.getString(counter.typeStringResId)
}
root.setOnClickListener {
onClick?.invoke(counter.index)
Expand Down
Loading

0 comments on commit 1b7e4e5

Please sign in to comment.