android:versionName="1.0" >\r
\r
<uses-sdk\r
- android:minSdkVersion="8"\r
+ android:minSdkVersion="9"\r
android:targetSdkVersion="18" />\r
\r
<application>\r
android:id="@+id/search_format_spinner"
android:layout_width="120dp"
android:layout_height="wrap_content"
- android:layout_gravity="right"
- android:entries="@array/search_format_options"/>
+ android:layout_gravity="right"/>
<Spinner
android:id="@+id/chose_organisation"
android:layout_width="fill_parent"
android:id="@+id/record_details_simple_title"
style="@style/textLarge"
/>
-
- <TextView
- android:id="@+id/record_details_simple_author"
- style="@style/textSmall"
- android:layout_marginTop="5dip"
- />
-
+
+ <TextView
+ android:id="@+id/record_details_format"
+ style="@style/textSmall"
+ android:layout_marginTop="5dip"
+ />
+
+ <TextView
+ android:id="@+id/record_details_simple_author"
+ style="@style/textSmall"
+ android:layout_marginTop="5dip"
+ />
+
<TextView
android:id="@+id/record_details_simple_publisher"
style="@style/textSmall"
android:id="@+id/search_format_spinner"
android:layout_width="120dp"
android:layout_height="wrap_content"
- android:layout_gravity="right"
- android:entries="@array/search_format_options"/>
+ android:layout_gravity="right"/>
</LinearLayout>
<LinearLayout
--- /dev/null
+[
+ {"l":"All Formats", "f":""},
+ {"l":"All Books", "f":"book", "L":"Book"},
+ {"l":"All Music", "f":"music"},
+ {"l":"Audiocassette music recording", "f":"casmusic", "h":1},
+ {"l":"Blu-ray", "f":"blu-ray"},
+ {"l":"Braille", "f":"braille", "h":1},
+ {"l":"Cassette audiobook", "f":"casaudiobook", "h":1},
+ {"l":"CD Audiobook", "f":"cdaudiobook"},
+ {"l":"CD Music recording", "f":"cdmusic"},
+ {"l":"DVD", "f":"dvd"},
+ {"l":"E-audio", "f":"eaudio"},
+ {"l":"E-book", "f":"ebook"},
+ {"l":"E-video", "f":"evideo"},
+ {"l":"Equipment, games, toys", "f":"equip", "h":1},
+ {"l":"Kit", "f":"kit", "h":1},
+ {"l":"Large Print Book", "f":"lpbook"},
+ {"l":"Map", "f":"map", "h":1},
+ {"l":"Microform", "f":"microform", "h":1},
+ {"l":"Music Score", "f":"score", "h":1},
+ {"l":"Phonograph music recording", "f":"phonomusic", "h":1},
+ {"l":"Phonograph spoken recording", "f":"phonospoken", "h":1},
+ {"l":"Picture", "f":"picture"},
+ {"l":"Serials and magazines", "f":"serial"},
+ {"l":"Software and video games", "f":"software"},
+ {"l":"VHS", "f":"vhs", "h":1}
+]
<item>Matches exactly</item>
</string-array>
- <string-array name="search_format_options">
- <item>All Formats</item>
- <item>All Books</item>
- <item>All Music</item>
- <!--<item>Audiocassette music recording</item>-->
- <item>Blu-ray</item>
- <!--<item>Braille</item>-->
- <!--<item>Cassette audiobook</item>-->
- <item>CD Audiobook</item>
- <item>CD Music recording</item>
- <item>DVD</item>
- <item>E-audio</item>
- <item>E-book</item>
- <item>E-video</item>
- <!--<item>Equipment, games, toys</item>-->
- <!--<item>Kit</item>-->
- <item>Large Print Book</item>
- <!--<item>Map</item>-->
- <!--<item>Microform</item>-->
- <!--<item>Music Score</item>-->
- <!--<item>Phonograph music recording</item>-->
- <!--<item>Phonograph spoken recording</item>-->
- <item>Picture</item>
- <item>Serials and magazines</item>
- <item>Software and video games</item>
- <!--<item>VHS</item>-->
- </string-array>
-
<string-array name="notification_preferences_list_values">
<item>1</item>
<item>2</item>
*/
package org.evergreen_ils.searchCatalog;
-import java.util.ArrayList;
-import java.util.List;
+import java.io.*;
+import java.util.*;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
public class SearchCatalogListView extends ActionBarActivity {
- private final String TAG = SearchCatalogListView.class.getName();
+ private final String TAG = SearchCatalogListView.class.getSimpleName();
private ArrayList<RecordInfo> recordList;
return searchClassSpinner.getSelectedItem().toString().toLowerCase();
}
- // Sadly there is currently no way to get these programmatically.
- // todo: instead of raw strings in the search_format_options string-array,
- // store an array of search_key:printable_strings, e.g. "book:All Books",
- // and dynamically construct the spinner.
private String getSearchFormat() {
- String value = "";
- String s = searchFormatSpinner.getSelectedItem().toString();
- if (!s.isEmpty()) value=s;
- if (s.equalsIgnoreCase("All Formats")) value="";
- else if (s.equalsIgnoreCase("All Books")) value="book";
- else if (s.equalsIgnoreCase("All Music")) value="music";
- else if (s.equalsIgnoreCase("Audiocassette music recording")) value="casmusic";
- else if (s.equalsIgnoreCase("Blu-ray")) value="blu-ray";
- else if (s.equalsIgnoreCase("Braille")) value="braille";
- else if (s.equalsIgnoreCase("Cassette audiobook")) value="casaudiobook";
- else if (s.equalsIgnoreCase("CD Audiobook")) value="cdaudiobook";
- else if (s.equalsIgnoreCase("CD Music recording")) value="cdmusic";
- else if (s.equalsIgnoreCase("DVD")) value="dvd";
- else if (s.equalsIgnoreCase("E-audio")) value="eaudio";
- else if (s.equalsIgnoreCase("E-book")) value="ebook";
- else if (s.equalsIgnoreCase("E-video")) value="evideo";
- else if (s.equalsIgnoreCase("Equipment, games, toys")) value="equip";
- else if (s.equalsIgnoreCase("Kit")) value="kit";
- else if (s.equalsIgnoreCase("Large Print Book")) value="lpbook";
- else if (s.equalsIgnoreCase("Map")) value="map";
- else if (s.equalsIgnoreCase("Microform")) value="microform";
- else if (s.equalsIgnoreCase("Music Score")) value="score";
- else if (s.equalsIgnoreCase("Phonograph music recording")) value="phonomusic";
- else if (s.equalsIgnoreCase("Phonograph spoken recording")) value="phonospoken";
- else if (s.equalsIgnoreCase("Picture")) value="picture";
- else if (s.equalsIgnoreCase("Serials and magazines")) value="serial";
- else if (s.equalsIgnoreCase("Software and video games")) value="software";
- else if (s.equalsIgnoreCase("VHS")) value="vhs";
- return value;
+ return SearchFormat.getSearchFormatFromSpinnerLabel(searchFormatSpinner.getSelectedItem().toString());
}
@Override
searchClassSpinner = (Spinner) findViewById(R.id.search_class_spinner);
searchFormatSpinner = (Spinner) findViewById(R.id.search_format_spinner);
searchResultsNumber = (TextView) findViewById(R.id.search_result_number);
+ initSearchFormatSpinner();
// Get reference to ListView holder
lv = (ListView) this.findViewById(R.id.search_results_list);
} else {
// start activity with book details
- Intent intent = new Intent(getBaseContext(),
- SampleUnderlinesNoFade.class);
+ Intent intent = new Intent(getBaseContext(), SampleUnderlinesNoFade.class);
// serialize object and pass it to next activity
intent.putExtra("recordInfo", info);
intent.putExtra("orgID", search.selectedOrganization.id);
}
+ private String loadJSONFromResource(int r) {
+ String json = "";
+ InputStream is = getResources().openRawResource(R.raw.search_formats);
+ int size = 0;
+ try {
+ size = is.available();
+ byte[] buf = new byte[size];
+ is.read(buf);
+ is.close();
+ json = new String(buf, "UTF-8");
+ } catch (IOException e) {
+ Log.d(TAG, "caught", e);
+ }
+ return json;
+ }
+
+ // unpack the json map to populate our spinner, and allow translation from search_format keyword <=> label
+ private void initSearchFormatSpinner() {
+ String formats_json = loadJSONFromResource(R.raw.search_formats);
+ SearchFormat.initFromJSON(formats_json);
+ List<String> labels = SearchFormat.getSpinnerLabels();
+ ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, labels);
+ searchFormatSpinner.setAdapter(adapter);
+ }
+
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
// set text
recordTitle.setText(record.title);
recordAuthor.setText(record.author);
- recordFormat.setText(record.search_format);
+ recordFormat.setText(SearchFormat.getLabelFromSearchFormat(record.search_format));
recordPublisher.setText(record.pubdate + " " + record.publisher);
return row;
--- /dev/null
+package org.evergreen_ils.searchCatalog;
+
+import android.util.Log;
+import org.opensrf.util.JSONException;
+import org.opensrf.util.JSONReader;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by kenstir on 10/17/2015.
+ */
+public class SearchFormat {
+
+ private static class SearchFormatItem {
+ public String spinnerLabel = null;
+ public String displayLabel = null;
+ public String searchFormat = null;
+ public boolean hidden;
+ }
+
+ private final static String TAG = SearchFormat.class.getSimpleName();
+
+ static List<SearchFormatItem> searchFormats = new ArrayList<SearchFormatItem>();
+
+ public static void initFromJSON(String formats_json) {
+ searchFormats.clear();
+
+ List<Map<String,?>> formatsList;
+ try {
+ formatsList = (List<Map<String, ?>>) new JSONReader(formats_json).readArray();
+ } catch (JSONException e) {
+ Log.d(TAG, "failed parsing json: "+formats_json, e);
+ return;
+ }
+ for (int i=0; i<formatsList.size(); ++i) {
+ Map<String, ?> m = formatsList.get(i);
+ Log.d(TAG, "item:"+m);
+ SearchFormatItem item = new SearchFormatItem();
+ item.spinnerLabel = (String)m.get("l");
+ item.displayLabel = (String)m.get("L");
+ item.searchFormat = (String)m.get("f");
+ item.hidden = m.containsKey("h");
+ searchFormats.add(item);
+ }
+ }
+
+ /// list of labels e.g. "All Formats", "All Books", ...
+ public static List<String> getSpinnerLabels() {
+ ArrayList<String> labels = new ArrayList<String>();
+ for (SearchFormatItem i : searchFormats) {
+ if (!i.hidden) {
+ labels.add(i.spinnerLabel);
+ }
+ }
+ return labels;
+ }
+
+ /// get search format "music" from label "All Music"
+ public static String getSearchFormatFromSpinnerLabel(String label) {
+ for (SearchFormatItem i : searchFormats) {
+ if (i.spinnerLabel.equalsIgnoreCase(label)) {
+ return i.searchFormat;
+ }
+ }
+ Log.w(TAG, "label not found: "+label);
+ return "";
+ }
+
+ /// get label "CD Music recording" from search format "cdmusic"
+ public static String getLabelFromSearchFormat(String search_format) {
+ for (SearchFormatItem i : searchFormats) {
+ if (i.searchFormat.equalsIgnoreCase(search_format)) {
+ return (i.displayLabel != null) ? i.displayLabel : i.spinnerLabel;
+ }
+ }
+ Log.w(TAG, "search format not found: "+search_format);
+ return "";
+ }
+}
import org.evergreen_ils.accountAccess.bookbags.BookBag;
import org.evergreen_ils.accountAccess.holds.PlaceHold;
import org.evergreen_ils.globals.GlobalConfigs;
-import org.evergreen_ils.searchCatalog.CopyInformation;
-import org.evergreen_ils.searchCatalog.ImageDownloader;
-import org.evergreen_ils.searchCatalog.MoreCopyInformation;
-import org.evergreen_ils.searchCatalog.RecordInfo;
-import org.evergreen_ils.searchCatalog.SearchCatalog;
+import org.evergreen_ils.searchCatalog.*;
import android.app.Dialog;
import android.app.ProgressDialog;
private TextView record_header;
private TextView titleTextView;
+ private TextView formatTextView;
private TextView authorTextView;
private TextView publisherTextView;
R.layout.record_details_basic_fragment, null);
record_header = (TextView) layout.findViewById(R.id.record_header_text);
- copyCountTextView = (TextView) layout
- .findViewById(R.id.record_details_simple_copy_count);
- showMore = (LinearLayout) layout
- .findViewById(R.id.record_details_show_more);
- titleTextView = (TextView) layout
- .findViewById(R.id.record_details_simple_title);
- authorTextView = (TextView) layout
- .findViewById(R.id.record_details_simple_author);
- publisherTextView = (TextView) layout
- .findViewById(R.id.record_details_simple_publisher);
-
- seriesTextView = (TextView) layout
- .findViewById(R.id.record_details_simple_series);
- 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);
-
- recordImage = (ImageView) layout
- .findViewById(R.id.record_details_simple_image);
-
- placeHoldButton = (Button) layout
- .findViewById(R.id.simple_place_hold_button);
- addToBookbagButton = (Button) layout
- .findViewById(R.id.simple_add_to_bookbag_button);
+ copyCountTextView = (TextView) layout.findViewById(R.id.record_details_simple_copy_count);
+ showMore = (LinearLayout) layout.findViewById(R.id.record_details_show_more);
+ titleTextView = (TextView) layout.findViewById(R.id.record_details_simple_title);
+ formatTextView = (TextView) layout.findViewById(R.id.record_details_format);
+ authorTextView = (TextView) layout.findViewById(R.id.record_details_simple_author);
+ publisherTextView = (TextView) layout.findViewById(R.id.record_details_simple_publisher);
+
+ seriesTextView = (TextView) layout.findViewById(R.id.record_details_simple_series);
+ 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);
+
+ recordImage = (ImageView) layout.findViewById(R.id.record_details_simple_image);
+
+ 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() {
record_header.setText(String.format(getString(R.string.record_of), position, total));
titleTextView.setText(record.title);
+ formatTextView.setText(SearchFormat.getLabelFromSearchFormat(record.search_format));
authorTextView.setText(record.author);
publisherTextView.setText(record.pubdate + " " + record.publisher);
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.cwmars"
android:installLocation="auto"
- android:versionCode="7"
+ android:versionCode="9"
android:versionName="1.3">
<uses-sdk
- android:minSdkVersion="8"
+ android:minSdkVersion="9"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />