aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/maps
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2014-05-18 07:57:12 +0200
committerBananeweizen <bananeweizen@gmx.de>2014-05-18 07:57:12 +0200
commit5fcce648e200669f1ae0875c7aea9dc3a4a37574 (patch)
treef3741fdf0c8fcb6e6728fa49d61af7ea6c7f1aaa /main/src/cgeo/geocaching/maps
parent6b2972bfd1fdc14cd84f78e3674e97b46675345d (diff)
parent786eccacbb285696d504d08ba02c61400ce063a2 (diff)
downloadcgeo-5fcce648e200669f1ae0875c7aea9dc3a4a37574.zip
cgeo-5fcce648e200669f1ae0875c7aea9dc3a4a37574.tar.gz
cgeo-5fcce648e200669f1ae0875c7aea9dc3a4a37574.tar.bz2
Merge remote-tracking branch 'schwabe/actionbar_pullrequest'
Conflicts: main/res/values/preference_keys.xml main/src/cgeo/geocaching/CgeoApplication.java
Diffstat (limited to 'main/src/cgeo/geocaching/maps')
-rw-r--r--main/src/cgeo/geocaching/maps/AbstractMap.java6
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java102
-rw-r--r--main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java12
-rw-r--r--main/src/cgeo/geocaching/maps/interfaces/MapActivityImpl.java1
4 files changed, 97 insertions, 24 deletions
diff --git a/main/src/cgeo/geocaching/maps/AbstractMap.java b/main/src/cgeo/geocaching/maps/AbstractMap.java
index d341823..aff9c75 100644
--- a/main/src/cgeo/geocaching/maps/AbstractMap.java
+++ b/main/src/cgeo/geocaching/maps/AbstractMap.java
@@ -5,10 +5,12 @@ import cgeo.geocaching.maps.interfaces.MapActivityImpl;
import android.app.Activity;
import android.content.res.Resources;
+import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.view.Window;
/**
* Base class for the map activity. Delegates base class calls to the
@@ -31,7 +33,11 @@ public abstract class AbstractMap {
}
public void onCreate(Bundle savedInstanceState) {
+
mapActivity.superOnCreate(savedInstanceState);
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
+ mapActivity.getActivity().requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+ }
}
public void onResume() {
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index 857dfbb..b4cb4b8 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -51,6 +51,7 @@ import rx.schedulers.Schedulers;
import rx.subscriptions.CompositeSubscription;
import rx.subscriptions.Subscriptions;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
@@ -61,6 +62,7 @@ import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.location.Location;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -70,9 +72,11 @@ import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
+import android.widget.CheckBox;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
+import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.ViewSwitcher.ViewFactory;
@@ -184,7 +188,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
private int detailProgress = 0;
private long detailProgressTime = 0L;
// views
- private ImageSwitcher myLocSwitch = null;
+ private CheckBox myLocSwitch = null;
/** Controls the map behaviour */
private MapMode mapMode = null;
@@ -240,7 +244,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
title.append('[').append(lastSearchResult.getUrl()).append(']');
}
- ActivityMixin.setTitle(activity, title.toString());
+ setTitle(title.toString());
break;
case INVALIDATE_MAP:
mapView.repaintRequired(null);
@@ -251,6 +255,24 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
}
};
+
+ private void setTitle(String title) {
+ /* Compatibily for the old Action Bar, only used by the maps activity at the moment */
+ final TextView titleview = (TextView) activity.findViewById(R.id.actionbar_title);
+ if (titleview != null) {
+ titleview.setText(title);
+
+ }
+ if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)) {
+ setTitleHoneyComb(title);
+ }
+ }
+
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ private void setTitleHoneyComb(String title) {
+ activity.getActionBar().setTitle(title);
+ }
+
/** Updates the progress. */
final private Handler showProgressHandler = new Handler() {
@@ -262,15 +284,32 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
if (what == HIDE_PROGRESS) {
if (--counter == 0) {
- ActivityMixin.showProgress(activity, false);
+ showProgress(false);
}
} else if (what == SHOW_PROGRESS) {
- ActivityMixin.showProgress(activity, true);
+ showProgress(true);
counter++;
}
}
+
+ private void showProgress(boolean show) {
+ final ProgressBar progress = (ProgressBar) activity.findViewById(R.id.actionbar_progress);
+ if (progress != null) {
+ if (show) {
+ progress.setVisibility(View.VISIBLE);
+ } else {
+ progress.setVisibility(View.GONE);
+
+ }
+ }
+ if (Build.VERSION.SDK_INT >= 11) {
+ activity.setProgressBarIndeterminateVisibility(show);
+ }
+ }
};
+
+
final private class LoadDetailsHandler extends CancellableHandler {
@Override
@@ -361,6 +400,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
}
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -418,10 +458,16 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
ActivityMixin.keepScreenOn(activity, true);
+
// set layout
- ActivityMixin.setTheme(activity);
+ //ActivityMixin.setTheme(activity);
+ // TODO: set a proper theme
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
+ activity.setTheme(android.R.style.Theme_Holo);
+ activity.getActionBar().setDisplayHomeAsUpEnabled(true);
+ }
activity.setContentView(mapProvider.getMapLayoutId());
- ActivityMixin.setTitle(activity, res.getString(R.string.map_map));
+ setTitle(res.getString(R.string.map_map));
// initialize map
mapView = (MapViewImpl) activity.findViewById(mapProvider.getMapViewId());
@@ -462,14 +508,11 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
centerMap(geocodeIntent, searchIntent, coordsIntent, mapStateIntent);
}
- // prepare my location button
- myLocSwitch = (ImageSwitcher) activity.findViewById(R.id.my_position);
- myLocSwitch.setFactory(this);
- myLocSwitch.setInAnimation(activity, android.R.anim.fade_in);
- myLocSwitch.setOutAnimation(activity, android.R.anim.fade_out);
- myLocSwitch.setOnClickListener(new MyLocationListener());
- switchMyLocationButton();
+ CheckBox locSwitch = (CheckBox) activity.findViewById(R.id.my_position);
+ if (locSwitch!=null) {
+ initMyLocationSwitchButton(locSwitch);
+ }
prepareFilterBar();
if (!app.isLiveMapHintShownInThisSession() && !Settings.getHideLiveMapHint() && Settings.getLiveMapHintShowCount() <= 3) {
@@ -477,6 +520,16 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
}
+ private void initMyLocationSwitchButton(CheckBox locSwitch) {
+ myLocSwitch = locSwitch;
+ /* TODO: Switch back to ImageSwitcher for animations?
+ myLocSwitch.setFactory(this);
+ myLocSwitch.setInAnimation(activity, android.R.anim.fade_in);
+ myLocSwitch.setOutAnimation(activity, android.R.anim.fade_out); */
+ myLocSwitch.setOnClickListener(new MyLocationListener());
+ switchMyLocationButton();
+ }
+
/**
* Set the zoom of the map. The zoom is restricted to a certain minimum in case of live map.
*
@@ -532,6 +585,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
super.onPause();
}
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// menu inflation happens in Google/Mapsforge specific classes
@@ -541,6 +595,19 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
final SubMenu subMenuStrategy = menu.findItem(R.id.submenu_strategy).getSubMenu();
subMenuStrategy.setHeaderTitle(res.getString(R.string.map_strategy_title));
+
+
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
+ /* if we have an Actionbar find the my position toggle */
+ MenuItem item = menu.findItem(R.id.menu_toggle_mypos);
+ myLocSwitch = new CheckBox(activity);
+ myLocSwitch.setButtonDrawable(R.drawable.ic_menu_myposition);
+ item.setActionView(myLocSwitch);
+ initMyLocationSwitchButton(myLocSwitch);
+ } else {
+ // Already on the fake Actionbar
+ menu.removeItem(R.id.menu_toggle_mypos);
+ }
return true;
}
@@ -617,6 +684,9 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
public boolean onOptionsItemSelected(MenuItem item) {
final int id = item.getItemId();
switch (id) {
+ case android.R.id.home:
+ ActivityMixin.navigateToMain(activity);
+ return true;
case R.id.menu_trail_mode:
Settings.setMapTrail(!Settings.isMapTrail());
mapView.repaintRequired(overlayPositionAndScale);
@@ -1461,11 +1531,9 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
// switch My Location button image
private void switchMyLocationButton() {
+ myLocSwitch.setChecked(followMyLocation);
if (followMyLocation) {
- myLocSwitch.setImageResource(R.drawable.actionbar_mylocation_on);
myLocationInMiddle(app.currentGeo());
- } else {
- myLocSwitch.setImageResource(R.drawable.actionbar_mylocation_off);
}
}
@@ -1494,7 +1562,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
// close activity and open homescreen
@Override
public void goHome(View view) {
- ActivityMixin.goHome(activity);
+ ActivityMixin.navigateToMain(activity);
}
@Override
diff --git a/main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java b/main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java
index a98241f..8a1bad6 100644
--- a/main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java
+++ b/main/src/cgeo/geocaching/maps/google/GoogleMapActivity.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.maps.google;
+import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.activity.FilteredActivity;
import cgeo.geocaching.maps.AbstractMap;
import cgeo.geocaching.maps.CGeoMap;
@@ -97,6 +98,11 @@ public class GoogleMapActivity extends MapActivity implements MapActivityImpl, F
}
@Override
+ public void goHome(View view) {
+ ActivityMixin.navigateToMain(this);
+ }
+
+ @Override
public void superOnResume() {
super.onResume();
}
@@ -116,12 +122,6 @@ public class GoogleMapActivity extends MapActivity implements MapActivityImpl, F
return super.onPrepareOptionsMenu(menu);
}
- // close activity and open homescreen
- @Override
- public void goHome(View view) {
- mapBase.goHome(view);
- }
-
@Override
public void showFilterMenu(View view) {
// do nothing, the filter bar only shows the global filter
diff --git a/main/src/cgeo/geocaching/maps/interfaces/MapActivityImpl.java b/main/src/cgeo/geocaching/maps/interfaces/MapActivityImpl.java
index e7deebd..08309f4 100644
--- a/main/src/cgeo/geocaching/maps/interfaces/MapActivityImpl.java
+++ b/main/src/cgeo/geocaching/maps/interfaces/MapActivityImpl.java
@@ -34,5 +34,4 @@ public interface MapActivityImpl {
boolean superOnOptionsItemSelected(MenuItem item);
public abstract void goHome(View view);
-
}