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

Commit

Permalink
Fixes for Beta 6 (#245)
Browse files Browse the repository at this point in the history
* Added recurve scoring style with (10-1)
* Fixed broken standard rounds
* Closed #233
* Fixed auto backup
* Fixed crash when deleting standard round without selecting new one
* Fixed target not redrawing after selecting “none” aggregation
* Updated dependencies
* Updated gradle
* Fixed groovy syntax errors
* Updated translators
  • Loading branch information
DreierF authored Mar 24, 2017
1 parent 5b1ab44 commit cd43268
Show file tree
Hide file tree
Showing 111 changed files with 776 additions and 441 deletions.
29 changes: 5 additions & 24 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* GNU General Public License for more details.
*/

import com.android.build.gradle.internal.tasks.databinding.DataBindingExportBuildInfoTask

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.github.triplet.play'
Expand Down Expand Up @@ -55,7 +53,7 @@ android {
keyAlias 'mytargets'
keyPassword project.hasProperty('KEY_PASSWORD') ? KEY_PASSWORD : System.getenv('KEY_PASSWORD')
} catch (ignored) {
throw new InvalidUserDataException('You should define KEYSTORE_PASSWORD and KEY_PASSWORD in gradle.properties.')
throw new Exception('You should define KEYSTORE_PASSWORD and KEY_PASSWORD in gradle.properties.')
}
}
}
Expand All @@ -81,30 +79,10 @@ android {
}
}

/*
* Workaround for https://code.google.com/p/android/issues/detail?id=182715
*
* The Android Gradle plugin is creating DataBindingExportBuildInfoTasks for the instrumentation
* APK that generates from the app APKs layouts. This creates duplicate classes in the app and
* instrumentation APK which leads to
* java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
* on older devices.
*
* The workaround is to get the DataBindingExportBuildInfoTasks tasks for the instrumentation APK
* and delete the files right after it creates them.
*/
tasks.withType(DataBindingExportBuildInfoTask) { task ->
if (task.name.endsWith('AndroidTest')) {
task.finalizedBy(tasks.create("${task.name}Workaround") << {
task.output.deleteDir()
})
}
}

