aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/CacheDetailActivity.java
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2014-04-20 21:38:19 +0200
committerArne Schwabe <arne@rfc2549.org>2014-05-17 13:08:14 +0200
commitbe26c1845210a1c8824677ed6e2d093073ea5c84 (patch)
tree81d02773f4fd9edc5d05b44c770be89994a9c207 /main/src/cgeo/geocaching/CacheDetailActivity.java
parent496878826d638367c129b02e66f992202e0d36c9 (diff)
downloadcgeo-be26c1845210a1c8824677ed6e2d093073ea5c84.zip
cgeo-be26c1845210a1c8824677ed6e2d093073ea5c84.tar.gz
cgeo-be26c1845210a1c8824677ed6e2d093073ea5c84.tar.bz2
Implement ActionBar using AppCompat in cgeo
This a first version of an ActionBar implementation with following properties: - The application should be usuable (there still might be bugs left from the conversation to Action) - Provides a more modern feeling on all devices - gets rid of the "dots of shame" on Android 3.0+ devices - The Maps classes MUST inherit from Activity instead of ActionBarActivity. There these classes use the old ActionBar on Android 2.3 devices and the real ActionBar on 3.0+ - This can be fixed when cgeo is ported to Google Maps API v2.0 API which usesFragment - The Dialog classes (CachePopup and WaypointPopup) have been converted to DialogFragments - The AppCombat themes provide no Theme.Dialog theme - this will later ease using these Fragment in other Activities - Use an almost empty activity which just shows the DialogFragment - Use the 'old' ActionBar but which overflow menu button to fit into Holo Design Style - Using a real ActionBar for Dialogs is not really support by Android and trying to force the frame into showing an Actionbar on a dialog leeds to strange bugs/effects - Most of the icon are still the Android 2.3 Menu Icon. These need to be replaced with Holo Style Icons - for most menu icon the ifRoom and/or withText attributes should be reviewed and set - The ActionBar of the main Activity is transparent. This is more or less by accident but looks good - Review Up Action of activities. Is going back to Main Activity always the semantically right thing to do? - Shortpress/Longpress on the Actionbars Compass Icon for primary/secondary Navigation clashes the normal ActionBar behaviour of long pressing to show the text of the action This commit contains many fixes and suggestions from rsudev
Diffstat (limited to 'main/src/cgeo/geocaching/CacheDetailActivity.java')
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java32
1 files changed, 9 insertions, 23 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 7d231c9..2af9f95 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -101,6 +101,7 @@ import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewParent;
+import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
@@ -272,15 +273,6 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
// nothing, we lost the window
}
- final ImageView defaultNavigationImageView = (ImageView) findViewById(R.id.defaultNavigation);
- defaultNavigationImageView.setOnLongClickListener(new OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- startDefaultNavigation2();
- return true;
- }
- });
-
final int pageToOpen = savedInstanceState != null ?
savedInstanceState.getInt(STATE_PAGE_INDEX, 0) :
Settings.isOpenLastDetailsPage() ? Settings.getLastDetailsPage() : 1;
@@ -510,7 +502,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
}
}
- return true;
+ return super.onOptionsItemSelected(item);
}
private static final class CacheDetailsGeoDirHandler extends GeoDirHandler {
@@ -609,11 +601,12 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
// action bar: title and icon
if (StringUtils.isNotBlank(cache.getName())) {
- setTitle(cache.getName() + " (" + cache.getGeocode() + ')');
+ getSupportActionBar().setTitle(cache.getName() + " (" + cache.getGeocode() + ')');
} else {
- setTitle(cache.getGeocode());
+ getSupportActionBar().setTitle(cache.getGeocode());
}
- ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(cache.getType().markerId), null, null, null);
+
+ getSupportActionBar().setIcon(getResources().getDrawable(cache.getType().markerId));
// reset imagesList so Images view page will be redrawn
imagesList = null;
@@ -632,13 +625,6 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
}
/**
- * Tries to navigate to the {@link Geocache} of this activity.
- */
- private void startDefaultNavigation2() {
- NavigationAppFactory.startDefaultNavigationApplication(2, this, cache);
- }
-
- /**
* Wrapper for the referenced method in the xml-layout.
*/
public void goDefaultNavigation(@SuppressWarnings("unused") View view) {
@@ -2112,9 +2098,9 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
}
static void updateOfflineBox(final View view, final Geocache cache, final Resources res,
- final OnClickListener refreshCacheClickListener,
- final OnClickListener dropCacheClickListener,
- final OnClickListener storeCacheClickListener) {
+ final OnClickListener refreshCacheClickListener,
+ final OnClickListener dropCacheClickListener,
+ final OnClickListener storeCacheClickListener) {
// offline use
final TextView offlineText = (TextView) view.findViewById(R.id.offline_text);
final Button offlineRefresh = (Button) view.findViewById(R.id.offline_refresh);