diff --git a/src/main/java/eu/siacs/conversations/ui/LocationActivity.java b/src/main/java/eu/siacs/conversations/ui/LocationActivity.java
index bbb536c34..2a8ab38bd 100644
--- a/src/main/java/eu/siacs/conversations/ui/LocationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/LocationActivity.java
@@ -50,7 +50,7 @@ public abstract class LocationActivity extends ActionBarActivity implements Loca
protected static final String KEY_ZOOM_LEVEL = "zoom";
protected Location myLoc = null;
- protected MapView map = null;
+ private MapView map = null;
protected IMapController mapController = null;
protected Bitmap marker_icon;
@@ -137,9 +137,8 @@ public abstract class LocationActivity extends ActionBarActivity implements Loca
}
}
- protected void setupMapView(final GeoPoint pos) {
- // Get map view and configure it.
- map = findViewById(R.id.map);
+ protected void setupMapView(MapView mapView, final GeoPoint pos) {
+ map = mapView;
map.setTileSource(tileSource());
map.setBuiltInZoomControls(false);
map.setMultiTouchControls(true);
diff --git a/src/main/java/eu/siacs/conversations/ui/ShareLocationActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareLocationActivity.java
index afd5fde7a..f85d0cc80 100644
--- a/src/main/java/eu/siacs/conversations/ui/ShareLocationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ShareLocationActivity.java
@@ -3,22 +3,22 @@ package eu.siacs.conversations.ui;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.databinding.DataBindingUtil;
import android.location.Location;
import android.location.LocationListener;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
-import android.support.design.widget.CoordinatorLayout;
-import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
+import android.support.v7.widget.Toolbar;
import android.view.View;
-import android.widget.Button;
import org.osmdroid.api.IGeoPoint;
import org.osmdroid.util.GeoPoint;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
+import eu.siacs.conversations.databinding.ActivityShareLocationBinding;
import eu.siacs.conversations.ui.util.LocationHelper;
import eu.siacs.conversations.ui.widget.Marker;
import eu.siacs.conversations.ui.widget.MyLocation;
@@ -26,6 +26,7 @@ import eu.siacs.conversations.ui.widget.MyLocation;
public class ShareLocationActivity extends LocationActivity implements LocationListener {
private Snackbar snackBar;
+ private ActivityShareLocationBinding binding;
private boolean marker_fixed_to_loc = false;
private static final String KEY_FIXED_TO_LOC = "fixed_to_loc";
private Boolean noAskAgain = false;
@@ -50,59 +51,48 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_share_location);
- setSupportActionBar(findViewById(R.id.toolbar));
+ this.binding = DataBindingUtil.setContentView(this,R.layout.activity_share_location);
+ setSupportActionBar((Toolbar) binding.toolbar);
configureActionBar(getSupportActionBar());
- setupMapView(Config.Map.INITIAL_POS);
+ setupMapView(binding.map, Config.Map.INITIAL_POS);
- // Setup the cancel button
- final Button cancelButton = findViewById(R.id.cancel_button);
- cancelButton.setOnClickListener(view -> {
+ this.binding.cancelButton.setOnClickListener(view -> {
setResult(RESULT_CANCELED);
finish();
});
- final CoordinatorLayout snackBarCoordinator = findViewById(R.id.snackbarCoordinator);
- if (snackBarCoordinator != null) {
- this.snackBar = Snackbar.make(snackBarCoordinator, R.string.location_disabled, Snackbar.LENGTH_INDEFINITE);
- snackBar.setAction(R.string.enable, view -> {
- if (isLocationEnabledAndAllowed()) {
- updateUi();
- } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !hasLocationPermissions()) {
- requestPermissions(REQUEST_CODE_SNACKBAR_PRESSED);
- } else if (!isLocationEnabled()) {
- startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
- }
- });
- }
+ this.snackBar = Snackbar.make(this.binding.snackbarCoordinator, R.string.location_disabled, Snackbar.LENGTH_INDEFINITE);
+ this.snackBar.setAction(R.string.enable, view -> {
+ if (isLocationEnabledAndAllowed()) {
+ updateUi();
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !hasLocationPermissions()) {
+ requestPermissions(REQUEST_CODE_SNACKBAR_PRESSED);
+ } else if (!isLocationEnabled()) {
+ startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
+ }
+ });
- // Setup the share button
- final Button shareButton = findViewById(R.id.share_button);
- if (shareButton != null) {
- shareButton.setOnClickListener(view -> {
- final Intent result = new Intent();
+ this.binding.shareButton.setOnClickListener(view -> {
+ final Intent result = new Intent();
- if (marker_fixed_to_loc && myLoc != null) {
- result.putExtra("latitude", myLoc.getLatitude());
- result.putExtra("longitude", myLoc.getLongitude());
- result.putExtra("altitude", myLoc.getAltitude());
- result.putExtra("accuracy", (int) myLoc.getAccuracy());
- } else {
- final IGeoPoint markerPoint = map.getMapCenter();
- result.putExtra("latitude", markerPoint.getLatitude());
- result.putExtra("longitude", markerPoint.getLongitude());
- }
+ if (marker_fixed_to_loc && myLoc != null) {
+ result.putExtra("latitude", myLoc.getLatitude());
+ result.putExtra("longitude", myLoc.getLongitude());
+ result.putExtra("altitude", myLoc.getAltitude());
+ result.putExtra("accuracy", (int) myLoc.getAccuracy());
+ } else {
+ final IGeoPoint markerPoint = this.binding.map.getMapCenter();
+ result.putExtra("latitude", markerPoint.getLatitude());
+ result.putExtra("longitude", markerPoint.getLongitude());
+ }
- setResult(RESULT_OK, result);
- finish();
- });
- }
+ setResult(RESULT_OK, result);
+ finish();
+ });
this.marker_fixed_to_loc = isLocationEnabledAndAllowed();
- // Setup the fab button
- final FloatingActionButton toggleFixedMarkerButton = findViewById(R.id.fab);
- toggleFixedMarkerButton.setOnClickListener(view -> {
+ this.binding.fab.setOnClickListener(view -> {
if (!marker_fixed_to_loc) {
if (!isLocationEnabled()) {
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
@@ -163,14 +153,14 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
protected void updateLocationMarkers() {
super.updateLocationMarkers();
if (this.myLoc != null) {
- this.map.getOverlays().add(new MyLocation(this, null, this.myLoc));
+ this.binding.map.getOverlays().add(new MyLocation(this, null, this.myLoc));
if (this.marker_fixed_to_loc) {
- map.getOverlays().add(new Marker(marker_icon, new GeoPoint(this.myLoc)));
+ this.binding.map.getOverlays().add(new Marker(marker_icon, new GeoPoint(this.myLoc)));
} else {
- map.getOverlays().add(new Marker(marker_icon));
+ this.binding.map.getOverlays().add(new Marker(marker_icon));
}
} else {
- map.getOverlays().add(new Marker(marker_icon));
+ this.binding.map.getOverlays().add(new Marker(marker_icon));
}
}
@@ -229,20 +219,18 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
this.snackBar.show();
}
- // Setup the fab button
- final FloatingActionButton fab = findViewById(R.id.fab);
if (isLocationEnabledAndAllowed()) {
- fab.setVisibility(View.VISIBLE);
+ this.binding.fab.setVisibility(View.VISIBLE);
runOnUiThread(() -> {
- fab.setImageResource(marker_fixed_to_loc ? R.drawable.ic_gps_fixed_white_24dp :
+ this.binding.fab.setImageResource(marker_fixed_to_loc ? R.drawable.ic_gps_fixed_white_24dp :
R.drawable.ic_gps_not_fixed_white_24dp);
- fab.setContentDescription(getResources().getString(
+ this.binding.fab.setContentDescription(getResources().getString(
marker_fixed_to_loc ? R.string.action_unfix_from_location : R.string.action_fix_to_location
));
- fab.invalidate();
+ this.binding.fab.invalidate();
});
} else {
- fab.setVisibility(View.GONE);
+ this.binding.fab.setVisibility(View.GONE);
}
}
}
\ No newline at end of file
diff --git a/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java b/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java
index 7e697f053..fe04b8300 100644
--- a/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java
@@ -1,17 +1,17 @@
package eu.siacs.conversations.ui;
-import android.app.ActionBar;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.ComponentName;
import android.content.Intent;
+import android.databinding.DataBindingUtil;
import android.location.Location;
import android.location.LocationListener;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
-import android.support.design.widget.FloatingActionButton;
+import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -25,6 +25,7 @@ import java.util.regex.Pattern;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
+import eu.siacs.conversations.databinding.ActivityShowLocationBinding;
import eu.siacs.conversations.ui.util.LocationHelper;
import eu.siacs.conversations.ui.util.UriHelper;
import eu.siacs.conversations.ui.widget.Marker;
@@ -34,7 +35,7 @@ import eu.siacs.conversations.ui.widget.MyLocation;
public class ShowLocationActivity extends LocationActivity implements LocationListener {
private GeoPoint loc = Config.Map.INITIAL_POS;
- private FloatingActionButton navigationButton;
+ private ActivityShowLocationBinding binding;
private Uri createGeoUri() {
@@ -45,19 +46,13 @@ public class ShowLocationActivity extends LocationActivity implements LocationLi
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- final ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- }
+ this.binding = DataBindingUtil.setContentView(this,R.layout.activity_show_location);
+ setSupportActionBar((Toolbar) binding.toolbar);
- setContentView(R.layout.activity_show_location);
- setSupportActionBar(findViewById(R.id.toolbar));
configureActionBar(getSupportActionBar());
- setupMapView(this.loc);
+ setupMapView(this.binding.map, this.loc);
- // Setup the fab button
- this.navigationButton = findViewById(R.id.fab);
- this.navigationButton.setOnClickListener(view -> startNavigation());
+ this.binding.fab.setOnClickListener(view -> startNavigation());
final Intent intent = getIntent();
if (intent != null) {
@@ -157,9 +152,9 @@ public class ShowLocationActivity extends LocationActivity implements LocationLi
protected void updateLocationMarkers() {
super.updateLocationMarkers();
if (this.myLoc != null) {
- this.map.getOverlays().add(new MyLocation(this, null, this.myLoc));
+ this.binding.map.getOverlays().add(new MyLocation(this, null, this.myLoc));
}
- this.map.getOverlays().add(new Marker(this.marker_icon, this.loc));
+ this.binding.map.getOverlays().add(new Marker(this.marker_icon, this.loc));
}
@Override
@@ -175,6 +170,7 @@ public class ShowLocationActivity extends LocationActivity implements LocationLi
if (clipboard != null) {
final ClipData clip = ClipData.newPlainText("location", createGeoUri().toString());
clipboard.setPrimaryClip(clip);
+ Toast.makeText(this,R.string.url_copied_to_clipboard,Toast.LENGTH_SHORT).show();
}
return true;
case R.id.action_share_location:
@@ -204,9 +200,7 @@ public class ShowLocationActivity extends LocationActivity implements LocationLi
protected void updateUi() {
final Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=0,0"));
final ComponentName component = i.resolveActivity(getPackageManager());
- if (this.navigationButton != null) {
- this.navigationButton.setVisibility(component == null ? View.GONE : View.VISIBLE);
- }
+ this.binding.fab.setVisibility(component == null ? View.GONE : View.VISIBLE);
}
@Override
diff --git a/src/main/res/layout/activity_share_location.xml b/src/main/res/layout/activity_share_location.xml
index fe73ff86f..fba3c9bbf 100644
--- a/src/main/res/layout/activity_share_location.xml
+++ b/src/main/res/layout/activity_share_location.xml
@@ -1,66 +1,75 @@
-
-
+
-
-
+ tools:context=".ui.ShareLocationActivity">
-
+
-
+
+ android:layout_above="@+id/button_bar" >
-
+
+
+
+
+
+
+
-
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentRight="true"
+ tools:ignore="RtlHardcoded">
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/res/layout/activity_show_location.xml b/src/main/res/layout/activity_show_location.xml
index 5df0c87dd..b5f1cc4ff 100644
--- a/src/main/res/layout/activity_show_location.xml
+++ b/src/main/res/layout/activity_show_location.xml
@@ -1,25 +1,31 @@
-
+
-
+
-
+
-
-
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 1ebec5c82..d0453900b 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -296,7 +296,7 @@
Copy original URL
Send again
File URL
- URL copied to clipboard
+ Copied URL to clipboard
Scan 2D Barcode
Show 2D Barcode
Show block list
@@ -698,4 +698,5 @@
Directions
Share location
Show location
+ Share
diff --git a/src/main/res/values/styles.xml b/src/main/res/values/styles.xml
index ad68d0678..282d6c9d7 100644
--- a/src/main/res/values/styles.xml
+++ b/src/main/res/values/styles.xml
@@ -38,6 +38,10 @@
- ?TextSizeBody1
+
+