GPSTracker Removed
lbs-gitea/maptology/master There was a failure building this commit

NoticeView Adjusted
Code Cleanup
This commit is contained in:
Arman Arzani
2017-12-12 22:36:41 +01:00
parent e70b52292f
commit 4ea45e5487
5 changed files with 14 additions and 206 deletions
@@ -1,177 +0,0 @@
package com.maptology.android.app;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import static android.content.ContentValues.TAG;
import static android.content.Context.LOCATION_SERVICE;
public class GPSTracker implements LocationListener{
//private Context context;
boolean isGPSEnabled=false;
boolean isNetworkEnabled=false;
boolean isGPSTrackingEnabled=false;
private Context context;
Location location;
public static double latitude;
public static double longitude;
private LocationListener locationListener;
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES =5 ;
private static final long MIN_TIME_BW_UPDATES = 2000;
protected LocationManager locationManager;
private String provider_info;
public GPSTracker(Context context,LocationListener locationListener){
this.context=context;
this.locationListener=locationListener;
//getLocation();
}
/*
public void getLocation(){
try {
locationManager = (LocationManager) context.getSystemService(LOCATION_SERVICE);
//getting GPS status
isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
//getting network status
isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
// Try to get location if you GPS Service is enabled
if (!MapFragment.stopService) {
if (isGPSEnabled) {
this.isGPSTrackingEnabled = true;
Log.d(TAG, "Application use GPS Service");
*/
/*
* This provider determines location using
* satellites. Depending on conditions, this provider may take a while to return
* a location fix.
*//*
provider_info = LocationManager.GPS_PROVIDER;
} else if (isNetworkEnabled) { // Try to get location if you Network Service is enabled
this.isGPSTrackingEnabled = true;
Log.d(TAG, "Application use Network State to get GPS coordinates");
*/
/*
* This provider determines location based on
* availability of cell tower and WiFi access points. Results are retrieved
* by means of a network lookup.
*//*
provider_info = LocationManager.NETWORK_PROVIDER;
}
// Application can use GPS or Network Provider
if (!provider_info.isEmpty()) {
locationManager.requestLocationUpdates(
provider_info,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES,
locationListener
);
if (locationManager != null) {
location = locationManager.getLastKnownLocation(provider_info);
updateGPSCoordinates();
}
}
}else{
locationManager.removeUpdates(locationListener);
locationManager=null;
System.out.println("Service Stopped receiving location updates");
}
}
catch (Exception e){
//e.printStackTrace();
Log.e(TAG, "Impossible to connect to LocationManager", e);
}
*/
/**
* Update GPSTracker latitude and longitude
*/
public void updateGPSCoordinates() {
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
/**
* GPSTracker latitude getter and setter
* @return latitude
*/
public double getLatitude() {
if (location != null) {
latitude = location.getLatitude();
}
return latitude;
}
/**
* GPSTracker longitude getter and setter
* @return
*/
public double getLongitude() {
if (location != null) {
longitude = location.getLongitude();
}
return longitude;
}
@Override
public void onLocationChanged(Location location) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
System.out.println("Provider has been Enabled");
}
@Override
public void onProviderDisabled(String provider) {
System.out.println("Provider has been Disabled");
}
}
@@ -35,8 +35,8 @@ public class MainActivity extends AppCompatActivity {
fragment = (MapFragment)getSupportFragmentManager().findFragmentByTag(TAG);
} else {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
//fragment = new MapFragment();
fragment = new NoticeFragment();
fragment = new MapFragment();
//fragment = new NoticeFragment();
ft.add(R.id.container, fragment, TAG);
ft.commit();
}
@@ -45,8 +45,7 @@ import java.util.ArrayList;
import java.util.List;
import static android.content.ContentValues.TAG;
import static com.maptology.android.app.GPSTracker.latitude;
import static com.maptology.android.app.GPSTracker.longitude;
/**
@@ -110,10 +109,6 @@ public class MapFragment extends AbstractFragment {
private View view;
private boolean resumeLoadingMap=true;
private MapView tempMap;
private IValueListener<Location> locationListener = new IValueListener<Location>() {
@Override
@@ -198,9 +193,7 @@ public class MapFragment extends AbstractFragment {
}
});
if(center!=null){
map.setCenter(longitude, latitude);
}
float scale = 0.5f;
IconOptions opts = new IconOptions("file:///android_asset/marker_normal.png");
opts.iconAnchor = new MapPoint((int)(100 * scale),(int)(190 * scale));
@@ -74,20 +74,6 @@ public class ShareFragment extends Fragment {
.setAction("Send", new View.OnClickListener() {
@Override
public void onClick(View view) {
/*
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("Link", SHARE_LINK);
clipboard.setPrimaryClip(clip);
snackbar.setText("Link Copied to Clipboard");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
*/
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, SHARE_LINK);
@@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:auto="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
@@ -11,7 +11,7 @@
auto:cardCornerRadius="4dp"
auto:cardElevation="4dp"
auto:cardUseCompatPadding="true"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
@@ -21,11 +21,13 @@
<TextView
android:id="@+id/view_notice_title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/view_notice_body"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
@@ -33,7 +35,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1.0"
android:layout_weight="0.5"
android:gravity="right"
android:paddingRight="4dp"
android:text="@string/view_notice_creation_title"
@@ -42,6 +44,8 @@
android:layout_height="wrap_content"/>
<TextView
tools:text="1.1.2018 10:30"
android:layout_weight="0.5"
android:layout_gravity="left"
android:id="@+id/view_notice_creation_time"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
@@ -52,7 +56,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1.0"
android:layout_weight="0.5"
android:gravity="right"
android:paddingRight="4dp"
android:text="@string/view_notice_modification_title"
@@ -61,6 +65,8 @@
android:layout_height="wrap_content" android:id="@+id/textView"/>
<TextView
tools:text="1.1.2018 10:30"
android:layout_weight="0.5"
android:gravity="left"
android:id="@+id/view_notice_modification_time"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"