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"
|
android:installLocation="auto"
|
||||||
package="com.TwentyCode.android.ExaltedDice"
|
package="com.TwentyCode.android.ExaltedDice"
|
||||||
android:versionCode="15"
|
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
|
<application
|
||||||
android:icon="@drawable/icon"
|
android:icon="@drawable/icon"
|
||||||
@@ -37,10 +39,6 @@
|
|||||||
</activity>
|
</activity>
|
||||||
</application>
|
</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" -->
|
</manifest> <!-- android:screenOrientation="portrait" -->
|
||||||
|
|||||||
@@ -20,13 +20,26 @@
|
|||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
layout="@layout/dice_selector" />
|
layout="@layout/dice_selector" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_below="@id/die_selector"
|
||||||
|
android:layout_marginTop="10dip" >
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/roll_button"
|
android:id="@+id/roll_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@id/die_selector"
|
|
||||||
android:layout_marginTop="10dip"
|
|
||||||
android:text="@string/roll" />
|
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>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
android:baselineAligned="false"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
@@ -26,12 +27,25 @@
|
|||||||
layout="@layout/dice_selector" />
|
layout="@layout/dice_selector" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<Button
|
<RelativeLayout
|
||||||
android:id="@+id/roll_button"
|
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1" >
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/roll_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
android:text="@string/roll" />
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<item>-3</item>
|
<item>-3</item>
|
||||||
<item>-2</item>
|
<item>-2</item>
|
||||||
<item>-1</item>
|
<item>-1</item>
|
||||||
<item>0</item>
|
<item>+0</item>
|
||||||
<item>+1</item>
|
<item>+1</item>
|
||||||
<item>+2</item>
|
<item>+2</item>
|
||||||
<item>+3</item>
|
<item>+3</item>
|
||||||
|
|||||||
@@ -554,6 +554,9 @@ public class Database {
|
|||||||
* update the game table
|
* update the game table
|
||||||
*/
|
*/
|
||||||
mDb.update(GAME_NAME_TABLE, game, "id" + "= "+ id, null);
|
mDb.update(GAME_NAME_TABLE, game, "id" + "= "+ id, null);
|
||||||
|
|
||||||
|
if(mListener != null)
|
||||||
|
mListener.onDatabaseInsertComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,4 +37,10 @@ public interface DatabaseListener {
|
|||||||
*/
|
*/
|
||||||
public void onDatabaseUpgrade();
|
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.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.NumberPicker;
|
import android.widget.NumberPicker;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.TwentyCodes.android.exception.ExceptionHandler;
|
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_QUIT = Menu.FIRST;
|
||||||
private static final int MENU_CLEAR = Menu.FIRST + 1;
|
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 SharedPreferences mSettings;
|
||||||
private String[] mModValues;
|
private String[] mModValues;
|
||||||
private NumberPicker mModPicker;
|
private NumberPicker mModPicker;
|
||||||
|
private ProgressBar mRollProgress;
|
||||||
|
private View mRollButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the presets from the provided roll
|
* Applies the presets from the provided roll
|
||||||
@@ -160,7 +163,10 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
mModPicker.setDisplayedValues(mModValues);
|
mModPicker.setDisplayedValues(mModValues);
|
||||||
mModPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
|
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
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
mDb = new Database(this);
|
mDb = new Database(this, this);
|
||||||
mListAdapter = new RollHistoryDatabaseAdapter(mGameId, mDb, this);
|
mListAdapter = new RollHistoryDatabaseAdapter(mGameId, mDb, this);
|
||||||
mListView.setAdapter(mListAdapter);
|
mListView.setAdapter(mListAdapter);
|
||||||
super.onStart();
|
super.onStart();
|
||||||
@@ -377,6 +383,12 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public void rollDice() {
|
public void rollDice() {
|
||||||
|
mRollButton.setEnabled(false);
|
||||||
|
mRollProgress.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
new Thread( new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run(){
|
||||||
// vibrate for 50 milliseconds
|
// vibrate for 50 milliseconds
|
||||||
vibrate(50);
|
vibrate(50);
|
||||||
|
|
||||||
@@ -390,8 +402,8 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
roll.put(Database.KEY_MOD, DatabaseUtils.sqlEscapeString(mModValues[mModPicker.getValue()]));
|
roll.put(Database.KEY_MOD, DatabaseUtils.sqlEscapeString(mModValues[mModPicker.getValue()]));
|
||||||
|
|
||||||
mDb.updateGame(mGameId, mGameName, roll, rollId);
|
mDb.updateGame(mGameId, mGameName, roll, rollId);
|
||||||
|
}
|
||||||
refresh();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -452,4 +464,38 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
Vibrator vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
Vibrator vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
vib.vibrate(milliseconds);
|
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);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDatabaseInsertComplete() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDatabaseUpgrade() {
|
public void onDatabaseUpgrade() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|||||||
Reference in New Issue
Block a user