diff options
| author | rsudev <rasch@munin-soft.de> | 2014-04-07 22:27:55 +0200 |
|---|---|---|
| committer | rsudev <rasch@munin-soft.de> | 2014-04-07 22:27:55 +0200 |
| commit | 0c407b7982e9f018853812731d69dc90f32358a2 (patch) | |
| tree | c09d1baef168392afd2a90cd53b31dd3943cf8bd /main/src/cgeo/geocaching/connector/oc/OCAuthorizationActivity.java | |
| parent | 3958777a5cf254ac2bfbb5cb569cfbd42abfb49f (diff) | |
| download | cgeo-0c407b7982e9f018853812731d69dc90f32358a2.zip cgeo-0c407b7982e9f018853812731d69dc90f32358a2.tar.gz cgeo-0c407b7982e9f018853812731d69dc90f32358a2.tar.bz2 | |
Refactoring opencaching implementation
Diffstat (limited to 'main/src/cgeo/geocaching/connector/oc/OCAuthorizationActivity.java')
| -rw-r--r-- | main/src/cgeo/geocaching/connector/oc/OCAuthorizationActivity.java | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/main/src/cgeo/geocaching/connector/oc/OCAuthorizationActivity.java b/main/src/cgeo/geocaching/connector/oc/OCAuthorizationActivity.java index 19f4447..eb7e7a1 100644 --- a/main/src/cgeo/geocaching/connector/oc/OCAuthorizationActivity.java +++ b/main/src/cgeo/geocaching/connector/oc/OCAuthorizationActivity.java @@ -1,6 +1,6 @@ package cgeo.geocaching.connector.oc; -import cgeo.geocaching.CgeoApplication; +import cgeo.geocaching.Intents; import cgeo.geocaching.R; import cgeo.geocaching.connector.oc.OkapiError.OkapiErrors; import cgeo.geocaching.network.OAuthAuthorizationActivity; @@ -12,43 +12,51 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.eclipse.jdt.annotation.Nullable; -public abstract class OCAuthorizationActivity extends OAuthAuthorizationActivity { +import android.os.Bundle; - final IOCAuthParams authParams; +public class OCAuthorizationActivity extends OAuthAuthorizationActivity { - public OCAuthorizationActivity(IOCAuthParams authParams) { - super(authParams.getSite(), - "/okapi/services/oauth/request_token", - "/okapi/services/oauth/authorize", - "/okapi/services/oauth/access_token", - false, - CgeoApplication.getInstance().getResources().getString(authParams.getCKResId()), - CgeoApplication.getInstance().getResources().getString(authParams.getCSResId()), - authParams.getCallbackUri()); - this.authParams = authParams; + private int titleResId; + private int tokenPublicPrefKey; + private int tokenSecretPrefKey; + private int tempTokenPublicPrefKey; + private int tempTokenSecretPrefKey; + + @Override + public void onCreate(Bundle savedInstanceState) { + + Bundle extras = getIntent().getExtras(); + if (extras != null) { + titleResId = extras.getInt(Intents.EXTRA_OAUTH_TITLE_RES_ID); + tokenPublicPrefKey = extras.getInt(Intents.EXTRA_OAUTH_TOKEN_PUBLIC_KEY); + tokenSecretPrefKey = extras.getInt(Intents.EXTRA_OAUTH_TOKEN_SECRET_KEY); + tempTokenPublicPrefKey = extras.getInt(Intents.EXTRA_OAUTH_TEMP_TOKEN_KEY_PREF); + tempTokenSecretPrefKey = extras.getInt(Intents.EXTRA_OAUTH_TEMP_TOKEN_SECRET_PREF); + } + super.onCreate(savedInstanceState); } @Override protected ImmutablePair<String, String> getTempTokens() { - return Settings.getTokenPair(authParams.getTempTokenPublicPrefKey(), authParams.getTempTokenSecretPrefKey()); + return Settings.getTokenPair(tempTokenPublicPrefKey, tempTokenSecretPrefKey); } @Override protected void setTempTokens(@Nullable final String tokenPublic, @Nullable final String tokenSecret) { - Settings.setTokens(authParams.getTempTokenPublicPrefKey(), tokenPublic, authParams.getTempTokenSecretPrefKey(), tokenSecret); + Settings.setTokens(tempTokenPublicPrefKey, tokenPublic, tempTokenSecretPrefKey, tokenSecret); } @Override protected void setTokens(@Nullable final String tokenPublic, @Nullable final String tokenSecret, final boolean enable) { - Settings.setTokens(authParams.getTokenPublicPrefKey(), tokenPublic, authParams.getTokenSecretPrefKey(), tokenSecret); + Settings.setTokens(tokenPublicPrefKey, tokenPublic, tokenSecretPrefKey, tokenSecret); if (tokenPublic != null) { - Settings.setTokens(authParams.getTempTokenPublicPrefKey(), null, authParams.getTempTokenSecretPrefKey(), null); + Settings.setTokens(tempTokenPublicPrefKey, null, tempTokenSecretPrefKey, null); } } @Override protected String getAuthTitle() { - return res.getString(authParams.getAuthTitleResId()); + return res.getString(titleResId); } @Override @@ -67,5 +75,4 @@ public abstract class OCAuthorizationActivity extends OAuthAuthorizationActivity } return StringUtils.EMPTY; } - } |
