Skip to content

Commit af4cc3c

Browse files
authored
Merge pull request #830 from modos189/feature/user-location
Add browser geolocation to user-location plugin
2 parents e66a03e + d27e620 commit af4cc3c

File tree

6 files changed

+293
-175
lines changed

6 files changed

+293
-175
lines changed

build_mobile.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ def build_mobile(source, scripts_dir, out_dir=None, out_name=None):
8080
assets_dir,
8181
ignore=shutil.ignore_patterns(*settings.ignore_patterns),
8282
)
83-
user_location_plug = source / 'plugins' / 'user-location.js'
84-
build_plugin.process_file(user_location_plug, assets_dir)
8583

8684
if settings.gradle_buildtype == 'copyonly':
8785
return

mobile/app/src/main/java/org/exarhteam/iitc_mobile/IITC_Mobile.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,33 @@ public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences,
343343
final int mode = Integer.parseInt(mSharedPrefs.getString("pref_user_location_mode", "0"));
344344
if (mUserLocation.setLocationMode(mode))
345345
mReloadNeeded = true;
346+
347+
// Sync plugin checkbox state with location mode preference
348+
boolean shouldBeEnabled = mode != 0;
349+
boolean isCurrentlyEnabled = mSharedPrefs.getBoolean("user-location.user.js", false);
350+
351+
if (shouldBeEnabled != isCurrentlyEnabled) {
352+
SharedPreferences.Editor editor = mSharedPrefs.edit();
353+
editor.putBoolean("user-location.user.js", shouldBeEnabled);
354+
editor.apply();
355+
}
356+
return;
357+
} else if (key.equals("user-location.user.js")) {
358+
// Sync location mode preference when user-location plugin checkbox changes
359+
boolean pluginEnabled = sharedPreferences.getBoolean(key, false);
360+
String currentMode = mSharedPrefs.getString("pref_user_location_mode", "0");
361+
362+
if (pluginEnabled && "0".equals(currentMode)) {
363+
// Enable location mode when plugin is enabled (default to show position)
364+
SharedPreferences.Editor editor = mSharedPrefs.edit();
365+
editor.putString("pref_user_location_mode", "1");
366+
editor.apply();
367+
} else if (!pluginEnabled && !"0".equals(currentMode)) {
368+
// Disable location mode when plugin is disabled
369+
SharedPreferences.Editor editor = mSharedPrefs.edit();
370+
editor.putString("pref_user_location_mode", "0");
371+
editor.apply();
372+
}
346373
return;
347374
} else if (key.equals("pref_language")) {
348375
final String lang = mSharedPrefs.getString("pref_language", this.getCurrentLanguage().toString());

mobile/app/src/main/java/org/exarhteam/iitc_mobile/IITC_WebViewClient.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ private void loadScripts(final IITC_WebView view) {
9191
scripts.add("plugin" + DOMAIN + "/" + plugin.filename);
9292
}
9393

94-
// Inject user location script if enabled
95-
if (Integer.parseInt(mSharedPrefs.getString("pref_user_location_mode", "0")) != 0) {
96-
scripts.add("script" + DOMAIN + "/user-location.user.js");
97-
}
98-
9994
scripts.add("script" + DOMAIN + "/total-conversion-build.user.js");
10095

10196
final String js = "(function(){['" + TextUtils.join("','", scripts) + "'].forEach(function(src) {" +

mobile/plugins/user-location.js

Lines changed: 0 additions & 165 deletions
This file was deleted.

mobile/plugins/user-location.css renamed to plugins/user-location.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
.user-location .container {
66
height: 32px;
77
width: 32px;
8-
transform-origin: center;
98
-webkit-transform-origin: center;
9+
transform-origin: center;
1010
}
1111

1212
.user-location .container .inner,
@@ -42,8 +42,8 @@
4242
}
4343

4444
.user-location .circle .inner {
45-
transform: scale(0.6);
4645
-webkit-transform: scale(0.6);
46+
transform: scale(0.6);
4747
}
4848

4949
.user-location .arrow .inner,
@@ -59,7 +59,7 @@
5959
}
6060

6161
.user-location .arrow .inner {
62-
transform: scale(0.6) translateY(15%);
6362
-webkit-transform: scale(0.6) translateY(15%);
63+
transform: scale(0.6) translateY(15%);
6464
}
6565

0 commit comments

Comments
 (0)