</activity>\r
<activity\r
android:name="org.evergreen.android.views.StartupActivity"\r
- android:label="@string/ou_app_label"\r
+ android:label="@string/ou_app_name"\r
android:windowSoftInputMode="adjustResize|stateVisible" >\r
<intent-filter>\r
<action android:name="android.intent.action.MAIN" />\r
<resources>
<!-- TODO: make this HTTPS -->
<string name="ou_gateway_url">http://bark.cwmars.org/osrf-gateway-v1</string>
- <string name="ou_app_name">C/W Mars Library Rover</string>
+ <string name="ou_app_name">C/W Mars Library</string>
<string name="ou_app_label">C/W Mars</string>
+ <string name="ou_app_welcome_label">Welcome</string>
<string name="ou_account_label">C/W Mars Library</string>
<string name="ou_account_sign_in_message">Sign in to your\nC/W Mars Library Account</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
- android:accountType="org.evergreen_ils.opac"
+ android:accountType="org.evergreen_ils"
android:icon="@drawable/evergreen_launcher_icon"
android:smallIcon="@drawable/evergreen_launcher_icon"
android:label="@string/ou_account_label"/>
package org.evergreen.android;
-import org.evergreen.android.accountAccess.CurrentLogin;
+import org.evergreen.android.accountAccess.LoginController;
import android.app.Activity;
import android.os.Bundle;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
- String account_name = CurrentLogin.getUsername();
- String auth_token = CurrentLogin.getAuthToken();
+ String account_name = LoginController.getInstance(this).getAccountName();
+ String auth_token = LoginController.getInstance(this).getAuthToken();
tv.setText("account.name="+((account_name==null)?"null":account_name)
+ "\nauth_token="+((auth_token==null)?"null":auth_token));
setContentView(tv);
*/
public class AccountAccess {
- // Used for authentication purpose
-
- /** The SERVICE. */
public static String SERVICE_AUTH = "open-ils.auth";
/** The METHOD Auth init. */
/** The METHOD Auth session retrieve. */
public static String METHOD_AUTH_SESSION_RETRV = "open-ils.auth.session.retrieve";
- // Used for the Checked out Items Tab
-
- /** The SERVIC e_ actor. */
public static String SERVICE_ACTOR = "open-ils.actor";
-
- /** The SERVIC e_ circ. */
public static String SERVICE_CIRC = "open-ils.circ";
-
- /** The SERVIC e_ search. */
public static String SERVICE_SEARCH = "open-ils.search";
-
- /** The SERVIC e_ serial. */
public static String SERVICE_SERIAL = "open-ils.serial";
-
- /** The SERVIC e_ fielder. */
public static String SERVICE_FIELDER = "open-ils.fielder";
/** The METHOD_FETCH_CHECKED_OUT_SUM description : for a given user returns a a structure of circulation objects sorted by out, overdue, lost, claims_returned, long_overdue; A list of ID's returned for each type : "out":[id1,id2,...] @returns: { "out":[id 's],"claims_returned":[],"long_overdue":[],"overdue":[],"lost":[] } */
+++ /dev/null
-package org.evergreen.android.accountAccess;
-
-/**
- * data representing the current logged-in user
- * @author kenstir
- */
-public class CurrentLogin {
-
- protected static CurrentLogin mInstance = null;
-
- protected String mUsername = null;
- protected String mAuthToken = null;
-
- protected CurrentLogin() {
- }
-
- protected static CurrentLogin getInstance() {
- if (mInstance == null)
- mInstance = new CurrentLogin();
- return mInstance;
- }
-
- public static void clear() {
- mInstance = null;
- }
-
- public static void setAccountInfo(String username, String auth_token) {
- getInstance().mUsername = username;
- getInstance().mAuthToken = auth_token;
- }
-
- public static String getUsername() {
- return getInstance().mUsername;
- }
-
- public static String getAuthToken() {
- return getInstance().mAuthToken;
- }
-}
--- /dev/null
+package org.evergreen.android.accountAccess;
+
+import org.evergreen.android.JunkActivity;
+import org.evergreen.android.R;
+import org.evergreen.android.globals.AppPreferences;
+import org.evergreen.android.views.StartupActivity;
+import org.evergreen_ils.auth.Const;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AccountManagerCallback;
+import android.accounts.AccountManagerFuture;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.ContextThemeWrapper;
+import android.widget.Toast;
+
+/**
+ * Handle common Activity startup: making sure we have an account, and an auth_token.
+ *
+ * @author kenstir
+ *
+ */
+public class LoginController {
+
+ protected static LoginController mInstance = null;
+
+ private String TAG = LoginController.class.getSimpleName();
+ protected String mAccountName = null;
+ protected String mAuthToken = null;
+ protected StartupTask mStartupTask = null;
+ private Activity mActivity = null;
+ private Class<?> mNextActivityClass = null;
+ private AppPreferences mAppPrefs = null;
+ private AccountManager mAccountManager;
+
+ protected LoginController() {
+ }
+
+ protected void setActivity(Activity a) {
+ mActivity = a;
+ if (mAppPrefs == null) mAppPrefs = new AppPreferences(a);
+ if (mAccountManager == null) mAccountManager = AccountManager.get(a);
+ }
+
+ public static LoginController getInstance(Activity a) {
+ if (mInstance == null)
+ mInstance = new LoginController();
+ mInstance.setActivity(a);
+ return mInstance;
+ }
+
+ public static LoginController getInstance() {
+ return mInstance;
+ }
+
+ public static String getAccountName() {
+ return getInstance().mAccountName;
+ }
+
+ public static String getAuthToken() {
+ return getInstance().mAuthToken;
+ }
+
+ /** login and stay on the current activity, for use by non-startup activity */
+ public void login() {
+ loginForActivity(null);
+ }
+
+ /** login and forward to another activity, for use by startup/splash activity */
+ public void loginForActivity(Class nextActivity) {
+ mNextActivityClass = nextActivity;
+
+ final String auth_token = getAuthToken();
+ if (TextUtils.isEmpty(auth_token)) {
+ getTokenForLastActiveAccount();
+ } else {
+ Log.d(TAG, "signIn> already have auth_token");
+ startNextActivity();
+ }
+ }
+
+ private void getTokenForLastActiveAccount() {
+ final String username = mAppPrefs.getLastAccountName();
+ Log.d(TAG, "getToken> username="+username);
+
+ // first try to get an auth token for the last account used
+ if (!TextUtils.isEmpty(username)) {
+ if (reuseExistingAccountAuthToken(username)) {
+ Log.d(TAG, "getToken> reuseExisting returned true");
+ }
+ } else {
+ getTokenForAccountCreateIfNeeded();
+ }
+ }
+
+ /**
+ * Add new account to the account manager
+ */
+ private void addNewAccount() {
+ //final AccountManagerFuture<Bundle> future =
+ mAccountManager.addAccount(Const.ACCOUNT_TYPE, Const.AUTHTOKEN_TYPE, null, null, mActivity, new AccountManagerCallback<Bundle>() {
+ @Override
+ public void run(AccountManagerFuture<Bundle> future) {
+ try {
+ Bundle bnd = future.getResult();
+ final String account_name = bnd.getString(AccountManager.KEY_ACCOUNT_NAME);
+ showMessage("Account "+account_name+" was created");
+ mAppPrefs.putLastAccountName(account_name);
+ Log.d(TAG, "addNewAccount bnd=" + bnd);
+ } catch (Exception e) {
+ mAppPrefs.clearLastAccountName();
+ e.printStackTrace();
+ showMessage(e.getMessage());
+ }
+ }
+ }, null);
+ }
+
+ /**
+ * Show all the accounts registered on the account manager. Request an auth token upon user select.
+ * @param authTokenType
+ */
+ private void showAccountPicker() {
+ final Account availableAccounts[] = mAccountManager.getAccountsByType(Const.ACCOUNT_TYPE);
+
+ if (availableAccounts.length == 0) {
+ Toast.makeText(mActivity, "No accounts", Toast.LENGTH_SHORT).show();
+ addNewAccount();
+ } else {
+ String name[] = new String[availableAccounts.length];
+ for (int i = 0; i < availableAccounts.length; i++) {
+ name[i] = availableAccounts[i].name;
+ }
+
+ // Account picker
+ AlertDialog.Builder builder;
+ if (Build.VERSION.SDK_INT >= 1/*Build.VERSION_CODES.HONEYCOMB*/) {
+ builder = new AlertDialog.Builder(mActivity);
+ } else {
+ ContextThemeWrapper wrapper = new ContextThemeWrapper(mActivity, R.style.EvergreenTheme);
+ builder = new AlertDialog.Builder(wrapper);
+ }
+ AlertDialog aDialog = builder.setTitle("Pick Account").setItems(name, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ getExistingAccountAuthToken(availableAccounts[which]);
+ }
+ }).create();
+ aDialog.show();
+ }
+ }
+
+ private void getExistingAccountAuthToken(final Account account) {
+ final AccountManagerFuture<Bundle> future = mAccountManager.getAuthToken(account, Const.AUTHTOKEN_TYPE, null, mActivity,
+ new AccountManagerCallback<Bundle>() {
+ @Override
+ public void run(AccountManagerFuture<Bundle> future) {
+ Log.d(TAG, "getExistingAccountAuthToken> callback run> got future "+future);
+ }
+ }, null);
+
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Bundle bnd = future.getResult();
+ Log.d(TAG, "getExistingAccountAuthToken> thread run> got future "+future);
+ final String authtoken = bnd.getString(AccountManager.KEY_AUTHTOKEN);
+ final String account_name = bnd.getString(AccountManager.KEY_ACCOUNT_NAME);
+ onSuccessfulLogin(account_name, authtoken);
+ } catch (Exception e) {
+ Log.d(TAG, "getExistingAccountAuthToken caught "+e.getMessage());
+ onFailedLogin(e.getMessage());
+ }
+ }
+ }).start();
+ }
+
+ protected void onSuccessfulLogin(String account_name, String auth_token) {
+ Log.d(TAG,"onSuccessfulLogin> account_name "+account_name+" token "+auth_token);
+ showMessage((auth_token != null) ? "SUCCESS with "+account_name+"\ntoken: " + auth_token : "FAIL");
+ if (auth_token != null) {
+ mAppPrefs.putLastAccountName(account_name);
+ mAccountName = account_name;
+ mAuthToken = auth_token;
+ startNextActivity();
+ }
+ }
+
+ protected void onFailedLogin(String msg) {
+ mAppPrefs.clearLastAccountName();
+ mAccountName = null;
+ mAuthToken = null;
+ showMessage(msg);
+ }
+
+ private boolean reuseExistingAccountAuthToken(final String account_name) {
+ final Account availableAccounts[] = mAccountManager.getAccountsByType(Const.ACCOUNT_TYPE);
+ for (int i = 0; i < availableAccounts.length; i++) {
+ Log.d(TAG, "reuseExistingAccountAuthToken> looking for "+account_name+", found "+availableAccounts[i].name);
+ if (account_name.equals(availableAccounts[i].name)) {
+ Log.d(TAG, "reuseExistingAccountAuthToken> found it");
+ getExistingAccountAuthToken(availableAccounts[i]);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Invalidates the auth token for the account
+ * @param account
+ * @param authTokenType
+ */
+ private void invalidateAuthToken(final Account account) {
+ final AccountManagerFuture<Bundle> future = mAccountManager.getAuthToken(account, Const.AUTHTOKEN_TYPE, null, mActivity, null, null);
+
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Bundle bnd = future.getResult();
+
+ final String authtoken = bnd.getString(AccountManager.KEY_AUTHTOKEN);
+ mAccountManager.invalidateAuthToken(account.type, authtoken);
+ showMessage(account.name + " invalidated");
+ mAppPrefs.putLastAccountName(null);
+ } catch (Exception e) {
+ mAppPrefs.putLastAccountName(null);
+ e.printStackTrace();
+ showMessage(e.getMessage());
+ }
+ }
+ }).start();
+ }
+
+ /**
+ * Get an auth token for the account.
+ * If not exist - add it and then return its auth token.
+ * If one exist - return its auth token.
+ * If more than one exists - show a picker and return the select account's auth token.
+ * @param accountType
+ * @param authTokenType
+ */
+ private void getTokenForAccountCreateIfNeeded() {
+ Log.d(TAG, "getTokenForAccountCreateIfNeeded> ");
+ final AccountManagerFuture<Bundle> future = mAccountManager.getAuthTokenByFeatures(Const.ACCOUNT_TYPE, Const.AUTHTOKEN_TYPE, null, mActivity, null, null,
+ new AccountManagerCallback<Bundle>() {
+ @Override
+ public void run(AccountManagerFuture<Bundle> future) {
+ Bundle bnd = null;
+ try {
+ bnd = future.getResult();
+ Log.d(TAG, "getTokenForAccountCreateIfNeeded> bnd="+bnd);
+ final String authtoken = bnd.getString(AccountManager.KEY_AUTHTOKEN);
+ final String account_name = bnd.getString(AccountManager.KEY_ACCOUNT_NAME);
+ onSuccessfulLogin(account_name, authtoken);
+ } catch (Exception e) {
+ Log.d(TAG, "getTokenForAccountCreateIfNeeded> caught "+e.getMessage());
+ onFailedLogin(e.getMessage());
+ }
+ }
+ }
+ , null);
+ }
+
+ private void showMessage(final String msg) {
+ if (TextUtils.isEmpty(msg))
+ return;
+
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Log.d(TAG, "showMessage> "+msg);
+ Toast.makeText(mActivity, msg, Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
+
+ private void startNextActivity() {
+ //Intent intent = new Intent(this, SearchCatalogListView.class);
+ Intent intent = new Intent(mActivity, mNextActivityClass);
+ mActivity.startActivity(intent);
+ mActivity.finish();
+ }
+
+ public void downloadResources() {
+ if (mStartupTask != null) {
+ return;
+ }
+
+ // blah blah blah
+ // mDownloadTask = new LoginTask();
+ }
+
+ private class StartupTask extends AsyncTask<Void, Void, Boolean> {
+ @Override
+ protected Boolean doInBackground(Void... params) {
+ try {
+ // TODO
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ protected void onProgressUpdate(Void... params) {
+ }
+
+ @Override
+ protected void onPostExecute(final Boolean success) {
+ mStartupTask = null;
+ if (success) {
+ startNextActivity();
+ }
+ }
+
+ @Override
+ protected void onCancelled() {
+ mStartupTask = null;
+ }
+ }
+}
* Initialize function that retrieves IDL file and Orgs file
*/
private boolean initialize(Context context) {
-
if (init == false) {
-
- init = true;
- SharedPreferences preferences = PreferenceManager
- .getDefaultSharedPreferences(context);
- GlobalConfigs.httpAddress = preferences
- .getString("library_url", "");
- boolean noNetworkAccess = false;
- System.out.println("Check for network conenctivity");
- try {
- Utils.checkNetworkStatus((ConnectivityManager) context
+ // TODO do this in AsyncTask
+ loadIDLFile(context);
+ getOrganisations();
+ getCopyStatusesAvailable((ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE));
-
- } catch (NoNetworkAccessException e) {
- noNetworkAccess = true;
- } catch (NoAccessToServer e) {
-
- System.out.println("No access to network");
- Intent preferencesAnctivity = new Intent(context,
- ApplicationPreferences.class);
- context.startActivity(preferencesAnctivity);
-
- noNetworkAccess = true;
-
- }
- if (!noNetworkAccess) {
- loadIDLFile(context);
- getOrganisations();
-
- getCopyStatusesAvailable((ConnectivityManager) context
- .getSystemService(Context.CONNECTIVITY_SERVICE));
-
- AccountAccess.setAccountInfo(
- preferences.getString("username", ""),
- preferences.getString("password", ""));
-
- return true;
- }
- return false;
+ init = true;
+ return true;
}
return false;
}
for (int i = 0; i < ccs_list.size(); i++) {
OSRFObject ccs_obj = ccs_list.get(i);
if (ccs_obj.getString("opac_visible").equals("t")) {
-
CopyInformation.availableOrgStatuses.put(
ccs_obj.getInt("id") + "",
ccs_obj.getString("name"));
package org.evergreen.android.views;
import org.evergreen.android.R;
-import org.evergreen.android.accountAccess.CurrentLogin;
+import org.evergreen.android.accountAccess.LoginController;
import org.evergreen.android.globals.AppPreferences;
import org.evergreen.android.searchCatalog.SearchCatalogListView;
import org.evergreen.android.JunkActivity;
private String TAG = StartupActivity.class.getSimpleName();
private TextView mLoginStatusMessageView;
- private StartupTask mStartupTask = null;
private String mAlertMessage = null;
- private AppPreferences mAppPrefs;
- private AccountManager mAccountManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_startup);
- mAppPrefs = new AppPreferences(this);
- mAccountManager = AccountManager.get(this);
-
mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message);
- signIn();
- }
-
- public void signIn() {
- final String auth_token = CurrentLogin.getAuthToken();
- if (TextUtils.isEmpty(auth_token)) {
- getTokenForLastActiveAccount();
- } else {
- Log.d(TAG, "signIn> already have auth_token");
- initializeAccountInfo();
- }
- }
-
- private void getTokenForLastActiveAccount() {
- final String username = mAppPrefs.getLastAccountName();
- Log.d(TAG, "getToken> username="+username);
-
- // first try to get an auth token for the last account used
- if (!TextUtils.isEmpty(username)) {
- if (reuseExistingAccountAuthToken(username)) {
- Log.d(TAG, "getToken> reuseExisting returned true");
- }
- } else {
- getTokenForAccountCreateIfNeeded();
- }
+ LoginController.getInstance(this).loginForActivity(JunkActivity.class);
}
@Override
return true;
}
*/
-
- /**
- * Add new account to the account manager
- */
- private void addNewAccount() {
- //final AccountManagerFuture<Bundle> future =
- mAccountManager.addAccount(Const.ACCOUNT_TYPE, Const.AUTHTOKEN_TYPE, null, null, this, new AccountManagerCallback<Bundle>() {
- @Override
- public void run(AccountManagerFuture<Bundle> future) {
- try {
- Bundle bnd = future.getResult();
- final String account_name = bnd.getString(AccountManager.KEY_ACCOUNT_NAME);
- showMessage("Account "+account_name+" was created");
- mAppPrefs.putLastAccountName(account_name);
- Log.d(TAG, "addNewAccount bnd=" + bnd);
- } catch (Exception e) {
- mAppPrefs.clearLastAccountName();
- e.printStackTrace();
- showMessage(e.getMessage());
- }
- }
- }, null);
- }
-
- /**
- * Show all the accounts registered on the account manager. Request an auth token upon user select.
- * @param authTokenType
- */
- private void showAccountPicker() {
- final Account availableAccounts[] = mAccountManager.getAccountsByType(Const.ACCOUNT_TYPE);
-
- if (availableAccounts.length == 0) {
- Toast.makeText(this, "No accounts", Toast.LENGTH_SHORT).show();
- addNewAccount();
- } else {
- String name[] = new String[availableAccounts.length];
- for (int i = 0; i < availableAccounts.length; i++) {
- name[i] = availableAccounts[i].name;
- }
-
- // Account picker
- AlertDialog.Builder builder;
- if (Build.VERSION.SDK_INT >= 1/*Build.VERSION_CODES.HONEYCOMB*/) {
- builder = new AlertDialog.Builder(this);
- } else {
- ContextThemeWrapper wrapper = new ContextThemeWrapper(this, R.style.EvergreenTheme);
- builder = new AlertDialog.Builder(wrapper);
- }
- AlertDialog aDialog = builder.setTitle("Pick Account").setItems(name, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- getExistingAccountAuthToken(availableAccounts[which]);
- }
- }).create();
- aDialog.show();
- }
- }
-
- private void getExistingAccountAuthToken(final Account account) {
- final AccountManagerFuture<Bundle> future = mAccountManager.getAuthToken(account, Const.AUTHTOKEN_TYPE, null, this,
- new AccountManagerCallback<Bundle>() {
- @Override
- public void run(AccountManagerFuture<Bundle> future) {
- Log.d(TAG, "getExistingAccountAuthToken> callback run> got future "+future);
- }
- }, null);
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- Bundle bnd = future.getResult();
- Log.d(TAG, "getExistingAccountAuthToken> thread run> got future "+future);
- final String authtoken = bnd.getString(AccountManager.KEY_AUTHTOKEN);
- final String account_name = bnd.getString(AccountManager.KEY_ACCOUNT_NAME);
- onSuccessfulLogin(account_name, authtoken);
- } catch (Exception e) {
- Log.d(TAG, "getExistingAccountAuthToken caught "+e.getMessage());
- onFailedLogin(e.getMessage());
- }
- }
- }).start();
- }
-
- protected void onSuccessfulLogin(String account_name, String auth_token) {
- Log.d(TAG,"onSuccessfulLogin> account_name "+account_name+" token "+auth_token);
- showMessage((auth_token != null) ? "SUCCESS with "+account_name+"\ntoken: " + auth_token : "FAIL");
- if (auth_token != null) {
- mAppPrefs.putLastAccountName(account_name);
- CurrentLogin.setAccountInfo(account_name, auth_token);
- startNextActivity();
- }
- }
-
- protected void onFailedLogin(String msg) {
- mAppPrefs.clearLastAccountName();
- CurrentLogin.clear();
- showMessage(msg);
- }
-
- private boolean reuseExistingAccountAuthToken(final String account_name) {
- final Account availableAccounts[] = mAccountManager.getAccountsByType(Const.ACCOUNT_TYPE);
- for (int i = 0; i < availableAccounts.length; i++) {
- Log.d(TAG, "reuseExistingAccountAuthToken> looking for "+account_name+", found "+availableAccounts[i].name);
- if (account_name.equals(availableAccounts[i].name)) {
- Log.d(TAG, "reuseExistingAccountAuthToken> found it");
- getExistingAccountAuthToken(availableAccounts[i]);
- return true;
- }
- }
- return false;
- }
-
- /**
- * Invalidates the auth token for the account
- * @param account
- * @param authTokenType
- */
- private void invalidateAuthToken(final Account account) {
- final AccountManagerFuture<Bundle> future = mAccountManager.getAuthToken(account, Const.AUTHTOKEN_TYPE, null, this, null,null);
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- Bundle bnd = future.getResult();
-
- final String authtoken = bnd.getString(AccountManager.KEY_AUTHTOKEN);
- mAccountManager.invalidateAuthToken(account.type, authtoken);
- showMessage(account.name + " invalidated");
- mAppPrefs.putLastAccountName(null);
- } catch (Exception e) {
- mAppPrefs.putLastAccountName(null);
- e.printStackTrace();
- showMessage(e.getMessage());
- }
- }
- }).start();
- }
-
- /**
- * Get an auth token for the account.
- * If not exist - add it and then return its auth token.
- * If one exist - return its auth token.
- * If more than one exists - show a picker and return the select account's auth token.
- * @param accountType
- * @param authTokenType
- */
- private void getTokenForAccountCreateIfNeeded() {
- Log.d(TAG, "getTokenForAccountCreateIfNeeded> ");
- final AccountManagerFuture<Bundle> future = mAccountManager.getAuthTokenByFeatures(Const.ACCOUNT_TYPE, Const.AUTHTOKEN_TYPE, null, this, null, null,
- new AccountManagerCallback<Bundle>() {
- @Override
- public void run(AccountManagerFuture<Bundle> future) {
- Bundle bnd = null;
- try {
- bnd = future.getResult();
- Log.d(TAG, "getTokenForAccountCreateIfNeeded> bnd="+bnd);
- final String authtoken = bnd.getString(AccountManager.KEY_AUTHTOKEN);
- final String account_name = bnd.getString(AccountManager.KEY_ACCOUNT_NAME);
- onSuccessfulLogin(account_name, authtoken);
- } catch (Exception e) {
- Log.d(TAG, "getTokenForAccountCreateIfNeeded> caught "+e.getMessage());
- onFailedLogin(e.getMessage());
- }
- }
- }
- , null);
- }
-
- private void showMessage(final String msg) {
- if (TextUtils.isEmpty(msg))
- return;
-
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Log.d(TAG, "showMessage> "+msg);
- Toast.makeText(getBaseContext(), msg, Toast.LENGTH_SHORT).show();
- }
- });
- }
-
- private void startNextActivity() {
- //Intent intent = new Intent(this, SearchCatalogListView.class);
- Intent intent = new Intent(this, JunkActivity.class);
- startActivity(intent);
- finish();
- }
-
- public void downloadResources() {
- if (mStartupTask != null) {
- return;
- }
-
- // blah blah blah
- // mDownloadTask = new LoginTask();
- }
-
- private class StartupTask extends AsyncTask<Void, Void, Boolean> {
- @Override
- protected Boolean doInBackground(Void... params) {
- try {
- // TODO
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- return false;
- }
-
- return true;
- }
-
- @Override
- protected void onProgressUpdate(Void... params) {
- }
-
- @Override
- protected void onPostExecute(final Boolean success) {
- mStartupTask = null;
- if (success) {
- startNextActivity();
- }
- }
-
- @Override
- protected void onCancelled() {
- mStartupTask = null;
- }
- }
}
package org.evergreen_ils.auth;
public class Const {
- public static final String ACCOUNT_TYPE = "org.evergreen_ils.opac";
+ public static final String ACCOUNT_TYPE = "org.evergreen_ils";
public static final String AUTHTOKEN_TYPE = "opac";
public static final String AUTHTOKEN_TYPE_LABEL = "Online Public Access Catalog";
}