aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/AndroidManifest.xml1
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java195
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java13
-rw-r--r--src/main/res/layout/activity_share_locaction.xml2
-rw-r--r--src/main/res/layout/activity_show_locaction.xml2
5 files changed, 120 insertions, 93 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 4298baf40..7e79e474a 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -204,6 +204,7 @@
<activity
android:name="de.pixart.messenger.ui.ShareLocationActivity"
android:label="@string/share_location"
+ android:parentActivityName="de.pixart.messenger.ui.ConversationActivity"
android:hardwareAccelerated="true">
<intent-filter>
<action android:name="de.pixart.messenger.location.request"/>
diff --git a/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java
index d20981ac3..03258712e 100644
--- a/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShareLocationActivity.java
@@ -1,9 +1,11 @@
package de.pixart.messenger.ui;
+import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
@@ -11,6 +13,7 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
+import android.support.v4.app.ActivityCompat;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
@@ -37,106 +40,126 @@ import de.pixart.messenger.Config;
import de.pixart.messenger.R;
public class ShareLocationActivity extends Activity implements OnMapReadyCallback,
- GoogleApiClient.ConnectionCallbacks,
- GoogleApiClient.OnConnectionFailedListener,
- LocationListener{
-
- private GoogleMap mGoogleMap;
- private GoogleApiClient mGoogleApiClient;
- private LocationRequest mLocationRequest;
- private Location mLastLocation;
- private Button mCancelButton;
- private Button mShareButton;
- private RelativeLayout mSnackbar;
+ GoogleApiClient.ConnectionCallbacks,
+ GoogleApiClient.OnConnectionFailedListener,
+ LocationListener {
+
+ private GoogleMap mGoogleMap;
+ private GoogleApiClient mGoogleApiClient;
+ private LocationRequest mLocationRequest;
+ private Location mLastLocation;
+ private Button mCancelButton;
+ private Button mShareButton;
+ private RelativeLayout mSnackbar;
private RelativeLayout mLocationInfo;
private TextView mSnackbarLocation;
private TextView mSnackbarAction;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_share_locaction);
- MapFragment fragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map_fragment);
- fragment.getMapAsync(this);
- mGoogleApiClient = new GoogleApiClient.Builder(this)
- .addApi(LocationServices.API)
- .addConnectionCallbacks(this)
- .addOnConnectionFailedListener(this)
- .build();
- mCancelButton = (Button) findViewById(R.id.cancel_button);
- mCancelButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- setResult(RESULT_CANCELED);
- finish();
- }
- });
- mShareButton = (Button) findViewById(R.id.share_button);
- mShareButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mLastLocation != null) {
- Intent result = new Intent();
- result.putExtra("latitude",mLastLocation.getLatitude());
- result.putExtra("longitude",mLastLocation.getLongitude());
- result.putExtra("altitude",mLastLocation.getAltitude());
- result.putExtra("accuracy",(int) mLastLocation.getAccuracy());
- setResult(RESULT_OK, result);
- finish();
- }
- }
- });
- mSnackbar = (RelativeLayout) findViewById(R.id.snackbar);
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (getActionBar() != null) {
+ getActionBar().setHomeButtonEnabled(true);
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+ }
+ setContentView(R.layout.activity_share_locaction);
+ MapFragment fragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map_fragment);
+ fragment.getMapAsync(this);
+ mGoogleApiClient = new GoogleApiClient.Builder(this)
+ .addApi(LocationServices.API)
+ .addConnectionCallbacks(this)
+ .addOnConnectionFailedListener(this)
+ .build();
+ mCancelButton = (Button) findViewById(R.id.cancel_button);
+ mCancelButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+ });
+ mShareButton = (Button) findViewById(R.id.share_button);
+ mShareButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mLastLocation != null) {
+ Intent result = new Intent();
+ result.putExtra("latitude", mLastLocation.getLatitude());
+ result.putExtra("longitude", mLastLocation.getLongitude());
+ result.putExtra("altitude", mLastLocation.getAltitude());
+ result.putExtra("accuracy", (int) mLastLocation.getAccuracy());
+ setResult(RESULT_OK, result);
+ finish();
+ }
+ }
+ });
+ mSnackbar = (RelativeLayout) findViewById(R.id.snackbar);
mLocationInfo = (RelativeLayout) findViewById(R.id.snackbar_location);
mSnackbarLocation = (TextView) findViewById(R.id.snackbar_location_message);
- mSnackbarAction = (TextView) findViewById(R.id.snackbar_action);
- mSnackbarAction.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
- }
- });
- }
+ mSnackbarAction = (TextView) findViewById(R.id.snackbar_action);
+ mSnackbarAction.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
+ }
+ });
+ }
- @Override
- protected void onResume() {
- super.onResume();
- this.mLastLocation = null;
- if (isLocationEnabled()) {
- this.mSnackbar.setVisibility(View.GONE);
- } else {
- this.mSnackbar.setVisibility(View.VISIBLE);
- }
- mShareButton.setEnabled(false);
- mShareButton.setTextColor(0x8a000000);
- mShareButton.setText(R.string.locating);
- mGoogleApiClient.connect();
- }
+ @Override
+ protected void onResume() {
+ super.onResume();
+ this.mLastLocation = null;
+ if (isLocationEnabled()) {
+ this.mSnackbar.setVisibility(View.GONE);
+ } else {
+ this.mSnackbar.setVisibility(View.VISIBLE);
+ }
+ mShareButton.setEnabled(false);
+ mShareButton.setTextColor(0x8a000000);
+ mShareButton.setText(R.string.locating);
+ mGoogleApiClient.connect();
+ }
- @Override
- protected void onPause() {
- mGoogleApiClient.disconnect();
- super.onPause();
- }
+ @Override
+ protected void onPause() {
+ mGoogleApiClient.disconnect();
+ super.onPause();
+ }
- @Override
- public void onMapReady(GoogleMap googleMap) {
- this.mGoogleMap = googleMap;
- this.mGoogleMap.setMyLocationEnabled(true);
- }
+ @Override
+ public void onMapReady(GoogleMap googleMap) {
+ this.mGoogleMap = googleMap;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
+ || checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
+ this.mGoogleMap.setBuildingsEnabled(true);
+ this.mGoogleMap.setMyLocationEnabled(true);
+ }
+ } else {
+ this.mGoogleMap.setBuildingsEnabled(true);
+ this.mGoogleMap.setMyLocationEnabled(true);
+ }
+ }
- private void centerOnLocation(LatLng location) {
- this.mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(location, Config.DEFAULT_ZOOM));
- }
+ private void centerOnLocation(LatLng location) {
+ this.mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(location, Config.DEFAULT_ZOOM));
+ }
- @Override
- public void onConnected(Bundle bundle) {
- mLocationRequest = LocationRequest.create();
+ @Override
+ public void onConnected(Bundle bundle) {
+ mLocationRequest = LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(1000);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
+ || checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
+ LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
+ }
+ } else {
+ LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
+ }
- LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
- }
+ }
@Override
public void onConnectionSuspended(int i) {
diff --git a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java
index 643cd6211..d9b71a8da 100644
--- a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java
@@ -11,7 +11,6 @@ import android.location.Geocoder;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
-import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
@@ -66,10 +65,10 @@ public class ShowLocationActivity extends Activity implements OnMapReadyCallback
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayHomeAsUpEnabled(true);
- }
+ if (getActionBar() != null) {
+ getActionBar().setHomeButtonEnabled(true);
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+ }
setContentView(R.layout.activity_show_locaction);
MapFragment fragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map_fragment);
@@ -114,8 +113,12 @@ public class ShowLocationActivity extends Activity implements OnMapReadyCallback
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
|| checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
+ this.mGoogleMap.setBuildingsEnabled(true);
this.mGoogleMap.setMyLocationEnabled(true);
}
+ } else {
+ this.mGoogleMap.setBuildingsEnabled(true);
+ this.mGoogleMap.setMyLocationEnabled(true);
}
if (this.mLocation != null) {
this.markAndCenterOnLocation(this.mLocation,this.mLocationName);
diff --git a/src/main/res/layout/activity_share_locaction.xml b/src/main/res/layout/activity_share_locaction.xml
index b360b649c..df3e08a95 100644
--- a/src/main/res/layout/activity_share_locaction.xml
+++ b/src/main/res/layout/activity_share_locaction.xml
@@ -12,7 +12,7 @@
android:layout_height="match_parent"
android:layout_above="@+id/snackbar"
map:mapType="normal"
- map:uiCompass="false"
+ map:uiCompass="true"
map:uiRotateGestures="false"
map:uiScrollGestures="true"
map:uiTiltGestures="false"
diff --git a/src/main/res/layout/activity_show_locaction.xml b/src/main/res/layout/activity_show_locaction.xml
index d22422015..95c22e09d 100644
--- a/src/main/res/layout/activity_show_locaction.xml
+++ b/src/main/res/layout/activity_show_locaction.xml
@@ -12,7 +12,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
map:mapType="normal"
- map:uiCompass="false"
+ map:uiCompass="true"
map:uiRotateGestures="false"
map:uiScrollGestures="true"
map:uiTiltGestures="false"