Skip to content

Commit

Permalink
changed link to systembolaget to link to their inventory mobile frien…
Browse files Browse the repository at this point in the history
…dly page instead
  • Loading branch information
johannilsson committed Jun 19, 2010
1 parent 3f32b0e commit 660a953
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 7 deletions.
54 changes: 54 additions & 0 deletions res/values/arrays.xml
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>

<resources>

<string-array name="sb_county_names">
<item>Hela landet</item>
<item>Blekinge län</item>
<item>Dalarnas län</item>
<item>Gotlands län</item>
<item>Gävleborgs län</item>
<item>Hallands län</item>
<item>Jämtlands län</item>
<item>Jönköpings län</item>
<item>Kalmar län</item>
<item>Kronobergs län</item>
<item>Norrbottens län</item>
<item>Skåne län</item>
<item>Stockholms län</item>
<item>Södermanlands län</item>
<item>Uppsala län</item>
<item>Värmlands län</item>
<item>Västerbottens län</item>
<item>Västernorrlands län</item>
<item>Västmanlands län</item>
<item>Västra Götalands län</item>
<item>Örebro län</item>
<item>Östergötlands län</item>
</string-array>

<string-array name="sb_county_ids">
<item>0</item>
<item>10</item>
<item>20</item>
<item>09</item>
<item>21</item>
<item>13</item>
<item>23</item>
<item>06</item>
<item>08</item>
<item>07</item>
<item>25</item>
<item>12</item>
<item>01</item>
<item>04</item>
<item>03</item>
<item>17</item>
<item>24</item>
<item>22</item>
<item>19</item>
<item>14</item>
<item>18</item>
<item>05</item>
</string-array>
</resources>
8 changes: 8 additions & 0 deletions res/xml/preferences.xml
Expand Up @@ -26,6 +26,14 @@
android:title="@string/clear_search_history_preference"
android:summary="@string/clear_search_history_summary_preference"
/>
<ListPreference
android:title="Län"
android:summary="Förvalt län för koll av lagersaldo."
android:key="sb_search_county"
android:entries="@array/sb_county_names"
android:entryValues="@array/sb_county_ids"
android:defaultValue="0"
/>
</PreferenceCategory>

</PreferenceScreen>
27 changes: 20 additions & 7 deletions src/com/markupartist/iglaset/activity/DrinkDetailActivity.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 660a953

Please sign in to comment.