Bug fix on ApplicationPreferences crash on back and resume
authordrizea <danielrizea27@gmail.com>
Thu, 14 Jun 2012 21:11:20 +0000 (00:11 +0300)
committerdrizea <danielrizea27@gmail.com>
Thu, 14 Jun 2012 21:11:20 +0000 (00:11 +0300)
13 files changed:
Open-ILS/src/Android/AndroidManifest.xml
Open-ILS/src/Android/bin/EvergreenApp.apk
Open-ILS/src/Android/bin/classes.dex
Open-ILS/src/Android/bin/classes/org/evergreen/android/R$style.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/globals/GlobalConfigs.class
Open-ILS/src/Android/bin/classes/org/evergreen/android/views/MainScreenDashboard.class
Open-ILS/src/Android/bin/resources.ap_
Open-ILS/src/Android/gen/org/evergreen/android/R.java
Open-ILS/src/Android/res/layout/search_result_item.xml
Open-ILS/src/Android/res/values/styles.xml
Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java
Open-ILS/src/Android/src/org/evergreen/android/views/ApplicationPreferences.java
Open-ILS/src/Android/src/org/evergreen/android/views/MainScreenDashboard.java

index 73aed05..62dd77e 100644 (file)
@@ -29,7 +29,9 @@
             ></activity>
         <activity
             android:name=".searchCatalog.SearchCatalogListView"
-            android:label="@string/app_name" >
+            android:label="@string/app_name" 
+            android:theme="@android:style/Theme.Light.NoTitleBar"
+            >
         </activity>
         <activity
             android:name=".views.ApplicationPreferences"
