Skip to content

Commit

Permalink
Resolving errors due to revert, increasing app number
Browse files Browse the repository at this point in the history
  • Loading branch information
autoreleasefool committed Oct 13, 2015
1 parent ec2c574 commit dca7f1c
Show file tree
Hide file tree
Showing 13 changed files with 203 additions and 221 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'
def versionMajor = 2
def versionMinor = 1
def versionPatch = 2
def versionPatch = 3

android {
compileSdkVersion 23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ public final class Constants {
public static final byte MAX_NUMBER_EVENT_GAMES = 20;
/** Maximum number of games in a league. */
public static final byte MAX_NUMBER_LEAGUE_GAMES = 5;
/** The number of balls in a frame. */
public static final byte NUMBER_OF_BALLS = 3;
/** The number of pins to be used in a game. */
public static final byte NUMBER_OF_PINS = 5;
/** The value of a strike in a game. */
public static final byte STRIKE_VALUE = 15;
/** The value of a foul in a game. */
public static final byte FOUL_VALUE = 15;

//SCORING VALUES
/** Symbol representing a strike. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
import ca.josephroque.bowlingcompanion.fragment.StatsListFragment;
import ca.josephroque.bowlingcompanion.theme.Theme;
import ca.josephroque.bowlingcompanion.utilities.AppRater;
import ca.josephroque.bowlingcompanion.utilities.DataFormatter;
import ca.josephroque.bowlingcompanion.utilities.DateUtils;
import ca.josephroque.bowlingcompanion.utilities.DisplayUtils;
import ca.josephroque.bowlingcompanion.utilities.EmailUtils;
import ca.josephroque.bowlingcompanion.utilities.FloatingActionButtonHandler;
Expand Down Expand Up @@ -1289,7 +1289,7 @@ protected Object[] doInBackground(Void... params) {
}

mainActivity.mSeriesId = seriesId;
mainActivity.mSeriesDate = DataFormatter.formattedDateToPrettyCompact(seriesDate);
mainActivity.mSeriesDate = DateUtils.formattedDateToPrettyCompact(seriesDate);
return new Object[]{gameId, frameId};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import ca.josephroque.bowlingcompanion.Constants;
import ca.josephroque.bowlingcompanion.data.Series;
import ca.josephroque.bowlingcompanion.utilities.DataFormatter;
import ca.josephroque.bowlingcompanion.utilities.DateUtils;

/**
* Created by Joseph Roque on 15-03-29. Provides a dialog and callback interface {@link
Expand Down Expand Up @@ -43,7 +43,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
if (savedInstanceState == null) {
mSeries = getArguments().getParcelable(Constants.EXTRA_SERIES);
assert mSeries != null;
date = DataFormatter.prettyCompactToFormattedDate(mSeries.getSeriesDate());
date = DateUtils.prettyCompactToFormattedDate(mSeries.getSeriesDate());
date[0] -= 1; //Must subtract one because method returns 1-12 for month, need 0-11
} else {
mSeries = savedInstanceState.getParcelable(Constants.EXTRA_SERIES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,13 @@ public View onCreateView(LayoutInflater inflater,
*/

//Calculates most static view sizes beforehand so they don't have to be recalculated
final int dp128 = DataFormatter.getPixelsFromDP(screenDensity, 128);
final int dp120 = DataFormatter.getPixelsFromDP(screenDensity, 120);
final int dp88 = DataFormatter.getPixelsFromDP(screenDensity, 88);
final int dp40 = DataFormatter.getPixelsFromDP(screenDensity, 40);
final int dp41 = DataFormatter.getPixelsFromDP(screenDensity, 41);
final int dp20 = DataFormatter.getPixelsFromDP(screenDensity, 20);
final int dp36 = DataFormatter.getPixelsFromDP(screenDensity, 36);
final int dp128 = DisplayUtils.getPixelsFromDP(screenDensity, 128);
final int dp120 = DisplayUtils.getPixelsFromDP(screenDensity, 120);
final int dp88 = DisplayUtils.getPixelsFromDP(screenDensity, 88);
final int dp40 = DisplayUtils.getPixelsFromDP(screenDensity, 40);
final int dp41 = DisplayUtils.getPixelsFromDP(screenDensity, 41);
final int dp20 = DisplayUtils.getPixelsFromDP(screenDensity, 20);
final int dp36 = DisplayUtils.getPixelsFromDP(screenDensity, 36);
for (int i = 0; i < Constants.NUMBER_OF_FRAMES; i++) {
//TextView to display score of a frame
TextView frameText = new TextView(getActivity());
Expand Down Expand Up @@ -394,7 +394,7 @@ public View onCreateView(LayoutInflater inflater,
frameText.setOnClickListener(onClickListeners[LISTENER_TEXT_FRAMES]);

layoutParams = new RelativeLayout.LayoutParams(dp120, dp88);
layoutParams.leftMargin = DataFormatter.getPixelsFromDP(screenDensity, 120 * i);
layoutParams.leftMargin = DisplayUtils.getPixelsFromDP(screenDensity, 120 * i);
layoutParams.topMargin = dp40;
relativeLayout.addView(frameText, layoutParams);
mTextViewFrames[i] = frameText;
Expand All @@ -406,7 +406,7 @@ public View onCreateView(LayoutInflater inflater,
text.setBackgroundResource(R.drawable.background_frame_text);
text.setGravity(Gravity.CENTER);
layoutParams = new RelativeLayout.LayoutParams(dp40, dp41);
layoutParams.leftMargin = DataFormatter.getPixelsFromDP(screenDensity,
layoutParams.leftMargin = DisplayUtils.getPixelsFromDP(screenDensity,
120 * i + j * 40);
relativeLayout.addView(text, layoutParams);
mTextViewBallScores[i][j] = text;
Expand All @@ -417,7 +417,7 @@ public View onCreateView(LayoutInflater inflater,
text.setGravity(Gravity.CENTER);
text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
layoutParams = new RelativeLayout.LayoutParams(dp40, dp20);
layoutParams.leftMargin = DataFormatter.getPixelsFromDP(screenDensity,
layoutParams.leftMargin = DisplayUtils.getPixelsFromDP(screenDensity,
120 * i + j * 40);
layoutParams.topMargin = dp40;
relativeLayout.addView(text, layoutParams);
Expand All @@ -431,7 +431,7 @@ public View onCreateView(LayoutInflater inflater,
frameText.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
frameText.setTextColor(DisplayUtils.getColorResource(getResources(), android.R.color.white));
layoutParams = new RelativeLayout.LayoutParams(dp120, dp36);
layoutParams.leftMargin = DataFormatter.getPixelsFromDP(screenDensity, 120 * i);
layoutParams.leftMargin = DisplayUtils.getPixelsFromDP(screenDensity, 120 * i);
layoutParams.addRule(RelativeLayout.BELOW, mTextViewFrames[i].getId());
relativeLayout.addView(frameText, layoutParams);
}
Expand All @@ -445,7 +445,7 @@ public View onCreateView(LayoutInflater inflater,
mTextViewFinalScore.setTextAppearance(getActivity(), android.R.style.TextAppearance_Large);
mTextViewFinalScore.setBackgroundResource(R.drawable.background_frame_text);
layoutParams = new RelativeLayout.LayoutParams(dp120, dp128);
layoutParams.leftMargin = DataFormatter.getPixelsFromDP(screenDensity,
layoutParams.leftMargin = DisplayUtils.getPixelsFromDP(screenDensity,
Constants.NUMBER_OF_FRAMES * 120);
relativeLayout.addView(mTextViewFinalScore, layoutParams);
mHorizontalScrollViewFrames.addView(relativeLayout);
Expand Down Expand Up @@ -1306,18 +1306,18 @@ private void showBestPossibleScoreDialog() {

if (mCurrentFrame < Constants.LAST_FRAME) {
if (Arrays.equals(mPinState[mCurrentFrame][0], Constants.FRAME_PINS_DOWN)) {
int firstBallNextFrame = Score.getValueOfFrame(mPinState[mCurrentFrame + 1][0]);
int firstBallNextFrame = Score.getValueOfFrame(mPinState[mCurrentFrame + 1][0], true);
possibleScore -= firstBallNextFrame;
if (firstBallNextFrame == 15) {
if (mCurrentFrame < Constants.LAST_FRAME - 1)
possibleScore -= Score.getValueOfFrame(mPinState[mCurrentFrame + 2][0]);
possibleScore -= Score.getValueOfFrame(mPinState[mCurrentFrame + 2][0], true);
else
possibleScore -= Score.getValueOfFrame(mPinState[mCurrentFrame + 1][1]);
possibleScore -= Score.getValueOfFrame(mPinState[mCurrentFrame + 1][1], true);
} else
possibleScore -= Score.getValueOfFrameDifference(mPinState[mCurrentFrame][0],
mPinState[mCurrentFrame][1]);
} else if (Arrays.equals(mPinState[mCurrentFrame][1], Constants.FRAME_PINS_DOWN)) {
int firstBallNextFrame = Score.getValueOfFrame(mPinState[mCurrentFrame + 1][0]);
int firstBallNextFrame = Score.getValueOfFrame(mPinState[mCurrentFrame + 1][0], true);
possibleScore -= firstBallNextFrame;
}
} else {
Expand All @@ -1326,25 +1326,7 @@ private void showBestPossibleScoreDialog() {
mPinState[mCurrentFrame][i]);
}

int pinsLeftStanding = 0;
for (int i = 0; i < 5; i++) {
if (!mPinState[mCurrentFrame][mCurrentBall][i]) {
switch (i) {
case 0:
case 4:
pinsLeftStanding += 2;
break;
case 1:
case 3:
pinsLeftStanding += 3;
break;
case 2:
pinsLeftStanding += 5;
break;
default: //do nothing
}
}
}
int pinsLeftStanding = Score.getValueOfFrame(mPinState[mCurrentFrame][mCurrentBall], false);

boolean strikeLastFrame = false;
boolean strikeTwoFramesAgo = false;
Expand Down Expand Up @@ -1638,12 +1620,12 @@ public void run() {
for (byte b = 2; b >= 0; b--) {
switch (b) {
case 2:
frameScores[f] += Score.getValueOfFrame(mPinState[f][b]);
frameScores[f] += Score.getValueOfFrame(mPinState[f][b], true);
break;
case 1:
case 0:
if (Arrays.equals(mPinState[f][b], Constants.FRAME_PINS_DOWN)) {
frameScores[f] += Score.getValueOfFrame(mPinState[f][b]);
frameScores[f] += Score.getValueOfFrame(mPinState[f][b], true);
}
break;
default: //do nothing
Expand All @@ -1652,13 +1634,13 @@ public void run() {
} else {
for (byte b = 0; b < 3; b++) {
if (b < 2 && Arrays.equals(mPinState[f][b], Constants.FRAME_PINS_DOWN)) {
frameScores[f] += Score.getValueOfFrame(mPinState[f][b]);
frameScores[f] += Score.getValueOfFrame(mPinState[f + 1][0]);
frameScores[f] += Score.getValueOfFrame(mPinState[f][b], true);
frameScores[f] += Score.getValueOfFrame(mPinState[f + 1][0], true);
if (b == 0) {
if (f == Constants.LAST_FRAME - 1) {
if (frameScores[f] == 30) {
frameScores[f] +=
Score.getValueOfFrame(mPinState[f + 1][1]);
Score.getValueOfFrame(mPinState[f + 1][1], true);
} else {
frameScores[f] +=
Score.getValueOfFrameDifference(
Expand All @@ -1671,12 +1653,12 @@ public void run() {
mPinState[f + 1][0], mPinState[f + 1][1]);
} else {
frameScores[f] +=
Score.getValueOfFrame(mPinState[f + 2][0]);
Score.getValueOfFrame(mPinState[f + 2][0], true);
}
}
break;
} else if (b == 2) {
frameScores[f] += Score.getValueOfFrame(mPinState[f][b]);
frameScores[f] += Score.getValueOfFrame(mPinState[f][b], true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import ca.josephroque.bowlingcompanion.database.Contract.SeriesEntry;
import ca.josephroque.bowlingcompanion.database.DatabaseHelper;
import ca.josephroque.bowlingcompanion.dialog.ChangeDateDialog;
import ca.josephroque.bowlingcompanion.utilities.DataFormatter;
import ca.josephroque.bowlingcompanion.theme.Theme;
import ca.josephroque.bowlingcompanion.utilities.DateUtils;
import ca.josephroque.bowlingcompanion.utilities.DisplayUtils;
import ca.josephroque.bowlingcompanion.utilities.FloatingActionButtonHandler;

Expand Down Expand Up @@ -251,7 +251,7 @@ public void onChangeDate(final Series series, int year, int month, int day) {
final SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CANADA);
final String formattedDate = dateFormat.format(c.getTime());
seriesInList.setSeriesDate(DataFormatter.formattedDateToPrettyCompact(formattedDate.substring(
seriesInList.setSeriesDate(DateUtils.formattedDateToPrettyCompact(formattedDate.substring(
0,
10)));

Expand Down Expand Up @@ -486,7 +486,7 @@ protected List<Series> doInBackground(Void... params) {

if (listSeries.size() == 0 || listSeries.get(listSeries.size() - 1).getSeriesId() != seriesId) {
listSeries.add(new Series(seriesId,
DataFormatter.formattedDateToPrettyCompact(seriesDate),
DateUtils.formattedDateToPrettyCompact(seriesDate),
new ArrayList<Short>(),
new ArrayList<Byte>()));
}
Expand Down Expand Up @@ -593,8 +593,7 @@ public void run() {
if (gameNumber == 1) {
String seriesDate = cursor.getString(cursor.getColumnIndex(
SeriesEntry.COLUMN_SERIES_DATE));
String dateFormatted = DataFormatter
.formattedDateToPrettyCompact(seriesDate);
String dateFormatted = DateUtils.formattedDateToPrettyCompact(seriesDate);

if (dateFormatted.equals(lastSeriesDate)) {
int startOfCurrentSeries = cursor.getPosition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import ca.josephroque.bowlingcompanion.database.Contract;
import ca.josephroque.bowlingcompanion.database.DatabaseHelper;
import ca.josephroque.bowlingcompanion.theme.Theme;
import ca.josephroque.bowlingcompanion.utilities.DataFormatter;
import ca.josephroque.bowlingcompanion.utilities.DisplayUtils;
import ca.josephroque.bowlingcompanion.utilities.FloatingActionButtonHandler;
import ca.josephroque.bowlingcompanion.utilities.Score;
Expand Down Expand Up @@ -213,15 +212,15 @@ private void setExpandableListViewIndicator(ExpandableListView listView) {
listView.setGroupIndicator(indicator);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
listView.setIndicatorBounds(
DataFormatter.getPixelsFromDP(getResources().getDisplayMetrics().density,
DisplayUtils.getPixelsFromDP(getResources().getDisplayMetrics().density,
16),
DataFormatter.getPixelsFromDP(getResources().getDisplayMetrics().density,
DisplayUtils.getPixelsFromDP(getResources().getDisplayMetrics().density,
16) + indicator.getMinimumWidth());
} else {
listView.setIndicatorBoundsRelative(
DataFormatter.getPixelsFromDP(getResources().getDisplayMetrics().density,
DisplayUtils.getPixelsFromDP(getResources().getDisplayMetrics().density,
16),
DataFormatter.getPixelsFromDP(getResources().getDisplayMetrics().density,
DisplayUtils.getPixelsFromDP(getResources().getDisplayMetrics().density,
16) + indicator.getMinimumWidth());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import ca.josephroque.bowlingcompanion.R;
import ca.josephroque.bowlingcompanion.theme.Theme;
import ca.josephroque.bowlingcompanion.utilities.DataFormatter;
import ca.josephroque.bowlingcompanion.utilities.DisplayUtils;

/**
Expand Down Expand Up @@ -152,7 +151,7 @@ public void updateTheme() {
* @param rootView root to attach views to
*/
private void setupTutorialPageAndText(RelativeLayout rootView) {
final int dp16 = DataFormatter.getPixelsFromDP(getResources().getDisplayMetrics().density,
final int dp16 = DisplayUtils.getPixelsFromDP(getResources().getDisplayMetrics().density,
VERTICAL_SPACE);

mTextViewTutorial = new TextView(getContext());
Expand Down Expand Up @@ -239,7 +238,7 @@ private void createPinGameAndSwipeTutorialPage() {
if (mTutorialPage != TutorialPage.PIN_GAME_AND_SWIPE)
throw new IllegalStateException("invalid tutorial page");

final int dp16 = DataFormatter.getPixelsFromDP(getResources().getDisplayMetrics().density,
final int dp16 = DisplayUtils.getPixelsFromDP(getResources().getDisplayMetrics().density,
VERTICAL_SPACE);

mTextViewTutorial.setText(R.string.text_tutorial_pin_game);
Expand Down Expand Up @@ -311,7 +310,7 @@ private void setTutorialLayout(RelativeLayout rootView) {
RelativeLayout.LayoutParams layoutParams;
rootView.removeAllViews();

final int dp16 = DataFormatter.getPixelsFromDP(getResources().getDisplayMetrics().density,
final int dp16 = DisplayUtils.getPixelsFromDP(getResources().getDisplayMetrics().density,
VERTICAL_SPACE);

if (mIsTablet)
Expand Down
Loading

0 comments on commit dca7f1c

Please sign in to comment.