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 2 (#228)
Browse files Browse the repository at this point in the history
* Removed useless translations and fixed %1$d crashes

* Added sight mark sorting

* Fixed Assertion Error

* Made controls in toolbar use white accent color

* Fixed more bugs

* Fixed standard round overwrite

* Dropped support for API 14 and 15

* Fixed repeated permission prompt

* Fixed missing translations warning
  • Loading branch information
DreierF authored Jan 16, 2017
1 parent f59167f commit 3aecb39
Show file tree
Hide file tree
Showing 148 changed files with 215 additions and 10,266 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ after_failure:
- >
adb logcat -d 2>&1 | python pidcat.py de.dreier.mytargets.debug | tee logcat.log &&
cd app/build/reports/androidTests/connected/flavors/REGULAR/ &&
mv ../../../../../../../logcat.log ogcat.log &&
mv ../../../../../../../logcat.log logcat.log &&
zip -r reports.zip . &&
cd ../../../../../../.. &&
./dropbox_uploader.sh upload app/build/reports/androidTests/connected/flavors/REGULAR/reports.zip /Reports/$TRAVIS_JOB_NUMBER.zip
Expand Down
6 changes: 5 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {

defaultConfig {
applicationId 'de.dreier.mytargets'
minSdkVersion 14
minSdkVersion 16
targetSdkVersion 25
versionCode appVersionCode
versionName appVersionName
Expand Down Expand Up @@ -79,6 +79,10 @@ android {
regular {}
screengrab {}
}

lintOptions {
disable 'MissingTranslation'
}
}

/*
Expand Down
114 changes: 54 additions & 60 deletions app/src/main/AndroidManifest.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ public Fragment getChildFragment() {
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
childFragment = instantiateFragment();
Bundle bundle = intent != null ? intent.getExtras() : null;
childFragment.setArguments(bundle);
childFragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG);
if (childFragment == null && intent!= null && intent.getExtras()!=null) {
childFragment = instantiateFragment();
childFragment.setArguments(intent.getExtras());
}

FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(android.R.id.content, childFragment, FRAGMENT_TAG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
new DefaultCallback() {

@Override
public void onImagePicked(File imageFile, EasyImage.ImageSource source, int type) {
public void onImagesPicked(@NonNull List<File> imageFiles, EasyImage.ImageSource source, int type) {
EditWithImageFragmentBase.this.oldImageFile = EditWithImageFragmentBase.this.imageFile;
loadImage(imageFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import android.print.PrintManager;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDelegate;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -39,6 +37,7 @@
import java.io.IOException;

import de.dreier.mytargets.R;
import de.dreier.mytargets.base.activities.ChildActivityBase;
import de.dreier.mytargets.databinding.ActivityScoreboardBinding;
import de.dreier.mytargets.features.settings.ESettingsScreens;
import de.dreier.mytargets.features.settings.SettingsActivity;
Expand All @@ -47,15 +46,11 @@

import static android.support.v4.content.FileProvider.getUriForFile;

public class ScoreboardActivity extends AppCompatActivity {
public class ScoreboardActivity extends ChildActivityBase {

private static final String TRAINING_ID = "training_id";
private static final String ROUND_ID = "round_id";

static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}

private long mTraining;
private long mRound;
private boolean pageLoaded = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
import de.dreier.mytargets.utils.ToolbarUtils;
import de.dreier.mytargets.utils.Utils;
import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.OnPermissionDenied;
import permissions.dispatcher.RuntimePermissions;

import static android.content.ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE;
import static android.content.ContentResolver.SYNC_OBSERVER_TYPE_PENDING;
import static android.support.v7.widget.DividerItemDecoration.VERTICAL;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static de.dreier.mytargets.features.settings.backup.BackupSettingsFragmentPermissionsDispatcher.applyBackupLocationWithCheck;
import static de.dreier.mytargets.features.settings.backup.BackupSettingsFragmentPermissionsDispatcher.showFilePickerWithCheck;

@RuntimePermissions
Expand Down Expand Up @@ -147,7 +147,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
updateInterval();

binding.backupLocation.getRoot().setOnClickListener(v -> onBackupLocationClicked());
updateBackupLocation();

binding.recentBackupsList.setNestedScrollingEnabled(false);
binding.recentBackupsList
Expand All @@ -157,6 +156,54 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
return binding.getRoot();
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.backup_import, menu);
}

public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_import) {
showFilePickerWithCheck(this);
return true;
}
return super.onOptionsItemSelected(item);
}

@Override
public void onResume() {
super.onResume();
applyBackupLocationWithCheck(SettingsManager.getBackupLocation());

mSyncStatusObserver.onStatusChanged(0);
mSyncObserverHandle = ContentResolver.addStatusChangeListener(
SYNC_OBSERVER_TYPE_PENDING | SYNC_OBSERVER_TYPE_ACTIVE, mSyncStatusObserver);
}

@Override
public void onPause() {
if (backup != null) {
backup.stop();
}
if (updateLabelTimer != null) {
updateLabelTimer.cancel();
}
if (mSyncObserverHandle != null) {
ContentResolver.removeStatusChangeListener(mSyncObserverHandle);
mSyncObserverHandle = null;
}
super.onPause();
}

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
backup.onActivityResult(requestCode, resultCode, data);
if (requestCode == IMPORT_FROM_URI && resultCode == AppCompatActivity.RESULT_OK) {
importFromUri(data.getData());
}
super.onActivityResult(requestCode, resultCode, data);
}

private void onAutomaticBackupChanged() {
boolean autoBackupEnabled = binding.automaticBackupSwitch.isChecked();
SettingsManager.setBackupAutomaticallyEnabled(autoBackupEnabled);
Expand Down Expand Up @@ -203,22 +250,30 @@ private void onBackupLocationClicked() {
if (backup != null) {
backup.stop();
}
updateBackupLocation(location);
applyBackupLocationWithCheck(location);
return true;
})
.show();
}

private void updateBackupLocation(EBackupLocation item) {
private void updateBackupLocation() {
EBackupLocation backupLocation = SettingsManager.getBackupLocation();
binding.backupLocation.image.setImageResource(backupLocation.getDrawableRes());
binding.backupLocation.name.setText(R.string.backup_location);
binding.backupLocation.summary.setText(backupLocation.toString());
}

private void applyBackupLocationWithCheck(EBackupLocation item) {
if (item.needsStoragePermissions()) {
applyBackupLocationWithCheck(this, item);
BackupSettingsFragmentPermissionsDispatcher.applyBackupLocationWithCheck(this, item);
} else {
applyBackupLocation(item);
}
}

@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
void applyBackupLocation(EBackupLocation item) {
SettingsManager.setBackupLocation(item);
backup = item.createAsyncRestore();
binding.recentBackupsProgress.setVisibility(VISIBLE);
binding.recentBackupsList.setVisibility(GONE);
Expand All @@ -227,7 +282,6 @@ void applyBackupLocation(EBackupLocation item) {
backup.connect(getActivity(), new IAsyncBackupRestore.ConnectionListener() {
@Override
public void onConnected() {
SettingsManager.setBackupLocation(item);
updateBackupLocation();
backup.getBackups(BackupSettingsFragment.this);
}
Expand All @@ -239,61 +293,6 @@ public void onConnectionSuspended() {
});
}

private void updateBackupLocation() {
EBackupLocation backupLocation = SettingsManager.getBackupLocation();
binding.backupLocation.image.setImageResource(backupLocation.getDrawableRes());
binding.backupLocation.name.setText(R.string.backup_location);
binding.backupLocation.summary.setText(backupLocation.toString());
}

@Override
public void onResume() {
super.onResume();
updateBackupLocation(SettingsManager.getBackupLocation());

mSyncStatusObserver.onStatusChanged(0);
mSyncObserverHandle = ContentResolver.addStatusChangeListener(
SYNC_OBSERVER_TYPE_PENDING | SYNC_OBSERVER_TYPE_ACTIVE, mSyncStatusObserver);
}

@Override
public void onPause() {
if (backup != null) {
backup.stop();
}
if (updateLabelTimer != null) {
updateLabelTimer.cancel();
}
if (mSyncObserverHandle != null) {
ContentResolver.removeStatusChangeListener(mSyncObserverHandle);
mSyncObserverHandle = null;
}
super.onPause();
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.backup_import, menu);
}

public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_import) {
showFilePickerWithCheck(this);
return true;
}
return super.onOptionsItemSelected(item);
}

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
backup.onActivityResult(requestCode, resultCode, data);
if (requestCode == IMPORT_FROM_URI && resultCode == AppCompatActivity.RESULT_OK) {
importFromUri(data.getData());
}
super.onActivityResult(requestCode, resultCode, data);
}

@Override
protected void setActivityTitle() {
getActivity().setTitle(R.string.backup_action);
Expand Down Expand Up @@ -391,7 +390,7 @@ public void onError(String message) {
});
}

@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
void showFilePicker() {
final Intent getContentIntent = new Intent(Intent.ACTION_GET_CONTENT);
getContentIntent.setType("application/zip");
Expand All @@ -400,6 +399,11 @@ void showFilePicker() {
startActivityForResult(intent, IMPORT_FROM_URI);
}

@OnPermissionDenied(Manifest.permission.WRITE_EXTERNAL_STORAGE)
void showDeniedForWrite() {
getActivity().onBackPressed();
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ protected void onDestroy() {
private void showEnd(int endIndex) {
// Create a new end
data.endIndex = endIndex;
if (endIndex == getEnds().size()) {
if (endIndex >= getEnds().size()) {
getCurrentRound().addEnd();
updateOldShoots();
}
Expand Down Expand Up @@ -398,7 +398,7 @@ private void updatePreviousButton() {
}

private void updateNextButton() {
final boolean endFinished = getCurrentEnd().getId() != null;
final boolean endFinished = getCurrentEnd() != null && getCurrentEnd().getId() != null;
boolean isLastEnd = getCurrentRound().maxEndCount != null && data.endIndex + 1 == getCurrentRound().maxEndCount;
final boolean hasOneMoreRound = data.roundIndex + 1 < data.training.getRounds().size();
boolean showNextRound = isLastEnd && hasOneMoreRound;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
if (standardRound.club == StandardRoundFactory.CUSTOM) {
binding.name.setText(standardRound.name);
} else {
standardRound.setId(null);
binding.name.setText(
String.format("%s %s", getString(R.string.custom), standardRound.name));
// When copying an existing standard round make sure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private class StandardRoundListAdapter extends HeaderListAdapter<StandardRound>
usagesR2 = 0;
}
final int i = usagesR2.compareTo(usagesR1);
return i == 0 ? r1.getName().compareTo(r2.getName()) : i;
return i == 0 ? r1.compareTo(r2) : i;
});
}

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fragment_edit_training.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar.WhiteControls">

<RelativeLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -78,7 +78,6 @@
android:textSize="14sp"
android:textStyle="normal" />


</RelativeLayout>

</android.support.v7.widget.Toolbar>
Expand Down
Loading

0 comments on commit 3aecb39

Please sign in to comment.