From 72ccd948f28c90074b17a0fd7061a1d8f9917297 Mon Sep 17 00:00:00 2001 From: lado Date: Sun, 22 Jan 2012 15:21:28 +0100 Subject: added omdb.org --- .../de/bjusystems/vdrmanager/data/Preferences.java | 15 ++++++ .../vdrmanager/gui/EpgDetailsActivity.java | 55 ++++++++++++++++------ 2 files changed, 55 insertions(+), 15 deletions(-) (limited to 'vdrmanager/src') diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java index ea3cfa2..8cc6a39 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java @@ -10,6 +10,7 @@ import android.content.res.Configuration; import android.text.TextUtils; import android.widget.Toast; import de.bjusystems.vdrmanager.R; +import de.bjusystems.vdrmanager.app.Intents; import de.bjusystems.vdrmanager.data.db.OrmDatabaseHelper; import de.bjusystems.vdrmanager.gui.VdrListActivity; @@ -66,6 +67,15 @@ public class Preferences { */ private boolean showImdbButton = true; + /** + * Show OMDB button in epg details + */ + private boolean showOmdbButton = true; + + public boolean isShowOmdbButton() { + return showOmdbButton; + } + /** * On Which imdb site to search? */ @@ -443,6 +453,10 @@ public class Preferences { prefs.showImdbButton = getBoolean(context, R.string.qui_show_imdb_button_key, true); + prefs.showOmdbButton = getBoolean(context, + R.string.qui_show_omdb_button_key, true); + + prefs.imdbUrl = getString(context, R.string.qui_imdb_url_key, "imdb.de"); thePrefs = prefs; @@ -504,6 +518,7 @@ public class Preferences { Intent intent = new Intent(); intent.setClass(context, VdrListActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.putExtra(Intents.EMPTY_CONFIG, Boolean.TRUE); context.startActivity(intent); Toast.makeText(context, R.string.no_vdr, Toast.LENGTH_SHORT).show(); } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java index 7843844..1b03a97 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java @@ -57,7 +57,13 @@ public class EpgDetailsActivity extends ICSBaseActivity implements OnClickListen public static String IMDB_URL = "http://%s/find?s=all&q=%s"; + public static String OMDB_URL = "http://www.omdb.org/search?search[text]=%s"; + private static final String IMDB_URL_ENCODING = "ISO-8859-1"; + + private static final String OMDB_URL_ENCODING = "UTF-8"; + + private String highlight = null; @@ -308,25 +314,29 @@ public class EpgDetailsActivity extends ICSBaseActivity implements OnClickListen b.setOnClickListener(new OnClickListener() { public void onClick(View v) { - final TextView title = (TextView) view - .findViewById(R.id.epg_detail_title); - String url = String.format(IMDB_URL, Preferences.get() - .getImdbUrl(), encode(String.valueOf(title.getText()), IMDB_URL_ENCODING)); - //url = encode(url, "utf-8"); - Intent i = new Intent(Intent.ACTION_VIEW); - i.setData(Uri.parse(url)); - i.addCategory(Intent.CATEGORY_BROWSABLE); - try{ - startActivity(i); - }catch(ActivityNotFoundException anfe){ - Log.w(TAG, anfe); - say(anfe.getLocalizedMessage()); - } + startFilmDatabaseBrowseIntent(String.format(IMDB_URL, Preferences.get().getImdbUrl()), view, IMDB_URL_ENCODING); } }); - // setThisAsOnClickListener(b); } + + b = view.findViewById(R.id.epg_event_omdb); + + if (Preferences.get().isShowOmdbButton() == false) { + b.setVisibility(View.GONE); + } else { + b.setVisibility(View.VISIBLE); + b.setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + startFilmDatabaseBrowseIntent(OMDB_URL, view, OMDB_URL_ENCODING); + } + }); + } + + + + b = view.findViewById(R.id.epg_event_livetv); if (Utils.isLive(event) == false) { b.setVisibility(View.GONE); @@ -345,6 +355,21 @@ public class EpgDetailsActivity extends ICSBaseActivity implements OnClickListen } } + + private void startFilmDatabaseBrowseIntent(String url, View view, String encoding){ + final TextView title = (TextView) view + .findViewById(R.id.epg_detail_title); + url = String.format(url, encode(String.valueOf(title.getText()), encoding)); + Intent i = new Intent(Intent.ACTION_VIEW); + i.setData(Uri.parse(url)); + i.addCategory(Intent.CATEGORY_BROWSABLE); + try{ + startActivity(i); + }catch(ActivityNotFoundException anfe){ + Log.w(TAG, anfe); + say(anfe.getLocalizedMessage()); + } + } private void setThisAsOnClickListener(View v) { if (v != null) { -- cgit v1.2.3