Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
Added exact arrow positioning feature
Browse files Browse the repository at this point in the history
  • Loading branch information
DreierF committed Nov 7, 2014
1 parent 6d69791 commit aa10eaa
Show file tree
Hide file tree
Showing 43 changed files with 908 additions and 217 deletions.
Binary file modified app/app-release.apk
Binary file not shown.
1 change: 1 addition & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.0" level="project" />
<orderEntry type="module" module-name="FloatLabel" exported="" />
<orderEntry type="module" module-name="FloatingActionButton" exported="" />
</component>
</module>

5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "de.dreier.mytargets"
minSdkVersion 14
targetSdkVersion 21
versionCode 5
versionName "1.4"
versionCode 7
versionName "1.6"
}
buildTypes {
release {
Expand All @@ -23,4 +23,5 @@ dependencies {
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile project(":libraries:FloatLabel")
compile project(":libraries:FloatingActionButton")
}
1 change: 1 addition & 0 deletions app/src/main/java/de/dreier/mytargets/BowActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class BowActivity extends NowListActivity {

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/de/dreier/mytargets/NowListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id)
}
}

public void onFabPressed(View view) {
Intent i = new Intent();
if (onItemClick(i, 0, 0)) {
startActivity(i);
overridePendingTransition(R.anim.right_in, R.anim.left_out);
}
}

