From fc1841db371214033ebba5c8e13bdcfd3395218b Mon Sep 17 00:00:00 2001 From: pfedor Date: Tue, 15 Dec 2009 17:15:01 +0000 Subject: [PATCH] Added a "Level Editor" menu entry (a patch from Rudolf Halmi). --- AndroidManifest.xml | 4 +-- res/values/strings.xml | 3 ++ src/org/jfedor/frozenbubble/FrozenBubble.java | 34 ++++++++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 3fe3ed3..5ae8f91 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="6" + android:versionName="1.5"> diff --git a/res/values/strings.xml b/res/values/strings.xml index 815c542..057b457 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -11,4 +11,7 @@ About Frozen Bubble Don't Rush Me Rush Me + Level Editor + Redirecting you to the Market to download the Frozen Bubble Level Editor... + Cannot find Android Market! Please install Frozen Bubble Level Editor manually. diff --git a/src/org/jfedor/frozenbubble/FrozenBubble.java b/src/org/jfedor/frozenbubble/FrozenBubble.java index fc51b97..9eb2128 100644 --- a/src/org/jfedor/frozenbubble/FrozenBubble.java +++ b/src/org/jfedor/frozenbubble/FrozenBubble.java @@ -67,14 +67,17 @@ package org.jfedor.frozenbubble; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.net.Uri; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.Window; import android.view.WindowManager; +import android.widget.Toast; import android.util.Log; @@ -107,6 +110,7 @@ public class FrozenBubble extends Activity public final static int MENU_RUSH_ME = 8; public final static int MENU_NEW_GAME = 9; public final static int MENU_ABOUT = 10; + public final static int MENU_EDITOR = 11; public final static String PREFS_NAME = "frozenbubble"; @@ -136,8 +140,9 @@ public boolean onCreateOptionsMenu(Menu menu) menu.add(0, MENU_SOUND_OFF, 0, R.string.menu_sound_off); menu.add(0, MENU_DONT_RUSH_ME, 0, R.string.menu_dont_rush_me); menu.add(0, MENU_RUSH_ME, 0, R.string.menu_rush_me); - menu.add(0, MENU_NEW_GAME, 0, R.string.menu_new_game); menu.add(0, MENU_ABOUT, 0, R.string.menu_about); + menu.add(0, MENU_NEW_GAME, 0, R.string.menu_new_game); + menu.add(0, MENU_EDITOR, 0, R.string.menu_editor); return true; } @@ -194,6 +199,9 @@ public boolean onOptionsItemSelected(MenuItem item) case MENU_RUSH_ME: setDontRushMe(false); return true; + case MENU_EDITOR: + startEditor(); + return true; } return false; } @@ -372,4 +380,28 @@ protected void onNewIntent(Intent intent) { } } } + + // Starts editor / market with editor's download. + private void startEditor() + { + Intent i = new Intent(); + i.setClassName("sk.halmi.fbedit", "sk.halmi.fbedit.EditorActivity"); + try { + startActivity(i); + finish(); + } catch (ActivityNotFoundException e) { + // But if user doesn't have Frozen Bubble Editor take him to market. + try { + Toast.makeText(getApplicationContext(), R.string.install_editor, 1000). + show(); + i = new Intent(Intent.ACTION_VIEW, + Uri.parse("market://search?q=pname:sk.halmi.fbedit")); + startActivity(i); + } catch (Exception ex) { + // Damn you don't have market? + Toast.makeText(getApplicationContext(), R.string.market_missing, 1000). + show(); + } + } + } }