advanced search added and working
authordrizea <danielrizea27@gmail.com>
Sat, 4 Aug 2012 18:09:39 +0000 (21:09 +0300)
committerdrizea <danielrizea27@gmail.com>
Sat, 4 Aug 2012 18:09:39 +0000 (21:09 +0300)
Open-ILS/src/Android/AndroidManifest.xml
Open-ILS/src/Android/res/drawable/rounded_contentbox.xml [new file with mode: 0644]
Open-ILS/src/Android/res/layout/advanced_search.xml [new file with mode: 0644]
Open-ILS/src/Android/res/layout/advanced_search_dialog.xml [deleted file]
Open-ILS/src/Android/res/values/resources.xml
Open-ILS/src/Android/res/values/strings.xml
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/AdvancedSearchActivity.java [new file with mode: 0644]
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java
Open-ILS/src/Android/src/org/evergreen/android/views/splashscreen/SplashActivity.java

index 0cd612e..7685a0d 100644 (file)
             >
         </activity>
                <activity android:name=".searchCatalog.MoreCopyInformation">
-                   
                </activity>
                <activity
             android:name=".searchCatalog.SearchCatalogListView"
             android:label="@string/app_name"
             >
-               
         </activity>
-        
+        <activity 
+            android:name=".searchCatalog.AdvancedSearchActivity">
+        </activity>
         
         <!-- Checkout Activities -->
         <activity android:name=".accountAccess.checkout.ItemsCheckOutListView"></activity>
diff --git a/Open-ILS/src/Android/res/drawable/rounded_contentbox.xml b/Open-ILS/src/Android/res/drawable/rounded_contentbox.xml
new file mode 100644 (file)
index 0000000..56da1bf
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?> 
+<shape xmlns:android="http://schemas.android.com/apk/res/android" 
+     android:shape="rectangle"> 
+    <solid android:color="#333"/>
+
+    <corners android:radius="8dip"/> 
+</shape> 
\ No newline at end of file
diff --git a/Open-ILS/src/Android/res/layout/advanced_search.xml b/Open-ILS/src/Android/res/layout/advanced_search.xml
new file mode 100644 (file)
index 0000000..75a8dcb
--- /dev/null
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+    
+    
+       <include android:id="@+id/header_actionbar" layout="@layout/simple_actionbar"/>
+    
+
+        <Spinner 
+        android:id="@+id/advanced_spinner_index"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/header_actionbar"
+        android:entries="@array/advanced_search_index"
+        android:layout_marginTop="10dip"
+        />
+            
+        <Spinner 
+        android:id="@+id/advanced_spinner_option"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/header_actionbar"
+        android:layout_marginTop="10dip"
+        android:entries="@array/advanced_search_options"
+        android:layout_toRightOf="@id/advanced_spinner_index" 
+        />
+        
+        <LinearLayout 
+            android:id="@+id/advanced_search_filter_container"
+            android:layout_below="@id/advanced_spinner_index"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            >
+            
+               <EditText 
+               android:id="@+id/advanced_search_text"
+               android:layout_width="0dip"
+               android:layout_height="wrap_content"
+               android:layout_weight="1"
+               android:hint="@string/advanced_search_hint"
+               android:singleLine="true"
+               />
+
+        
+               <Button 
+            android:id="@+id/advanced_search_add_filter_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/advanced_search_add_filter_button"
+            />  
+            
+            
+        </LinearLayout>
+        
+        <ScrollView
+            android:id="@+id/advanced_search_scrollview"
+            android:layout_width="fill_parent"
+            android:layout_height="100dip"
+            android:layout_below="@id/advanced_search_filter_container"
+            android:background="@drawable/rounded_contentbox"
+            >
+            
+            <LinearLayout 
+                android:id="@+id/advanced_search_filters"
+                android:orientation="vertical"
+                android:layout_width="fill_parent"
+                android:layout_height="fill_parent"
+                >
+                               
+                               <TextView 
+                           android:layout_height="wrap_content"
+                           android:layout_width="wrap_content"
+                           android:text="@string/advanced_search_filter_text"
+                           />
+                        
+            </LinearLayout>
+        </ScrollView>
+        
+
+        <Button 
+            android:id="@+id/advanced_search_cancel"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_below="@id/advanced_search_scrollview"
+            android:text="@string/cancel"
+            />
+        
+        
+        <Button
+            android:id="@+id/advanced_search_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_below="@id/advanced_search_scrollview"
+            android:layout_toRightOf="@id/advanced_search_cancel"
+            android:text="@string/advanced_search"
+            
+            />
+       
+
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/Open-ILS/src/Android/res/layout/advanced_search_dialog.xml b/Open-ILS/src/Android/res/layout/advanced_search_dialog.xml
deleted file mode 100644 (file)
index 3fd28b9..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
-    android:orientation="vertical" >
-
-
-        <Spinner 
-        android:id="@+id/advanced_spinner_index"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:entries="@array/advanced_search_index"
-        />
-            
-        <Spinner 
-        android:id="@+id/advanced_spinner_option"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:entries="@array/advanced_search_options"
-        android:layout_toRightOf="@id/advanced_spinner_index" 
-        />
-        
-        <LinearLayout 
-            android:id="@+id/advanced_search_filter_container"
-            android:layout_below="@id/advanced_spinner_index"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal"
-            >
-            
-               <EditText 
-               android:id="@+id/advanced_search_text"
-               android:layout_width="0dip"
-               android:layout_height="wrap_content"
-               android:layout_weight="1"
-               android:hint="@string/advanced_search_hint"
-               android:singleLine="true"
-               />
-
-        
-               <Button 
-            android:id="@+id/advanced_search_add_filter_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/advanced_search_add_filter_button"
-            />  
-            
-            
-        </LinearLayout>
-        
-        <ScrollView
-            android:id="@+id/advanced_search_scrollview"
-            android:layout_width="fill_parent"
-            android:layout_height="100dip"
-            android:layout_below="@id/advanced_search_filter_container"
-            >
-            
-            <LinearLayout 
-                android:id="@+id/advanced_search_filters"
-                android:orientation="vertical"
-                android:layout_width="fill_parent"
-                android:layout_height="fill_parent"
-                android:background="@color/white"
-                >
-                               
-                               <TextView 
-                           android:layout_height="wrap_content"
-                           android:layout_width="wrap_content"
-                           android:text="@string/advanced_search_filter_text"
-                           />
-                        
-            </LinearLayout>
-        </ScrollView>
-        
-
-        <Button 
-            android:id="@+id/advanced_search_cancel"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_below="@id/advanced_search_scrollview"
-            android:text="cancel"
-            />
-        
-        
-        <Button
-            android:id="@+id/advanced_search_button"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_below="@id/advanced_search_scrollview"
-            android:layout_toRightOf="@id/advanced_search_cancel"
-            android:text="search"
-            
-            />
-
-</RelativeLayout>
\ No newline at end of file
index edba3c1..bda6a70 100644 (file)
@@ -3,7 +3,7 @@
     <string-array name="advanced_search_index">
                <item>Keyword</item>
                <item>Title</item>
