Skip to content

Commit b7585d2

Browse files
authored
Merge pull request #128 from arcao/dev
Release version 3.0.7
2 parents 4efb7a2 + df27319 commit b7585d2

33 files changed

+167
-198
lines changed

.idea/codeStyles/Project.xml

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ dependencies {
1111
implementation "androidx.cardview:cardview:$card_view_version"
1212
implementation "com.google.android.material:material:$material_version"
1313
implementation "androidx.constraintlayout:constraintlayout:$constraint_layout_version"
14-
implementation "androidx.preference:preference:$preference_version"
14+
implementation "androidx.preference:preference-ktx:$preference_version"
1515

16-
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
17-
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
16+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
17+
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
1818
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
1919

2020
implementation "androidx.core:core-ktx:$core_version"
@@ -23,7 +23,7 @@ dependencies {
2323
implementation "androidx.fragment:fragment-ktx:$fragment_version"
2424
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
2525
implementation "androidx.multidex:multidex:$multidex_version"
26-
implementation "androidx.paging:paging-runtime:$paging_version"
26+
implementation "androidx.paging:paging-runtime-ktx:$paging_version"
2727

2828
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:$desugar_jdk_libs_version"
2929

app/src/main/AndroidManifest.xml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
android:exported="true"
7878
android:icon="@drawable/ic_action_search"
7979
android:label="@string/launcher_nearest_geocaches"
80+
android:launchMode="singleTask"
8081
android:theme="@style/AppTheme.DialogWhenLarge">
8182
<intent-filter>
8283
<action android:name="locus.api.android.INTENT_ITEM_POINT_TOOLS" />
@@ -95,6 +96,7 @@
9596
android:name=".settings.SettingsActivity"
9697
android:exported="false"
9798
android:label="@string/action_settings"
99+
android:launchMode="singleTask"
98100
android:theme="@style/AppTheme.Settings">
99101
<intent-filter android:label="@string/app_name">
100102
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
@@ -112,6 +114,7 @@
112114
android:exported="true"
113115
android:icon="@drawable/ic_action_update"
114116
android:label="@string/launcher_update_geocache"
117+
android:launchMode="singleTask"
115118
android:theme="@style/AppTheme.Invisible">
116119
<intent-filter>
117120
<action android:name="locus.api.android.INTENT_ITEM_POINT_TOOLS" />
@@ -128,6 +131,7 @@
128131
android:exported="true"
129132
android:icon="@drawable/ic_action_download_logs"
130133
android:label="@string/launcher_download_logs"
134+
android:launchMode="singleTask"
131135
android:targetActivity=".update.UpdateActivity">
132136
<intent-filter>
133137
<action android:name="locus.api.android.INTENT_ITEM_POINT_TOOLS" />
@@ -144,6 +148,7 @@
144148
android:exported="true"
145149
android:icon="@drawable/ic_action_update"
146150
android:label="@string/launcher_update_geocaches"
151+
android:launchMode="singleTask"
147152
android:theme="@style/AppTheme.Invisible">
148153
<intent-filter>
149154
<action android:name="locus.api.android.INTENT_ITEM_POINTS_SCREEN_TOOLS" />
@@ -154,6 +159,7 @@
154159
android:name=".importgc.ImportUrlActivity"
155160
android:exported="true"
156161
android:label="@string/launcher_import_geocache"
162+
android:launchMode="singleTask"
157163
android:theme="@style/AppTheme.Invisible">
158164
<intent-filter>
159165
<action android:name="android.intent.action.VIEW" />
@@ -217,6 +223,7 @@
217223
android:name=".dashboard.DashboardActivity"
218224
android:exported="true"
219225
android:label="@string/app_name"
226+
android:launchMode="singleTask"
220227
android:theme="@style/AppTheme.Dashboard">
221228
<intent-filter>
222229
<action android:name="android.intent.action.MAIN" />
@@ -225,10 +232,12 @@
225232
</activity>
226233
<activity
227234
android:name=".authentication.LoginActivity"
228-
android:exported="true"
229235
android:label="@string/title_login"
230-
android:launchMode="singleTop"
231-
android:theme="@style/AppTheme">
236+
android:launchMode="singleTask"
237+
android:theme="@style/AppTheme" />
238+
<activity
239+
android:name=".authentication.RedirectUriReceiverActivity"
240+
android:exported="true">
232241
<intent-filter>
233242
<action android:name="android.intent.action.VIEW" />
234243

@@ -245,6 +254,7 @@
245254
android:exported="true"
246255
android:icon="@drawable/ic_action_gc_input"
247256
android:label="@string/launcher_import_from_gc"
257+
android:launchMode="singleTask"
248258
android:theme="@style/AppTheme.Invisible">
249259
<intent-filter>
250260
<action android:name="locus.api.android.INTENT_ITEM_MAIN_FUNCTION_GC" />
@@ -260,6 +270,7 @@
260270
android:exported="true"
261271
android:icon="@drawable/ic_action_import_bookmark"
262272
android:label="@string/launcher_import_bookmarks"
273+
android:launchMode="singleTask"
263274
android:theme="@style/AppTheme.DialogWhenLarge">
264275
<intent-filter>
265276
<action android:name="locus.api.android.INTENT_ITEM_MAIN_FUNCTION_GC" />
@@ -271,6 +282,7 @@
271282
android:exported="true"
272283
android:icon="@drawable/ic_action_watch_geocache"
273284
android:label="@string/launcher_watch_geocache"
285+
android:launchMode="singleTask"
274286
android:theme="@style/AppTheme.Invisible">
275287
<intent-filter>
276288
<action android:name="locus.api.android.INTENT_ITEM_POINT_TOOLS" />
@@ -286,6 +298,7 @@
286298
android:exported="true"
287299
android:icon="@drawable/ic_action_bookmark_geocache"
288300
android:label="@string/launcher_bookmark_geocache"
301+
android:launchMode="singleTask"
289302
android:theme="@style/AppTheme.Invisible">
290303
<intent-filter>
291304
<action android:name="locus.api.android.INTENT_ITEM_POINT_TOOLS" />
@@ -301,6 +314,7 @@
301314
android:exported="true"
302315
android:icon="@drawable/ic_action_live_map_download_caches"
303316
android:label="@string/launcher_download_rectangle"
317+
android:launchMode="singleTask"
304318
android:theme="@style/AppTheme.Invisible">
305319
<intent-filter>
306320
<action android:name="locus.api.android.INTENT_ITEM_MAIN_FUNCTION_GC" />
@@ -312,18 +326,22 @@
312326
<activity-alias
313327
android:name=".DashboardActivity"
314328
android:exported="true"
329+
android:launchMode="singleTask"
315330
android:targetActivity=".dashboard.DashboardActivity" />
316331
<activity-alias
317332
android:name=".SearchNearestActivity"
318333
android:exported="true"
334+
android:launchMode="singleTask"
319335
android:targetActivity=".search_nearest.SearchNearestActivity" />
320336
<activity-alias
321337
android:name=".ImportFromGCActivity"
322338
android:exported="true"
339+
android:launchMode="singleTask"
323340
android:targetActivity=".importgc.ImportGeocacheCodeActivity" />
324341
<activity-alias
325342
android:name=".ImportBookmarkActivity"
326343
android:exported="true"
344+
android:launchMode="singleTask"
327345
android:targetActivity=".import_bookmarks.ImportBookmarkActivity" />
328346
</application>
329347
</manifest>

app/src/main/java/com/arcao/feedback/FeedbackHelper.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ class FeedbackHelper(
6262
}
6363
}
6464

65+
@Suppress("BlockingMethodInNonBlockingContext")
6566
@Throws(IOException::class)
6667
private suspend fun createReport(reportFile: File) {
67-
reportFile.parentFile.mkdirs()
68+
reportFile.parentFile?.mkdirs()
6869

6970
if (reportFile.exists()) {
7071
Timber.d("Report file $reportFile already exist.")
@@ -78,6 +79,7 @@ class FeedbackHelper(
7879
Timber.d("Report created.")
7980
}
8081

82+
@Suppress("BlockingMethodInNonBlockingContext")
8183
@Throws(IOException::class)
8284
private suspend fun writeCollectors(zos: ZipOutputStream) {
8385
for (collector in collectors) {

app/src/main/java/com/arcao/feedback/collector/ConfigurationCollector.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.util.SparseArray
66
import timber.log.Timber
77
import java.lang.reflect.Field
88
import java.lang.reflect.Modifier
9+
import java.util.Locale
910

1011
class ConfigurationCollector(private val context: Context) : Collector() {
1112
override val name: String
@@ -122,7 +123,7 @@ class ConfigurationCollector(private val context: Context) : Collector() {
122123
if (f.type == Int::class.javaPrimitiveType) {
123124
result.append(getFieldValueName(conf, f))
124125
} else if (f.get(conf) != null) {
125-
result.append(f.get(conf).toString())
126+
result.append(f.get(conf)?.toString())
126127
}
127128
result.append('\n')
128129
}
@@ -156,7 +157,7 @@ class ConfigurationCollector(private val context: Context) : Collector() {
156157
FIELD_SCREENLAYOUT -> return activeFlags(VALUE_ARRAYS[PREFIX_SCREENLAYOUT]!!, f.getInt(conf))
157158
else -> {
158159
val values =
159-
VALUE_ARRAYS[fieldName.toUpperCase() + '_'] // Unknown field, return the raw int as String
160+
VALUE_ARRAYS[fieldName.toUpperCase(Locale.ROOT) + '_'] // Unknown field, return the raw int as String
160161
?: return f.getInt(conf).toString()
161162

162163
return values.get(f.getInt(conf)) // Unknown value, return the raw int as String

app/src/main/java/com/arcao/feedback/collector/ConstantsCollector.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ConstantsCollector(private val source: Class<*>, private val prefix: Strin
1616
result.append(
1717
when (val value = field.get(null)) {
1818
is Array<*> -> Arrays.toString(value)
19-
else -> value.toString()
19+
else -> value?.toString()
2020
}
2121
)
2222
} catch (e: IllegalArgumentException) {

app/src/main/java/com/arcao/feedback/collector/SharedPreferencesCollector.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.arcao.feedback.collector
22

33
import android.content.Context
44
import android.content.SharedPreferences
5-
import android.preference.PreferenceManager
5+
import androidx.preference.PreferenceManager
66

77
class SharedPreferencesCollector @JvmOverloads constructor(
88
private val context: Context,

app/src/main/java/com/arcao/geocaching4locus/App.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
@file:Suppress("DEPRECATION")
2+
13
package com.arcao.geocaching4locus
24

35
import android.app.Application
46
import android.content.Context
57
import android.os.Build
6-
import android.preference.PreferenceManager
78
import android.webkit.CookieManager
89
import android.webkit.CookieSyncManager
910
import androidx.annotation.WorkerThread
1011
import androidx.core.content.edit
1112
import androidx.core.content.pm.PackageInfoCompat
1213
import androidx.multidex.MultiDex
14+
import androidx.preference.PreferenceManager
1315
import com.arcao.feedback.feedbackModule
1416
import com.arcao.geocaching4locus.authentication.util.isPremium
1517
import com.arcao.geocaching4locus.base.constants.CrashlyticsConstants
@@ -29,8 +31,8 @@ import timber.log.Timber
2931
import java.util.UUID
3032

3133
class App : Application() {
32-
val accountManager by inject<AccountManager>()
33-
val analyticsManager by inject<AnalyticsManager>()
34+
private val accountManager by inject<AccountManager>()
35+
private val analyticsManager by inject<AnalyticsManager>()
3436

3537
private val deviceId: String by lazy {
3638
val pref = PreferenceManager.getDefaultSharedPreferences(this)
@@ -44,7 +46,7 @@ class App : Application() {
4446
putString(PrefConstants.DEVICE_ID, value)
4547
}
4648
}
47-
value
49+
value.orEmpty()
4850
}
4951

5052
val version: String by lazy {

app/src/main/java/com/arcao/geocaching4locus/authentication/LoginActivity.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.app.Activity
44
import android.content.ActivityNotFoundException
55
import android.content.Context
66
import android.content.Intent
7+
import android.net.Uri
78
import android.os.Bundle
89
import android.view.MenuItem
910
import android.view.View
@@ -44,8 +45,8 @@ class LoginActivity : AbstractActionBarActivity() {
4445

4546
Timber.i("source: login")
4647

47-
if (savedInstanceState == null) {
48-
if (!viewModel.handleIntent(intent)) {
48+
if (!viewModel.handleIntent(intent)) {
49+
if (savedInstanceState == null) {
4950
viewModel.startLogin()
5051
}
5152
}
@@ -128,5 +129,12 @@ class LoginActivity : AbstractActionBarActivity() {
128129
fun createIntent(context: Context): Intent {
129130
return Intent(context, LoginActivity::class.java)
130131
}
132+
133+
fun createResponseHandlingIntent(context: Context, responseUri: Uri?): Intent {
134+
val intent = createIntent(context)
135+
intent.data = responseUri
136+
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
137+
return intent
138+
}
131139
}
132140
}

app/src/main/java/com/arcao/geocaching4locus/authentication/LoginViewModel.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ class LoginViewModel(
117117

118118
fun handleIntent(intent: Intent): Boolean {
119119
val data = intent.data
120-
val action = intent.action
121120

122-
if (Intent.ACTION_VIEW == action && data != null && data.getQueryParameter(OAuthConstants.CODE) != null) {
121+
if (data?.getQueryParameter(OAuthConstants.CODE) != null) {
123122
val code = requireNotNull(data.getQueryParameter(OAuthConstants.CODE))
124123
fromIntent = true
125124
finishLogin(code)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.arcao.geocaching4locus.authentication
2+
3+
import android.app.Activity
4+
import android.os.Bundle
5+
6+
class RedirectUriReceiverActivity : Activity() {
7+
override fun onCreate(savedInstanceState: Bundle?) {
8+
super.onCreate(savedInstanceState)
9+
10+
// redirect to LoginActivity with FLAG_SINGLE_TOP and FLAG_CLEAR_TOP to close Chrome Custom
11+
// Tab
12+
startActivity(LoginActivity.createResponseHandlingIntent(this, this.intent.data))
13+
finish()
14+
}
15+
}

0 commit comments

Comments
 (0)