diff options
| -rw-r--r-- | main/res/values/strings.xml | 3 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/CacheListActivity.java | 17 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/LogCacheActivity.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/MainActivity.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/SearchActivity.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/activity/AbstractActivity.java | 23 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/activity/AbstractListActivity.java | 24 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/activity/ActivityMixin.java | 24 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/activity/IAbstractActivity.java | 14 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java | 3 |
10 files changed, 75 insertions, 39 deletions
diff --git a/main/res/values/strings.xml b/main/res/values/strings.xml index 8fbb72e..381e07e 100644 --- a/main/res/values/strings.xml +++ b/main/res/values/strings.xml @@ -1274,5 +1274,6 @@ <string name="showcase_logcache_text">Remember, many commands are now in the title bar. There you find the button for sending the finished log.</string> <string name="showcase_main_title">New menus</string> <string name="showcase_main_text">c:geo now places menu items in the title bar like other modern apps. Some items are hidden behind the dotted symbol. Long press a button to see its description.</string> - + <string name="showcase_cachelist_title">Switching lists</string> + <string name="showcase_cachelist_text">You can switch between your geocache lists by clicking the title of the list.</string> </resources> diff --git a/main/src/cgeo/geocaching/CacheListActivity.java b/main/src/cgeo/geocaching/CacheListActivity.java index 611d17e..717b6f5 100644 --- a/main/src/cgeo/geocaching/CacheListActivity.java +++ b/main/src/cgeo/geocaching/CacheListActivity.java @@ -7,6 +7,7 @@ import cgeo.geocaching.activity.AbstractListActivity; import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.activity.FilteredActivity; import cgeo.geocaching.activity.Progress; +import cgeo.geocaching.activity.ShowcaseViewBuilder; import cgeo.geocaching.apps.cache.navi.NavigationAppFactory; import cgeo.geocaching.apps.cachelist.CacheListAppFactory; import cgeo.geocaching.compatibility.Compatibility; @@ -58,6 +59,9 @@ import cgeo.geocaching.utils.Log; import ch.boye.httpclientandroidlib.HttpResponse; +import com.github.amlcurran.showcaseview.targets.ActionViewTarget; +import com.github.amlcurran.showcaseview.targets.ActionViewTarget.Type; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; @@ -427,9 +431,9 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA if (isInvokedFromAttachment()) { importGpxAttachement(); } - - - + else { + presentShowcase(); + } } /** @@ -1741,4 +1745,11 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA } return numbers.isEmpty() ? null : StringUtils.join(numbers, '/'); } + + @Override + public ShowcaseViewBuilder getShowcase() { + return new ShowcaseViewBuilder(this) + .setTarget(new ActionViewTarget(this, Type.SPINNER)) + .setContent(R.string.showcase_cachelist_title, R.string.showcase_cachelist_text); + } } diff --git a/main/src/cgeo/geocaching/LogCacheActivity.java b/main/src/cgeo/geocaching/LogCacheActivity.java index 26b4f26..bc87525 100644 --- a/main/src/cgeo/geocaching/LogCacheActivity.java +++ b/main/src/cgeo/geocaching/LogCacheActivity.java @@ -645,7 +645,7 @@ public class LogCacheActivity extends AbstractLoggingActivity implements DateDia } @Override - protected ShowcaseViewBuilder getShowcase() { + public ShowcaseViewBuilder getShowcase() { return new ShowcaseViewBuilder(this) .setTarget(new ActionItemTarget(this, R.id.menu_send)) .setContent(R.string.showcase_logcache_title, R.string.showcase_logcache_text); diff --git a/main/src/cgeo/geocaching/MainActivity.java b/main/src/cgeo/geocaching/MainActivity.java index ed58875..18b3b01 100644 --- a/main/src/cgeo/geocaching/MainActivity.java +++ b/main/src/cgeo/geocaching/MainActivity.java @@ -753,7 +753,7 @@ public class MainActivity extends AbstractActionBarActivity { } @Override - protected ShowcaseViewBuilder getShowcase() { + public ShowcaseViewBuilder getShowcase() { return new ShowcaseViewBuilder(this) .setTarget(new ActionViewTarget(this, ActionViewTarget.Type.OVERFLOW)) .setContent(R.string.showcase_main_title, R.string.showcase_main_text); diff --git a/main/src/cgeo/geocaching/SearchActivity.java b/main/src/cgeo/geocaching/SearchActivity.java index 363b157..edd611a 100644 --- a/main/src/cgeo/geocaching/SearchActivity.java +++ b/main/src/cgeo/geocaching/SearchActivity.java @@ -421,7 +421,7 @@ public class SearchActivity extends AbstractActionBarActivity implements Coordin } @Override - protected ShowcaseViewBuilder getShowcase() { + public ShowcaseViewBuilder getShowcase() { // The showcase doesn't work well with the search activity, because on searching a geocode (or // selecting a cache from the search field) we immediately close the activity. That in turn confuses the delayed // creation of the showcase bitmap. To avoid someone running into this issue again, this method explicitly overrides diff --git a/main/src/cgeo/geocaching/activity/AbstractActivity.java b/main/src/cgeo/geocaching/activity/AbstractActivity.java index 442217d..4480f8f 100644 --- a/main/src/cgeo/geocaching/activity/AbstractActivity.java +++ b/main/src/cgeo/geocaching/activity/AbstractActivity.java @@ -77,26 +77,13 @@ public abstract class AbstractActivity extends ActionBarActivity implements IAbs initializeCommonFields(); } - /** - * Call this method to actually present a showcase. The right time to invoke this method depends on the showcase - * target. I.e. if the showcase target is an action bar item, this method can only be invoked after that item has - * been created in onCreateOptionsMenu. - */ - protected final void presentShowcase() { - final ShowcaseViewBuilder builder = getShowcase(); - if (builder != null) { - builder.setStyle(R.style.ShowcaseView); - builder.build(); - } + @Override + public final void presentShowcase() { + ActivityMixin.presentShowcase(this); } - /** - * Override this method to create a showcase view highlighting the most important UI element. - * - * @return - */ - @SuppressWarnings("static-method") - protected ShowcaseViewBuilder getShowcase() { + @Override + public ShowcaseViewBuilder getShowcase() { // do nothing by default return null; } diff --git a/main/src/cgeo/geocaching/activity/AbstractListActivity.java b/main/src/cgeo/geocaching/activity/AbstractListActivity.java index eac191a..718dc70 100644 --- a/main/src/cgeo/geocaching/activity/AbstractListActivity.java +++ b/main/src/cgeo/geocaching/activity/AbstractListActivity.java @@ -32,17 +32,17 @@ public abstract class AbstractListActivity extends ActionBarListActivity impleme } @Override - public final void showToast(String text) { + public final void showToast(final String text) { ActivityMixin.showToast(this, text); } @Override - public final void showShortToast(String text) { + public final void showShortToast(final String text) { ActivityMixin.showShortToast(this, text); } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); @@ -55,7 +55,7 @@ public abstract class AbstractListActivity extends ActionBarListActivity impleme } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(final MenuItem item) { if (item.getItemId()== android.R.id.home) { return ActivityMixin.navigateUp(this); } @@ -79,7 +79,7 @@ public abstract class AbstractListActivity extends ActionBarListActivity impleme ActivityMixin.invalidateOptionsMenu(this); } - public void onCreate(Bundle savedInstanceState, int resourceLayoutID) { + public void onCreate(final Bundle savedInstanceState, final int resourceLayoutID) { super.onCreate(savedInstanceState); initializeCommonFields(); @@ -88,10 +88,22 @@ public abstract class AbstractListActivity extends ActionBarListActivity impleme } @Override - public void setContentView(int layoutResID) { + public void setContentView(final int layoutResID) { super.setContentView(layoutResID); // initialize action bar title with activity title ActivityMixin.setTitle(this, getTitle()); } + + @Override + public final void presentShowcase() { + ActivityMixin.presentShowcase(this); + } + + @Override + public ShowcaseViewBuilder getShowcase() { + // do nothing by default + return null; + } + } diff --git a/main/src/cgeo/geocaching/activity/ActivityMixin.java b/main/src/cgeo/geocaching/activity/ActivityMixin.java index b58d3ae..f91de7e 100644 --- a/main/src/cgeo/geocaching/activity/ActivityMixin.java +++ b/main/src/cgeo/geocaching/activity/ActivityMixin.java @@ -103,13 +103,13 @@ public final class ActivityMixin { postShowToast(activity, text, Toast.LENGTH_SHORT); } - public static void keepScreenOn(final Activity abstractActivity, boolean keepScreenOn) { + public static void keepScreenOn(final Activity abstractActivity, final boolean keepScreenOn) { if (keepScreenOn) { abstractActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } } - public static void invalidateOptionsMenu(Activity activity) { + public static void invalidateOptionsMenu(final Activity activity) { if (activity instanceof ActionBarActivity) { ((ActionBarActivity) activity).supportInvalidateOptionsMenu(); } @@ -127,10 +127,10 @@ public final class ActivityMixin { * place the cursor after the inserted text */ public static void insertAtPosition(final EditText editText, final String insertText, final boolean moveCursor) { - int selectionStart = editText.getSelectionStart(); - int selectionEnd = editText.getSelectionEnd(); - int start = Math.min(selectionStart, selectionEnd); - int end = Math.max(selectionStart, selectionEnd); + final int selectionStart = editText.getSelectionStart(); + final int selectionEnd = editText.getSelectionEnd(); + final int start = Math.min(selectionStart, selectionEnd); + final int end = Math.max(selectionStart, selectionEnd); final String content = editText.getText().toString(); String completeText; @@ -141,13 +141,13 @@ public final class ActivityMixin { } editText.getText().replace(start, end, completeText); - int newCursor = moveCursor ? start + completeText.length() : start; + final int newCursor = moveCursor ? start + completeText.length() : start; editText.setSelection(newCursor); } public static boolean navigateUp(@NonNull final Activity activity) { // see http://developer.android.com/training/implementing-navigation/ancestral.html - Intent upIntent = NavUtils.getParentActivityIntent(activity); + final Intent upIntent = NavUtils.getParentActivityIntent(activity); if (upIntent == null) { activity.finish(); return true; @@ -167,4 +167,12 @@ public final class ActivityMixin { } return true; } + + public static void presentShowcase(final IAbstractActivity activity) { + final ShowcaseViewBuilder builder = activity.getShowcase(); + if (builder != null) { + builder.setStyle(R.style.ShowcaseView); + builder.build(); + } + } } diff --git a/main/src/cgeo/geocaching/activity/IAbstractActivity.java b/main/src/cgeo/geocaching/activity/IAbstractActivity.java index 4fb6a2a..59aa284 100644 --- a/main/src/cgeo/geocaching/activity/IAbstractActivity.java +++ b/main/src/cgeo/geocaching/activity/IAbstractActivity.java @@ -8,4 +8,18 @@ public interface IAbstractActivity { public void showShortToast(String text); public void invalidateOptionsMenuCompatible(); + + /** + * Override this method to create a showcase view highlighting the most important UI element. + * + */ + public ShowcaseViewBuilder getShowcase(); + + /** + * Call this method to actually present a showcase. The right time to invoke this method depends on the showcase + * target. I.e. if the showcase target is an action bar item, this method can only be invoked after that item has + * been created in onCreateOptionsMenu. + */ + public void presentShowcase(); + } diff --git a/main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java b/main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java index 2d34b34..6b00f0f 100644 --- a/main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java +++ b/main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java @@ -5,6 +5,9 @@ import com.github.amlcurran.showcaseview.targets.Target; import android.app.Activity; +/** + * TODO: replace by simple utility class embedding a builder instead of inheriting from it + */ public class ShowcaseViewBuilder extends Builder { private final Activity activity; |
