Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.2.0 Release! #9

Merged
merged 24 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 48 additions & 38 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "kr.yhs.traffic"
minSdk 26
targetSdk 33
versionCode 1111
versionName "1.1.1"
versionCode 1112
versionName "1.2.0"
}
buildTypes {
release {
Expand All @@ -22,7 +22,7 @@ android {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion "1.2.0"
kotlinCompilerExtensionVersion libs.versions.compose.get()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
Expand All @@ -39,51 +39,61 @@ android {
}

dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'com.google.android.gms:play-services-wearable:18.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.wear:wear:1.2.0'
implementation 'androidx.wear:wear-input:1.2.0-alpha02'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.security:security-crypto-ktx:1.1.0-alpha03'
implementation(libs.androidx.coreKtx)
implementation(libs.kotlin.reflect)
implementation(libs.percentlayout)
implementation(libs.legacy)
implementation(libs.lifecycle)
implementation(libs.security)

// Wearable
implementation(libs.wear)
implementation(libs.wear.input)
implementation(libs.wear.tile)
implementation(libs.wear.tile.material)

// Google Play Services
implementation(libs.google.gms.wearable)
implementation(libs.google.gms.location)

// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4'
implementation(libs.coroutines.android)
implementation(libs.coroutines.core)
implementation(libs.coroutines.guava)
implementation(libs.coroutines.playServices)

// accompanist pager
implementation 'com.google.accompanist:accompanist-pager:0.24.6-alpha'
implementation 'com.google.accompanist:accompanist-pager-indicators:0.24.6-alpha'
implementation 'com.google.accompanist:accompanist-permissions:0.24.6-alpha'
// Accompaist Pager & Permission
implementation(libs.accompaist.pager)
implementation(libs.accompaist.pagerIndicators)
implementation(libs.accompaist.permissions)

// Jetpack Compose
implementation "androidx.activity:activity-compose:1.6.0"
implementation "androidx.compose.ui:ui-tooling-preview:1.3.0-rc01"
implementation "androidx.compose.foundation:foundation:1.3.0-rc01"
implementation "androidx.compose.material:material-icons-extended:1.3.0-rc01"
implementation(libs.androidx.activity.compose)
implementation(libs.compose.uiToolingPreview)
implementation(libs.compose.foundation)
implementation(libs.compose.materialIconExtended)

// Jetpack Compose (Wearable)
implementation "androidx.wear.compose:compose-material:1.1.0-alpha07"
implementation "androidx.wear.compose:compose-foundation:1.1.0-alpha07"
implementation "androidx.wear.compose:compose-navigation:1.1.0-alpha07"
// Wear Jetpack Compose
implementation(libs.compose.wear.material)
implementation(libs.compose.wear.foundation)
implementation(libs.compose.wear.navigation)

// GMS Location
implementation 'com.google.android.gms:play-services-location:21.0.0'
// Horologist
implementation(libs.horologist.tiles)

// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
implementation(libs.retrofit.core)
implementation(libs.retrofit.converter.gson)
implementation(libs.retrofit.converter.scalars)

// Fragment
implementation(libs.androidx.fragment)
implementation(libs.androidx.fragmentKtx)

// For Testing
testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.3.0-rc01"
debugImplementation "androidx.compose.ui:ui-tooling:1.3.0-rc01"
testImplementation(libs.bundles.tests)
androidTestImplementation(libs.bundles.androidTest)
debugImplementation(libs.bundles.debugTest)

compileOnly 'com.google.android.wearable:wearable:2.9.0'
compileOnly(libs.wearable)
}
41 changes: 40 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,45 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application> <!-- Sensitive -->

<activity
android:name=".SettingTileActivity"
android:exported="true" />

<activity
android:name=".StationInfoActivity"
android:exported="true" />

<service
android:name="kr.yhs.traffic.tiles.services.Station1TileService"
android:icon="@mipmap/ic_launcher"
android:label="@string/station1_tile_service_title"
android:description="@string/station1_tile_service_description"
android:exported="true"
android:permission="com.google.android.wearable.permission.BIND_TILE_PROVIDER">

<intent-filter>
<action android:name="androidx.wear.tiles.action.BIND_TILE_PROVIDER" />
</intent-filter>

<meta-data android:name="androidx.wear.tiles.PREVIEW" android:resource="@mipmap/ic_launcher" />

</service>

<service
android:name="kr.yhs.traffic.tiles.services.Station2TileService"
android:label="@string/station2_tile_service_title"
android:description="@string/station2_tile_service_description"
android:exported="true"
android:permission="com.google.android.wearable.permission.BIND_TILE_PROVIDER">

<intent-filter>
<action android:name="androidx.wear.tiles.action.BIND_TILE_PROVIDER" />
</intent-filter>

<meta-data android:name="androidx.wear.tiles.PREVIEW" android:resource="@mipmap/ic_launcher" />

</service>
</application>

</manifest>
23 changes: 23 additions & 0 deletions app/src/main/java/kr/yhs/traffic/BaseEncryptedSharedPreference.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package kr.yhs.traffic

import android.content.Context
import android.content.SharedPreferences
import androidx.security.crypto.EncryptedSharedPreferences
import androidx.security.crypto.MasterKey

open class BaseEncryptedSharedPreference(private val context: Context) {
lateinit var masterKey: MasterKey

fun getPreferences(filename: String): SharedPreferences =
EncryptedSharedPreferences.create(
context, filename, masterKey,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)

fun masterKeyBuild() {
masterKey = MasterKey.Builder(context)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build()
}
}
28 changes: 9 additions & 19 deletions app/src/main/java/kr/yhs/traffic/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,25 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import com.google.android.gms.location.FusedLocationProviderClient
import com.google.android.gms.location.LocationServices
import kr.yhs.traffic.module.TrafficClient
import kr.yhs.traffic.ui.ComposeApp
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import kr.yhs.traffic.utils.ClientBuilder
import kr.yhs.traffic.utils.TrafficClient

class MainActivity : ComponentActivity() {
var fusedLocationClient: FusedLocationProviderClient? = null
var client: TrafficClient? = null
var spClient: SharedPreferencesClient? = null
private val sharedPreference = BaseEncryptedSharedPreference(this)

fun getPreferences(filename: String) = sharedPreference.getPreferences(filename)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val httpClient = OkHttpClient.Builder()
val retrofit = Retrofit.Builder()
.baseUrl("https://api.yhs.kr")
.addConverterFactory(GsonConverterFactory.create())
.client(httpClient.build())
.build()
sharedPreference.masterKeyBuild()
val clientBuilder = ClientBuilder()
clientBuilder.httpClient = clientBuilder.httpClientBuild()

val retrofit = clientBuilder.build()
client = retrofit.create(TrafficClient::class.java)
spClient = SharedPreferencesClient("traffic", this)
val versionCode = spClient!!.getInt("versionCode", default = 1005)
if (versionCode < 1006) {
// Conflict Prevention by Version Update
spClient!!.clear()
spClient!!.setInt("versionCode", 1006)
}

setContent {
ComposeApp(this).Content()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.yhs.traffic.ui.pages
package kr.yhs.traffic

const val STATION_TYPE = "stationType"

Expand Down
35 changes: 35 additions & 0 deletions app/src/main/java/kr/yhs/traffic/SettingTileActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package kr.yhs.traffic

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.fragment.app.FragmentActivity
import androidx.wear.tiles.TileService
import kr.yhs.traffic.ui.ComposeSettingTile
import kr.yhs.traffic.utils.ClientBuilder
import kr.yhs.traffic.utils.TrafficClient

class SettingTileActivity: FragmentActivity() {
var client: TrafficClient? = null
private val sharedPreference = BaseEncryptedSharedPreference(this)

fun getPreferences(filename: String) = sharedPreference.getPreferences(filename)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
sharedPreference.masterKeyBuild()
val clickableId = intent.getStringExtra(TileService.EXTRA_CLICKABLE_ID)
val stationTileType = StationTileType::class.sealedSubclasses.filter {
it.objectInstance?.id == clickableId
}[0].objectInstance

val clientBuilder = ClientBuilder()
clientBuilder.httpClient = clientBuilder.httpClientBuild()

val retrofit = clientBuilder.build()
client = retrofit.create(TrafficClient::class.java)

setContent {
ComposeSettingTile(this, stationTileType!!).Content()
}
}
}
Loading