Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #3627 - Adding Content Offset to TestApp
Browse files Browse the repository at this point in the history
  • Loading branch information
bleege committed Jan 27, 2016
1 parent 3d32c63 commit 435afd7
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
<activity
android:name=".DoubleMapActivity"
android:label="@string/activity_double_map" />
<activity android:name=".ContentOffsetActivity"
android:label="@string/activity_content_offset"/>

<meta-data
android:name="com.mapbox.AccessToken"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.mapbox.mapboxsdk.testapp;

import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;

public class ContentOffsetActivity extends AppCompatActivity {

private static final String TAG = "ContentOffsetActivity";

private MapView mMapView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_content_offset);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}

mMapView = (MapView) findViewById(R.id.contentOffsetMapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.setStyle(Style.MAPBOX_STREETS);
mMapView.onCreate(savedInstanceState);
}

@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}

@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}

@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}

@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}

@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}

@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
startActivity(new Intent(getApplicationContext(), GeocoderActivity.class));
return true;

case R.id.action_content_offset:
startActivity(new Intent(getApplicationContext(), ContentOffsetActivity.class));
return true;

default:
return changeMapStyle(menuItem.getItemId());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M19,12h-2v3h-3v2h5v-5zM7,9h3V7H5v5h2V9zm14,-6H3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2zm0,16.01H3V4.99h18v14.02z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/contentOffsetMapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar"/>

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@
android:icon="@drawable/ic_directions"
android:title="@string/activity_geocoder" />

<item
android:id="@+id/action_content_offset"
android:checkable="false"
android:icon="@drawable/ic_aspect_ratio_24dp"
android:title="@string/activity_content_offset" />

</menu>
</item>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<string name="activity_directions">Directions Activity</string>
<string name="activity_geocoder">Geocoder Activity</string>
<string name="activity_double_map">Double Map Activity</string>
<string name="activity_content_offset">Content Offset</string>

<string name="navdrawer_menu_title_mainactivity_controls">Main Activity Controls</string>
<string name="navdrawer_menu_title_mainactivity_styles">Main Activity Styles</string>
Expand Down

0 comments on commit 435afd7

Please sign in to comment.