+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="lib" path="libs/android-support-v4.jar">
- <attributes>
- <attribute name="javadoc_location" value="file:/E:/tools/adt-bundle-windows-x86_64-20130917/sdk/extras/android/support/v4/docs/"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="lib" path="libs/org.opensrf2_serialized_reg.jar"/>
- <classpathentry kind="lib" path="libs/zxing_barcode.jar"/>
- <classpathentry kind="lib" path="libs/androwrapee-1.1.0.jar"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>EvergreenApp</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ApkBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
android:minSdkVersion="10"\r
android:targetSdkVersion="19" />\r
\r
+ <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>\r
+\r
+ <uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>\r
+ <uses-permission android:name="android.permission.USE_CREDENTIALS"/>\r
<application>\r
</application>\r
</manifest>\r
TextView signInText = (TextView) findViewById(R.id.account_sign_in_text);
signInText.setText(String.format(getString(R.string.ou_account_sign_in_message),
- AppPrefs.get(AppPrefs.LIBRARY_NAME)));
+ AppPrefs.getString(AppPrefs.LIBRARY_NAME)));
if (accountName != null) {
((TextView) findViewById(R.id.accountName)).setText(accountName);
}
submit();
}
});
- /*
- * findViewById(R.id.signUp).setOnClickListener(new
- * View.OnClickListener() {
- *
- * @Override public void onClick(View v) { // Since there can only be
- * one AuthenticatorActivity, we call the sign up activity, get his
- * results, // and return them in setAccountAuthenticatorResult(). See
- * finishLogin(). Intent signup = new Intent(getBaseContext(),
- * SignUpActivity.class); signup.putExtras(getIntent().getExtras());
- * startActivityForResult(signup, REQ_SIGNUP); } });
- */
+
if (savedInstanceState != null) {
Log.d(TAG, "onCreate> savedInstanceState="+savedInstanceState);
if (savedInstanceState.getString(STATE_ALERT_MESSAGE) != null) {
HttpConnection conn;
try {
- conn = new HttpConnection(AppPrefs.get(AppPrefs.LIBRARY_URL) + "/osrf-gateway-v1");
+ conn = new HttpConnection(AppPrefs.getString(AppPrefs.LIBRARY_URL) + "/osrf-gateway-v1");
} catch (MalformedURLException e) {
throw new AuthenticationException(e);
}
Log.d(TAG, "authtoken: " + authtoken);
Integer authtime = ((Map<String, Integer>) payload).get("authtime");
Log.d(TAG, "authtime: " + authtime);
+ AppPrefs.setBoolean(AppPrefs.EVER_LOGGED_IN, true);
return authtoken;
} else if (textcode.equals("LOGIN_FAILED")) {
String desc = ((Map<String, String>) resp).get("desc");
import android.preference.PreferenceManager;
import android.util.Log;
import org.evergreen_ils.R;
+import org.evergreen_ils.accountAccess.bookbags.BookBag;
/**
* Created by kenstir on 11/8/2015.
*/
public class AppPrefs {
+ public static final String EVER_LOGGED_IN = "ever_logged_in";
public static final String LIBRARY_URL = "library_url";
public static final String LIBRARY_NAME = "library_name";
private static final String VERSION = "version";
- private static final int PREFS_VERSION = 1;
+ // increment PREFS_VERSION every time you make a change to the persistent pref storage
+ private static final int PREFS_VERSION = 2;
private static final String TAG = AppPrefs.class.getSimpleName();
private static Context context;
private static boolean initialized;
SharedPreferences.Editor editor = prefs.edit();
version = PREFS_VERSION;
editor.putInt(VERSION, PREFS_VERSION);
- editor.putString("library_url", context.getString(R.string.ou_library_url));
- editor.putString("library_name", context.getString(R.string.ou_library_name));
+ editor.putBoolean(EVER_LOGGED_IN, false);
+ editor.putString(LIBRARY_URL, context.getString(R.string.ou_library_url));
+ editor.putString(LIBRARY_NAME, context.getString(R.string.ou_library_name));
editor.commit();
}
Log.d(TAG, "version=" + version);
- Log.d(TAG, "library_url=" + get(LIBRARY_URL));
- Log.d(TAG, "library_name=" + get(LIBRARY_NAME));
+ Log.d(TAG, "library_url=" + getString(LIBRARY_URL));
+ Log.d(TAG, "library_name=" + getString(LIBRARY_NAME));
}
- public static String get(String key) {
+ public static String getString(String key) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
return prefs.getString(key, null);
}
- public static void set(String key, String value) {
+ public static boolean getBoolean(String key) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ return prefs.getBoolean(key, false);
+ }
+
+ public static void setString(String key, String value) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
editor.putString(key, value);
editor.commit();
}
+
+ public static void setBoolean(String key, boolean value) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean(key, value);
+ editor.commit();
+ }
}
try {
// configure the connection
- conn = new HttpConnection(AppPrefs.get(AppPrefs.LIBRARY_URL) + "/osrf-gateway-v1");
+ conn = new HttpConnection(AppPrefs.getString(AppPrefs.LIBRARY_URL) + "/osrf-gateway-v1");
} catch (Exception e) {
Log.d(TAG, "error", e);
private void selectLibrary() {
if (selected_library != null) {
Log.d(TAG, "selected library " + selected_library.directory_name);
- AppPrefs.set(AppPrefs.LIBRARY_URL, selected_library.url);
- AppPrefs.set(AppPrefs.LIBRARY_NAME, selected_library.short_name);
+ AppPrefs.setString(AppPrefs.LIBRARY_URL, selected_library.url);
+ AppPrefs.setString(AppPrefs.LIBRARY_NAME, selected_library.short_name);
startSplashActivity();
}
@Override
protected void onStart() {
super.onStart();
- GlobalConfigs.httpAddress = AppPrefs.get(AppPrefs.LIBRARY_URL);// kenstir todo: replace all refs to GlobalConfigs.httpAddress
+ GlobalConfigs.httpAddress = AppPrefs.getString(AppPrefs.LIBRARY_URL);// kenstir todo: replace all refs to GlobalConfigs.httpAddress
Log.d(TAG, "kcxxx: onstart: url=" + GlobalConfigs.httpAddress);
if (!TextUtils.isEmpty(GlobalConfigs.httpAddress) && !restarted) {
startSplashActivity();
}
for (Map<String, ?> map : l) {
String url = (String) map.get("url");
- String directory_name = (String) map.get("library_name");
+ String directory_name = (String) map.get("directory_name");
String short_name = (String) map.get("short_name");
- if (short_name == null) {
- short_name = directory_name;
- try {
- short_name = short_name.replaceAll(".*\\((.*)\\).*", "$1");
- } catch (Exception e) {
- Log.d(TAG, "failed trimming short_name: " + short_name, e);
- }
- }
Library library = new Library(url, short_name, directory_name);
libraries.add(library);
}
import android.content.SharedPreferences;
import org.evergreen_ils.R;
import org.evergreen_ils.globals.GlobalConfigs;
-import org.evergreen_ils.searchCatalog.Library;
import org.evergreen_ils.globals.AppPrefs;
import org.evergreen_ils.views.MainActivity;
import org.evergreen_ils.views.splashscreen.LoadingTask.LoadingTaskListener;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
-import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
@Override
protected void onStart() {
super.onStart();
- GlobalConfigs.httpAddress = AppPrefs.get(AppPrefs.LIBRARY_URL);// kenstir todo: replace all refs to GlobalConfigs.httpAddress
- Log.d(TAG, "kcxxx: onstart: url=" + GlobalConfigs.httpAddress);
- if (!TextUtils.isEmpty(GlobalConfigs.httpAddress) && !restarted) {
+ GlobalConfigs.httpAddress = AppPrefs.getString(AppPrefs.LIBRARY_URL);// kenstir todo: replace all refs to GlobalConfigs.httpAddress
+ boolean ever_logged_in = AppPrefs.getBoolean(AppPrefs.EVER_LOGGED_IN);
+ Log.d(TAG, "kcxxx: onstart: url=" + GlobalConfigs.httpAddress + " ever_logged_in=" + ever_logged_in);
+ if (!TextUtils.isEmpty(GlobalConfigs.httpAddress) && ever_logged_in && !restarted) {
startTask();
}
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>android-support-v7-appcompat</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ApkBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>