def CROWDIN_API_KEY = project.hasProperty('CROWDIN_API_KEY') ? CROWDIN_API_KEY : System.getenv('CROWDIN_API_KEY')
if (CROWDIN_API_KEY != null && !CROWDIN_API_KEY.isEmpty()) {
tasks.whenTaskAdded { task ->
if (task.name.equals("generateRegularReleasePlayResources")) {
if (task.name == "generateRegularReleasePlayResources") {
task.dependsOn ':crowdinDownload'
}
}
Expand All @@ -116,6 +94,7 @@ if (CROWDIN_API_KEY != null && !CROWDIN_API_KEY.isEmpty()) {

if (new File('googlePlayAndroidDeveloper.json').exists()) {
play {
track = 'beta'
jsonFile = file('../googlePlayAndroidDeveloper.json')
}
}
Expand All @@ -126,12 +105,14 @@ dependencies {
compile "com.android.support:support-core-utils:$libraryVersion.support"
compile "com.android.support:support-core-ui:$libraryVersion.support"
compile "com.android.support:support-fragment:$libraryVersion.support"
compile "com.android.support:support-v13:$libraryVersion.support"
compile "com.android.support:appcompat-v7:$libraryVersion.support"
compile "com.android.support:design:$libraryVersion.support"
compile "com.android.support:support-annotations:$libraryVersion.support"
compile "com.android.support:preference-v7:$libraryVersion.support"
compile "com.android.support:preference-v14:$libraryVersion.support"
compile "com.android.support:recyclerview-v7:$libraryVersion.support"
compile "com.android.support:cardview-v7:$libraryVersion.support"
compile "com.android.support:preference-v14:$libraryVersion.support"

compile "com.google.android.gms:play-services-wearable:$libraryVersion.playService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void assertRound11(List<Round> rounds) {
Truth.assertThat(round1.distance).isEqualTo(new Dimension(50, METER));
Truth.assertThat(round1.comment).isEqualTo("");
Truth.assertThat(round1.getTarget().getId()).isEqualTo(1);
Truth.assertThat(round1.getTarget().scoringStyle).isEqualTo(1);
Truth.assertThat(round1.getTarget().scoringStyle).isEqualTo(2);
Truth.assertThat(round1.getTarget().size).isEqualTo(new Dimension(40, CENTIMETER));
final List<End> ends = round1.getEnds();
Truth.assertThat(ends).hasSize(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public void setUp() {
SettingsManager.setInputTargetZoom(3.0f);
SettingsManager.setInputArrowDiameterScale(1.0f);
SettingsManager.setBackupLocation(EBackupLocation.INTERNAL_STORAGE);
SettingsManager.setBackupAutomaticallyEnabled(false);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,6 @@ public void setBackupInterval() {
assertThat(SettingsManager.getBackupInterval()).isEqualTo(EBackupInterval.MONTHLY);
}

@Test
public void setBackupAutomaticallyEnabled() {
SettingsManager.setBackupAutomaticallyEnabled(true);
assertThat(SettingsManager.isBackupAutomaticallyEnabled()).isEqualTo(true);
}

@Test
public void setStandardRoundsLastUsedEmpty() {
SettingsManager.setStandardRoundsLastUsed(Collections.emptyMap());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void createFreeTraining() {
onView(withId(R.id.target)).perform(nestedScrollTo(), click());
onView(withId(R.id.recyclerView)).perform(actionOnItemAtPosition(5, click()));
onView(withId(R.id.scoring_style)).perform(click());
onData(instanceOf(String.class)).atPosition(1).perform(click());
onData(instanceOf(String.class)).atPosition(2).perform(click());
onView(withId(R.id.target_size)).perform(click());
onView(withText("40cm")).perform(click());
pressBack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.support.test.runner.AndroidJUnit4;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -119,5 +120,7 @@ public void editStandardRoundActivity() {
onView(withId(R.id.standardRound))
.check(matches(hasDescendant(withText(
allOf(startsWith("20m: 10 × 3"), containsString("15m: 5 × 6"))))));

activityTestRule.getActivity().finish();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@
import java.util.Locale;

public class InstrumentedTestBase {

@Rule
public TestName testName = new TestName() {
@Override
protected void starting(Description d) {
super.starting(d);
Log.d("TestName", d.getDisplayName());
}
};

protected void setLocale(Locale locale) {
// here we update locale for date formatter
Locale.setDefault(locale);
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2017 Florian Dreier
~
~ This file is part of MyTargets.
Expand Down Expand Up @@ -27,6 +26,7 @@
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.READ_SYNC_STATS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Expand All @@ -44,7 +44,7 @@
android:restoreAnyVersion="false"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="UnusedAttribute">
tools:replace="android:name">
<meta-data
android:name="com.google.android.backup.api_key"
android:value="AEdPqrEAAAAIy_jZMyyGuh5M-ICvUll4H1WyF1R9M8cUcN5wVw" />
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/assets/migrations/database/20.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
UPDATE Round SET targetScoringStyle=targetScoringStyle+1
WHERE targetScoringStyle>0
AND (targetId<7 OR targetId=26 OR targetId=27);
UPDATE RoundTemplate SET targetScoringStyle=targetScoringStyle+1
WHERE targetScoringStyle>0
AND (targetId<7 OR targetId=26 OR targetId=27);
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public class SettingsManager {
.getSharedPreferences();
private static final String KEY_BACKUP_LOCATION = "backup_location";
private static final String KEY_AGGREGATION_STRATEGY = "aggregation_strategy";
private static final String KEY_BACKUP_AUTOMATICALLY = "backup_automatically";
private static final String KEY_STANDARD_ROUNDS_LAST_USED = "standard_round_last_used";
private static final String KEY_INTRO_SHOWED = "intro_showed";
private static final String KEY_OVERVIEW_SHOW_REACHED_SCORE = "overview_show_reached_score";
Expand Down Expand Up @@ -212,8 +211,7 @@ public static void setEndCount(int endCount) {
}

public static boolean isTranslationDialogShown() {
SharedPreferences prefs = preferences;
return prefs.getBoolean(KEY_TRANSLATION_DIALOG_SHOWN, false);
return preferences.getBoolean(KEY_TRANSLATION_DIALOG_SHOWN, false);
}

public static void setTranslationDialogShown(boolean shown) {
Expand Down Expand Up @@ -469,7 +467,8 @@ public static void setBackupLocation(EBackupLocation location) {
}

public static EBackupInterval getBackupInterval() {
return EBackupInterval.valueOf(preferences.getString(KEY_BACKUP_INTERVAL, "WEEKLY"));
return EBackupInterval.valueOf(preferences.getString(KEY_BACKUP_INTERVAL,
EBackupInterval.WEEKLY.name()));
}

public static void setBackupInterval(EBackupInterval interval) {
Expand All @@ -478,16 +477,6 @@ public static void setBackupInterval(EBackupInterval interval) {
.apply();
}

public static boolean isBackupAutomaticallyEnabled() {
return preferences.getBoolean(KEY_BACKUP_AUTOMATICALLY, false);
}

public static void setBackupAutomaticallyEnabled(boolean enabled) {
preferences.edit()
.putBoolean(KEY_BACKUP_AUTOMATICALLY, enabled)
.apply();
}

public static Map<Long, Integer> getStandardRoundsLastUsed() {
String[] split = lastUsed.getString(KEY_STANDARD_ROUNDS_LAST_USED, "").split(",");
return Stream.of(Arrays.asList(split))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
.addGitHub("DreierF")
.addItem(getLinkedInItem())
.addGroup(getString(R.string.special_thanks_to))
.addItem(new Element("testers", getString(R.string.all_beta_testers), null))
.addItem(new Element("translators", getString(R.string.all_translators)
.addItem(new Element(getString(R.string.all_beta_testers), null))
.addItem(new Element(getString(R.string.all_translators)
+ "\n" + getString(R.string.translators), null))
.create();
}
Expand Down Expand Up @@ -97,8 +97,7 @@ private Element getLinkedInItem() {
}

private Element getShareElement() {
Element shareElement = new Element(null, getString(R.string.share_with_friends),
R.drawable.about_icon_share);
Element shareElement = new Element(getString(R.string.share_with_friends), R.drawable.about_icon_share);
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, URL_PLAY_STORE);
Expand All @@ -109,15 +108,14 @@ private Element getShareElement() {
}

private Element getDonateElement() {
Element donateElement = new Element(null, getString(R.string.donate),
R.drawable.about_icon_donate);
Element donateElement = new Element(getString(R.string.donate), R.drawable.about_icon_donate);
donateElement.setIntent(new Intent(getContext(), DonateActivity.class));
return donateElement;
}

private class WebElement extends Element {
WebElement(@StringRes int title, Integer icon, String url) {
super(null, getString(title), icon);
super(getString(title), icon);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
binding.backupNowButton.setOnClickListener(v -> SyncUtils.triggerBackup());

binding.automaticBackupSwitch.setOnClickListener(v -> onAutomaticBackupChanged());
updateAutomaticBackupSwitch();

binding.backupIntervalPreference.getRoot()
.setOnClickListener(view -> onBackupIntervalClicked());
Expand Down Expand Up @@ -176,6 +175,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
public void onResume() {
super.onResume();
applyBackupLocationWithCheck(SettingsManager.getBackupLocation());
updateAutomaticBackupSwitch();

syncStatusObserver.onStatusChanged(0);
syncObserverHandle = ContentResolver.addStatusChangeListener(
Expand Down Expand Up @@ -210,14 +210,12 @@ public void onActivityResult(final int requestCode, final int resultCode, final

private void onAutomaticBackupChanged() {
boolean autoBackupEnabled = binding.automaticBackupSwitch.isChecked();
SettingsManager.setBackupAutomaticallyEnabled(autoBackupEnabled);
binding.backupIntervalLayout.setVisibility(autoBackupEnabled ? VISIBLE : GONE);
SyncUtils.setSyncAccountPeriodicSync(
autoBackupEnabled ? SettingsManager.getBackupInterval() : null);
SyncUtils.setSyncAutomaticallyEnabled(autoBackupEnabled);
}

private void updateAutomaticBackupSwitch() {
boolean autoBackupEnabled = SettingsManager.isBackupAutomaticallyEnabled();
boolean autoBackupEnabled = SyncUtils.isSyncAutomaticallyEnabled();
binding.automaticBackupSwitch.setChecked(autoBackupEnabled);
}

Expand All @@ -237,7 +235,7 @@ private void onBackupIntervalClicked() {
}

private void updateInterval() {
boolean autoBackupEnabled = SettingsManager.isBackupAutomaticallyEnabled();
boolean autoBackupEnabled = SyncUtils.isSyncAutomaticallyEnabled();
binding.backupIntervalLayout.setVisibility(autoBackupEnabled ? VISIBLE : GONE);
binding.backupIntervalPreference.summary
.setText(SettingsManager.getBackupInterval().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -129,16 +130,20 @@ public static void zip(Context context, OutputStream dest) throws IOException {

String[] files = getImages();
for (String file : files) {
fi = new FileInputStream(new File(context.getFilesDir(), file));
origin = new BufferedInputStream(fi, BUFFER);
try {
fi = new FileInputStream(new File(context.getFilesDir(), file));
origin = new BufferedInputStream(fi, BUFFER);

entry = new ZipEntry("/" + file);
out.putNextEntry(entry);
entry = new ZipEntry("/" + file);
out.putNextEntry(entry);

while ((count = origin.read(data, 0, BUFFER)) != -1) {
out.write(data, 0, count);
while ((count = origin.read(data, 0, BUFFER)) != -1) {
out.write(data, 0, count);
}
origin.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
origin.close();
}

out.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@
import de.dreier.mytargets.features.settings.backup.BackupException;

public class GoogleDriveBackup {
public static class AsyncRestore implements IAsyncBackupRestore {
private static final String TAG = "GoogleDriveBackup";
private static final String MYTARGETS_MIME_TYPE = "application/zip";

private static final String TAG = "GoogleDriveBackup";
public static class AsyncRestore implements IAsyncBackupRestore {

/**
* Request code for auto Google Play Services error resolution.
Expand All @@ -74,7 +75,8 @@ public void connect(Activity activity, ConnectionListener listener) {
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(@Nullable Bundle bundle) {
listener.onConnected();
Drive.DriveApi.requestSync(googleApiClient)
.setResultCallback(result -> listener.onConnected());
}

@Override
Expand Down Expand Up @@ -105,7 +107,7 @@ public void onConnectionSuspended(int cause) {
@Override
public void getBackups(OnLoadFinishedListener listener) {
Query query = new Query.Builder()
.addFilter(Filters.eq(SearchableField.MIME_TYPE, "mytargets/zip"))
.addFilter(Filters.eq(SearchableField.MIME_TYPE, MYTARGETS_MIME_TYPE))
.addFilter(Filters.eq(SearchableField.TRASHED, false))
.setSortOrder(new SortOrder.Builder()
.addSortDescending(SortableField.MODIFIED_DATE).build())
Expand Down Expand Up @@ -211,7 +213,8 @@ public void performBackup(Context context) throws BackupException {

MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle(BackupUtils.getBackupName())
.setMimeType("mytargets/zip")
.setMimeType(MYTARGETS_MIME_TYPE)
.setStarred(true)
.build();

// create a file in selected folder
Expand Down
Loading

0 comments on commit cd43268

Please sign in to comment.