Moved All menus to XML
Change-Id: I97a891d2da149aa107a1617a3a4afdfbe861ce08 Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
13
ExaltedDice/res/menu/dice_roller_menu.xml
Normal file
13
ExaltedDice/res/menu/dice_roller_menu.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_clear"
|
||||||
|
android:icon="@android:drawable/ic_menu_close_clear_cancel"
|
||||||
|
android:showAsAction="ifRoom|withText"
|
||||||
|
android:title="@string/clear_history"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_settings"
|
||||||
|
android:icon="@android:drawable/ic_menu_preferences"
|
||||||
|
android:showAsAction="ifRoom|withText"
|
||||||
|
android:title="@string/settings"/>
|
||||||
|
</menu>
|
||||||
8
ExaltedDice/res/menu/game_list_context_menu.xml
Normal file
8
ExaltedDice/res/menu/game_list_context_menu.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_delete"
|
||||||
|
android:icon="@android:drawable/ic_menu_delete"
|
||||||
|
android:title="@string/delete"/>
|
||||||
|
|
||||||
|
</menu>
|
||||||
10
ExaltedDice/res/menu/game_list_menu.xml
Normal file
10
ExaltedDice/res/menu/game_list_menu.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
|
||||||
|
<!-- <item -->
|
||||||
|
<!-- android:id="@+id/menu_settings" -->
|
||||||
|
<!-- android:icon="@android:drawable/ic_menu_preferences" -->
|
||||||
|
<!-- android:showAsAction="ifRoom|withText" -->
|
||||||
|
<!-- android:title="@string/settings"/> -->
|
||||||
|
|
||||||
|
|
||||||
|
</menu>
|
||||||
@@ -17,6 +17,7 @@ import android.util.Log;
|
|||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@@ -37,10 +38,7 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
public static final String KEY_GAME_ID = "game_id";
|
public static final String KEY_GAME_ID = "game_id";
|
||||||
|
|
||||||
private static final String TAG = "ExaltedDice";
|
private static final String TAG = "ExaltedDice";
|
||||||
private static final int MENU_QUIT = Menu.FIRST;
|
|
||||||
private static final int MENU_CLEAR = Menu.FIRST + 1;
|
|
||||||
private static final int DELETE = 0;
|
private static final int DELETE = 0;
|
||||||
private static final int SETTINGS = Menu.FIRST + 2;
|
|
||||||
|
|
||||||
private String[] mDiceValues;
|
private String[] mDiceValues;
|
||||||
private ListView mListView;
|
private ListView mListView;
|
||||||
@@ -224,9 +222,8 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
* @author WWPowers 3-27-2010
|
* @author WWPowers 3-27-2010
|
||||||
*/
|
*/
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
menu.add(1, MENU_CLEAR, 0, R.string.clear_history).setIcon(android.R.drawable.ic_menu_close_clear_cancel);
|
MenuInflater inflater = getMenuInflater();
|
||||||
menu.add(1, SETTINGS, 0, R.string.settings).setIcon(android.R.drawable.ic_menu_preferences);;
|
inflater.inflate(R.menu.dice_roller_menu, menu);
|
||||||
menu.add(1, MENU_QUIT, 0, R.string.quit).setIcon(android.R.drawable.ic_menu_revert);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,13 +285,10 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
Intent intent = new Intent(this, GameListActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
Intent intent = new Intent(this, GameListActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
case MENU_QUIT:
|
case R.id.menu_clear:
|
||||||
quitDialog();
|
|
||||||
return true;
|
|
||||||
case MENU_CLEAR:
|
|
||||||
mDb.clearHistory(mGameId);
|
mDb.clearHistory(mGameId);
|
||||||
return true;
|
return true;
|
||||||
case SETTINGS:
|
case R.id.menu_settings:
|
||||||
startActivity(new Intent(this, Settings.class).putExtras(getIntent().getExtras()));
|
startActivity(new Intent(this, Settings.class).putExtras(getIntent().getExtras()));
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import android.os.Bundle;
|
|||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@@ -28,7 +29,6 @@ import android.widget.ListView;
|
|||||||
*/
|
*/
|
||||||
public class GameListActivity extends Activity implements OnClickListener, DatabaseListener, OnItemClickListener {
|
public class GameListActivity extends Activity implements OnClickListener, DatabaseListener, OnItemClickListener {
|
||||||
|
|
||||||
private static final int DELETE = 0;
|
|
||||||
private ListView mList;
|
private ListView mList;
|
||||||
private Database mDb;
|
private Database mDb;
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public class GameListActivity extends Activity implements OnClickListener, Datab
|
|||||||
public boolean onContextItemSelected(MenuItem item) {
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
|
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
|
||||||
switch(item.getItemId()){
|
switch(item.getItemId()){
|
||||||
case DELETE:
|
case R.id.menu_delete:
|
||||||
mDb.deleteGame(info.id+1);
|
mDb.deleteGame(info.id+1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -73,14 +73,22 @@ public class GameListActivity extends Activity implements OnClickListener, Datab
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||||
/*
|
MenuInflater inflater = getMenuInflater();
|
||||||
* TODO
|
inflater.inflate(R.menu.game_list_context_menu, menu);
|
||||||
* rename game
|
|
||||||
*/
|
|
||||||
menu.add(0, DELETE, Menu.FIRST, R.string.delete);
|
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see android.app.Activity#onCreateOptionsMenu(android.view.Menu)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.game_list_menu, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDatabaseInsertComplete() {
|
public void onDatabaseInsertComplete() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
@@ -111,6 +119,21 @@ public class GameListActivity extends Activity implements OnClickListener, Datab
|
|||||||
.putExtra(ExaltedDice.KEY_GAME_MODE, mDb.getGameOptions(id+1).getAsString(Database.KEY_MODE)));
|
.putExtra(ExaltedDice.KEY_GAME_MODE, mDb.getGameOptions(id+1).getAsString(Database.KEY_MODE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch(item.getItemId()){
|
||||||
|
case R.id.menu_settings:
|
||||||
|
startActivity(new Intent(this, Settings.class));
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see android.app.Activity#onPause()
|
* @see android.app.Activity#onPause()
|
||||||
|
|||||||
Reference in New Issue
Block a user