Skip to content

Commit

Permalink
Added a "Level Editor" menu entry (a patch from Rudolf Halmi).
Browse files Browse the repository at this point in the history
  • Loading branch information
pfedor committed Dec 15, 2009
1 parent 62fa35d commit fc1841d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.jfedor.frozenbubble"
android:versionCode="5"
android:versionName="1.4">
android:versionCode="6"
android:versionName="1.5">
<uses-sdk android:minSdkVersion="2" />
<application android:label="@string/app_name"
android:icon="@drawable/app_frozen_bubble">
Expand Down
3 changes: 3 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
<string name="menu_about">About Frozen Bubble</string>
<string name="menu_dont_rush_me">Don't Rush Me</string>
<string name="menu_rush_me">Rush Me</string>
<string name="menu_editor">Level Editor</string>
<string name="install_editor">Redirecting you to the Market to download the Frozen Bubble Level Editor...</string>
<string name="market_missing">Cannot find Android Market! Please install Frozen Bubble Level Editor manually.</string>
</resources>
34 changes: 33 additions & 1 deletion src/org/jfedor/frozenbubble/FrozenBubble.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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";

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
}
}
}
}

0 comments on commit fc1841d

Please sign in to comment.