added place hold and add to bookbag search details buttons
authordrizea <danielrizea27@gmail.com>
Thu, 26 Jul 2012 18:43:42 +0000 (21:43 +0300)
committerdrizea <danielrizea27@gmail.com>
Thu, 26 Jul 2012 18:43:42 +0000 (21:43 +0300)
19 files changed:
Open-ILS/src/Android/res/drawable/dark_text_color.xml [new file with mode: 0644]
Open-ILS/src/Android/res/drawable/details_button.xml [new file with mode: 0644]
Open-ILS/src/Android/res/layout/bookbag_spinner.xml
Open-ILS/src/Android/res/layout/place_hold.xml
Open-ILS/src/Android/res/layout/record_details_basic_fragment.xml
Open-ILS/src/Android/res/layout/simple_actionbar.xml
Open-ILS/src/Android/res/values/colors.xml
Open-ILS/src/Android/res/values/strings.xml
Open-ILS/src/Android/res/values/styles.xml
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookBagDetails.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/bookbags/BookbagsListView.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/checkout/ItemsCheckOutListView.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/fines/FinesActivity.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldDetails.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/HoldsListView.java
Open-ILS/src/Android/src/org/evergreen/android/accountAccess/holds/PlaceHold.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SampleUnderlinesNoFade.java
Open-ILS/src/Android/src/org/evergreen/android/searchCatalog/SearchCatalogListView.java
Open-ILS/src/Android/src/org/evergreen/android/utils/ui/BasicDetailsFragment.java

diff --git a/Open-ILS/src/Android/res/drawable/dark_text_color.xml b/Open-ILS/src/Android/res/drawable/dark_text_color.xml
new file mode 100644 (file)
index 0000000..46e4ad7
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android" >
+    <item android:state_focused="true" android:color="@color/dark">
+    </item>
+    <item android:state_pressed="true" android:color="@color/dark">
+    </item>
+    <item android:color="@color/white">
+    </item>
+</selector>
\ No newline at end of file
diff --git a/Open-ILS/src/Android/res/drawable/details_button.xml b/Open-ILS/src/Android/res/drawable/details_button.xml
new file mode 100644 (file)
index 0000000..a3a9915
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true">
+        <shape>
+            <gradient android:startColor="@color/light_green"
+                android:endColor="@color/light_green" android:angle="270" />
+            <corners android:radius="5dp" />
+            <stroke android:width="1dp" android:color="@color/button_stroke"/>
+             <padding android:left="4dp" android:top="4dp" android:right="4dp" android:bottom="4dp" />
+        </shape>
+    </item>
+    <item android:state_focused="true">
+        <shape>
+            <gradient android:endColor="@color/light_green"
+                android:startColor="@color/light_green" android:angle="270" />
+            <corners android:radius="5dp" />
+            <stroke android:width="1dp" android:color="@color/button_stroke"/>
+             <padding android:left="4dp" android:top="4dp" android:right="4dp" android:bottom="4dp" />
+        </shape>
+    </item>
+    <item>
+        <shape>
+
+            <gradient android:endColor="@color/dark_green"
+                android:startColor="@color/normal_green" android:angle="270" />
+            <corners android:radius="5dp" />
+            <stroke android:width="1dp" android:color="@color/button_stroke"/>
+            <padding android:left="4dp" android:top="4dp" android:right="4dp" android:bottom="4dp" />
+        </shape>
+    </item>
+
+</selector>
index cbd348e..0e9f974 100644 (file)
@@ -1,18 +1,26 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
+    android:layout_width="wrap_content"
+    android:layout_height="200dip"
     android:orientation="vertical" >
+    
+    <TextView
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/bookbag_choose_text"
+        />
+        
     <Spinner
         android:id="@+id/bookbag_spinner"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content" />
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" 
+        android:layout_marginTop="5dip"
+        android:layout_marginLeft="20dip"
+        />
     
     <Button 
         android:id="@+id/add_to_bookbag_button"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:text="@string/add_button"
-        
-        />
+        android:text="@string/add_button"/>
 </LinearLayout>
index 800816a..fd99ac8 100644 (file)
@@ -4,26 +4,8 @@
     android:layout_height="match_parent" >
   
     
-    <LinearLayout
-               android:id="@+id/header"
-        android:layout_width="fill_parent"
-        android:layout_height="40dip"
-        android:background="@color/blue"
-        android:layout_alignParentTop="true"
-    >
-           <TextView
-               android:id="@+id/header_title"
-               android:layout_width="wrap_content"
-               android:layout_height="wrap_content"
-               android:paddingLeft="5dip"
-               android:paddingTop="5dip"
-               android:textColor="@color/white"
-               android:textStyle="bold"
-               android:textSize="16dip"
-               />
-
-        
-    </LinearLayout>
+       <include android:id="@+id/header_actionbar" layout="@layout/simple_actionbar"/>
+   
         
        <LinearLayout
            android:id="@+id/action_bar"
