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

Fixed various bugs #227

Merged
merged 27 commits into from
Jan 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ff251bf
Fixed crash when opening InputActivity
DreierF Jan 13, 2017
9c32bac
Fixed critical crash in statistics activity
DreierF Jan 13, 2017
a4d8ecc
Collapse unused properties for arrows like for bows
DreierF Jan 13, 2017
a5857e1
Fixed wrong end number in input
DreierF Jan 13, 2017
73bdfbd
Fixed persistence of incomplete ends
DreierF Jan 13, 2017
fa97505
Removed timer setting from training
DreierF Jan 13, 2017
c0acbd2
Added arrow diameter input validation
DreierF Jan 13, 2017
a4b4e22
Fixed backup and added automatic label update
DreierF Jan 13, 2017
32f68fb
Fixed import selection from Google Drive
DreierF Jan 13, 2017
a646ed1
Added arrow to shooting indoor image
DreierF Jan 13, 2017
8d08f37
Fixed color in shortcuts
DreierF Jan 13, 2017
d7ce6fe
Fixed end index update on delete
DreierF Jan 13, 2017
fe4aa30
Made fab buttons green
DreierF Jan 13, 2017
6d23b3e
Persist last indoor/outdoor selection
DreierF Jan 13, 2017
c721ce3
Fixed old shots not updating bug
DreierF Jan 13, 2017
e908c98
Fixed android test compile
DreierF Jan 13, 2017
6083e71
Updated translations
DreierF Jan 13, 2017
e34b4c7
Closed #186
DreierF Jan 14, 2017
519b448
Closed #188
DreierF Jan 14, 2017
cdd61b8
Fixed few more bugs
DreierF Jan 14, 2017
8f714c9
Updated translations
DreierF Jan 14, 2017
f56b724
Fixed back stack
DreierF Jan 15, 2017
82dcf36
Fixed crash in EditStandardRoundFragment
DreierF Jan 15, 2017
e57b72f
Fixed disabled button color
DreierF Jan 15, 2017
0341915
Fix crash on wear app
DreierF Jan 15, 2017
b006dfa
Fixed bug in migration
DreierF Jan 15, 2017
49131c7
Adjusted test
DreierF Jan 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
Expand All @@ -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("");
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand Down Expand Up @@ -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()
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Up @@ -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()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/assets/migrations/database/18.sql
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ CREATE TABLE IF NOT EXISTS `Training`(
`bow` INTEGER,
`arrow` INTEGER,
`arrowNumbering` INTEGER,
`timePerEnd` INTEGER,
`indoor` INTEGER,
`weather` INTEGER,
`windDirection` INTEGER,
Expand All @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

public enum ESettingsScreens {
MAIN(MainSettingsFragment.class),
OVERVIEW(OverviewSettingsFragment.class),
INPUT(InputSettingsFragment.class),
TIMER(TimerSettingsFragment.class),
SCOREBOARD(ScoreboardSettingsFragment.class),
Expand All @@ -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":
Expand Down
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