diff options
| author | Arne Schwabe <arne@rfc2549.org> | 2014-04-20 21:38:19 +0200 |
|---|---|---|
| committer | Arne Schwabe <arne@rfc2549.org> | 2014-05-17 13:08:14 +0200 |
| commit | be26c1845210a1c8824677ed6e2d093073ea5c84 (patch) | |
| tree | 81d02773f4fd9edc5d05b44c770be89994a9c207 /main/src/cgeo/geocaching/MainActivity.java | |
| parent | 496878826d638367c129b02e66f992202e0d36c9 (diff) | |
| download | cgeo-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/MainActivity.java')
| -rw-r--r-- | main/src/cgeo/geocaching/MainActivity.java | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/main/src/cgeo/geocaching/MainActivity.java b/main/src/cgeo/geocaching/MainActivity.java index 42dd58d..d8958b4 100644 --- a/main/src/cgeo/geocaching/MainActivity.java +++ b/main/src/cgeo/geocaching/MainActivity.java @@ -3,7 +3,7 @@ package cgeo.geocaching; import butterknife.ButterKnife; import butterknife.InjectView; -import cgeo.geocaching.activity.AbstractActivity; +import cgeo.geocaching.activity.AbstractActionBarActivity; import cgeo.geocaching.connector.ConnectorFactory; import cgeo.geocaching.connector.capability.ILogin; import cgeo.geocaching.enumerations.CacheType; @@ -25,7 +25,9 @@ import cgeo.geocaching.utils.Version; import com.google.zxing.integration.android.IntentIntegrator; import com.google.zxing.integration.android.IntentResult; + import org.apache.commons.lang3.StringUtils; + import rx.Observable; import rx.Observable.OnSubscribe; import rx.Subscriber; @@ -37,6 +39,7 @@ import rx.subscriptions.Subscriptions; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.SearchManager; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; @@ -45,6 +48,8 @@ import android.location.Geocoder; import android.os.Bundle; import android.os.Handler; import android.os.Message; +import android.support.v4.view.MenuItemCompat; +import android.support.v7.widget.SearchView; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -61,7 +66,7 @@ import java.util.Comparator; import java.util.List; import java.util.Locale; -public class MainActivity extends AbstractActivity { +public class MainActivity extends AbstractActionBarActivity { @InjectView(R.id.nav_satellites) protected TextView navSatellites; @InjectView(R.id.filter_button_title)protected TextView filterTitle; @InjectView(R.id.map) protected ImageView findOnMap; @@ -189,6 +194,10 @@ public class MainActivity extends AbstractActivity { public void onCreate(final Bundle savedInstanceState) { // don't call the super implementation with the layout argument, as that would set the wrong theme super.onCreate(savedInstanceState); + + // Disable the up navigation for this activity + getSupportActionBar().setDisplayHomeAsUpEnabled(false); + setContentView(R.layout.main_activity); ButterKnife.inject(this); @@ -262,6 +271,11 @@ public class MainActivity extends AbstractActivity { @Override public boolean onCreateOptionsMenu(final Menu menu) { getMenuInflater().inflate(R.menu.main_activity_options, menu); + SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); + MenuItem searchItem = menu.findItem(R.id.menu_gosearch); + SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); + searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); + return true; } @@ -303,6 +317,9 @@ public class MainActivity extends AbstractActivity { } }); return true; + case R.id.menu_gosearch: + onSearchRequested(); + return true; default: return super.onOptionsItemSelected(item); } @@ -712,13 +729,4 @@ public class MainActivity extends AbstractActivity { public void showAbout(final View view) { startActivity(new Intent(this, AboutActivity.class)); } - - /** - * @param view - * unused here but needed since this method is referenced from XML layout - */ - public void goSearch(final View view) { - onSearchRequested(); - } - } |