@@ -54,7 +36,7 @@
         android:layout_height="wrap_content"
         android:fillViewport="true"
         android:layout_above="@id/action_bar"
-        android:layout_below="@id/header"
+        android:layout_below="@id/header_actionbar"
         >
        <LinearLayout 
            android:layout_width="fill_parent"
index 040b94e..b994b54 100644 (file)
                     />
                 
             </LinearLayout>
-
-
+            
+            <RelativeLayout 
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                >
+                <Button
+                    android:id="@+id/simple_place_hold_button"
+                    style="@style/SearchDetailsActionButton"
+                    android:layout_height="wrap_content"
+                    android:layout_width="150dip"
+                    android:layout_alignParentLeft="true"
+                    android:text="@string/button_place_hold"    
+                    />
+                
+                <Button
+                    android:id="@+id/simple_add_to_bookbag_button"
+                    style="@style/SearchDetailsActionButton"
+                    android:layout_height="wrap_content"
+                    android:layout_width="150dip"
+                    android:layout_alignParentRight="true"
+                                       android:text="@string/button_add_to_bookbag"
+                    />
+            </RelativeLayout>
 
             <TextView
                 android:id="@+id/record_details_simple_copy_count"
index f8c8a2f..0efa592 100644 (file)
@@ -27,7 +27,7 @@
             />
 
         <Button
-            android:id="@+id/my_acount_button"
+            android:id="@+id/my_account_button"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/my_account_button_text"
index b3818a3..215a258 100644 (file)
     <color name="header_gradient_stop">#6F9669</color>
     <color name="library_logo_text_coor">#000</color>
     
+    
+    
+    <color name="dark_green">#387962</color>
+    <color name="light_green">#E0F6E0</color>
+    <color name="normal_green">#A7EA9D</color>
+    
     <color name="header_title">#ffffff</color>
     
+    <color name="button_stroke">#aaa</color>
+    
     <!-- Search Details -->
     <color name="dark">#000</color>
 </resources>
index fefb9c2..3bd7df7 100644 (file)
     <string name="bookbag_details_title">bookbag details</string>
     <string name="fines_title">fines</string>
     
-    
+    <string name="button_place_hold">Place Hold</string>
+    <string name="button_add_to_bookbag">Add to Bookbag</string>
     
     <string name="server_name_dialog">http:// </string>
     <string name="username">username : </string>
     <string name="password">password : </string>
     
+    <string name="bookbag_choose_text">Choose a bookbag from the list.</string>
+    
     <string name="cancel_button">cancel</string>
     <string name="connect_button">connect</string>
     
index d52bc2c..dd62183 100644 (file)
    </style>
    
    
+   <style name="SearchDetailsActionButton">
+       <item name="android:background">@drawable/details_button</item>
+       <item name="android:textColor">@drawable/dark_text_color</item>
+       
+   </style>
+   
    <style name="HeaderTitle">
        <item name="android:background">@drawable/header_rounded_corners</item>
        <item name="android:textSize">16dip</item>
index 9047a0f..4519399 100644 (file)
@@ -78,7 +78,7 @@ private String TAG = "BookBags";
                setContentView(R.layout.bookbagitem_list);
                 //header portion actions
         homeButton = (ImageButton) findViewById(R.id.library_logo);
-        myAccountButton = (Button) findViewById(R.id.my_acount_button);
+        myAccountButton = (Button) findViewById(R.id.my_account_button);
         headerTitle = (TextView) findViewById(R.id.header_title);
         headerTitle.setText(R.string.bookbag_details_title);
         
