Permalink
Browse files

fixed search with spaces/special chars

  • Loading branch information...
1 parent 70a52ad commit 66c5f5a2c78cf6f54f38754fca964b04b5804509 @Kagetsuki committed Jun 13, 2012
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -112,6 +112,45 @@
android:text="@string/freestyle_url" />
<ImageView
+ android:id="@+id/ImageView03"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:scaleType="fitXY"
+ android:src="@drawable/hr" />
+
+ <TextView
+ android:id="@+id/textView5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/serverside_developer"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+
+ <ImageView
+ android:id="@+id/imageView4"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/camplight" />
+
+ <TextView
+ android:id="@+id/textView6"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/camplight"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
+
+ </LinearLayout>
+
+ <Button
+ android:id="@+id/camplight_link_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/camplight_url" />
+
+ <ImageView
android:id="@+id/ImageView02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -82,10 +82,13 @@
<string name="icon_bases">アイコンの元:</string>
<string name="pixture_hide">PIXTURE STUDIO社のHideさん</string>
<string name="pixture_url">http://pixture.com</string>
-
+ <string name="serverside_developer">サーバ側開発</string>
+ <string name="camplight">CampLight Ltd.</string>
+ <string name="camplight_url">http://camplight.net</string>
<!-- alert content -->
+ <string name="unregistered_barcode_title">未登録バーコード</string>
<string name="unregistered_barcode_new_product">バーコードが未登録です。\n新規商品登録を行いますか?</string>
<!-- GSA Dialog Text -->
View
@@ -83,8 +83,12 @@
<string name="icon_bases">Base Icon Images:</string>
<string name="pixture_hide">Hide of PIXTURE STUDIO</string>
<string name="pixture_url">http://pixture.com</string>
+ <string name="serverside_developer">Serverside Development</string>
+ <string name="camplight">CampLight Ltd.</string>
+ <string name="camplight_url">http://camplight.net</string>
<!-- alert content -->
+ <string name="unregistered_barcode_title">Unregistered Barcode</string>
<string name="unregistered_barcode_new_product">This Barcode is not registered.\nRegister a new product?</string>
<!-- GSA Dialog Text -->
@@ -94,4 +98,5 @@
<string name="loading">Loading</string>
<string name="saving">Saving</string>
<string name="deleting">Deleting</string>
+
</resources>
@@ -2,7 +2,12 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.net.Socket;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.KeyStore;
@@ -121,14 +126,16 @@ public void setup(String server, int port, String apiKey) {
// Set up the Getter with the API token and proper URL
private HttpGet getGetter(String targetURL) {
- HttpGet getter = new HttpGet(baseURL() + targetURL);
+ HttpGet getter = new HttpGet(baseURL() + targetURL);
getter.addHeader("X-Spree-Token", this.apiKey);
return getter;
}
// Process the Getter and handle response exceptions
public HttpResponse getResponse(HttpGet getter) {
+ if (getter == null)
+ return null;
try {
HttpResponse response = client.execute(getter);
@@ -183,6 +190,9 @@ public JSONObject getJSONObject(String targetURL) {
JSONObject data = new JSONObject();
HttpResponse response = this.getResponse(getGetter(targetURL));
+
+ if (response == null)
+ return null;
HttpEntity entity = response.getEntity();
String content;
@@ -2,10 +2,13 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLEncoder;
import java.util.ArrayList;
+import org.apache.http.client.methods.HttpGet;
import org.genshin.gsa.Dialogs;
import org.genshin.spree.SpreeConnector;
import org.genshin.warehouse.R;
@@ -41,6 +44,9 @@ public Products(Context ctx, SpreeConnector spree) {
private ArrayList<Product> processProductContainer(JSONObject productContainer) {
ArrayList<Product> collection = new ArrayList<Product>();
+ if (productContainer == null)
+ return null;
+
//Pick apart JSON object
try {
this.count = productContainer.getInt("count");
@@ -105,7 +111,14 @@ public void clear() {
Dialogs.showSearching(ctx);
ArrayList<Product> collection = new ArrayList<Product>();
- JSONObject productContainer = spree.connector.getJSONObject("api/products/search.json?q[name_cont]=" + query);
+ String escapedQuery = query;
+ try {
+ escapedQuery = URLEncoder.encode(query, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ // WTF unsupported encoding? fine, just take it raw
+ escapedQuery = query;
+ }
+ JSONObject productContainer = spree.connector.getJSONObject("api/products/search.json?q[name_cont]=" + escapedQuery);
collection = processProductContainer(productContainer);
Dialogs.dismiss();
@@ -117,7 +130,7 @@ public void unregisteredBarcode(final String code) {
AlertDialog.Builder question = new AlertDialog.Builder(ctx);
question.setMessage(ctx.getString(R.string.unregistered_barcode_new_product));
- question.setTitle("タイトル");
+ question.setTitle(ctx.getString(R.string.unregistered_barcode_title));
question.setIcon(R.drawable.newproduct);
question.setPositiveButton(ctx.getString(R.string.register_to_new_product), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
@@ -13,6 +13,7 @@
private Button genshinButton;
private Button freeStyleButton;
private Button pixtureButton;
+ private Button camplightButton;
@Override
@@ -41,6 +42,13 @@ public void onClick(View v) {
}
});
+ camplightButton = (Button) findViewById(R.id.camplight_link_button);
+ camplightButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ openLink("http://camplight.net");
+ }
+ });
+
}
private void openLink(String url) {

0 comments on commit 66c5f5a

Please sign in to comment.