-               <item>Author</item>
+               <item>Suthor</item>
                <item>Subject</item>
                <item>Series</item>
     </string-array>
index f500c53..1fe47d9 100644 (file)
     <string name="password">Password: </string>
     
     
-    <string name="cancel_button">cancel</string>
-    <string name="connect_button">connect</string>
+    <string name="cancel_button">Cancel</string>
+    <string name="connect_button">Connect</string>
     
     <string name="search_hint">What are you looking for?</string>
+    <string name="advanced_search">Search</string>
+    
     <string name="advanced_search_hint">Enter text here</string>
     <string name="advanced_search_add_filter_button">Add filter</string>
     <string name="advanced_search_filter_text">Added filters:</string>
diff --git a/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/AdvancedSearchActivity.java b/Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/AdvancedSearchActivity.java
new file mode 100644 (file)
index 0000000..70fe36b
--- /dev/null
@@ -0,0 +1,152 @@
+package org.evergreen.android.searchCatalog;
+
+import java.util.StringTokenizer;
+
+import org.evergreen.android.R;
+import org.evergreen.android.accountAccess.AccountAccess;
+import org.evergreen.android.views.AccountScreenDashboard;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup.LayoutParams;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+public class AdvancedSearchActivity extends Activity{
+
+       private String TAG = "AdvancedSearchActivity";
+       
+       private AccountAccess accountAccess = null;
+       
+       private Context context;
+
+       private ImageButton homeButton;
+       
+       private Button myAccountButton;
+       
+       private TextView headerTitle;
+       
+       private StringBuilder advancedSearchFormattedText;
+       
+       public static final int RESULT_ADVANCED_SEARCH = 10;
+       
+       @Override
+       public void onCreate(Bundle savedInstanceState) {
+               super.onCreate(savedInstanceState);
+               
+               setContentView(R.layout.advanced_search);
+               
+               
+                //header portion actions
+        homeButton = (ImageButton) findViewById(R.id.library_logo);
+        myAccountButton = (Button) findViewById(R.id.my_account_button);
+        headerTitle = (TextView) findViewById(R.id.header_title);
+        headerTitle.setText(R.string.advanced_search);
+        
+        advancedSearchFormattedText = new StringBuilder();
+        
+        myAccountButton.setOnClickListener(new OnClickListener() {
+                       @Override
+                       public void onClick(View v) {
+                               Intent intent = new Intent(getApplicationContext(),AccountScreenDashboard.class);
+                               startActivity(intent);
+                       }
+               });
+        
+        homeButton.setOnClickListener(new OnClickListener() {
+                       @Override
+                       public void onClick(View v) {
+                               Intent intent = new Intent(getApplicationContext(),SearchCatalogListView.class);
+                               startActivity(intent);
+                       }
+               });
+        //end header portion actions
+               
+               context = this;
+       
+        final LinearLayout layout = (LinearLayout) findViewById(R.id.advanced_search_filters);
+
+        Button addFilter = (Button) findViewById(R.id.advanced_search_add_filter_button);
+        
+        final Spinner search_index = (Spinner) findViewById(R.id.advanced_spinner_index);
+        final Spinner search_option = (Spinner) findViewById(R.id.advanced_spinner_option);
+        final EditText search_filter_text = (EditText) findViewById(R.id.advanced_search_text);
+
+        addFilter.setOnClickListener(new OnClickListener() {
+                       @Override
+                       public void onClick(View v) {
+                               
+                               int searchOptionVal = search_option.getSelectedItemPosition();
+                               
+                               String searchText = search_index.getSelectedItem().toString().toLowerCase() + ": ";
+                               
+                               advancedSearchFormattedText.append(search_index.getSelectedItem().toString().toLowerCase() + ": ");
+                               
+                               switch(searchOptionVal){
+                               
+                               case 0 : {
+                                       //contains
+                                       advancedSearchFormattedText.append(search_filter_text.getText().toString());
+                                       searchText = searchText + search_filter_text.getText().toString();
+                               }break;
+                               case 1 : {
+                                       //excludes
+                                       
+                                       StringTokenizer str = new StringTokenizer(search_filter_text.getText().toString());
+                                       
+                                       while(str.hasMoreTokens()){
+                                               String token = str.nextToken(" ");
+                                               advancedSearchFormattedText.append(" -"+token);
+                                               searchText = searchText + " -"+token;
+                                       }
+                                       
+                               }break;
+                               case 2 : {
+                                       //matches exactly
+                                       advancedSearchFormattedText.append(" \"" + search_filter_text.getText().toString() + "\"");
+                                       searchText = searchText + " \"" + search_filter_text.getText().toString() + "\"";
+                               }break;
+                               
+                               }
+                               
+                TextView text = new TextView(context);
+                text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
+                text.setText(searchText);
+                layout.addView(text);
+
+                       }
+               });
+        
+        Button cancel = (Button) findViewById(R.id.advanced_search_cancel);
+        
+        cancel.setOnClickListener(new OnClickListener() {
+                       @Override
+                       public void onClick(View v) {
+                               
+                       }
+               });   
+        
+        Button search = (Button) findViewById(R.id.advanced_search_button);
+        
+        search.setOnClickListener(new OnClickListener() {
+                       
+                       @Override
+                       public void onClick(View v) {
+                                Intent returnIntent = new Intent();
+                                returnIntent.putExtra("advancedSearchText",advancedSearchFormattedText.toString());
+                                setResult(RESULT_ADVANCED_SEARCH,returnIntent);     
+                                finish();
+                       }
+               });
+
+       }
+       
+}
index db99ef9..3804917 100644 (file)
@@ -140,41 +140,8 @@ public class SearchCatalogListView extends Activity{
                        @Override
                        public void onClick(View v) {
                                //show advanced view dialog
-                               
-                               final Dialog dialog = new Dialog(context);
-                dialog.setContentView(R.layout.advanced_search_dialog);
-                dialog.setTitle("Advanced search");
-             
-                final LinearLayout layout = (LinearLayout) dialog.findViewById(R.id.advanced_search_filters);
-
-                Button addFilter = (Button) dialog.findViewById(R.id.advanced_search_add_filter_button);
-                
-                final Spinner search_index = (Spinner) dialog.findViewById(R.id.advanced_spinner_index);
-                final Spinner search_option = (Spinner) dialog.findViewById(R.id.advanced_spinner_option);
-                final EditText search_filter_text = (EditText) dialog.findViewById(R.id.advanced_search_text);
-      
-                addFilter.setOnClickListener(new OnClickListener() {
-                                       @Override
-                                       public void onClick(View v) {
-                               TextView text = new TextView(context);
-                               text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
-                               text.setText(search_index.getSelectedItem().toString() + " " + search_option.getSelectedItem().toString() + " " + search_filter_text.getText().toString());
-                               layout.addView(text);
-
-                                       }
-                               });
-
-                
-                Button cancel = (Button) dialog.findViewById(R.id.advanced_search_cancel);
-                
-                cancel.setOnClickListener(new OnClickListener() {
-                                       @Override
-                                       public void onClick(View v) {
-                                               dialog.dismiss();
-                                       }
-                               });   
-                dialog.setCancelable(true);
-                dialog.show();
+                               Intent advancedSearch = new Intent(context,AdvancedSearchActivity.class);
+                               startActivityForResult(advancedSearch, 2);
                        }
                });
         //get bookbags