index dbb7510..d5581ba 100644 (file)
Binary files a/Open-ILS/src/Android/bin/EvergreenApp.apk and b/Open-ILS/src/Android/bin/EvergreenApp.apk differ
index ee1dc7c..36443ad 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes.dex and b/Open-ILS/src/Android/bin/classes.dex differ
index 0f3ca57..e228baf 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/R$style.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/R$style.class differ
index 6ec8940..0597be3 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/globals/GlobalConfigs.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/globals/GlobalConfigs.class differ
index 72463ce..6d79b61 100644 (file)
Binary files a/Open-ILS/src/Android/bin/classes/org/evergreen/android/views/MainScreenDashboard.class and b/Open-ILS/src/Android/bin/classes/org/evergreen/android/views/MainScreenDashboard.class differ
index 4e5716c..d9de5e2 100644 (file)
Binary files a/Open-ILS/src/Android/bin/resources.ap_ and b/Open-ILS/src/Android/bin/resources.ap_ differ
index f87a72c..89fde60 100644 (file)
@@ -93,8 +93,11 @@ public final class R {
         public static final int title_search=0x7f070002;
     }
     public static final class style {
+        public static final int AuthorSearchStyleList=0x7f080007;
         public static final int EvergreenTheme=0x7f080004;
         public static final int HomeButton=0x7f080005;
+        public static final int PubSearchStyleList=0x7f080008;
+        public static final int TitleSearchStyleList=0x7f080006;
         public static final int sectionHeader=0x7f080000;
         public static final int spacer=0x7f080003;
         public static final int textLarge=0x7f080002;
index ea8ffbb..aba6b72 100644 (file)
         android:layout_marginRight="6dip"
                android:src="@drawable/address_book"/>
        
+       
+       
        <LinearLayout 
        android:layout_width="wrap_content"
     android:layout_height="fill_parent"
-    android:orientation="vertical" 
+    android:orientation="vertical"
+    android:gravity="center_vertical" 
+       android:paddingLeft="4dip"
        >
                <TextView
                android:id="@+id/search_record_title"
-               android:paddingLeft="10dip"
-               android:gravity="left"
+               style="@style/TitleSearchStyleList"
                android:layout_width="wrap_content"
-               android:layout_height="wrap_content" />   
+               android:layout_height="wrap_content"
+               
+                />   
            
-                       <TextView
+               <TextView
                android:id="@+id/search_record_author"
-               android:paddingRight="10dip"
+               style="@style/AuthorSearchStyleList"
                android:layout_width="wrap_content"
-               android:gravity="right"
-               android:layout_height="wrap_content" />
+               android:layout_height="wrap_content"
+
+               />
                    
-                               <TextView
+               <TextView
                android:id="@+id/search_record_publishing"
-               android:paddingRight="10dip"
-               android:gravity="right"
+               style="@style/PubSearchStyleList"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
 
index 37bdd8f..376cc04 100644 (file)
         <item name="android:background">@null</item>
     </style>
     
+     
+     <style name="TitleSearchStyleList">
+        <item name="android:textSize">18sp</item>
+               <item name="android:gravity">left</item>
+        <item name="android:textStyle">bold</item>
+        <item name="android:singleLine">true</item>
+        <item name="android:ellipsize">end</item> 
+     </style>
+     
+     <style name="AuthorSearchStyleList">
+        <item name="android:textSize">14sp</item>
+               <item name="android:gravity">left</item>
+        <item name="android:textStyle">italic</item>
+        <item name="android:singleLine">true</item>
+        <item name="android:ellipsize">end</item> 
+     </style>
+     
+     <style name="PubSearchStyleList">
+        <item name="android:textSize">12sp</item>
+               <item name="android:gravity">right</item>
+        <item name="android:textStyle">italic</item>
+        <item name="android:singleLine">true</item>
+        <item name="android:ellipsize">end</item> 
+     </style>
+     
 </resources>
index caf1eac..50141d8 100644 (file)
@@ -62,6 +62,10 @@ public class GlobalConfigs {
                        GlobalConfigs.httpAddress = preferences.getString("library_url", "");
                        AccountAccess.setAccountInfo(preferences.getString("username", ""), preferences.getString("password", ""));
                        
+                       //authenticate
+                       AccountAccess ac = new AccountAccess(GlobalConfigs.httpAddress);
+                       ac.authenticate();
+                       
                        return true;
                }
                return false;
@@ -94,7 +98,7 @@ public class GlobalConfigs {
                        System.out.println("Request org " + httpAddress + collectionsRequest );
                }catch(Exception e){};
                
-               
+               organisations = new ArrayList<Organisation>();
                
                if(orgFile != null){
                        organisations = new ArrayList<Organisation>();
index c745c5c..e7d82e2 100644 (file)
@@ -27,10 +27,13 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
        
        private ProgressDialog progressDialog;
        
+       private ApplicationPreferences reference;
        
        private Context context;
        
        private String TAG = "ApplicationPreferences";
+       
+       private Thread connectionThread = null;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
 
@@ -39,12 +42,35 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
                addPreferencesFromResource(R.xml.application_preference_screen);
                
                context = this;
-               
+               reference = this;
                SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
                //register preference listener
                prefs.registerOnSharedPreferenceChangeListener(this);
        }
 
+       
+       @Override
+       protected void onResume() {
+               super.onResume();
+               reference = this;
+       }
+       @Override
+       protected void onPause() {
+               super.onPause();
+               reference = null;
+       }
+       
+       @Override
+       protected void onStop() {
+               super.onStop();
+               reference = null;
+       }
+       
+       @Override
+       protected void onDestroy() {
+               super.onDestroy();
+               reference = null;
+       }
        @Override
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
                        String key) {
@@ -60,10 +86,10 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
                                }
                
                //test connection
+               if(!isFinishing())
+                       progressDialog = ProgressDialog.show(this, "Account login", "Please wait while we test the new user account information");      
                
