Move location picker to main source set

pull/795/head
Alex Baker 7 years ago
parent 588688357e
commit be0432c86c

@ -25,6 +25,8 @@ android {
targetSdkVersion 28
minSdkVersion 16
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue 'string', 'mapbox_key', project.hasProperty('tasks_mapbox_key') ? tasks_mapbox_key : ''
resValue 'string', 'google_key', project.hasProperty('tasks_google_key') ? tasks_google_key : ''
javaCompileOptions {
annotationProcessorOptions {
@ -44,14 +46,10 @@ android {
buildTypes {
debug {
resValue 'string', "mapbox_key", project.hasProperty('tasks_mapbox_key') ? tasks_mapbox_key : ''
resValue 'string', "google_key", project.hasProperty('tasks_google_key') ? tasks_google_key : ''
multiDexEnabled true
testCoverageEnabled true
}
release {
resValue 'string', "mapbox_key", tasks_mapbox_key
resValue 'string', "google_key", tasks_google_key
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.pro'
signingConfig signingConfigs.release
@ -175,6 +173,8 @@ dependencies {
// https://groups.google.com/forum/#!topic/guava-announce/Km82fZG68Sw
exclude group: 'com.google.guava', module: 'listenablefuture'
}
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:7.3.0'
implementation'com.mapbox.mapboxsdk:mapbox-sdk-services:4.5.0'
googleplayImplementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
googleplayImplementation "com.google.firebase:firebase-core:16.0.7"
@ -184,8 +184,6 @@ dependencies {
googleplayImplementation 'com.google.android.libraries.places:places:1.0.0'
googleplayImplementation 'com.google.android.gms:play-services-maps:16.1.0'
googleplayImplementation 'androidx.appcompat:appcompat:1.0.2'
googleplayImplementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:7.3.0'
googleplayImplementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:4.5.0'
amazonImplementation "com.google.android.gms:play-services-analytics:16.0.7"

@ -7,6 +7,7 @@ import io.reactivex.disposables.Disposable;
import io.reactivex.disposables.Disposables;
import javax.inject.Inject;
import org.tasks.drive.DriveLoginActivity;
import org.tasks.location.LocationPickerActivity;
import org.tasks.play.AuthResultHandler;
public class PlayServices {
@ -37,4 +38,8 @@ public class PlayServices {
public Disposable check(MainActivity mainActivity) {
return Disposables.empty();
}
public Disposable checkMaps(LocationPickerActivity locationPickerActivity) {
return Disposables.empty();
}
}

@ -0,0 +1,28 @@
package org.tasks.location;
import android.content.Context;
import androidx.fragment.app.FragmentManager;
import java.util.List;
import org.tasks.data.Place;
public class GoogleMapFragment implements MapFragment {
public GoogleMapFragment(Context context) {}
@Override
public void init(FragmentManager fragmentManager, MapFragmentCallback callback, boolean dark) {}
@Override
public MapPosition getMapPosition() {
return null;
}
@Override
public void movePosition(MapPosition mapPosition, boolean animate) {}
@Override
public void setMarkers(List<Place> places) {}
@Override
public void showMyLocation() {}
}

@ -0,0 +1,29 @@
package org.tasks.location;
import android.content.Context;
import android.os.Bundle;
import java.util.List;
import org.tasks.Callback;
import org.tasks.data.Place;
public class GooglePlacesSearchProvider implements PlaceSearchProvider {
public GooglePlacesSearchProvider(Context context) {}
@Override
public void restoreState(Bundle savedInstanceState) {}
@Override
public void saveState(Bundle outState) {}
@Override
public void search(
String query,
MapPosition bias,
Callback<List<PlaceSearchResult>> onSuccess,
Callback<String> onError) {}
@Override
public void fetch(
PlaceSearchResult placeSearchResult, Callback<Place> onSuccess, Callback<String> onError) {}
}

@ -1,18 +0,0 @@
package org.tasks.location;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import org.tasks.data.Location;
import org.tasks.preferences.Preferences;
public class PlacePicker {
public static Intent getIntent(Activity activity) {
return null;
}
public static Location getPlace(Context context, Intent data, Preferences preferences) {
return null;
}
}

@ -28,8 +28,6 @@
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_key"/>
<activity android:name=".location.LocationPickerActivity"/>
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false"/>

@ -109,6 +109,8 @@
android:taskAffinity=""
android:theme="@style/TranslucentDialog"/>
<activity android:name=".location.LocationPickerActivity"/>
<activity
android:exported="true"
android:name=".activities.FilterSelectionActivity"

@ -34,11 +34,12 @@ import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.AppBarLayout.Behavior;
import com.google.common.base.Strings;
import com.mapbox.android.core.location.LocationEngineCallback;
import com.mapbox.android.core.location.LocationEngineProvider;
import com.mapbox.android.core.location.LocationEngineResult;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
@ -118,7 +119,6 @@ public class LocationPickerActivity extends InjectingAppCompatActivity
@Inject DialogBuilder dialogBuilder;
@Inject MapFragment map;
private FusedLocationProviderClient fusedLocationProviderClient;
private CompositeDisposable disposables;
private MapPosition mapPosition;
private LocationPickerAdapter recentsAdapter = new LocationPickerAdapter(this);
@ -196,8 +196,6 @@ public class LocationPickerActivity extends InjectingAppCompatActivity
map.init(getSupportFragmentManager(), this, theme.getThemeBase().isDarkTheme(this));
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
CoordinatorLayout.LayoutParams params =
(CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
Behavior behavior = new Behavior();
@ -353,13 +351,22 @@ public class LocationPickerActivity extends InjectingAppCompatActivity
@SuppressLint("MissingPermission")
private void moveToCurrentLocation(boolean animate) {
fusedLocationProviderClient
.getLastLocation()
.addOnSuccessListener(
location -> {
LocationEngineProvider.getBestLocationEngine(this)
.getLastLocation(
new LocationEngineCallback<LocationEngineResult>() {
@Override
public void onSuccess(LocationEngineResult result) {
Location location = result.getLastLocation();
if (location != null) {
map.movePosition(
new MapPosition(location.getLatitude(), location.getLongitude(), 15f), animate);
new MapPosition(location.getLatitude(), location.getLongitude(), 15f),
animate);
}
}
@Override
public void onFailure(@NonNull Exception exception) {
toaster.longToast(exception.getMessage());
}
});
}
Loading…
Cancel
Save