index 7466dd5..ac3bb80 100644 (file)
@@ -70,7 +70,7 @@ public class BookbagsListView extends Activity{
                
                 //header portion actions
         homeButton = (ImageButton) findViewById(R.id.library_logo);
-        myAccountButton = (Button) findViewById(R.id.my_acount_button);
+        myAccountButton = (Button) findViewById(R.id.my_account_button);
         headerTitle = (TextView) findViewById(R.id.header_title);
         headerTitle.setText(R.string.bookbag_items_title);
         
index d42b72d..0877dce 100644 (file)
@@ -65,7 +65,7 @@ public class ItemsCheckOutListView extends Activity{
                
                 //header portion actions
         homeButton = (ImageButton) findViewById(R.id.library_logo);
-        myAccountButton = (Button) findViewById(R.id.my_acount_button);
+        myAccountButton = (Button) findViewById(R.id.my_account_button);
         headerTitle = (TextView) findViewById(R.id.header_title);
         headerTitle.setText(R.string.checkout_items_title);
         
index add7fd9..9313839 100644 (file)
@@ -63,7 +63,7 @@ public class FinesActivity extends Activity{
                
                 //header portion actions
         homeButton = (ImageButton) findViewById(R.id.library_logo);
-        myAccountButton = (Button) findViewById(R.id.my_acount_button);
+        myAccountButton = (Button) findViewById(R.id.my_account_button);
         headerTitle = (TextView) findViewById(R.id.header_title);
         headerTitle.setText(R.string.fines_title);
         
index c8cfce9..4d37c18 100644 (file)
@@ -114,7 +114,7 @@ public class HoldDetails extends Activity {
 
                
                homeButton = (ImageButton) findViewById(R.id.library_logo);
-               myAccountButton = (Button) findViewById(R.id.my_acount_button);
+               myAccountButton = (Button) findViewById(R.id.my_account_button);
                headerTitle = (TextView) findViewById(R.id.header_title);
                headerTitle.setText(R.string.hold_details_title);
                homeButton.setOnClickListener(new OnClickListener() {
index c8c5742..36e04da 100644 (file)
@@ -62,7 +62,7 @@ public class HoldsListView extends Activity{
                
                 //header portion actions
         homeButton = (ImageButton) findViewById(R.id.library_logo);
-        myAccountButton = (Button) findViewById(R.id.my_acount_button);
+        myAccountButton = (Button) findViewById(R.id.my_account_button);
         headerTitle = (TextView) findViewById(R.id.header_title);
         headerTitle.setText(R.string.hold_items_title);
         
index 680190f..f886cfd 100644 (file)
@@ -105,7 +105,7 @@ public class PlaceHold extends Activity{
                RecordInfo record = (RecordInfo) getIntent().getSerializableExtra("recordInfo");
                
                homeButton = (ImageButton) findViewById(R.id.library_logo);
-               myAccountButton = (Button) findViewById(R.id.my_acount_button);
+               myAccountButton = (Button) findViewById(R.id.my_account_button);
                headerTitle = (TextView) findViewById(R.id.header_title);
                headerTitle.setText(R.string.hold_place_title);
                
index 822d4f9..c95f672 100644 (file)
@@ -39,7 +39,7 @@ public class SampleUnderlinesNoFade extends BaseSampleActivity {
         
         //header portion actions
         homeButton = (ImageButton) findViewById(R.id.library_logo);
-        myAccountButton = (Button) findViewById(R.id.my_acount_button);
+        myAccountButton = (Button) findViewById(R.id.my_account_button);
         headerTitle = (TextView) findViewById(R.id.header_title);
         headerTitle.setText(R.string.search_details_title);
         
index 11add84..25d3e4d 100644 (file)
@@ -55,7 +55,7 @@ public class SearchCatalogListView extends Activity{
 
        private String TAG ="SearchCatalogListView";
        
-       private List<RecordInfo> recordList;
+       private ArrayList<RecordInfo> recordList;
        
        private EditText searchText;
        
@@ -381,7 +381,7 @@ public class SearchCatalogListView extends Activity{
                                intent.putExtra("orgID",search.selectedOrganization.id);
                                intent.putExtra("depth",(search.selectedOrganization.level-1));
                                
-                               intent.putExtra("recordList", searchResults);
+                               intent.putExtra("recordList", recordList);
                                intent.putExtra("recordPosition", position);
                                startActivity(intent);
                        }
@@ -389,8 +389,7 @@ public class SearchCatalogListView extends Activity{
                });
         
         searchText = (EditText) findViewById(R.id.searchText);
-        
+
         searchText.setOnKeyListener(new OnKeyListener() {
                        
                        @Override
@@ -410,8 +409,7 @@ public class SearchCatalogListView extends Activity{
         searchButton = (ImageButton) findViewById(R.id.searchButton);
 
         searchButton.setOnClickListener(new OnClickListener() {
-       
-        
+
                        @Override
                        public void onClick(View v) {   
                                        Thread searchThread = new Thread(searchForResultsRunnable);                             
@@ -440,8 +438,7 @@ public class SearchCatalogListView extends Activity{
                        public void onItemSelected(AdapterView<?> arg0, View arg1,
                                        int ID, long arg3) {
                                //select the specific organization
-                               search.selectOrganisation(globalConfigs.organisations.get(ID));
-                               
+                               search.selectOrganisation(globalConfigs.organisations.get(ID));         
                        }
                        
                        @Override
@@ -514,21 +511,17 @@ public class SearchCatalogListView extends Activity{
                        intent.putExtra("recordInfo", info);
                        
                        startActivity(intent);
-               }
-               
+               }       
                case BOOK_BAG : {
-                       
-                       
+
                        if(bookBags.size() > 0){
                                String array_spinner[] = new String[bookBags.size()];
                                        
                                for(int i=0;i<array_spinner.length;i++)
                                        array_spinner[i] = bookBags.get(i).name;
-                               
-       
+                                       
                                AlertDialog.Builder builder;
 
-       
                                LayoutInflater inflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
                                View layout = inflater.inflate(R.layout.bookbag_spinner,null);
        
@@ -578,8 +571,6 @@ public class SearchCatalogListView extends Activity{
                                                        addtoBookbag.start();
 
                                                }});
-                               
-
                                alertDialog.show();
        
                                s.setOnItemSelectedListener(new OnItemSelectedListener() {
@@ -595,12 +586,9 @@ public class SearchCatalogListView extends Activity{
                                                }
                                        
                                });
-
-                       
                        }
                        else
                                Toast.makeText(context, "No bookbags", Toast.LENGTH_SHORT).show();
-                       
                }
                break;
        }
@@ -647,8 +635,7 @@ public class SearchCatalogListView extends Activity{
                                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                        row = inflater.inflate(R.layout.search_result_footer_view, parent, false);
                        Log.d(tag, "Successfully completed XML view more Inflation!");
-
-                       
+       
                        }
                else{
                
@@ -684,12 +671,8 @@ public class SearchCatalogListView extends Activity{
                recordTitle.setText(record.title);
                recordAuthor.setText(record.author);
                recordPublisher.setText(record.pubdate + " " + record.publisher);
-               }
-               
+               }               
                return row;
        }
     }
-
-}
-
-
+}
\ No newline at end of file
index 692f6da..48dcd58 100644 (file)
@@ -1,16 +1,25 @@
 package org.evergreen.android.utils.ui;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Map.Entry;
 import java.util.Set;
-import java.util.zip.Inflater;
 
 import org.evergreen.android.R;
+import org.evergreen.android.accountAccess.AccountAccess;
+import org.evergreen.android.accountAccess.SessionNotFoundException;
+import org.evergreen.android.accountAccess.bookbags.BookBag;
+import org.evergreen.android.accountAccess.holds.PlaceHold;
 import org.evergreen.android.globals.GlobalConfigs;
+import org.evergreen.android.globals.NoAccessToServer;
+import org.evergreen.android.globals.NoNetworkAccessException;
 import org.evergreen.android.searchCatalog.CopyInformation;
 import org.evergreen.android.searchCatalog.RecordInfo;
 import org.evergreen.android.searchCatalog.SearchCatalog;
 
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.content.Intent;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.view.LayoutInflater;
@@ -18,8 +27,14 @@ import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.view.ViewGroup.LayoutParams;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
 import android.widget.LinearLayout;
+import android.widget.Spinner;
 import android.widget.TextView;
+import android.widget.Toast;
 
 public class BasicDetailsFragment extends Fragment{
 
@@ -39,13 +54,25 @@ public class BasicDetailsFragment extends Fragment{
        private TextView synopsisTextView;
        private TextView isbnTextView;
        
-       private TextView copyCountTestView;
+       private TextView copyCountTestView;     
+       
+       private Button placeHoldButton;
+       
+       private Button addToBookbagButton;
        
        private LinearLayout showMore;
        
        private SearchCatalog search = null;
        
        private GlobalConfigs gl;
+       
+       private ProgressDialog progressDialog;
+       
+       private Integer bookbag_selected;
+       
+       private Dialog dialog;
+       
+       private ArrayList<BookBag> bookBags;
 
        //max display info
        private int list_size = 3;
@@ -84,7 +111,8 @@ public class BasicDetailsFragment extends Fragment{
                
                gl = GlobalConfigs.getGlobalConfigs(getActivity());
                
-               LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.record_details_basic_fragment, null);
+               LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.record_details_basic_fragment,null);
+
 
                record_header = (TextView) layout.findViewById(R.id.record_header_text);
                copyCountTestView = (TextView) layout.findViewById(R.id.record_details_simple_copy_count);
@@ -97,6 +125,105 @@ public class BasicDetailsFragment extends Fragment{
                        subjectTextView = (TextView) layout.findViewById(R.id.record_details_simple_subject);
                        synopsisTextView = (TextView) layout.findViewById(R.id.record_details_simple_synopsis);
                        isbnTextView = (TextView) layout.findViewById(R.id.record_details_simple_isbn);
+
+               placeHoldButton = (Button) layout.findViewById(R.id.simple_place_hold_button);
+               addToBookbagButton = (Button) layout.findViewById(R.id.simple_add_to_bookbag_button);
+
+               placeHoldButton.setOnClickListener(new OnClickListener() {
+                               
+                               @Override
+                               public void onClick(View v) {
+                                       Intent intent = new Intent(getActivity().getApplicationContext(),PlaceHold.class);
+                                       intent.putExtra("recordInfo",record);
+                                       startActivity(intent);
+                               }
+                       });
+
+                       AccountAccess ac = AccountAccess.getAccountAccess();
+
+                       bookBags = ac.bookBags;
+                       String array_spinner[] = new String[bookBags.size()];
+                               
+                       for(int i=0;i<array_spinner.length;i++)
+                               array_spinner[i] = bookBags.get(i).name;
+                               
+
+                       dialog = new Dialog(getActivity());
+                       dialog.setContentView(R.layout.bookbag_spinner);
+                       dialog.setTitle("Choose bookbag");
+                       Spinner s = (Spinner) dialog.findViewById(R.id.bookbag_spinner);
+
+                       Button add = (Button) dialog.findViewById(R.id.add_to_bookbag_button);
+                       ArrayAdapter adapter = new ArrayAdapter(getActivity().getApplicationContext(),android.R.layout.simple_spinner_item, array_spinner);
+                       s.setAdapter(adapter);
+                       
+                       add.setOnClickListener(new OnClickListener() {
+                                       
+                                       @Override
+                                       public void onClick(View v) {
+                                               // TODO Auto-generated method stub
+                                               Thread addtoBookbag = new Thread(new Runnable() {
+                                                       @Override
+                                                       public void run() {
+                                                               AccountAccess ac = AccountAccess.getAccountAccess();
+                                                               try {
+                                                                       ac.addRecordToBookBag(record.doc_id, ac.bookBags.get(bookbag_selected).id);
+                                                               } catch (SessionNotFoundException e) {
+                                                                       // TODO Auto-generated catch block
+                                                                       e.printStackTrace();
+                                                               } catch (NoAccessToServer e) {
+                                                                       // TODO Auto-generated catch block
+                                                                       e.printStackTrace();
+                                                               } catch (NoNetworkAccessException e) {
+                                                                       // TODO Auto-generated catch block
+                                                                       e.printStackTrace();
+                                                               }
+                                                       
+                                                               getActivity().runOnUiThread(new Runnable() {
+                                                                       @Override
+                                                                       public void run() {
+                                                                               progressDialog.dismiss();
+                                                                               dialog.dismiss();
+                                                                       }
+                                                               });
+
+                                                       }
+                               });
+                                               progressDialog = ProgressDialog.show(getActivity(), "Please wait", "Add to bookbag");
+                                               addtoBookbag.start();
+
+                                       }});
+                       s.setOnItemSelectedListener(new OnItemSelectedListener() {
+
+                                       @Override
+                                       public void onItemSelected(AdapterView<?> arg0, View arg1,
+                                                       int position, long arg3) {      
+                                       bookbag_selected = position;
+                                       }
+
+                                       @Override
+                                       public void onNothingSelected(AdapterView<?> arg0) {
+                                       }
+                               
+                       });
+
+                       
+                       addToBookbagButton.setOnClickListener(new OnClickListener() {
+                               @Override
+                               public void onClick(View v) {
+                                       getActivity().runOnUiThread(new Runnable() {
+                                               @Override
+                                               public void run() {
+                                               
+                                               if(bookBags.size() > 0)
+                                                       dialog.show();
+                                               else
+                                                       Toast.makeText(getActivity(), "No bookbags", Toast.LENGTH_SHORT).show();
+                                               }
+                                               
+                                       });
+                               }
+                       });
                        
                        record_header.setText("Record " + position + "of " + total  );
                        
@@ -109,6 +236,7 @@ public class BasicDetailsFragment extends Fragment{
                        synopsisTextView.setText(record.synopsis);
                        
                        isbnTextView.setText(record.isbn);
+
                        
                        int current_org = 0;
                        if(search != null)
@@ -152,6 +280,7 @@ public class BasicDetailsFragment extends Fragment{
                        addCopyInfo(0, list_size, inflater, insertPoint);
                        
 
+                       
                return layout;
            }