From c85df2fdcad70d4b74c4c0fe970a2bf146e12882 Mon Sep 17 00:00:00 2001 From: kenstir Date: Sun, 8 Nov 2015 21:55:33 -0500 Subject: [PATCH] Mostly working version of generic EG app. Main points are: * eg_app main activity is ChooseLibraryActivity, whereas cwmars_app main activity is SplashActivity (need a better name for that). * there is a little bit of weirdness when you create an account using eg_app and then restart and then hit Back. * there is a bug when you add a 2nd account using the eg_app * in general the app prefs are stored in the new class AppPrefs, though there are still some references to GlobalConfigs.httpAddress --- .../src/Android/core/res/layout/activity_login.xml | 2 +- .../Android/core/res/layout/activity_splash.xml | 2 +- Open-ILS/src/Android/core/res/values/ou.xml | 21 ++-- Open-ILS/src/Android/core/res/xml/preferences.xml | 4 + .../evergreen_ils/accountAccess/AccountAccess.java | 2 +- .../accountAccess/holds/PlaceHold.java | 2 +- .../evergreen_ils/auth/AuthenticatorActivity.java | 7 +- .../evergreen_ils/auth/EvergreenAuthenticator.java | 4 +- .../evergreen_ils/barcodescan/CaptureActivity.java | 2 +- .../src/org/evergreen_ils/globals/AppPrefs.java | 55 +++++++++++ .../core/src/org/evergreen_ils/globals/Utils.java | 2 +- .../org/evergreen_ils/searchCatalog/Library.java | 12 ++- .../evergreen_ils/searchCatalog/SearchCatalog.java | 10 +- .../searchCatalog/SearchCatalogListView.java | 2 +- .../evergreen_ils/views/ChooseLibraryActivity.java | 107 +++++++++++++++------ ...ferences.java => UnusedPreferenceActivity.java} | 11 +-- .../views/splashscreen/SplashActivity.java | 57 ++++++----- .../src/Android/cwmars_app/AndroidManifest.xml | 4 +- Open-ILS/src/Android/cwmars_app/res/values/ou.xml | 5 +- Open-ILS/src/Android/eg_app/AndroidManifest.xml | 10 +- Open-ILS/src/Android/eg_app/res/values/ou.xml | 8 +- Open-ILS/src/Android/kenstir_parse_logcat.pl | 4 +- 22 files changed, 224 insertions(+), 109 deletions(-) create mode 100644 Open-ILS/src/Android/core/src/org/evergreen_ils/globals/AppPrefs.java rename Open-ILS/src/Android/core/src/org/evergreen_ils/views/{ApplicationPreferences.java => UnusedPreferenceActivity.java} (92%) diff --git a/Open-ILS/src/Android/core/res/layout/activity_login.xml b/Open-ILS/src/Android/core/res/layout/activity_login.xml index acb821d2e7..bf9fb155f5 100644 --- a/Open-ILS/src/Android/core/res/layout/activity_login.xml +++ b/Open-ILS/src/Android/core/res/layout/activity_login.xml @@ -9,7 +9,7 @@ > + android:contentDescription="@string/ou_library_name" /> - Evergreen Library - Sign in to your\nEvergreen Library Account - - org.evergreen_ils - Evergreen Library - Evergreen Library - + + Example Library + + Sign in to your\n%1$s account + + org.evergreen_ils.example + + Evergreen + + EXAMPLE + + https://demo.evergreencatalog.com diff --git a/Open-ILS/src/Android/core/res/xml/preferences.xml b/Open-ILS/src/Android/core/res/xml/preferences.xml index 69026924d2..b9032ea127 100644 --- a/Open-ILS/src/Android/core/res/xml/preferences.xml +++ b/Open-ILS/src/Android/core/res/xml/preferences.xml @@ -20,5 +20,9 @@ android:entryValues="@array/notification_preferences_list_values" android:defaultValue="3" /> + + \ No newline at end of file diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/AccountAccess.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/AccountAccess.java index 0cc1683837..7f2319c183 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/AccountAccess.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/AccountAccess.java @@ -150,7 +150,7 @@ public class AccountAccess { private String httpAddress = "http://ulysses.calvin.edu"; /** The TAG. */ - private final String TAG = AccountAccess.class.getName(); + private final String TAG = AccountAccess.class.getSimpleName(); /** * The auth token. Sent with every request that needs authentication diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/holds/PlaceHold.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/holds/PlaceHold.java index 65df3b48b8..54b8eeb078 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/holds/PlaceHold.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/accountAccess/holds/PlaceHold.java @@ -328,7 +328,7 @@ public class PlaceHold extends ActionBarActivity { } }); - // kcxxx: factor this out + // kenstir todo: factor this out int homeLibrary = 0; if (AccountAccess.getAccountAccess() != null) { homeLibrary = AccountAccess.getAccountAccess().getHomeLibraryID(); diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AuthenticatorActivity.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AuthenticatorActivity.java index f43042a15d..eb8223dfd2 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AuthenticatorActivity.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AuthenticatorActivity.java @@ -18,6 +18,7 @@ import android.util.Log; import android.view.ContextThemeWrapper; import android.view.View; import android.widget.TextView; +import org.evergreen_ils.globals.AppPrefs; public class AuthenticatorActivity extends AccountAuthenticatorActivity { @@ -46,8 +47,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); - // make sure default values are set up for preferences - PreferenceManager.setDefaultValues(this, R.xml.preferences, false); + AppPrefs.init(this); accountManager = AccountManager.get(getBaseContext()); @@ -58,6 +58,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity { authTokenType = Const.AUTHTOKEN_TYPE; Log.d(TAG, "onCreate> authTokenType="+authTokenType); + 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))); if (accountName != null) { ((TextView) findViewById(R.id.accountName)).setText(accountName); } diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/EvergreenAuthenticator.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/EvergreenAuthenticator.java index 0e32462f57..6725506f82 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/EvergreenAuthenticator.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/auth/EvergreenAuthenticator.java @@ -7,6 +7,7 @@ import java.util.HashMap; import java.util.Map; import android.preference.PreferenceManager; +import org.evergreen_ils.globals.AppPrefs; import org.opensrf.Method; import org.opensrf.net.http.GatewayRequest; import org.opensrf.net.http.HttpConnection; @@ -74,10 +75,9 @@ public class EvergreenAuthenticator { public static String signIn(Context context, String username, String password) throws AuthenticationException { Log.d(TAG, "signIn> "+username); - final String library_url = context.getString(R.string.ou_library_url); HttpConnection conn; try { - conn = new HttpConnection(library_url + "/osrf-gateway-v1"); + conn = new HttpConnection(AppPrefs.get(AppPrefs.LIBRARY_URL) + "/osrf-gateway-v1"); } catch (MalformedURLException e) { throw new AuthenticationException(e); } diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/barcodescan/CaptureActivity.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/barcodescan/CaptureActivity.java index 8516c3e039..868e53dd84 100755 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/barcodescan/CaptureActivity.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/barcodescan/CaptureActivity.java @@ -156,7 +156,7 @@ public class CaptureActivity extends Activity implements SurfaceHolder.Callback private void displayFrameworkBugMessageAndExit(String info) { AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(getString(R.string.ou_app_name)); + builder.setTitle(getString(R.string.ou_library_name)); builder.setMessage("[" + info + "] " + getString(R.string.msg_camera_framework_bug)); builder.setPositiveButton(R.string.button_ok, new FinishListener(this)); diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/AppPrefs.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/AppPrefs.java new file mode 100644 index 0000000000..1ea141034b --- /dev/null +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/AppPrefs.java @@ -0,0 +1,55 @@ +package org.evergreen_ils.globals; + +import android.content.Context; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; +import android.util.Log; +import org.evergreen_ils.R; + +/** + * Created by kenstir on 11/8/2015. + */ +public class AppPrefs { + 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; + private static final String TAG = AppPrefs.class.getSimpleName(); + private static Context context; + private static boolean initialized; + + public static void init(Context app_context) { + if (initialized) + return; + + context = app_context; + initialized = true; + + // set default values unless already set + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + int version = prefs.getInt(VERSION, 0); + if (version < PREFS_VERSION) { + 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.commit(); + } + Log.d(TAG, "version=" + version); + Log.d(TAG, "library_url=" + get(LIBRARY_URL)); + Log.d(TAG, "library_name=" + get(LIBRARY_NAME)); + } + + public static String get(String key) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + return prefs.getString(key, null); + } + + public static void set(String key, String value) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + SharedPreferences.Editor editor = prefs.edit(); + editor.putString(key, value); + editor.commit(); + } +} diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/Utils.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/Utils.java index 0126c16614..46b9fc2500 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/Utils.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/Utils.java @@ -170,7 +170,7 @@ public class Utils { } // alternate version of doRequest - // kcxxx: not sure why this one loops calling req.recv and the other doesn't + // kenstir todo: not sure why this one loops calling req.recv and the other doesn't public static Object doRequest(HttpConnection conn, String service, String methodName, Object[] params) { diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/Library.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/Library.java index 80d40ec533..ef0f5a9cbe 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/Library.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/Library.java @@ -1,9 +1,17 @@ package org.evergreen_ils.searchCatalog; +import android.text.TextUtils; + /** value class * Created by kenstir on 11/5/2015. */ public class Library { - public String name; - public String library_url; + public String url; // e.g. "https://catalog.cwmars.org" + public String short_name; // e.g. "C/W MARS" + public String directory_name; // e.g. "Massachusetts, US (C/W MARS)" + public Library(String url, String short_name, String directory_name) { + this.url = url; + this.short_name = short_name; + this.directory_name = directory_name; + } } diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalog.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalog.java index d4cc9285ad..9e0b7d9f10 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalog.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalog.java @@ -27,6 +27,7 @@ import java.util.Map; import android.text.TextUtils; import org.evergreen_ils.accountAccess.AccountAccess; +import org.evergreen_ils.globals.AppPrefs; import org.evergreen_ils.globals.GlobalConfigs; import org.evergreen_ils.globals.Utils; import org.opensrf.Method; @@ -131,16 +132,11 @@ public class SearchCatalog { try { // configure the connection - conn = new HttpConnection(GlobalConfigs.httpAddress - + "/osrf-gateway-v1"); + conn = new HttpConnection(AppPrefs.get(AppPrefs.LIBRARY_URL) + "/osrf-gateway-v1"); } catch (Exception e) { - System.err.println("Exception in establishing connection " - + e.getMessage()); + Log.d(TAG, "error", e); } - // registering classes so no longer necessary to register object classes - // manually - } /** diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalogListView.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalogListView.java index c5a996fe90..47403c2f5d 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalogListView.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/searchCatalog/SearchCatalogListView.java @@ -426,7 +426,7 @@ public class SearchCatalogListView extends ActionBarActivity { } }); - //kcxxx: factor this out + //kenstir todo: factor this out int selectedOrgPos = 0; int homeLibrary = 0; if (AccountAccess.getAccountAccess() != null) { diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/views/ChooseLibraryActivity.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/views/ChooseLibraryActivity.java index 64ad929b4b..282cf61c0d 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/views/ChooseLibraryActivity.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/views/ChooseLibraryActivity.java @@ -1,12 +1,14 @@ package org.evergreen_ils.views; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; +import android.text.TextUtils; import android.util.Log; import android.view.View; import android.widget.AdapterView; @@ -14,8 +16,11 @@ import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; import org.evergreen_ils.R; +import org.evergreen_ils.globals.AppPrefs; +import org.evergreen_ils.globals.GlobalConfigs; import org.evergreen_ils.globals.Utils; import org.evergreen_ils.searchCatalog.Library; +import org.evergreen_ils.views.splashscreen.SplashActivity; import org.opensrf.util.JSONException; import org.opensrf.util.JSONReader; @@ -28,12 +33,12 @@ public class ChooseLibraryActivity extends ActionBarActivity { public final static int CHOOSE_LIBRARY_REQUEST = 0; private final String TAG = ChooseLibraryActivity.class.getSimpleName(); - public static String consortiumsJSONUrl = "http://evergreen-ils.org/testing/libraries.json"; + public static String librariesJSONUrl = "http://evergreen-ils.org/testing/libraries.json"; Context context; Spinner consortiumSpinner; - Button button; - String library_url = null; + Library selected_library = null; List libraries = new ArrayList(); + private boolean restarted = false; private class FetchConsortiumsTask extends AsyncTask { protected String doInBackground(String... params) { @@ -50,10 +55,10 @@ public class ChooseLibraryActivity extends ActionBarActivity { protected void onPostExecute(String result) { Log.d(TAG, "results available: "+result); - libraries = parseEvergreenConsortiums(result); + parseLibrariesJSON(result); ArrayList l = new ArrayList(libraries.size()); for (Library library : libraries) { - l.add(library.name); + l.add(library.directory_name); } ArrayAdapter adapter = new ArrayAdapter(context, android.R.layout.simple_spinner_dropdown_item, l); consortiumSpinner.setAdapter(adapter); @@ -64,70 +69,110 @@ public class ChooseLibraryActivity extends ActionBarActivity { super.onCreate(savedInstanceState); context = getApplicationContext(); - // do not start SplashActivity here...it started us - setContentView(R.layout.activity_choose_library); + AppPrefs.init(getApplicationContext()); + ActionBar actionBar = getSupportActionBar(); consortiumSpinner = (Spinner) findViewById(R.id.choose_library_spinner); consortiumSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - library_url = libraries.get(position).library_url; + selected_library = libraries.get(position); } @Override - public void onNothingSelected(AdapterView parent) {} + public void onNothingSelected(AdapterView parent) { + selected_library = null; + } }); - button = (Button) findViewById(R.id.choose_library_button); - button.setOnClickListener(new View.OnClickListener() { + ((Button)findViewById(R.id.choose_library_button)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (library_url != null) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); - SharedPreferences.Editor editor = prefs.edit(); - editor.putString("library_url", library_url); - editor.commit(); - setResult(RESULT_OK); - finish(); - } + selectLibrary(); } }); + } + + 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); + + startSplashActivity(); + } + } - FetchConsortiumsTask task = new FetchConsortiumsTask(); - task.execute(consortiumsJSONUrl); + private void startSplashActivity() { + // This is different from SplashActivity.restartApp(this) in that it does not clear the back stack. + // This is so that a user can back up and choose a different library. + Intent i = new Intent(this, SplashActivity.class); + startActivity(i); } - public List parseEvergreenConsortiums(String json) { - List libraries = new ArrayList(); + @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) { + startSplashActivity(); + } else { + startTask(); + } + } + + @Override + protected void onRestart() { + super.onRestart(); + restarted = true; + Log.d(TAG, "kcxxx: onrestart"); + } + + private void startTask() { + new FetchConsortiumsTask().execute(librariesJSONUrl); + } + + private void parseLibrariesJSON(String json) { + libraries.clear(); + if (json != null) { List> l; try { l = (List>) new JSONReader(json).readArray(); } catch (JSONException e) { Log.d(TAG, "failed parsing libraries array", e); - return libraries; + return; } for (Map map : l) { - Library c = new Library(); - c.name = (String) map.get("library_name"); - c.library_url = (String) map.get("url"); - libraries.add(c); + String url = (String) map.get("url"); + String directory_name = (String) map.get("library_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); } Collections.sort(libraries, new Comparator() { @Override public int compare(Library a, Library b) { - return a.name.compareTo(b.name); + return a.directory_name.compareTo(b.directory_name); } }); for (int i = 0; i< libraries.size(); ++i) { - Log.d(TAG, "c["+i+"]: "+ libraries.get(i).name); + Log.d(TAG, "c["+i+"]: "+ libraries.get(i).directory_name); } } - return libraries; } } diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/views/ApplicationPreferences.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/views/UnusedPreferenceActivity.java similarity index 92% rename from Open-ILS/src/Android/core/src/org/evergreen_ils/views/ApplicationPreferences.java rename to Open-ILS/src/Android/core/src/org/evergreen_ils/views/UnusedPreferenceActivity.java index 3b0ed13a6c..0ec67c689a 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/views/ApplicationPreferences.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/views/UnusedPreferenceActivity.java @@ -22,35 +22,30 @@ package org.evergreen_ils.views; import java.util.Calendar; import org.evergreen_ils.R; -import org.evergreen_ils.globals.GlobalConfigs; import org.evergreen_ils.services.NotificationAlert; import org.evergreen_ils.services.PeriodicServiceBroadcastReceiver; import org.evergreen_ils.services.ScheduledIntentService; -import org.evergreen_ils.auth.Const; import android.app.AlarmManager; import android.app.PendingIntent; import android.app.ProgressDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; -import android.net.ConnectivityManager; import android.os.Bundle; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; -import android.provider.Settings; import android.widget.Toast; -public class ApplicationPreferences extends PreferenceActivity implements +public class UnusedPreferenceActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener { - private final String TAG = ApplicationPreferences.class.getName(); + private final String TAG = UnusedPreferenceActivity.class.getSimpleName(); private ProgressDialog progressDialog; - private ApplicationPreferences reference; + private UnusedPreferenceActivity reference; private Context context; diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/views/splashscreen/SplashActivity.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/views/splashscreen/SplashActivity.java index 3626f5aa31..e398e0d1eb 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/views/splashscreen/SplashActivity.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/views/splashscreen/SplashActivity.java @@ -22,7 +22,8 @@ package org.evergreen_ils.views.splashscreen; import android.content.SharedPreferences; import org.evergreen_ils.R; import org.evergreen_ils.globals.GlobalConfigs; -import org.evergreen_ils.views.ChooseLibraryActivity; +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; @@ -49,9 +50,9 @@ public class SplashActivity extends Activity implements LoadingTaskListener { private ProgressBar mProgressBar; private AlertDialog mAlertDialog; private Button mRetryButton; - //private SharedPreferences prefs; private LoadingTask mTask; private static boolean mInitialized; + private boolean restarted = false; public static boolean isAppInitialized() { return mInitialized; @@ -74,7 +75,7 @@ public class SplashActivity extends Activity implements LoadingTaskListener { */ public static void restartApp(Activity a) { Log.d(TAG, "restartApp> Restarting SplashActivity"); - final Intent i = new Intent(a, SplashActivity.class); + Intent i = new Intent(a, SplashActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); a.startActivity(i); a.finish(); @@ -82,42 +83,23 @@ public class SplashActivity extends Activity implements LoadingTaskListener { @Override public void onCreate(Bundle savedInstanceState) { - Log.d(TAG, "kcxxx: oncreate: splash"); + Log.d(TAG, "kcxxx: oncreate"); super.onCreate(savedInstanceState); - // make sure default values are set up for preferences - PreferenceManager.setDefaultValues(this, R.xml.preferences, false); - String library_url = getString(R.string.ou_library_url); - if (library_url.isEmpty()) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - library_url = prefs.getString("library_url", ""); - } - if (library_url.isEmpty()) { - Intent i = new Intent(this, ChooseLibraryActivity.class); - //i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - Log.d(TAG, "kcxxx: oncreate: startactivity chooselibrary"); - startActivityForResult(i, REQUEST_SELECT_LIBRARY); - return; - } - Log.d(TAG, "kcxxx: oncreate: afterloop"); - GlobalConfigs.httpAddress = library_url; - this.mContext = this; - setContentView(R.layout.activity_splash); + AppPrefs.init(getApplicationContext()); + mProgressText = (TextView) findViewById(R.id.action_in_progress); mProgressBar = (ProgressBar) findViewById(R.id.activity_splash_progress_bar); mRetryButton = (Button) findViewById(R.id.activity_splash_retry_button); - Log.d(TAG, "onCreate>"); mRetryButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startTask(); } }); - - startTask(); } protected void startTask() { @@ -129,8 +111,32 @@ public class SplashActivity extends Activity implements LoadingTaskListener { } @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) { + startTask(); + } + } + + @Override + protected void onRestart() { + super.onRestart(); + restarted = true; + Log.d(TAG, "kcxxx: onrestart"); + } + + @Override + protected void onResume() { + super.onResume(); + Log.d(TAG, "kcxxx: onresume"); + } + + @Override protected void onStop() { super.onStop(); + Log.d(TAG, "kcxxx: onstop"); if (mAlertDialog != null) { mAlertDialog.dismiss(); } @@ -139,7 +145,6 @@ public class SplashActivity extends Activity implements LoadingTaskListener { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(TAG, "kcxxx: onactivityresult: " + requestCode + " " + resultCode); - Log.d(TAG, "onActivityResult> " + requestCode + " " + resultCode); } private void startApp() { diff --git a/Open-ILS/src/Android/cwmars_app/AndroidManifest.xml b/Open-ILS/src/Android/cwmars_app/AndroidManifest.xml index 4b615f4205..b8b71f9fe1 100644 --- a/Open-ILS/src/Android/cwmars_app/AndroidManifest.xml +++ b/Open-ILS/src/Android/cwmars_app/AndroidManifest.xml @@ -23,7 +23,7 @@ @@ -58,7 +58,7 @@ - + diff --git a/Open-ILS/src/Android/cwmars_app/res/values/ou.xml b/Open-ILS/src/Android/cwmars_app/res/values/ou.xml index 6dc1c405b2..4aac9db8c8 100644 --- a/Open-ILS/src/Android/cwmars_app/res/values/ou.xml +++ b/Open-ILS/src/Android/cwmars_app/res/values/ou.xml @@ -1,10 +1,11 @@ + C/W MARS Library - Sign in to your\nC/W MARS Library Account + Sign in to your\n%1$s account org.cwmars C/W MARS - C/W MARS + C/W MARS https://bark.cwmars.org diff --git a/Open-ILS/src/Android/eg_app/AndroidManifest.xml b/Open-ILS/src/Android/eg_app/AndroidManifest.xml index 007dbe3795..706b8a193a 100644 --- a/Open-ILS/src/Android/eg_app/AndroidManifest.xml +++ b/Open-ILS/src/Android/eg_app/AndroidManifest.xml @@ -28,16 +28,14 @@ - - - - - - + + + + diff --git a/Open-ILS/src/Android/eg_app/res/values/ou.xml b/Open-ILS/src/Android/eg_app/res/values/ou.xml index b6ebfaa8ad..60a1cf8682 100644 --- a/Open-ILS/src/Android/eg_app/res/values/ou.xml +++ b/Open-ILS/src/Android/eg_app/res/values/ou.xml @@ -1,11 +1,11 @@ - + + Evergreen Library - Sign in to your\nEvergreen Library Account + Sign in to your\n%1$s account org.evergreen-ils.eg_app Evergreen - Evergreen - + diff --git a/Open-ILS/src/Android/kenstir_parse_logcat.pl b/Open-ILS/src/Android/kenstir_parse_logcat.pl index 3b0ed1e1aa..3691d15ec2 100644 --- a/Open-ILS/src/Android/kenstir_parse_logcat.pl +++ b/Open-ILS/src/Android/kenstir_parse_logcat.pl @@ -13,11 +13,11 @@ use JSON; my $debug = 0; GetOptions("-d=i" => \$debug) or die; -my $logcat = `adb logcat -d`; +my $logcat = `adb logcat -d -v printable`; my @lines = split(/\r\n/, $logcat); foreach my $line (@lines) { print "line: $line\n" if $debug; - if ($line =~ /org.opensrf.net.http.GatewayRequest\( *\d+\): ?([^:]+):(.+)/) { + if ($line =~ /org.opensrf.net.http.GatewayRequest: ([^:]+):(.+)/) { my($key,$val) = ($1,$2); if ($key eq 'result') { my $obj = decode_json($val); -- 2.11.0