Skip to content

Commit c87df08

Browse files
authored
Add the ShopFinder feature to the ui toolkit module (#61)
1 parent 8c016a8 commit c87df08

File tree

76 files changed

+3312
-140
lines changed

Some content is hidden

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

76 files changed

+3312
-140
lines changed

.phrase.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,37 +49,37 @@ phrase:
4949
params:
5050
<<: *defaults
5151
locale_id: b220db5757be359631c55ec54fb65ac6 # en-US
52-
tags: Onboarding
52+
tags: Onboarding,Shop
5353
- file: ./ui-toolkit/src/main/res/values-de/strings.xml
5454
params:
5555
<<: *defaults
5656
locale_id: 512f99f8cd03c80affd16303fb5de9c2 # de
57-
tags: Onboarding
57+
tags: Onboarding,Shop
5858
- file: ./ui-toolkit/src/main/res/values-fr/strings.xml
5959
params:
6060
<<: *defaults
6161
locale_id: edf0b29dd998221329199f185d360ae4 # fr
62-
tags: Onboarding
62+
tags: Onboarding,Shop
6363
- file: ./ui-toolkit/src/main/res/values-fr-rCH/strings.xml
6464
params:
6565
<<: *defaults
6666
locale_id: fae2e092d1704da2ed88f3f56eb6f219 # fr-CH
67-
tags: Onboarding
67+
tags: Onboarding,Shop
6868
- file: ./ui-toolkit/src/main/res/values-hu/strings.xml
6969
params:
7070
<<: *defaults
7171
locale_id: 8f797bd77008e27f6286531a5ad55f67 # hu
72-
tags: Onboarding
72+
tags: Onboarding,Shop
7373
- file: ./ui-toolkit/src/main/res/values-it/strings.xml
7474
params:
7575
<<: *defaults
7676
locale_id: a4dea5c3e2c77e7c6ea344e69db63ed9 # it
77-
tags: Onboarding
77+
tags: Onboarding,Shop
7878
- file: ./ui-toolkit/src/main/res/values-sk/strings.xml
7979
params:
8080
<<: *defaults
8181
locale_id: 9ee4c528e480d56878c98ee8bfbc521b # sk
82-
tags: Onboarding
82+
tags: Onboarding,Shop
8383

8484
# kotlin-sample module
8585
- file: ./kotlin-sample/src/main/res/values/strings.xml

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4-
## [0.69.0]
4+
## [0.69.0] (not yet released)
55

66
### Changed
77
- Added ui-toolkit for more realistic sample app with onboarding

core/src/main/java/io/snabble/sdk/Snabble.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,14 @@ object Snabble {
245245
*/
246246
var checkedInShop: Shop? = null
247247
set(value) {
248-
val currentShopId = this.checkedInShop?.id.orEmpty()
249-
val newShopId = value?.id.orEmpty()
248+
val currentShopId = this.checkedInShop?.id
249+
val newShopId = value?.id
250250
if (currentShopId != newShopId) {
251251
field = value
252-
if (newShopId == "") {
252+
if (newShopId.isNullOrEmpty()) {
253253
userPreferences.lastCheckedInShopId = null
254254
checkedInProject.value = null
255+
mutableCurrentCheckedInShop.value = null
255256
} else {
256257
userPreferences.lastCheckedInShopId = newShopId
257258

core/src/main/java/io/snabble/sdk/UserAgentInterceptor.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ internal class UserAgentInterceptor(context: Context) : Interceptor {
2222

2323
init {
2424
val appName = (context.packageManager.getApplicationLabel(context.applicationInfo)).toString()
25-
userAgent = "$appName/${Snabble.versionName} snabble/${Snabble.version} " +
25+
val appVersion = try {
26+
context.packageManager.getPackageInfo(context.packageName,0).versionName
27+
} catch (e: Exception) {
28+
"Unknown"
29+
}
30+
userAgent = "$appName/$appVersion snabble/${Snabble.version} " +
2631
"(Android ${Build.VERSION.RELEASE}; ${Build.BRAND}; " +
2732
"${Build.MODEL}) okhttp/${OkHttp.VERSION}"
2833
}

core/src/main/java/io/snabble/sdk/checkin/CheckInLocationManager.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ import android.Manifest
44
import android.annotation.SuppressLint
55
import android.app.Application
66
import android.content.Context
7-
import android.content.SharedPreferences
87
import android.content.pm.PackageManager
98
import android.location.*
109
import android.os.Bundle
11-
import android.util.Log
1210
import androidx.core.app.ActivityCompat
1311
import androidx.lifecycle.MutableLiveData
14-
import com.google.android.gms.tasks.Task
1512
import io.snabble.sdk.Snabble
1613
import io.snabble.sdk.utils.Dispatch
1714
import io.snabble.sdk.utils.Logger

core/src/main/java/io/snabble/sdk/checkin/CheckInManager.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ import android.os.Handler
77
import android.os.Looper
88
import androidx.annotation.RequiresPermission
99
import androidx.lifecycle.Observer
10-
import com.google.android.gms.maps.model.LatLng
1110
import io.snabble.sdk.Project
1211
import io.snabble.sdk.Shop
1312
import io.snabble.sdk.Snabble
1413
import io.snabble.sdk.utils.Dispatch
1514
import io.snabble.sdk.utils.Logger
1615
import java.util.concurrent.CopyOnWriteArrayList
1716
import java.util.concurrent.TimeUnit
18-
import kotlin.collections.HashMap
1917

2018
/**
2119
* Listener for check in states. Notifies about check in / check out and if multiple shops are
@@ -223,7 +221,6 @@ class CheckInManager(val snabble: Snabble,
223221

224222
if (lastCheckedInProject != newCheckedInProject) {
225223
lastCheckedInProject = newCheckedInProject
226-
Snabble.checkedInShop = null
227224
}
228225

229226
Snabble.checkedInShop = checkInShop

kotlin-compose-sample/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ plugins {
44
}
55

66
android {
7-
compileSdk 32
7+
compileSdk 33
88

99
defaultConfig {
1010
applicationId "io.snabble.sdk.composesample"
1111
minSdk 21
12-
targetSdk 32
12+
targetSdk 33
1313
versionCode 1
1414
versionName "1.0"
1515

@@ -58,12 +58,12 @@ dependencies {
5858
implementation "androidx.core:core-ktx:1.8.0"
5959
implementation "androidx.compose.ui:ui:$compose_version"
6060
implementation "androidx.compose.ui:ui-viewbinding:$compose_version"
61-
implementation "androidx.compose.material3:material3:1.0.0-alpha13"
61+
implementation "androidx.compose.material3:material3:1.0.0-beta01"
6262
implementation "com.google.android.material:material:1.6.1"
6363
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
64-
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.1"
65-
implementation "androidx.activity:activity-compose:1.4.0"
66-
implementation "androidx.navigation:navigation-compose:2.5.0-rc01"
64+
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
65+
implementation "androidx.activity:activity-compose:1.5.1"
66+
implementation "androidx.navigation:navigation-compose:2.5.1"
6767

6868
testImplementation "junit:junit:4.13.2"
6969

kotlin-customization-sample/src/main/java/io/snabble/sdk/customization/LoadingActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.content.Intent
44
import android.os.Bundle
55
import androidx.appcompat.app.AlertDialog
66
import androidx.appcompat.app.AppCompatActivity
7+
import io.snabble.sdk.BuildConfig
78
import io.snabble.sdk.InitializationState
89
import io.snabble.sdk.Snabble
910

kotlin-sample/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33

44
android {
5-
compileSdkVersion 31
5+
compileSdkVersion 33
66

77
defaultConfig {
88
applicationId 'io.snabble.sdk.sample'
99
minSdkVersion 21
10-
targetSdkVersion 31
10+
targetSdkVersion 33
1111
versionCode 1
1212
versionName '1.0'
1313

@@ -31,6 +31,7 @@ android {
3131
}
3232

3333
dependencies {
34+
implementation 'androidx.preference:preference-ktx:1.2.0'
3435
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:${project.desugarVersion}"
3536

3637
implementation project(':core')
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
package io.snabble.sdk.sample
22

3-
import android.Manifest
43
import android.os.Bundle
54
import android.view.LayoutInflater
65
import android.view.View
76
import android.view.ViewGroup
87
import android.widget.Button
9-
import android.widget.TextView
10-
import androidx.activity.result.contract.ActivityResultContracts
118
import androidx.fragment.app.Fragment
129
import androidx.navigation.fragment.findNavController
13-
import io.snabble.sdk.sample.R
10+
import io.snabble.sdk.sample.utils.PermissionSupport
1411

1512
class HomeFragment : Fragment() {
13+
1614
override fun onCreateView(
17-
inflater: LayoutInflater,
18-
container: ViewGroup?,
19-
savedInstanceState: Bundle?
15+
inflater: LayoutInflater,
16+
container: ViewGroup?,
17+
savedInstanceState: Bundle?
2018
): View? {
2119
val root = inflater.inflate(R.layout.fragment_home, container, false)
2220

2321
root.findViewById<Button>(R.id.show_payment_credentials).setOnClickListener {
2422
findNavController().navigate(R.id.navigation_payment_credentials)
2523
}
2624

27-
root.findViewById<Button>(R.id.request_location_permission).setOnClickListener {
28-
(requireActivity() as MainActivity).locationPermission.launch(Manifest.permission.ACCESS_FINE_LOCATION)
29-
}
25+
root.findViewById<Button>(R.id.request_location_permission)
26+
.setOnClickListener {
27+
(requireActivity() as? PermissionSupport)?.startLocationPermissionRequest()
28+
}
3029

3130
return root
3231
}
33-
}
32+
}

0 commit comments

Comments
 (0)