aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java16
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java14
2 files changed, 14 insertions, 16 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java
index 92ed28ad2..36454d1cb 100644
--- a/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java
@@ -104,12 +104,12 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
if (snackBarCoordinator != null) {
this.snackBar = Snackbar.make(snackBarCoordinator, R.string.location_sharing_disabled, Snackbar.LENGTH_INDEFINITE);
snackBar.setAction(R.string.enable, view -> {
+ showLocation(null, "");
if (isLocationEnabled()) {
if (hasLocationPermission(LocationActivity.REQUEST_LOCATION_PERMISSION)) {
requestLocationUpdates();
}
} else {
- showLocation(null, null);
setShareButtonEnabled(false);
if (hasLocationPermission(LocationActivity.REQUEST_LOCATION_PERMISSION)) {
requestLocationUpdates();
@@ -142,7 +142,7 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
super.onResume();
if (isLocationEnabled()) {
this.snackBar.dismiss();
- showLocation(null, null);
+ showLocation(null, "");
} else {
this.snackBar.show();
}
@@ -208,7 +208,7 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
}
}
- private void showLocation(@Nullable Location location, @Nullable String address) {
+ private void showLocation(@Nullable Location location, String address) {
if (location == null && TextUtils.isEmpty(address)) { // no location and no address available
final WebView webView = findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
@@ -217,12 +217,12 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
String LocationName = "<b>" + mLocationName + "</b>";
final WebView webView = findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("file:///android_asset/map.html?lat=" + mLastLocation.getLatitude() + "&lon=" + mLastLocation.getLongitude() + "&name=" + LocationName);
+ webView.loadUrl("javascript:toCoordinates(" + mLastLocation.getLatitude() + "," + mLastLocation.getLongitude() + "," + "'" + LocationName + "'" +");");
} else if (location != null && !TextUtils.isEmpty(address)) { // location and address available
String LocationName = "<b>" + mLocationName + "</b><br>" + address;
final WebView webView = findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("file:///android_asset/map.html?lat=" + mLastLocation.getLatitude() + "&lon=" + mLastLocation.getLongitude() + "&name=" + LocationName);
+ webView.loadUrl("javascript:toCoordinates(" + mLastLocation.getLatitude() + "," + mLastLocation.getLongitude() + "," + "'" + LocationName + "'" +");");
}
}
@@ -238,12 +238,14 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
@Override
protected void onPreExecute() {
super.onPreExecute();
- showLocation(mLastLocation, null);
+ showLocation(mLastLocation, "");
}
@Override
protected Void doInBackground(Void... params) {
- address = getAddress(ShareLocationActivity.this, mLastLocation);
+ if (mLastLocation != null) {
+ address = getAddress(ShareLocationActivity.this, mLastLocation);
+ }
return null;
}
diff --git a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java
index 3cf0da9e9..aba15eb43 100644
--- a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java
@@ -66,7 +66,7 @@ public class ShowLocationActivity extends XmppActivity {
setTitle(getString(R.string.show_location));
setSupportActionBar(findViewById(R.id.toolbar));
configureActionBar(getSupportActionBar());
-
+ showLocation(null, "");
Intent intent = getIntent();
this.mLocationName = intent != null ? intent.getStringExtra("name") : null;
@@ -136,12 +136,8 @@ public class ShowLocationActivity extends XmppActivity {
super.onSaveInstanceState(outState);
}
- private void showLocation(@Nullable Location location, @Nullable String address) {
- if (location == null && TextUtils.isEmpty(address)) { // no location and no address available
- final WebView webView = findViewById(R.id.webView);
- webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("file:///android_asset/map.html");
- } else if (location != null && TextUtils.isEmpty(address)) { // location but no address available
+ private void showLocation(Location location, String address) {
+ if (location != null && TextUtils.isEmpty(address)) { // location but no address available
String LocationName = "<b>" + mLocationName + "</b>";
final WebView webView = findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
@@ -150,7 +146,7 @@ public class ShowLocationActivity extends XmppActivity {
String LocationName = "<b>" + mLocationName + "</b><br>" + address;
final WebView webView = findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
- webView.loadUrl("file:///android_asset/map.html?lat=" + location.getLatitude() + "&lon=" + location.getLongitude() + "&name=" + LocationName);
+ webView.loadUrl("javascript:toCoordinates(" + location.getLatitude() + "," + location.getLongitude() + "," + "'" + LocationName + "'" +");");
}
}
@@ -182,7 +178,7 @@ public class ShowLocationActivity extends XmppActivity {
@Override
protected void onPreExecute() {
super.onPreExecute();
- showLocation(location, null);
+ showLocation(location, "");
}
@Override