-               progressDialog = ProgressDialog.show(this, "Account login", "Please wait while we test the new user account information");      
-               
-               Thread thread = new Thread(new Runnable() {
+               connectionThread = new Thread(new Runnable() {
                        
                        @Override
                        public void run() {
@@ -71,7 +97,7 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
                                boolean routeToAddress = true;
                                AccountAccess account = new AccountAccess(GlobalConfigs.httpAddress);
                                try{
-                                       Utils.checkNetworkStatus((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE), getApplicationContext());
+                                       Utils.checkNetworkStatus((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE), context);
                                }catch(NoNetworkAccessException e){
                                        routeToAddress = false;
                                        
@@ -81,10 +107,12 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
                                                
                                                @Override
                                                public void run() {
-                                                       progressDialog.dismiss();
-                                                       AlertDialog.Builder builder = new AlertDialog.Builder(context);
-                                                       builder.setMessage("There seams to be no network connectivity! Do you want to start network settings?").setPositiveButton("Yes", dialogClickListener)
-                                                   .setNegativeButton("No", dialogClickListener).show();
+                                                       if(reference != null){
+                                                               progressDialog.dismiss();
+                                                               AlertDialog.Builder builder = new AlertDialog.Builder(context);
+                                                               builder.setMessage("There seams to be no network connectivity! Do you want to start network settings?").setPositiveButton("Yes", dialogClickListener)
+                                                               .setNegativeButton("No", dialogClickListener).show();
+                                                       }
                                                }
                                        });
 
@@ -96,7 +124,8 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
                                                
                                                @Override
                                                public void run() {
-                                                       Toast.makeText(getApplicationContext(), "There is no route to host :" + GlobalConfigs.httpAddress, Toast.LENGTH_LONG);
+                                                       if(reference != null)
+                                                               Toast.makeText(getApplicationContext(), "There is no route to host :" + GlobalConfigs.httpAddress, Toast.LENGTH_LONG).show();
                                                }
        
                                        });
@@ -110,8 +139,10 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
                                                        
                                                        @Override
                                                        public void run() {
-                                                               progressDialog.dismiss();
-                                                               Toast.makeText(context, "Autenthication successfully established :" + GlobalConfigs.httpAddress, Toast.LENGTH_LONG);
+                                                               if(reference != null){
+                                                                       progressDialog.dismiss();
+                                                                       Toast.makeText(context, "Autenthication successfully established :" + GlobalConfigs.httpAddress, Toast.LENGTH_LONG).show();
+                                                               }
                                                        }
                                                });
                                        }else{
@@ -119,8 +150,10 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
                                                        
                                                        @Override
                                                        public void run() {
-                                                               progressDialog.dismiss();
-                                                               Toast.makeText(context, "Please check username and password ", Toast.LENGTH_LONG);
+                                                               if(reference != null){
+                                                                       progressDialog.dismiss();
+                                                                       Toast.makeText(context, "Please check username and password ", Toast.LENGTH_LONG).show();
+                                                               }
                                                        }
                                                });
                                        }
@@ -130,13 +163,15 @@ public class ApplicationPreferences extends PreferenceActivity implements OnShar
                                                
                                                @Override
                                                public void run() {
-                                               progressDialog.dismiss();       
+                                               if(reference != null)   
+                                                       progressDialog.dismiss();       
                                                }
                                        });
                        }
                });
                
-               thread.start();
+               connectionThread.start();
+
        }
 /*
  *  Dialog interface for starting the network settings
index 4d4df21..5473e9a 100644 (file)
@@ -3,6 +3,7 @@ package org.evergreen.android.views;
 
 import org.evergreen.android.R;
 import org.evergreen.android.globals.GlobalConfigs;
+import org.evergreen.android.searchCatalog.SearchCatalogListView;
 
 import android.app.Activity;
 import android.content.Intent;
@@ -115,7 +116,7 @@ public class MainScreenDashboard extends Activity {
            switch (id) {
            
              case R.id.main_btn_search :
-                  //startActivity (new Intent(getApplicationContext(), F1Activity.class));
+                  startActivity (new Intent(getApplicationContext(), SearchCatalogListView.class));
                   break;
              case R.id.main_btn_account:
                   startActivity (new Intent(getApplicationContext(), AccountScreenDashboard.class));