@@ -217,19 +184,6 @@ public class SearchCatalogListView extends Activity{
        
        searchOptionsMenu = findViewById(R.id.search_preference_options);
         
-       // Creating a button - Load More
-       Button btnLoadMore = new Button(this);
-       btnLoadMore.setText("Load More");
-       
-       // Adding button to listview at footer
-       //lv.addFooterView(btnLoadMore);
-       
-       View footerView = findViewById(R.layout.search_result_footer_view);
-       //call before set adapter
-       //lv.addFooterView(footerView);
-       
-       //System.out.println("Here it is "  + lv);
-       
                progressDialog = new ProgressDialog(context);
                
                progressDialog.setMessage("Fetching data");
@@ -478,9 +432,9 @@ public class SearchCatalogListView extends Activity{
         AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo;
         menu.setHeaderTitle("Options");
         
-          menu.add(Menu.NONE, DETAILS,0,"Details");
-          menu.add(Menu.NONE,PLACE_HOLD,1,"Place Hold");
-          menu.add(Menu.NONE,BOOK_BAG,2,"Add to bookbag");
+        menu.add(Menu.NONE, DETAILS,0,"Details");
+        menu.add(Menu.NONE,PLACE_HOLD,1,"Place Hold");
+        menu.add(Menu.NONE,BOOK_BAG,2,"Add to bookbag");
         
       }
     }
