Changes for eg_app and cwmars_app to peacefully coexist.
authorkenstir <kenstir@gmail.com>
Fri, 20 Nov 2015 01:46:37 +0000 (20:46 -0500)
committerkenstir <kenstir@gmail.com>
Fri, 20 Nov 2015 01:46:37 +0000 (20:46 -0500)
* AuthenticatorActivity only displays/downloads library list in eg_app
  (that is if it doesn't have a library_url).
* export the AuthenticatorService.  Not sure that this is the Right Thing.

13 files changed:
Open-ILS/src/Android/core/AndroidManifest.xml
Open-ILS/src/Android/core/res/layout/activity_choose_library.xml [deleted file]
Open-ILS/src/Android/core/res/layout/activity_login.xml
Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AccountAuthenticator.java
Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AuthenticatorActivity.java
Open-ILS/src/Android/core/src/org/evergreen_ils/auth/AuthenticatorService.java
Open-ILS/src/Android/core/src/org/evergreen_ils/views/ChooseLibraryActivity.java [deleted file]
Open-ILS/src/Android/core/src/org/evergreen_ils/views/splashscreen/SplashActivity.java
Open-ILS/src/Android/cwmars_app/AndroidManifest.xml
Open-ILS/src/Android/cwmars_app/res/layout/activity_login.xml [new file with mode: 0644]
Open-ILS/src/Android/cwmars_app/res/values/ou.xml
Open-ILS/src/Android/eg_app/AndroidManifest.xml
Open-ILS/src/Android/eg_app/res/values/ou.xml

index e4faa79..a0d21ad 100644 (file)
@@ -1,4 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>\r
+<!-- This file is eclipsed by the AndroidManifest.xml in each project.\r
+     It exists here merely to keep the IDE happy. -->\r
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
     package="org.evergreen_ils"\r
     android:installLocation="auto"\r
diff --git a/Open-ILS/src/Android/core/res/layout/activity_choose_library.xml b/Open-ILS/src/Android/core/res/layout/activity_choose_library.xml
deleted file mode 100644 (file)
index 65c6256..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              android:orientation="vertical"
-              android:layout_width="match_parent"
-              android:layout_height="match_parent"
-              android:paddingTop="32dp"
-              android:paddingLeft="17dp"
-              android:paddingRight="17dp"
-        >
-
-    <TextView
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/choose_library_message"
-        android:textAppearance="?android:attr/textAppearanceLarge" />
-    
-    <Spinner
-        android:id="@+id/choose_library_spinner"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="30dip"
-        android:layout_marginBottom="30dip"
-        />
-
-    <Button android:id="@+id/choose_library_button"
-              android:layout_width="wrap_content"
-              android:layout_height="wrap_content"
-              android:layout_gravity="right"
-              android:layout_marginTop="16dp"
-              android:text="@string/action_choose_library"
-              android:paddingLeft="32dp"
-              android:paddingRight="32dp"/>
-
-</LinearLayout>
-
index 98247dc..9973028 100644 (file)
@@ -28,8 +28,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginTop="0dp"
-            android:layout_marginBottom="32dp"
-    />
+            android:layout_marginBottom="32dp" />
 
     <TextView
             android:layout_width="wrap_content"
index 7318165..5a56423 100644 (file)
@@ -52,8 +52,6 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
         final AccountManager am = AccountManager.get(context);
         String library_url = am.getUserData(account, Const.KEY_LIBRARY_URL);
         Log.d(TAG, "getAuthToken> library_url=" + library_url);
-//        if (TextUtils.isEmpty(library_url)) {
-//        }
 
         String authToken = am.peekAuthToken(account, authTokenType);
         Log.d(TAG, "getAuthToken> peekAuthToken returned " + authToken);
index 6d84927..ab61728 100644 (file)
@@ -77,6 +77,12 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity {
         }
     }
 
