Search in sources :

Example 1 with BackendMapView

use of org.microg.gms.maps.BackendMapView in project android_packages_apps_GmsCore by microg.

the class PlacePickerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    resultIntent = new Intent();
    place = new PlaceImpl();
    setContentView(R.layout.pick_place);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    if (getIntent().hasExtra(EXTRA_PRIMARY_COLOR)) {
        toolbar.setBackgroundColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR, 0));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            getWindow().setStatusBarColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR_DARK, 0));
        ((TextView) findViewById(R.id.place_picker_title)).setTextColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR_DARK, 0));
    }
    mapView = (BackendMapView) findViewById(R.id.map);
    mapView.map().getEventLayer().enableRotation(false);
    mapView.map().getEventLayer().enableTilt(false);
    mapView.map().events.bind(this);
    LatLngBounds latLngBounds = getIntent().getParcelableExtra(LocationConstants.EXTRA_BOUNDS);
    if (latLngBounds != null) {
        place.viewport = latLngBounds;
        MapPosition mp = new MapPosition();
        mp.setByBoundingBox(fromLatLngBounds(latLngBounds), mapView.map().getWidth(), mapView.map().getHeight());
        mapView.map().getMapPosition(mp);
    } else {
        if (ActivityCompat.checkSelfPermission(PlacePickerActivity.this, ACCESS_FINE_LOCATION) != PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(PlacePickerActivity.this, new String[] { ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION }, 0);
        } else {
            updateMapFromLocationManager();
        }
    }
    findViewById(R.id.place_picker_select).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            resultIntent.putExtra(LocationConstants.EXTRA_STATUS, SafeParcelUtil.asByteArray(new Status(CommonStatusCodes.SUCCESS)));
            resultIntent.putExtra(LocationConstants.EXTRA_PLACE, SafeParcelUtil.asByteArray(place));
            resultIntent.putExtra(LocationConstants.EXTRA_FINAL_BOUNDS, SafeParcelUtil.asByteArray(place.viewport));
            setResult(RESULT_OK, resultIntent);
            finish();
        }
    });
}
Also used : Status(com.google.android.gms.common.api.Status) PlaceImpl(com.google.android.gms.location.places.internal.PlaceImpl) LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) GmsMapsTypeHelper.fromLatLngBounds(org.microg.gms.maps.GmsMapsTypeHelper.fromLatLngBounds) Intent(android.content.Intent) TextView(android.widget.TextView) SearchView(android.support.v7.widget.SearchView) View(android.view.View) TextView(android.widget.TextView) BackendMapView(org.microg.gms.maps.BackendMapView) MapPosition(org.oscim.core.MapPosition) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Intent (android.content.Intent)1 SearchView (android.support.v7.widget.SearchView)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 TextView (android.widget.TextView)1 Status (com.google.android.gms.common.api.Status)1 PlaceImpl (com.google.android.gms.location.places.internal.PlaceImpl)1 LatLngBounds (com.google.android.gms.maps.model.LatLngBounds)1 BackendMapView (org.microg.gms.maps.BackendMapView)1 GmsMapsTypeHelper.fromLatLngBounds (org.microg.gms.maps.GmsMapsTypeHelper.fromLatLngBounds)1 MapPosition (org.oscim.core.MapPosition)1