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

Commit

Permalink
Fixed various bugs (#227)
Browse files Browse the repository at this point in the history
* Fixed crash when opening InputActivity

* Fixed critical crash in statistics activity

* Collapse unused properties for arrows like for bows

* Fixed wrong end number in input
Fixed minimum cluster size

* Fixed persistence of incomplete ends

* Removed timer setting from training

* Added arrow diameter input validation

* Fixed backup and added automatic label update

* Fixed import selection from Google Drive

* Added arrow to shooting indoor image

* Fixed color in shortcuts

* Fixed end index update on delete

* Made fab buttons green

* Persist last indoor/outdoor selection

* Fixed old shots not updating bug

* Fixed android test compile

* Updated translations

* Closed #186

* Closed #188

* Fixed few more bugs

* Updated translations

* Fixed back stack

* Fixed crash in EditStandardRoundFragment

* Fixed disabled button color

* Fix crash on wear app

* Fixed bug in migration

* Adjusted test
DreierF authored Jan 15, 2017

Unverified

The email in this signature doesn’t match the committer email.
1 parent 77d30c8 commit f59167f
Showing 111 changed files with 1,299 additions and 355 deletions.
Original file line number Diff line number Diff line change
@@ -112,7 +112,6 @@ private void assertTraining1(Training training) {
Truth.assertThat(training.bowId).isEqualTo(null);
Truth.assertThat(training.arrowId).isEqualTo(null);
Truth.assertThat(training.arrowNumbering).isEqualTo(false);
Truth.assertThat(training.timePerEnd).isEqualTo(-1);
Truth.assertThat(training.indoor).isEqualTo(true);
Truth.assertThat(training.weather).isEqualTo(EWeather.SUNNY);
Truth.assertThat(training.windDirection).isEqualTo(0);
@@ -125,7 +124,7 @@ private void assertTraining1(Training training) {
Truth.assertThat(rounds.get(1).getId()).isEqualTo(2L);
Truth.assertThat(rounds.get(1).trainingId).isEqualTo(1L);
Truth.assertThat(rounds.get(1).index).isEqualTo(1);
Truth.assertThat(rounds.get(1).shotsPerEnd).isEqualTo(2);
Truth.assertThat(rounds.get(1).shotsPerEnd).isEqualTo(3);
Truth.assertThat(rounds.get(1).maxEndCount).isEqualTo(null);
Truth.assertThat(rounds.get(1).distance).isEqualTo(new Dimension(20, METER));
Truth.assertThat(rounds.get(1).comment).isEqualTo("Kommentar");
@@ -140,7 +139,7 @@ private void assertRound11(List<Round> rounds) {
Truth.assertThat(round1.getId()).isEqualTo(1L);
Truth.assertThat(round1.trainingId).isEqualTo(1L);
Truth.assertThat(round1.index).isEqualTo(0);
Truth.assertThat(round1.shotsPerEnd).isEqualTo(3);
Truth.assertThat(round1.shotsPerEnd).isEqualTo(4);
Truth.assertThat(round1.maxEndCount).isEqualTo(null);
Truth.assertThat(round1.distance).isEqualTo(new Dimension(50, METER));
Truth.assertThat(round1.comment).isEqualTo("");
@@ -177,7 +176,6 @@ private void assertTraining2(Training training) {
Truth.assertThat(training.bowId).isEqualTo(1);
Truth.assertThat(training.arrowId).isEqualTo(1);
Truth.assertThat(training.arrowNumbering).isEqualTo(false);
Truth.assertThat(training.timePerEnd).isEqualTo(-1);
Truth.assertThat(training.indoor).isEqualTo(false);
Truth.assertThat(training.weather).isEqualTo(EWeather.LIGHT_RAIN);
Truth.assertThat(training.windDirection).isEqualTo(0);
Original file line number Diff line number Diff line change
@@ -77,6 +77,11 @@ public void settingsActivityTest() {

clickOnPreference(1);

matchToolbarTitle(getActivity().getString(R.string.overview));
pressBack();

clickOnPreference(2);

matchToolbarTitle(getActivity().getString(R.string.input));

matchPreferenceSummary(7, "3.0x");
@@ -94,7 +99,7 @@ public void settingsActivityTest() {
pressBack();
matchToolbarTitle(getActivity().getString(R.string.preferences));

clickOnPreference(2);
clickOnPreference(3);
matchToolbarTitle(getActivity().getString(R.string.scoreboard));

clickOnPreference(1);
@@ -133,7 +138,7 @@ public void settingsActivityTest() {
pressBack();
matchToolbarTitle(getActivity().getString(R.string.preferences));

clickOnPreference(3);
clickOnPreference(4);
matchToolbarTitle(getActivity().getString(R.string.timer));

matchPreferenceSummary(0, getActivity()
@@ -147,16 +152,16 @@ public void settingsActivityTest() {

pressBack();

clickOnPreference(5);
clickOnPreference(6);
allowPermissionsIfNeeded(getActivity(), WRITE_EXTERNAL_STORAGE);
matchToolbarTitle(getActivity().getString(R.string.backup_action));
pressBack();

clickOnPreference(7);
clickOnPreference(8);
matchToolbarTitle(getActivity().getString(R.string.about));
pressBack();

clickOnPreference(8);
clickOnPreference(9);
matchToolbarTitle(getActivity().getString(R.string.licences));
pressBack();
}
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@
import de.dreier.mytargets.features.training.input.TargetView;
import de.dreier.mytargets.shared.analysis.aggregation.EAggregationStrategy;
import de.dreier.mytargets.shared.models.Dimension;
import de.dreier.mytargets.shared.models.Score;
import de.dreier.mytargets.shared.models.Target;
import de.dreier.mytargets.shared.targets.models.NFAAAnimal;
import de.dreier.mytargets.shared.targets.models.WAFull;
@@ -294,4 +295,15 @@ public void setInputSummaryConfiguration() {
SettingsManager.setInputSummaryConfiguration(config);
assertThat(SettingsManager.getInputSummaryConfiguration()).isEqualTo(config);
}

@Test
public void setScoreConfiguration() {
Score.Configuration config = new Score.Configuration();
config.showReachedScore = true;
config.showTotalScore = true;
config.showPercentage = false;
config.showAverage = true;
SettingsManager.setScoreConfiguration(config);
assertThat(SettingsManager.getScoreConfiguration()).isEqualTo(config);
}
}
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ public void inputActivityTest() {
onView(allOf(withContentDescription("X"), withId(R.id.targetView)))
.check(doesNotExist());

clickActionBarItem(R.id.action_show_sidebar, R.string.keyboard);
clickActionBarItem(R.id.action_keyboard, R.string.keyboard);

//onView(withContentDescription("X")).check(matches(isDisplayed()));
}
Original file line number Diff line number Diff line change
@@ -130,7 +130,6 @@ protected Training saveDefaultTraining(Long standardRoundId, Random generator) {
training.bowId = null;
training.arrowId = null;
training.arrowNumbering = false;
training.timePerEnd = 0;
training.save();
return training;
}
Original file line number Diff line number Diff line change
@@ -147,7 +147,6 @@ private void addFullTraining(Bow bow) {
training.bowId = bow.id;
training.arrowId = null;
training.arrowNumbering = false;
training.timePerEnd = 0;
training.save();

Round round1 = new Round(standardRound.getRounds().get(0));
7 changes: 3 additions & 4 deletions app/src/main/assets/migrations/database/18.sql
Original file line number Diff line number Diff line change
@@ -131,7 +131,6 @@ CREATE TABLE IF NOT EXISTS `Training`(
`bow` INTEGER,
`arrow` INTEGER,
`arrowNumbering` INTEGER,
`timePerEnd` INTEGER,
`indoor` INTEGER,
`weather` INTEGER,
`windDirection` INTEGER,
@@ -147,7 +146,7 @@ UPDATE TRAINING_OLD SET arrow = null WHERE arrow < 1;
INSERT INTO `Training`
SELECT t.`_id`,t.`title`,t.`datum`,
CASE WHEN s.club < 512 THEN t.`standard_round` ELSE NULL END,
t.`bow`,t.`arrow`, t.`arrow_numbering`,t.`time`,
t.`bow`,t.`arrow`, t.`arrow_numbering`,
s.`indoor`,t.`weather`,t.`wind_direction`,t.`wind_speed`,t.`location`
FROM TRAINING_OLD t, STANDARD_ROUND_TEMPLATE_OLD s
WHERE t.standard_round=s._id;
@@ -167,8 +166,8 @@ CREATE TABLE IF NOT EXISTS `Round`(
FOREIGN KEY(`training`) REFERENCES Training(`_id`) ON UPDATE NO ACTION ON DELETE CASCADE
);
INSERT INTO `Round`
SELECT r.`_id`,r.`training`,t.`r_index`,t.`passes`,
CASE WHEN s.club = 512 THEN NULL ELSE t.`arrows` END,
SELECT r.`_id`,r.`training`,t.`r_index`,t.`arrows`,
CASE WHEN s.club = 512 THEN NULL ELSE t.`passes` END,
t.`distance` || ' ' || t.`unit`, r.`comment`,r.`target`,r.`scoring_style`,
t.`size` || ' ' || t.`target_unit`
FROM ROUND_OLD r, ROUND_TEMPLATE_OLD t, STANDARD_ROUND_TEMPLATE_OLD s
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@

package de.dreier.mytargets.base.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
@@ -49,4 +50,17 @@ public void onCreate(Bundle savedInstanceState) {
public Fragment getChildFragment() {
return getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG);
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
childFragment = instantiateFragment();
Bundle bundle = intent != null ? intent.getExtras() : null;
childFragment.setArguments(bundle);

FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(android.R.id.content, childFragment, FRAGMENT_TAG);
ft.commit();
}
}
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ protected HeaderViewHolder<P> getTopLevelViewHolder(ViewGroup parent) {
return new HeaderViewHolder<>(itemView);
}

private static class HeaderViewHolder<HEADER> extends ExpandableHeaderBindingHolder<HEADER> {
private static class HeaderViewHolder<P> extends ExpandableHeaderBindingHolder<P> {
private final ItemHeaderExpandableBinding binding;

HeaderViewHolder(View itemView) {
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
package de.dreier.mytargets.base.fragments;

import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
@@ -25,6 +26,8 @@
import android.support.v4.content.AsyncTaskLoader;
import android.support.v4.content.Loader;

import com.google.firebase.analytics.FirebaseAnalytics;

import de.dreier.mytargets.R;
import de.dreier.mytargets.utils.Utils;
import icepick.Icepick;
@@ -38,9 +41,15 @@ public abstract class FragmentBase extends Fragment implements LoaderManager.Loa

private static final int LOADER_ID = 0;

public void logEvent(String event) {
FirebaseAnalytics.getInstance(getContext()).logEvent(event, null);
}

@CallSuper
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
logEvent(getClass().getSimpleName());
Icepick.restoreInstanceState(this, savedInstanceState);
}

Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ public static IntentWrapper editIntent(Arrow arrow) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = super.onCreateView(inflater, container, savedInstanceState);
contentBinding = FragmentEditArrowBinding.inflate(inflater, binding.content, true);
contentBinding.moreFields.setOnClickListener(v -> contentBinding.setShowAll(true));

if (savedInstanceState == null) {
Bundle bundle = getArguments();
@@ -73,9 +74,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
}

setImageFiles(arrow.getImages());
ToolbarUtils.setTitle(this, arrow.name);
contentBinding.diameterUnit.setSelection(arrow.diameter.unit == MILLIMETER ? 0 : 1);
}
ToolbarUtils.setTitle(this, arrow.name);
contentBinding.setArrow(arrow);
loadImage(imageFile);
return rootView;
@@ -90,10 +91,41 @@ public void onSaveInstanceState(Bundle outState) {
@Override
public void onSave() {
super.onSave();
if (!validateInput()) {
return;
}
buildArrow().save();
finish();
}

private boolean validateInput() {
float diameterValue;
try {
diameterValue = Float.parseFloat(contentBinding.diameter.getText().toString());
} catch (NumberFormatException ignored) {
contentBinding.diameterTextInputLayout
.setError(getString(R.string.invalid_decimal_number));
return false;
}
final int selectedUnit = contentBinding.diameterUnit.getSelectedItemPosition();
Dimension.Unit diameterUnit = selectedUnit == 0 ? MILLIMETER : INCH;
if (diameterUnit == MILLIMETER) {
if (diameterValue < 1 || diameterValue > 20) {
contentBinding.diameterTextInputLayout
.setError(getString(R.string.not_within_expected_range_mm));
return false;
}
} else {
if (diameterValue < 0 || diameterValue > 1) {
contentBinding.diameterTextInputLayout
.setError(getString(R.string.not_within_expected_range_inch));
return false;
}
}
contentBinding.diameterTextInputLayout.setError(null);
return true;
}

private Arrow buildArrow() {
arrow.name = contentBinding.name.getText().toString();
arrow.length = contentBinding.length.getText().toString();
Original file line number Diff line number Diff line change
@@ -100,8 +100,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
bow.getSightMarks().add(new SightMark());
}
setImageFiles(bow.getImages());
ToolbarUtils.setTitle(this, bow.name);
}
ToolbarUtils.setTitle(this, bow.name);
contentBinding.setBow(bow);

loadImage(imageFile);
Original file line number Diff line number Diff line change
@@ -34,15 +34,15 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
addSlide(new SlideFragmentBuilder()
.backgroundColor(R.color.introBackground)
.buttonsColor(R.color.colorAccent)
.image(R.drawable.ic_intro_screen_1)
.image(R.drawable.intro_screen_1)
.title(getString(R.string.intro_title_track_training_progress))
.description(getString(R.string.intro_description_track_training_progress))
.build());

addSlide(new SlideFragmentBuilder()
.backgroundColor(R.color.introBackground)
.buttonsColor(R.color.colorAccent)
.image(R.drawable.ic_intro_screen_2)
.image(R.drawable.intro_screen_2)
.title(getString(R.string.intro_title_everything_in_one_place))
.description(getString(R.string.intro_description_everything_in_one_place))
.build());
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@

public enum ESettingsScreens {
MAIN(MainSettingsFragment.class),
OVERVIEW(OverviewSettingsFragment.class),
INPUT(InputSettingsFragment.class),
TIMER(TimerSettingsFragment.class),
SCOREBOARD(ScoreboardSettingsFragment.class),
@@ -32,6 +33,8 @@ public enum ESettingsScreens {

public static ESettingsScreens from(String key) {
switch (key) {
case "overview":
return OVERVIEW;
case "input":
return INPUT;
case "timer":
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2017 Florian Dreier
*
* This file is part of MyTargets.
*
* MyTargets is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* MyTargets is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

package de.dreier.mytargets.features.settings;

public class OverviewSettingsFragment extends SettingsFragmentBase {

}
Loading

0 comments on commit f59167f

Please sign in to comment.