+    // returns true if this is the generic app, which needs a library spinner etc.
+    private boolean isGenericApp() {
+        String library_url = getString(R.string.ou_library_url);
+        return TextUtils.isEmpty(library_url);
+    }
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -95,18 +101,23 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity {
             authTokenType = Const.AUTHTOKEN_TYPE;
         Log.d(TAG, "onCreate> authTokenType="+authTokenType);
 
-        librarySpinner = (Spinner) findViewById(R.id.choose_library_spinner);
-        librarySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
-            @Override
-            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
-                selected_library = libraries.get(position);
-            }
+        if (isGenericApp()) {
+            librarySpinner = (Spinner) findViewById(R.id.choose_library_spinner);
+            librarySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+                @Override
+                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+                    selected_library = libraries.get(position);
+                }
 
-            @Override
-            public void onNothingSelected(AdapterView<?> parent) {
-                selected_library = null;
-            }
-        });
+                @Override
+                public void onNothingSelected(AdapterView<?> parent) {
+                    selected_library = null;
+                }
+            });
+        } else {
+            selected_library = new Library(getString(R.string.ou_library_url),
+                    getString(R.string.ou_library_name), null);
+        }
 
         TextView signInText = (TextView) findViewById(R.id.account_sign_in_text);
         signInText.setText(String.format(getString(R.string.ou_account_sign_in_message),
@@ -135,7 +146,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity {
     protected void onStart() {
         super.onStart();
         Log.d(TAG, "onstart");
-        startTask();
+        if (isGenericApp()) {
+            startTask();
+        }
     }
 
     @Override
index bb4f082..2d0d493 100644 (file)
@@ -1,5 +1,6 @@
 package org.evergreen_ils.auth;
 
+import android.util.Log;
 import org.evergreen_ils.auth.AccountAuthenticator;
 
 import android.app.Service;
@@ -9,6 +10,7 @@ import android.os.IBinder;
 public class AuthenticatorService extends Service {
     @Override
     public IBinder onBind(Intent arg0) {
+        Log.d(Const.AUTH_TAG, "onBind intent:"+arg0);
         return new AccountAuthenticator(this).getIBinder();
     }
 }
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
deleted file mode 100644 (file)
index a2fc2cc..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-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;
-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;
-
-import java.util.*;
-
-/**
- * Created by kenstir on 2015-11-05.
- */
-public class ChooseLibraryActivity extends ActionBarActivity {
-
-    /*
-    todo: DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME
-    DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME
-    DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME DELETE ME
-    public final static int CHOOSE_LIBRARY_REQUEST = 0;
-    private final String TAG = ChooseLibraryActivity.class.getSimpleName();
-    public static String librariesJSONUrl = "http://evergreen-ils.org/testing/libraries.json";
-    Context context;
-    Spinner consortiumSpinner;
-    Library selected_library = null;
-    List<Library> libraries = new ArrayList<Library>();
-    private boolean restarted = false;
-
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        context = getApplicationContext();
-
-        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) {
-                selected_library = libraries.get(position);
-            }
-
-            @Override
-            public void onNothingSelected(AdapterView<?> parent) {
-                selected_library = null;
-            }
-        });
-        ((Button)findViewById(R.id.choose_library_button)).setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                selectLibrary();
-            }
-        });
-    }
-
-    private void selectLibrary() {
-        if (selected_library != null) {
-            Log.d(TAG, "selected library " + selected_library.directory_name);
-            AppPrefs.setString(AppPrefs.LIBRARY_URL, selected_library.url);
-            AppPrefs.setString(AppPrefs.LIBRARY_NAME, selected_library.short_name);
-
-            startSplashActivity();
-        }
-    }
-
-    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);
-    }
-
-    @Override
-    protected void onStart() {
-        super.onStart();
-        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();
-        } 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<Map<String,?>> l;
-            try {
-                l = (List<Map<String,?>>) new JSONReader(json).readArray();
-            } catch (JSONException e) {
-                Log.d(TAG, "failed parsing libraries array", e);
-                return;
-            }
-            for (Map<String, ?> map : l) {
-                String url = (String) map.get("url");
-                String directory_name = (String) map.get("directory_name");
-                String short_name = (String) map.get("short_name");
-                Library library = new Library(url, short_name, directory_name);
-                libraries.add(library);
-            }
-
-            Collections.sort(libraries, new Comparator<Library>() {
-                @Override
-                public int compare(Library a, Library b) {
-                    return a.directory_name.compareTo(b.directory_name);
-                }
-            });
-
-            for (int i = 0; i< libraries.size(); ++i) {
-                Log.d(TAG, "c["+i+"]: "+ libraries.get(i).directory_name);
-            }
-        }
-    }
-*/
-}
index fa25ae9..e0b2878 100644 (file)
@@ -171,9 +171,9 @@ public class SplashActivity extends Activity implements LoadingTaskListener {
         } else {
             String extra_text;
             if (!TextUtils.isEmpty(result))
-                extra_text = "...Failed:\n" + result;
+                extra_text = "...failed:\n" + result;
             else
-                extra_text = "...Cancelled";
+                extra_text = "...cancelled";
             Log.d(TAG, "progresstext += " + extra_text);
             mProgressText.setText(mProgressText.getText() + extra_text);
             mRetryButton.setVisibility(View.VISIBLE);
index 871d8cd..c6add35 100644 (file)
 
         <service
             android:name="org.evergreen_ils.auth.AuthenticatorService"
-            android:exported="false" >
+            android:exported="true" >
             <intent-filter>
                 <action android:name="android.accounts.AccountAuthenticator" />
             </intent-filter>
diff --git a/Open-ILS/src/Android/cwmars_app/res/layout/activity_login.xml b/Open-ILS/src/Android/cwmars_app/res/layout/activity_login.xml
new file mode 100644 (file)
index 0000000..e1c874e
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:paddingTop="32dp"
+              android:paddingLeft="17dp"
+              android:paddingRight="17dp"
+        >
+
+    <TextView
+            android:id="@+id/account_sign_in_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/ou_account_sign_in_message"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:layout_marginBottom="32dp"/>
+
+    <EditText android:id="@+id/accountName"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:layout_marginTop="20dp"
+              android:inputType="text"
+              android:hint="@string/hint_username"
+              android:padding="10dp"
+            />
+
+    <EditText android:id="@+id/accountPassword"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:layout_marginTop="10dp"
+              android:inputType="textPassword"
+              android:hint="@string/hint_password"
+              android:padding="10dp"
+            />
+
+    <Button android:id="@+id/submit"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:layout_gravity="right"
+              android:layout_marginTop="16dp"
+              android:text="@string/action_sign_in"
+              android:paddingLeft="32dp"
+              android:paddingRight="32dp"/>
+
+</LinearLayout>
+
index 2222191..f4a0ecc 100644 (file)
@@ -2,8 +2,10 @@
 <!-- ou.xml - C/W MARS organizational unit -->
 <resources>
     <!-- see ../core/res/values/ou.xml for a description -->
-    <string name="ou_account_label">C/W MARS Library</string>
+    <string name="ou_account_label">C/W MARS</string>
     <string name="ou_account_sign_in_message">Sign in to your\nC/W MARS account</string>
+    <string name="ou_choose_library_label"></string>
+    <string name="ou_sign_in_label"></string>
     <string name="ou_account_type">org.cwmars</string>
     <string name="ou_app_label">C/W MARS</string>
     <string name="ou_library_name">C/W MARS</string>
index 7e49885..f5247e2 100644 (file)
 
         <service
             android:name="org.evergreen_ils.auth.AuthenticatorService"
-            android:exported="false" >
+            android:exported="true" >
             <intent-filter>
                 <action android:name="android.accounts.AccountAuthenticator" />
             </intent-filter>
index f0fbe38..6ee097d 100644 (file)
@@ -2,7 +2,7 @@
 <!-- ou.xml - app customization -->
 <resources>
     <!-- see ../core/res/values/ou.xml for a description -->
-    <string name="ou_account_label">Evergreen Library</string>
+    <string name="ou_account_label">Evergreen</string>
     <string name="ou_account_sign_in_message">Sign in to your library account</string>
     <string name="ou_choose_library_label">Location:</string>
     <string name="ou_sign_in_label">Login:</string>