android:name=".searchCatalog.SearchCatalogListView"
android:label="@string/app_name" >
</activity>
-
+ <activity
+ android:name=".views.ApplicationPreferences"
+ >
+
+ </activity>
<activity android:name=".searchCatalog.RecordDetails_Info"></activity>
<activity android:name=".searchCatalog.RecordDetails_Content"></activity>
<activity android:name=".searchCatalog.RecordDetails_Details"></activity>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:key="first_preferencescreen">
+ <PreferenceCategory
+ android:summary="Username and password information"
+ android:title="Login information" >
+ <EditTextPreference
+ android:key="username"
+ android:summary="Please enter your login username"
+ android:title="Username" />
+ <EditTextPreference
+ android:key="password"
+ android:summary="Enter your password"
+ android:title="Password"
+ android:inputType="textPassword"
+ />
+ </PreferenceCategory>
+
+
+ <PreferenceCategory
+ android:summary="Username and password information"
+ android:title="Login information" >
+ <EditTextPreference
+ android:key="library_url"
+ android:summary="Please enter the library url in format http://"
+ android:title="Library url address" />
+
+ </PreferenceCategory>
+
+</PreferenceScreen>
\ No newline at end of file
import org.opensrf.net.http.HttpRequest;
import org.opensrf.util.OSRFObject;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+
/**
* The Class AuthenticateUser.
*/
private Integer userID = null;
//for demo purpose
/** The user name. */
- private String userName = "daniel";
+ public static String userName = "daniel";
/** The password. */
- private String password = "demo123";
+ public static String password = "demo123";
/**
* Instantiates a new authenticate user.
return "";
}
+ public static void setAccountInfo(String username, String password){
+
+ AccountAccess.userName = username;
+ AccountAccess.password = password;
+
+ }
+
/**
* Authenticate.
*/
- public void authenticate(){
+ public boolean authenticate(){
String seed = authenticateInit();
- authenticateComplete(seed);
+ return authenticateComplete(seed);
}
/**
* Phase 2 of login process
* Application send's username and hash to confirm login
* @param seed the seed
+ * @returns bollean if auth was ok
*/
- private void authenticateComplete(String seed) {
-
+ private boolean authenticateComplete(String seed) {
+
//calculate hash to pass to server for authentication process phase 2
//seed = "b18a9063e0c6f49dfe7a854cc6ab5775";
String hash = md5(seed+md5(password));
}catch(Exception e){
System.err.println("Error in parsing authtime " + e.getMessage());
}
- System.out.println();
+
+ return true;
}
}
+ return false;
}
}
-
-
}
package org.evergreen.android.globals;
import java.io.InputStream;
-import java.security.KeyStore.LoadStoreParameter;
import java.util.ArrayList;
import java.util.StringTokenizer;
+import org.evergreen.android.accountAccess.AccountAccess;
import org.evergreen.android.searchCatalog.Organisation;
import org.open_ils.idl.IDLParser;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
import android.util.Log;
public class GlobalConfigs {
private String collectionsRequest = "/opac/common/js/";
- private GlobalConfigs(){
+ private GlobalConfigs(Context context){
- initialize();
+ initialize(context);
}
- public static GlobalConfigs getGlobalConfigs(){
+ public static GlobalConfigs getGlobalConfigs(Context context){
if(globalConfigSingleton == null)
{
- globalConfigSingleton = new GlobalConfigs();
+ globalConfigSingleton = new GlobalConfigs(context);
}
return globalConfigSingleton;
/* Initialize function that retrieves IDL file and Orgs file
*/
- private boolean initialize(){
+ private boolean initialize(Context context){
if(init == false){
init = true;
loadIDLFile();
getOrganisations();
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+ GlobalConfigs.httpAddress = preferences.getString("library_url", "");
+ AccountAccess.setAccountInfo(preferences.getString("username", ""), preferences.getString("password", ""));
+
return true;
}
return false;
setContentView(R.layout.search_result_list);
//singleton initialize necessary IDL and Org data
- globalConfigs = GlobalConfigs.getGlobalConfigs();
+ globalConfigs = GlobalConfigs.getGlobalConfigs(this);
context = this;
search = new SearchCatalog("http://ulysses.calvin.edu",this);
--- /dev/null
+package org.evergreen.android.views;
+
+import org.evergreen.android.R;
+import org.evergreen.android.accountAccess.AccountAccess;
+import org.evergreen.android.globals.GlobalConfigs;
+
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceManager;
+
+public class ApplicationPreferences extends PreferenceActivity implements OnSharedPreferenceChangeListener{
+
+
+ private ProgressDialog progressDialog;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.application_preference_screen);
+
+ Context context = getApplicationContext();
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ //register preference listener
+ prefs.registerOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
+ String key) {
+
+ if(key.equals("username")){
+ AccountAccess.userName = sharedPreferences.getString("username", "");
+ }else
+ if(key.equals("password")){
+ AccountAccess.password = sharedPreferences.getString("password", "");
+ }else
+ if(key.equals("library_url")){
+ GlobalConfigs.httpAddress = sharedPreferences.getString("library_url", "");
+ }
+
+ //test connection
+
+ progressDialog = ProgressDialog.show(this, "Account login", "Please wait while we test the new user account information");
+
+ Thread thread = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+
+ AccountAccess account = new AccountAccess(GlobalConfigs.httpAddress);
+ account.authenticate();
+ runOnUiThread(new Runnable() {
+
+ @Override
+ public void run() {
+ progressDialog.dismiss();
+
+ }
+ });
+ }
+ });
+
+ thread.start();
+ }
+
+
+
+}
//init here globals,
//TODO in future do a splash screen (loading data)
- GlobalConfigs globalConfigs = GlobalConfigs.getGlobalConfigs();
+ GlobalConfigs globalConfigs = GlobalConfigs.getGlobalConfigs(this);
}
/**
startActivity (new Intent(getApplicationContext(), AccountScreenDashboard.class));
break;
case R.id.main_btn_app_settings :
- //startActivity (new Intent(getApplicationContext(), F3Activity.class));
+ startActivity(new Intent(getApplicationContext(),ApplicationPreferences.class));
break;
default: