Updated UI
Added a progress bar (indeterminate circle) centered over the roll button. It is shown only during rolls. Moved rolling to another thread Roll Button is disabled during a roll Change-Id: I6a6bfb9723af3b1292eb3df2f8810fb738f83876 Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
android:installLocation="auto"
|
||||
package="com.TwentyCode.android.ExaltedDice"
|
||||
android:versionCode="15"
|
||||
android:versionName="1.0.1" >
|
||||
android:versionName="1.0.1" ><uses-sdk android:minSdkVersion="4" /><uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_LOGS" />
|
||||
|
||||
<application
|
||||
android:icon="@drawable/icon"
|
||||
@@ -37,10 +39,6 @@
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="4" />
|
||||
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_LOGS" />
|
||||
|
||||
</manifest> <!-- android:screenOrientation="portrait" -->
|
||||
|
||||
@@ -20,13 +20,26 @@
|
||||
android:layout_centerHorizontal="true"
|
||||
layout="@layout/dice_selector" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/roll_button"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/die_selector"
|
||||
android:layout_marginTop="10dip"
|
||||
android:text="@string/roll" />
|
||||
android:layout_marginTop="10dip" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/roll_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/roll" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/roll_progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<RelativeLayout
|
||||
@@ -26,12 +27,25 @@
|
||||
layout="@layout/dice_selector" />
|
||||
</RelativeLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/roll_button"
|
||||
<RelativeLayout
|
||||
android:layout_width="0px"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/roll" />
|
||||
android:layout_weight="1" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/roll_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/roll" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/roll_progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<item>-3</item>
|
||||
<item>-2</item>
|
||||
<item>-1</item>
|
||||
<item>0</item>
|
||||
<item>+0</item>
|
||||
<item>+1</item>
|
||||
<item>+2</item>
|
||||
<item>+3</item>
|
||||
|
||||
@@ -554,6 +554,9 @@ public class Database {
|
||||
* update the game table
|
||||
*/
|
||||
mDb.update(GAME_NAME_TABLE, game, "id" + "= "+ id, null);
|
||||
|
||||
if(mListener != null)
|
||||
mListener.onDatabaseInsertComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,5 +36,11 @@ public interface DatabaseListener {
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public void onDatabaseUpgrade();
|
||||
|
||||
/**
|
||||
* Called when information has been inserted into the database
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public void onDatabaseInsertComplete();
|
||||
|
||||
}
|
||||
@@ -25,11 +25,12 @@ import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.NumberPicker;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.TwentyCodes.android.exception.ExceptionHandler;
|
||||
|
||||
public class ExaltedDice extends Activity implements OnClickListener, OnItemClickListener {
|
||||
public class ExaltedDice extends Activity implements OnClickListener, OnItemClickListener, DatabaseListener {
|
||||
|
||||
private static final int MENU_QUIT = Menu.FIRST;
|
||||
private static final int MENU_CLEAR = Menu.FIRST + 1;
|
||||
@@ -50,6 +51,8 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
private SharedPreferences mSettings;
|
||||
private String[] mModValues;
|
||||
private NumberPicker mModPicker;
|
||||
private ProgressBar mRollProgress;
|
||||
private View mRollButton;
|
||||
|
||||
/**
|
||||
* Applies the presets from the provided roll
|
||||
@@ -160,7 +163,10 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
mModPicker.setDisplayedValues(mModValues);
|
||||
mModPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
|
||||
|
||||
findViewById(R.id.roll_button).setOnClickListener(this);
|
||||
mRollProgress = (ProgressBar) findViewById(R.id.roll_progress);
|
||||
|
||||
mRollButton = findViewById(R.id.roll_button);
|
||||
mRollButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,7 +267,7 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
*/
|
||||
@Override
|
||||
protected void onStart() {
|
||||
mDb = new Database(this);
|
||||
mDb = new Database(this, this);
|
||||
mListAdapter = new RollHistoryDatabaseAdapter(mGameId, mDb, this);
|
||||
mListView.setAdapter(mListAdapter);
|
||||
super.onStart();
|
||||
@@ -377,21 +383,27 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public void rollDice() {
|
||||
// vibrate for 50 milliseconds
|
||||
vibrate(50);
|
||||
mRollButton.setEnabled(false);
|
||||
mRollProgress.setVisibility(View.VISIBLE);
|
||||
|
||||
int rollId = mDb.getGameRollCount(mGameId) +1;
|
||||
|
||||
ContentValues roll = new ContentValues();
|
||||
roll.put(Database.KEY_D_TYPE, mDiceValues[mDPicker.getValue()]);
|
||||
roll.put(Database.KEY_NUMBER, mNumberPicker.getValue());
|
||||
roll.putAll(results(mNumberPicker.getValue()));
|
||||
|
||||
roll.put(Database.KEY_MOD, DatabaseUtils.sqlEscapeString(mModValues[mModPicker.getValue()]));
|
||||
|
||||
mDb.updateGame(mGameId, mGameName, roll, rollId);
|
||||
|
||||
refresh();
|
||||
new Thread( new Runnable() {
|
||||
@Override
|
||||
public void run(){
|
||||
// vibrate for 50 milliseconds
|
||||
vibrate(50);
|
||||
|
||||
int rollId = mDb.getGameRollCount(mGameId) +1;
|
||||
|
||||
ContentValues roll = new ContentValues();
|
||||
roll.put(Database.KEY_D_TYPE, mDiceValues[mDPicker.getValue()]);
|
||||
roll.put(Database.KEY_NUMBER, mNumberPicker.getValue());
|
||||
roll.putAll(results(mNumberPicker.getValue()));
|
||||
|
||||
roll.put(Database.KEY_MOD, DatabaseUtils.sqlEscapeString(mModValues[mModPicker.getValue()]));
|
||||
|
||||
mDb.updateGame(mGameId, mGameName, roll, rollId);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -452,4 +464,38 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
Vibrator vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||
vib.vibrate(milliseconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDatabaseUpgradeComplete() {
|
||||
// do nothing
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeletionComplete() {
|
||||
// do nothing
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestoreComplete() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDatabaseUpgrade() {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDatabaseInsertComplete() {
|
||||
this.runOnUiThread(new Runnable(){
|
||||
@Override
|
||||
public void run(){
|
||||
mRollProgress.setVisibility(View.GONE);
|
||||
mRollButton.setEnabled(true);
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,12 @@ public class GameListActivity extends Activity implements OnClickListener, Datab
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDatabaseInsertComplete() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDatabaseUpgrade() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Reference in New Issue
Block a user