Skip to content

Commit

Permalink
Switched to Jetpack Compose
Browse files Browse the repository at this point in the history
  • Loading branch information
ElishaAz committed Sep 28, 2023
1 parent c1f161c commit cf5cf1b
Show file tree
Hide file tree
Showing 46 changed files with 1,199 additions and 1,043 deletions.
61 changes: 56 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ android {
}
buildFeatures {
viewBinding true
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.3"
}

namespace 'com.elishaazaria.sayboard'

packagingOptions {
Expand Down Expand Up @@ -63,10 +68,10 @@ dependencies {
implementation group: 'com.alphacephei', name: 'vosk-android', version: '0.3.32'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1'
implementation 'androidx.navigation:navigation-fragment:2.7.1'
implementation 'androidx.navigation:navigation-ui:2.7.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
implementation 'androidx.navigation:navigation-fragment:2.7.2'
implementation 'androidx.navigation:navigation-ui:2.7.2'
implementation 'androidx.preference:preference:1.2.1'

implementation 'org.greenrobot:eventbus:3.3.1'
Expand All @@ -79,5 +84,51 @@ dependencies {
compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+


implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.0'

implementation 'dev.patrickgold.jetpref:jetpref-datastore-model:0.1.0-beta14'
implementation 'dev.patrickgold.jetpref:jetpref-datastore-ui:0.1.0-beta14'
implementation 'dev.patrickgold.jetpref:jetpref-material-ui:0.1.0-beta14'

def composeBom = platform('androidx.compose:compose-bom:2023.08.00')
implementation composeBom
androidTestImplementation composeBom

// Choose one of the following:
// Material Design 3
implementation 'androidx.compose.material3:material3'
// or Material Design 2
// implementation 'androidx.compose.material:material'
// or skip Material Design and build directly on top of foundational components
// implementation 'androidx.compose.foundation:foundation'
// or only import the main APIs for the underlying toolkit systems,
// such as input and measurement/layout
// implementation 'androidx.compose.ui:ui'

// Android Studio Preview support
implementation 'androidx.compose.ui:ui-tooling-preview'
debugImplementation 'androidx.compose.ui:ui-tooling'

// UI Tests
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-test-manifest'

// Optional - Included automatically by material, only add when you need
// the icons but not the material library (e.g. when using Material3 or a
// custom design system based on Foundation)
// implementation 'androidx.compose.material:material-icons-core'
// Optional - Add full set of material icons
implementation 'androidx.compose.material:material-icons-extended'
// Optional - Add window size utils
implementation 'androidx.compose.material3:material3-window-size-class'

// Optional - Integration with activities
implementation 'androidx.activity:activity-compose:1.7.2'
// Optional - Integration with ViewModels
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2'
// Optional - Integration with LiveData
implementation 'androidx.compose.runtime:runtime-livedata'
// Optional - Integration with RxJava
implementation 'androidx.compose.runtime:runtime-rxjava2'

}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
Expand Down
90 changes: 90 additions & 0 deletions app/src/main/java/com/elishaazaria/sayboard/AppPrefs.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.elishaazaria.sayboard

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import com.elishaazaria.sayboard.data.KeepScreenAwakeMode
import dev.patrickgold.jetpref.datastore.JetPref
import dev.patrickgold.jetpref.datastore.model.PreferenceModel

// Defining a getter function for easy retrieval of the AppPrefs model.
// You can name this however you want, the convention is <projectName>PreferenceModel
fun sayboardPreferenceModel() = JetPref.getOrCreatePreferenceModel(AppPrefs::class, ::AppPrefs)

// Defining a preference model for our app prefs
// The name we give here is the file name of the preferences and is saved
// within the app's `jetpref_datastore` directory.
class AppPrefs : PreferenceModel("example-app-preferences") {
val logicKeepScreenAwake = enum(
key = "e_keep_screen_awake",
default = KeepScreenAwakeMode.NEVER
)

val logicListenImmediately = boolean(
key = "b_listen_immediately",
default = false
)

val logicAutoSwitchBack = boolean(
key = "b_auto_switch_back_ime",
default = false
)

val logicWeakRefToModel = boolean(
key = "b_weak_ref_to_model",
default = false
)

val uiDayForegroundMaterialYou = boolean(
key = "b_day_foreground_material_you",
default = false
)
val uiDayForeground = int(
key = "c_day_foreground_color",
default = Color(0xFF377A00).toArgb()
)
val uiDayBackground = int(
key = "c_day_background_color",
default = Color(0xFFFFFFFF).toArgb()
)

val uiNightForegroundMaterialYou = boolean(
key = "b_night_foreground_material_you",
default = false
)
val uiNightForeground = int(
key = "c_night_foreground_color",
default = Color(0xFF66BB6A).toArgb()
)
val uiNightBackground = int(
key = "c_night_background_color",
default = Color(0xFF000000).toArgb()
)

val uiKeyboardHeightPortrait = float(
key = "f_keyboard_height_portrait",
default = 0.3f
)

val uiKeyboardHeightLandscape = float(
key = "f_keyboard_height_landscape",
default = 0.5f
)


val showExampleGroup = boolean(
key = "show_example_group",
default = true,
)
val boxSizePortrait = int(
key = "box_size_portrait",
default = 40,
)
val boxSizeLandscape = int(
key = "box_size_landscape",
default = 20,
)
val welcomeMessage = string(
key = "welcome_message",
default = "Hello world!",
)
}
13 changes: 13 additions & 0 deletions app/src/main/java/com/elishaazaria/sayboard/SayboardApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@ package com.elishaazaria.sayboard

import android.app.Application
import com.elishaazaria.sayboard.AppCtx.setAppCtx
import dev.patrickgold.jetpref.datastore.JetPref
import org.greenrobot.eventbus.EventBus

class SayboardApplication : Application() {
private val prefs by sayboardPreferenceModel()
override fun onCreate() {
super.onCreate()

// Optionally initialize global JetPref configs. This must be done before
// any preference datastore is initialized!
JetPref.configure(
saveIntervalMs = 500,
encodeDefaultValues = true,
)

// Initialize your datastore here (required)
prefs.initializeBlocking(this)

EventBus.builder().logNoSubscriberMessages(false).sendNoSubscriberEvent(false)
.installDefaultEventBus()
setAppCtx(this)
Expand Down
Loading

0 comments on commit cf5cf1b

Please sign in to comment.