diff options
Diffstat (limited to 'main/src/cgeo/geocaching/activity')
5 files changed, 15 insertions, 62 deletions
diff --git a/main/src/cgeo/geocaching/activity/AbstractActivity.java b/main/src/cgeo/geocaching/activity/AbstractActivity.java index 4cddfe6..6ceead0 100644 --- a/main/src/cgeo/geocaching/activity/AbstractActivity.java +++ b/main/src/cgeo/geocaching/activity/AbstractActivity.java @@ -6,6 +6,7 @@ import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.Geocache; import cgeo.geocaching.R; import cgeo.geocaching.enumerations.CacheType; +import cgeo.geocaching.network.AndroidBeam; import cgeo.geocaching.network.Cookies; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.ClipboardUtils; @@ -20,14 +21,8 @@ import org.eclipse.jdt.annotation.Nullable; import rx.Subscription; import rx.subscriptions.Subscriptions; -import android.annotation.TargetApi; import android.content.Intent; import android.content.res.Resources; -import android.nfc.NdefMessage; -import android.nfc.NdefRecord; -import android.nfc.NfcAdapter; -import android.nfc.NfcEvent; -import android.os.Build; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.support.v7.view.ActionMode; @@ -78,6 +73,7 @@ public abstract class AbstractActivity extends ActionBarActivity implements IAbs supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); initializeCommonFields(); + AndroidBeam.disable(this); } @Override @@ -206,44 +202,6 @@ public abstract class AbstractActivity extends ActionBarActivity implements IAbs } } - // Do not support older devices than Android 4.0 - // Although there even are 2.3 devices (Nexus S) - // these are so few that we don't want to deal with the older (non Android Beam) API - - public interface ActivitySharingInterface { - /** Return an URL that represent the current activity for sharing or null for no sharing. */ - public String getAndroidBeamUri(); - } - - protected void initializeAndroidBeam(final ActivitySharingInterface sharingInterface) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - initializeICSAndroidBeam(sharingInterface); - } - } - - @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) - protected void initializeICSAndroidBeam(final ActivitySharingInterface sharingInterface) { - final NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); - if (nfcAdapter == null) { - return; - } - nfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() { - @Override - public NdefMessage createNdefMessage(final NfcEvent event) { - final String uri = sharingInterface.getAndroidBeamUri(); - if (uri == null) { - return null; - } - final NdefRecord[] records = { - NdefRecord.createUri(uri), - NdefRecord.createApplicationRecord(CgeoApplication.getInstance().getPackageName()) - }; - return new NdefMessage(records); - } - }, this); - - } - protected void setCacheTitleBar(@Nullable final String geocode, @Nullable final String name, @Nullable final CacheType type) { if (StringUtils.isNotBlank(name)) { setTitle(StringUtils.isNotBlank(geocode) ? name + " (" + geocode + ")" : name); diff --git a/main/src/cgeo/geocaching/activity/AbstractListActivity.java b/main/src/cgeo/geocaching/activity/AbstractListActivity.java index d7482c3..86ca98f 100644 --- a/main/src/cgeo/geocaching/activity/AbstractListActivity.java +++ b/main/src/cgeo/geocaching/activity/AbstractListActivity.java @@ -1,6 +1,7 @@ package cgeo.geocaching.activity; import cgeo.geocaching.CgeoApplication; +import cgeo.geocaching.network.AndroidBeam; import android.content.res.Resources; import android.os.Bundle; @@ -48,6 +49,7 @@ public abstract class AbstractListActivity extends ActionBarListActivity impleme initializeCommonFields(); initUpAction(); + AndroidBeam.disable(this); } protected void initUpAction() { diff --git a/main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java b/main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java index 64186a0..11a5436 100644 --- a/main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java +++ b/main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java @@ -68,14 +68,12 @@ public abstract class AbstractViewPagerActivity<Page extends Enum<Page>> extends /** * Returns a validated view. * - * @return */ public View getDispatchedView(final ViewGroup parentView); /** * Returns a (maybe cached) view. * - * @return */ public View getView(final ViewGroup parentView); diff --git a/main/src/cgeo/geocaching/activity/ActivityMixin.java b/main/src/cgeo/geocaching/activity/ActivityMixin.java index 14a2fbf..5b3be70 100644 --- a/main/src/cgeo/geocaching/activity/ActivityMixin.java +++ b/main/src/cgeo/geocaching/activity/ActivityMixin.java @@ -1,5 +1,7 @@ package cgeo.geocaching.activity; +import cgeo.geocaching.CgeoApplication; +import cgeo.geocaching.MainActivity; import cgeo.geocaching.R; import cgeo.geocaching.settings.Settings; @@ -133,8 +135,6 @@ public final class ActivityMixin { /** * insert text into the EditText at the current cursor position * - * @param editText - * @param insertText * @param moveCursor * place the cursor after the inserted text */ @@ -157,22 +157,18 @@ public final class ActivityMixin { editText.setSelection(newCursor); } - /** - * This is the exact code from Google to implement Up navigation, with one exception: activity.isTaskRoot() was - * added as {@link NavUtils#shouldUpRecreateTask(Activity, Intent)} seems not to handle the case, that this activity - * was created from an intent by another app, and our own app is not yet running. The bug seems to be fixed in - * Android 4.4.something, however. - * - * @param activity - * @return - */ public static boolean navigateUp(@NonNull final Activity activity) { - // see http://developer.android.com/training/implementing-navigation/ancestral.html - final Intent upIntent = NavUtils.getParentActivityIntent(activity); - if (upIntent == null) { + // first check if there is a parent declared in the manifest + Intent upIntent = NavUtils.getParentActivityIntent(activity); + // if there is no parent, and if this was not a new task, then just go back to simulate going to a parent + if (upIntent == null && !activity.isTaskRoot()) { activity.finish(); return true; } + // use the main activity, if there was no back stack and no manifest based parent + if (upIntent == null) { + upIntent = new Intent(CgeoApplication.getInstance(), MainActivity.class); + } if (NavUtils.shouldUpRecreateTask(activity, upIntent) || activity.isTaskRoot()) { // This activity is NOT part of this app's task, so create a new task // when navigating up, with a synthesized back stack. @@ -190,7 +186,7 @@ public final class ActivityMixin { } public static void presentShowcase(final IAbstractActivity activity) { - if (VERSION.SDK_INT < 11) { + if (VERSION.SDK_INT < 14) { return; } final ShowcaseViewBuilder builder = activity.getShowcase(); diff --git a/main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java b/main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java index 14f9281..86f5302 100644 --- a/main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java +++ b/main/src/cgeo/geocaching/activity/ShowcaseViewBuilder.java @@ -29,7 +29,6 @@ public class ShowcaseViewBuilder extends Builder { /** * Use the hash of the title for the single shot remembering * - * @param title */ private void setSingleshot(final CharSequence title) { super.singleShot(title.hashCode()); |