@Override
public void onBackPressed() {
super.onBackPressed();
Expand Down
40 changes: 29 additions & 11 deletions app/src/main/java/de/dreier/mytargets/PasseActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package de.dreier.mytargets;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBarActivity;
Expand All @@ -10,17 +12,21 @@
import android.view.View;
import android.widget.Button;

import de.dreier.mytargets.TargetOpenHelper.Passe;

public class PasseActivity extends ActionBarActivity implements TargetView.OnTargetSetListener {

public static final String ROUND_ID = "round_id";
public static final String PASSE_IND = "passe_ind";
private static final String EXTRA_VOICE_REPLY = "voice_input";
private static final String TARGET_MODE = "target_mode";
private TargetView target;
private Button next, prev;
private int curPasse = 1;
private int savedPasses = 0;
private long mRound, mTraining;
private TargetOpenHelper db;
private boolean mMode = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -51,6 +57,9 @@ protected void onCreate(Bundle savedInstanceState) {
mTraining = r.training;
target.setTargetRound(r.target);
target.setPPP(r.ppp);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
mMode = prefs.getBoolean(TARGET_MODE, true);
target.switchMode(mMode, false);
/*
Bundle remoteInput = RemoteInput.getResultsFromIntent(i);
if (remoteInput != null) {
Expand Down Expand Up @@ -146,10 +155,10 @@ public void onClick(View view) {

public void setPasse(int passe) {
if (passe <= savedPasses) {
int[] points = db.getPasse(mRound, passe);
if (points != null)
target.setZones(points);
else
Passe p = db.getPasse(mRound, passe);
if (p != null) {
target.setZones(p);
} else
target.reset();
} else if (passe != curPasse) {
target.reset();
Expand All @@ -170,21 +179,30 @@ public boolean onCreateOptionsMenu(Menu menu) {
return true;
}

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.action_switch_mode).setIcon(mMode?R.drawable.ic_target_exact_24dp:R.drawable.ic_target_zone_24dp);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent i;
switch (item.getItemId()) {
/*case R.id.action_settings:
i = new Intent(this,SettingsActivity.class);
startActivity(i);
return true;*/
case R.id.action_new_runde:
i = new Intent(this, NewRoundActivity.class);
i.putExtra(NewRoundActivity.TRAINING_ID, mTraining);
i.putExtra(NewRoundActivity.FROM_PASSE, true);
startActivity(i);
overridePendingTransition(R.anim.left_in_complete, R.anim.right_out_half);
return true;
case R.id.action_switch_mode:
mMode = !mMode;
target.switchMode(mMode, true);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.edit().putBoolean(TARGET_MODE, mMode).apply();
supportInvalidateOptionsMenu();
return true;
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
overridePendingTransition(R.anim.left_in, R.anim.right_out);
Expand All @@ -201,14 +219,14 @@ protected void onSaveInstanceState(@NonNull Bundle outState) {
}

@Override
public void OnTargetSet(int[] zones) {
public void OnTargetSet(Passe passe) {
TargetOpenHelper db = new TargetOpenHelper(this);

if (curPasse > savedPasses) {
savedPasses++;
db.addPasseToRound(mRound, zones);
db.addPasseToRound(mRound, passe);
} else {
db.updatePasse(mRound, curPasse, zones);
db.updatePasse(mRound, curPasse, passe);
}
db.close();
updatePasse();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/de/dreier/mytargets/PasseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected View buildExtraCard(int pos, View convertView, ViewGroup parent) {
view = convertView;
}

int[] target = TargetView.target_points[mRoundInfo.target];
int[] target = Target.target_points[mRoundInfo.target];
int reached = db.getRoundPoints(mRound, mRoundInfo.target);
int maxP = mRoundInfo.ppp * target[0] * db.getPasses(mRound).getCount();

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/de/dreier/mytargets/PassenView.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ protected void onDraw(Canvas canvas) {
private void drawCircle(Canvas can, float x, float y, int zone) {
int colorInd;
if(zone>-1) {
colorInd = TargetView.target_rounds[targetRound][zone];
colorInd = Target.target_rounds[targetRound][zone];
} else {
colorInd = 3;
}
circleColorP.setStyle(Paint.Style.FILL_AND_STROKE);
circleColorP.setColor(TargetView.rectColor[colorInd]);
circleColorP.setColor(Target.rectColor[colorInd]);
can.drawCircle(x, y, 17*density, circleColorP);
circleColorP.setStyle(Paint.Style.STROKE);
circleColorP.setColor(TargetView.circleStrokeColor[colorInd]);
circleColorP.setColor(Target.circleStrokeColor[colorInd]);
can.drawCircle(x, y, 17*density, circleColorP);
mTextPaint.setColor(colorInd==0||colorInd==4 ? Color.BLACK : Color.WHITE);
can.drawText(TargetView.getStringByZone(targetRound, zone), x, y + 7*density, mTextPaint);
can.drawText(Target.getStringByZone(targetRound, zone), x, y + 7*density, mTextPaint);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/de/dreier/mytargets/RoundActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public boolean onCreateOptionsMenu(Menu menu) {

// Construct share intent
mRoundInfo = db.getRound(mRound);
int[] target = TargetView.target_points[mRoundInfo.target];
int[] target = Target.target_points[mRoundInfo.target];
int reached = db.getRoundPoints(mRound, mRoundInfo.target);
int maxP = mRoundInfo.ppp * target[0] * db.getPasses(mRound).getCount();
String text = String.format(getString(R.string.my_share_text),
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/de/dreier/mytargets/RoundsAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.TextView;

/**
Expand Down Expand Up @@ -44,7 +42,7 @@ public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
public void bindView(View view, Context context, Cursor cursor) {
int tar = cursor.getInt(targetInd);
long round = cursor.getLong(idInd);
int[] target = TargetView.target_points[tar];
int[] target = Target.target_points[tar];
int reached = db.getRoundPoints(round,tar);
int maxP = cursor.getInt(pppInd)*target[0]*db.getPasses(round).getCount();

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/de/dreier/mytargets/ScoreboardActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ protected String doInBackground(Void... params) {
tmp_html += "<tr>";
for (int aPasse : passe) {
tmp_html += "<td>";
tmp_html += TargetView.getStringByZone(info.target, aPasse);
tmp_html += Target.getStringByZone(info.target, aPasse);
tmp_html += "</td>";
final int points = aPasse==-1?0:TargetView.target_points[info.target][aPasse];
final int points = aPasse==-1?0:Target.target_points[info.target][aPasse];
arrows += points;
sum += points;
carry += points;
Expand All @@ -99,9 +99,9 @@ protected String doInBackground(Void... params) {
html += "<tr>";
for (int aPasse : passe) {
html += "<td>";
html += TargetView.getStringByZone(info.target, aPasse);
html += Target.getStringByZone(info.target, aPasse);
html += "</td>";
final int points = aPasse==-1?0:TargetView.target_points[info.target][aPasse];
final int points = aPasse==-1?0:Target.target_points[info.target][aPasse];
arrows += points;
sum += points;
carry += points;
Expand Down
79 changes: 79 additions & 0 deletions app/src/main/java/de/dreier/mytargets/Target.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package de.dreier.mytargets;

import android.graphics.Color;

public class Target {
public static final int[] highlightColor = {
0xFFFCEA0F, // Gelb
0xFFE30513, // Rot
0xFF1D70B7, //Blau
0xFF050505, // Schwarz
Color.WHITE, // Weiß
0xFF1C1C1B // Mistake
};

public static final int[] circleStrokeColor = {
0xFFFCEA0F, // Gelb
0xFFE30513, // Rot
0xFF1D70B7, //Blau
0xFF050505, // Schwarz
0xFF1C1C1B, // Weiß wird schwarz dargestellt
0xFF1C1C1B, // Mistake
};

public static final int[] rectColor = {
0xFFFCEA0F, // Gelb
0xFFE30513, // Rot
0xFF1D70B7, //Blau
0xFF1C1C1B, // Schwarz
Color.WHITE, // Weiß
0xFF1C1C1B // Mistake
};

public static final int[] grayColor = {
0xFF7a7439, // Gelb
0xFF7a2621, // Rot
0xFF234466, //Blau
0xFF1C1C1B, // Schwarz
0xFF7d7a80 // Weiß
};

public static final int[][] target_rounds = {
{0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4}, //WA
{0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4},
{0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4},
{0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4},
{0, 0, 0, 1, 1, 2}, // WA Spot
{0, 0, 0, 1, 1, 2},
{0, 0, 0, 1, 1, 2},
{0, 0, 0, 1, 1, 2},
{0, 0, 3, 3, 3, 3}, // WA Field
{4, 4, 3, 3, 3, 3}, //DFBV Spiegel
{4, 4, 3} //DFBV Spiegel Spot
};

public static final int[][] target_points = {
{10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, //WA
{10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
{10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
{10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
{10, 10, 9, 8, 7, 6}, // WA Spot
{10, 10, 9, 8, 7, 6},
{10, 10, 9, 8, 7, 6},
{10, 10, 9, 8, 7, 6},
{5, 5, 4, 3, 2, 1}, // WA Field
{5, 5, 4, 3, 2, 1}, //DFBV Spiegel
{5, 5, 4} //DFBV Spiegel Spot
};

public static String getStringByZone(int target, int zone) {
final int[] points = target_points[target];
if (zone <= -1 || zone >= points.length) {
return "M";
} else if (zone == 0 && target < 8) {
return "X";
} else {
return String.valueOf(points[zone]);
}
}
}
Loading

0 comments on commit aa10eaa

Please sign in to comment.