@@ -602,6 +556,21 @@ public class SearchCatalogListView extends Activity{
        return super.onContextItemSelected(item);
     }
     
+    
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+       
+       switch(resultCode){
+       
+       case AdvancedSearchActivity.RESULT_ADVANCED_SEARCH : {
+               Log.d(TAG, "result text"+data.getStringExtra("advancedSearchText"));
+               searchText.setText(data.getStringExtra("advancedSearchText"));
+                       Thread searchThread = new Thread(searchForResultsRunnable);                             
+                       searchThread.start();
+       } break;
+       
+       }
+    }
     class SearchArrayAdapter extends ArrayAdapter<RecordInfo> {
        
        private static final String tag = "SearchArrayAdapter";
index 2e63dae..182e5b1 100644 (file)
@@ -39,7 +39,6 @@ public class SplashActivity extends Activity implements
 
        private ProgressBar progressBar;
 
-
        private String TAG = "SplashActivity";
 
        @Override
@@ -89,11 +88,7 @@ public class SplashActivity extends Activity implements
 
        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-               
-               Log.d(TAG, "Result code return " + resultCode);
-               
                switch(resultCode){
-               
                case ConfigureApplicationActivity.RESULT_CONFIGURE_SUCCESS : {
                        new LoadingTask(progressBar, this, this, progressText, this).execute("download");