From 660a95384bec03ad0025a8d97ddf83c2ae3a567d Mon Sep 17 00:00:00 2001 From: Johan Nilsson Date: Sat, 19 Jun 2010 13:25:18 +0200 Subject: [PATCH] changed link to systembolaget to link to their inventory mobile friendly page instead --- res/values/arrays.xml | 54 +++++++++++++++++++ res/xml/preferences.xml | 8 +++ .../iglaset/activity/DrinkDetailActivity.java | 27 +++++++--- 3 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 res/values/arrays.xml diff --git a/res/values/arrays.xml b/res/values/arrays.xml new file mode 100644 index 0000000..22a5ea7 --- /dev/null +++ b/res/values/arrays.xml @@ -0,0 +1,54 @@ + + + + + + Hela landet + Blekinge län + Dalarnas län + Gotlands län + Gävleborgs län + Hallands län + Jämtlands län + Jönköpings län + Kalmar län + Kronobergs län + Norrbottens län + Skåne län + Stockholms län + Södermanlands län + Uppsala län + Värmlands län + Västerbottens län + Västernorrlands län + Västmanlands län + Västra Götalands län + Örebro län + Östergötlands län + + + + 0 + 10 + 20 + 09 + 21 + 13 + 23 + 06 + 08 + 07 + 25 + 12 + 01 + 04 + 03 + 17 + 24 + 22 + 19 + 14 + 18 + 05 + + diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 3f2820f..e3e5f21 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -26,6 +26,14 @@ android:title="@string/clear_search_history_preference" android:summary="@string/clear_search_history_summary_preference" /> + diff --git a/src/com/markupartist/iglaset/activity/DrinkDetailActivity.java b/src/com/markupartist/iglaset/activity/DrinkDetailActivity.java index 8ca71d0..b44826c 100644 --- a/src/com/markupartist/iglaset/activity/DrinkDetailActivity.java +++ b/src/com/markupartist/iglaset/activity/DrinkDetailActivity.java @@ -8,18 +8,21 @@ import java.util.Map; import java.util.Set; +import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.ListActivity; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.SharedPreferences; import android.content.DialogInterface.OnClickListener; import android.graphics.Paint; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; +import android.preference.PreferenceManager; import android.text.Editable; import android.text.TextWatcher; import android.text.format.Time; @@ -401,12 +404,7 @@ protected void onListItemClick(ListView l, View v, int position, long id) { if (item instanceof Volume) { Volume volume = (Volume) item; - if (!volume.isRetired()) { - Intent browserIntent = new Intent(Intent.ACTION_VIEW, - Uri.parse("http://systembolaget.se/SokDrycker/Produkt?VaruNr=" - + volume.getArticleId())); - startActivity(browserIntent); - } + startActivity(createInventoryIntent(volume)); } else if (section.adapter instanceof UserRatingAdapter) { tryShowAuthenticatedDialog(DIALOG_RATE); } else if (section.adapter instanceof DrinkDescriptionAdapter) { @@ -809,7 +807,22 @@ private void cancelGetDrinkTask() { mGetDrinkTask = null; } } - + + private Intent createInventoryIntent(Volume volume) { + SharedPreferences sharedPreferences = PreferenceManager + .getDefaultSharedPreferences(getApplicationContext()); + String county = sharedPreferences + .getString("sb_search_county", "0"); + + Uri uri = Uri.parse(String.format( + "http://mobil.systembolaget.se/SokDryck/SokDryck.aspx?artnr=%s&lan=%s", + String.valueOf(volume.getArticleId()), county)); + + Intent intent = new Intent(Intent.ACTION_VIEW, uri); + + return intent; + } + /** * Background task for fetching a drink. */