Skip to content

Commit

Permalink
Merge pull request #960 from gerhardol/feature/play-crashes2
Browse files Browse the repository at this point in the history
Check for Battery Optimization when starting GPS
  • Loading branch information
gerhardol authored Aug 21, 2020
2 parents ba282ac + b5ac8db commit 037e2aa
Show file tree
Hide file tree
Showing 45 changed files with 490 additions and 447 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
env:
global:
- ANDROID_API=29
- ANDROID_BUILD_TOOLS=30.0.1
- ANDROID_BUILD_TOOLS=30.0.2
- ADB_INSTALL_TIMEOUT=5
language: android
jdk:
Expand Down
8 changes: 8 additions & 0 deletions app/assets/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
</head>
<body>
<h1>What's new</h1>
<h2>v2.2.2.2</h2>
<p>
<ul>
<li>#960 Check for Battery Optimization when starting GPS</li>
<li>Avoid a few exceptions</li>
<li>Transifex ru, pl, de</li>
<li>Update internal libraries - AppCompatActivity update</li>
</ul>
<h2>v2.2.1.0</h2>
<p>
<ul>
Expand Down
7 changes: 5 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ dependencies {
latestWearApp project(':wear')
}

implementation 'androidx.annotation:annotation:1.1.0'
latestImplementation "com.google.android.material:material:1.1.0"
implementation "androidx.annotation:annotation:${rootProject.ext.annotation_version}"
implementation "androidx.appcompat:appcompat:${rootProject.ext.appcompat_version}"

latestImplementation "com.google.android.material:material:1.2.0"
if (rootProject.ext.enableWear) {
//noinspection GradleDependency
latestImplementation "com.google.android.gms:play-services-wearable:${rootProject.ext.googlePlayServicesVersion}"
Expand All @@ -132,6 +134,7 @@ dependencies {
latestImplementation 'com.getpebble:pebblekit:4.0.1'
// MapBox uses telemetry, without Play there may be exceptions from mapbox: just ignore
//latestImplementation "com.google.android.gms:play-services-location:${rootProject.ext.googlePlayServicesVersion}"
//noinspection GradleDependency
latestImplementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.2.2'
latestImplementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v8:0.7.0'
latestImplementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-scalebar-v8:0.2.0'
Expand Down
2 changes: 1 addition & 1 deletion app/res/layout/account_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:orientation="vertical" >

<ListView
android:id="@+id/account_list"
android:id="@+id/account_list_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentStart="true"
Expand Down
4 changes: 2 additions & 2 deletions app/res/values-de/cues.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<string name="cue_activity">Aktivität</string>
<string name="cue_interval">Intervall</string>
<string name="cue_lap">Runde</string>
<string name="cue_warmup">Aufwärmen</string>
<string name="cue_cooldown">Abkühlen</string>
<string name="cue_warmup">Aufwärmphase</string>
<string name="cue_cooldown">Abkühlphase</string>
<string name="cue_current">Aktuell</string>
<string name="cue_perkilometer">pro Kilometer</string>
<string name="cue_permile">pro Meile</string>
Expand Down
2 changes: 1 addition & 1 deletion app/res/values-pl/cues.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<string name="cue_interval">interwał</string>
<string name="cue_lap">okrążenie</string>
<string name="cue_warmup">rozgrzewka</string>
<string name="cue_cooldown">uspokojenie</string>
<string name="cue_cooldown">Uspokojenie</string>
<string name="cue_current">aktualny</string>
<string name="cue_perkilometer">na kilometr</string>
<string name="cue_permile">na milę</string>
Expand Down
6 changes: 6 additions & 0 deletions app/res/values-ru/cues.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@
<item quantity="many">%d ударов в минуту</item>
<item quantity="other">%d ударов в минуту</item>
</plurals>
<plurals name="cue_rpm">
<item quantity="one">%d оборот в минуту</item>
<item quantity="few">%d оборота в минуту</item>
<item quantity="many">%d оборотов в минуту</item>
<item quantity="other">%d оборотов в минуту</item>
</plurals>
<string name="cue_activity_paused">Пауза</string>
<string name="cue_activity_resumed">Продолжил движение</string>
<string name="cue_activity_stopped">Остановился</string>
Expand Down
1 change: 1 addition & 0 deletions app/res/values/pref_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@

<string name="pref_keystartstop_active">pref_keystartstop_active</string>
<string name="pref_lock_run">pref_lock_run</string>
<string name="pref_suppress_battery_optimization_popup">pref_suppress_battery_optimization_popup</string>

<string name="pref_bt_name">pref_bt_name</string>
<string name="pref_bt_address">pref_bt_address</string>
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/org/runnerup/db/DBHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,10 @@ public static void importDatabase(Context ctx, String from) {
int cnt = FileUtil.copyFile(to, from);
builder.setMessage("Copied " + cnt + " bytes from " + from +
"\n\nRestart to use the database")
.setPositiveButton(ctx.getString(R.string.OK), listener);
.setPositiveButton(R.string.OK, listener);
} catch (IOException e) {
builder.setMessage("Exception: " + e.toString() + " for " + from)
.setNegativeButton(ctx.getString(R.string.Cancel), listener);
.setNegativeButton(R.string.Cancel, listener);
}
builder.show();
}
Expand All @@ -671,10 +671,10 @@ public static void exportDatabase(Context ctx, String to) {
int cnt = FileUtil.copyFile(to, from);
builder.setMessage("Exported " + cnt + " bytes to " + to +
"\n\nNote that the file will be deleted at uninstall")
.setPositiveButton(ctx.getString(R.string.OK), listener);
.setPositiveButton(R.string.OK, listener);
} catch (IOException e) {
builder.setMessage("Exception: " + e.toString() + " for " + to)
.setNegativeButton(ctx.getString(R.string.Cancel), listener);
.setNegativeButton(R.string.Cancel, listener);
}
builder.show();
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/org/runnerup/export/SyncManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private void askUsernamePassword(final Synchronizer sync, final AuthMethod authM
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
.setView(view)
.setPositiveButton(getResources().getString(R.string.OK), (dialog, which) -> {
.setPositiveButton(R.string.OK, (dialog, which) -> {
try {
//noinspection ConstantConditions
authConfig.put("username", tv1.getText());
Expand All @@ -404,7 +404,7 @@ private void askUsernamePassword(final Synchronizer sync, final AuthMethod authM
testUserPass(sync, authConfig);
})
.setNeutralButton("Skip", (dialog, which) -> handleAuthComplete(sync, Status.SKIP))
.setNegativeButton(getResources().getString(R.string.Cancel), (dialog, which) -> handleAuthComplete(sync, Status.SKIP))
.setNegativeButton(R.string.Cancel, (dialog, which) -> handleAuthComplete(sync, Status.SKIP))
.setOnKeyListener((dialogInterface, i, keyEvent) -> {
if (i == KeyEvent.KEYCODE_BACK && keyEvent.getAction() == KeyEvent.ACTION_UP) {
handleAuthComplete(sync, Status.CANCEL);
Expand Down Expand Up @@ -475,7 +475,7 @@ private void askFileUrl(final Synchronizer sync) {
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
.setView(view)
.setPositiveButton(getResources().getString(R.string.OK), (dialog, which) -> {
.setPositiveButton(R.string.OK, (dialog, which) -> {
//Set default values
ContentValues tmp = new ContentValues();
String uri = tv1.getText().toString().trim();
Expand All @@ -495,7 +495,7 @@ private void askFileUrl(final Synchronizer sync) {

handleAuthComplete(sync, sync.connect());
})
.setNegativeButton(getResources().getString(R.string.Cancel), (dialog, which) -> handleAuthComplete(sync, Status.SKIP))
.setNegativeButton(R.string.Cancel, (dialog, which) -> handleAuthComplete(sync, Status.SKIP))
.setOnKeyListener((dialogInterface, i, keyEvent) -> {
if (i == KeyEvent.KEYCODE_BACK && keyEvent.getAction() == KeyEvent.ACTION_UP) {
handleAuthComplete(sync, Status.CANCEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static boolean isAvailable(final Context context) {

private Sensor getSensor(final Context context) {
Sensor sensor = null;
if (Build.VERSION.SDK_INT >= 20) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (mSensorManager == null) {
mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/org/runnerup/util/Formatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private class LocaleResources {
}

void setLang(Locale locale) {
if (Build.VERSION.SDK_INT >= 17) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
configuration.setLocale(locale);
} else {
configuration.locale = locale;
Expand Down
18 changes: 13 additions & 5 deletions app/src/main/org/runnerup/util/MapWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import android.util.Log;
import android.view.ViewTreeObserver;

import androidx.appcompat.content.res.AppCompatResources;

import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
Expand All @@ -55,6 +57,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import static org.runnerup.util.Formatter.Format.TXT_SHORT;

Expand Down Expand Up @@ -287,19 +290,24 @@ public void onGlobalLayout() {

// Images id from text
route.map.getStyle().addImage(((Integer)DB.LOCATION.TYPE_START).toString(),
BitmapUtils.getBitmapFromDrawable(context.getResources().getDrawable(R.drawable.ic_map_marker_start)),
Objects.requireNonNull(BitmapUtils.getBitmapFromDrawable(
AppCompatResources.getDrawable(context, R.drawable.ic_map_marker_start))),
false);
route.map.getStyle().addImage(((Integer)DB.LOCATION.TYPE_END).toString(),
BitmapUtils.getBitmapFromDrawable(context.getResources().getDrawable(R.drawable.ic_map_marker_end)),
Objects.requireNonNull(BitmapUtils.getBitmapFromDrawable(
AppCompatResources.getDrawable(context, R.drawable.ic_map_marker_end))),
false);
route.map.getStyle().addImage(((Integer)DB.LOCATION.TYPE_PAUSE).toString(),
BitmapUtils.getBitmapFromDrawable(context.getResources().getDrawable(R.drawable.ic_map_marker_pause)),
Objects.requireNonNull(BitmapUtils.getBitmapFromDrawable(
AppCompatResources.getDrawable(context, R.drawable.ic_map_marker_pause))),
false);
route.map.getStyle().addImage(((Integer)DB.LOCATION.TYPE_RESUME).toString(),
BitmapUtils.getBitmapFromDrawable(context.getResources().getDrawable(R.drawable.ic_map_marker_resume)),
Objects.requireNonNull(BitmapUtils.getBitmapFromDrawable(
AppCompatResources.getDrawable(context, R.drawable.ic_map_marker_resume))),
false);
route.map.getStyle().addImage("lap",
BitmapUtils.getBitmapFromDrawable(context.getResources().getDrawable(R.drawable.ic_map_marker_lap)),
Objects.requireNonNull(BitmapUtils.getBitmapFromDrawable(
AppCompatResources.getDrawable(context, R.drawable.ic_map_marker_lap))),
false);

symbolManager.setIconAllowOverlap(true);
Expand Down
42 changes: 20 additions & 22 deletions app/src/main/org/runnerup/view/AccountActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import androidx.core.content.ContextCompat;

import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.text.TextUtils;
Expand Down Expand Up @@ -173,7 +174,7 @@ private void fillData() {
im.setVisibility(View.GONE);
tv.setVisibility(View.VISIBLE);
} else {
im.setImageDrawable(ContextCompat.getDrawable(this, synchronizer.getIconId()));
im.setImageDrawable(AppCompatResources.getDrawable(this, synchronizer.getIconId()));
if (!TextUtils.isEmpty(synchronizer.getPublicUrl())) {
im.setTag(synchronizer.getPublicUrl());
im.setOnClickListener(urlButtonClick);
Expand Down Expand Up @@ -289,18 +290,17 @@ public boolean onOptionsItemSelected(MenuItem item) {
private final OnClickListener clearUploadsButtonClick = new OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(
new AlertDialog.Builder(
AccountActivity.this)
.setTitle(getString(R.string.Clear_uploads))
.setMessage(getResources().getString(R.string.Clear_uploads_from_phone))
.setPositiveButton(getString(R.string.OK),
.setTitle(R.string.Clear_uploads)
.setMessage(R.string.Clear_uploads_from_phone)
.setPositiveButton(R.string.OK,
(dialog, which) -> syncManager.clearUploadsByName(callback, mSynchronizerName))
.setNegativeButton(getString(R.string.Cancel),
(dialog, which) -> {
// Do nothing but close the dialog
dialog.dismiss();
});
builder.show();
.setNegativeButton(R.string.Cancel,
// Do nothing but close the dialog
(dialog, which) -> dialog.dismiss()
)
.show();
}
};

Expand Down Expand Up @@ -391,20 +391,18 @@ public void onClick(View v) {
final boolean[] selected = {
true
};
AlertDialog.Builder builder = new AlertDialog.Builder(
new AlertDialog.Builder(
AccountActivity.this)
.setTitle(getString(R.string.Disconnect_account))
.setPositiveButton(getString(R.string.OK),
.setTitle(R.string.Disconnect_account)
.setPositiveButton(R.string.OK,
(dialog, which) -> syncManager.disableSynchronizer(disconnectCallback, mSynchronizerName,
selected[0]))
.setNegativeButton(getString(R.string.Cancel),
(dialog, which) -> {
// Do nothing but close the dialog
dialog.dismiss();
})
.setNegativeButton(R.string.Cancel,
// Do nothing but close the dialog
(dialog, which) -> dialog.dismiss())
.setMultiChoiceItems(items, selected,
(arg0, arg1, arg2) -> selected[arg1] = arg2);
builder.show();
(arg0, arg1, arg2) -> selected[arg1] = arg2)
.show();
}
};

Expand Down
17 changes: 9 additions & 8 deletions app/src/main/org/runnerup/view/AccountListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.loader.app.LoaderManager.LoaderCallbacks;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import androidx.loader.app.LoaderManager.LoaderCallbacks;
import androidx.loader.content.Loader;
import androidx.cursoradapter.widget.CursorAdapter;
import androidx.appcompat.app.AppCompatActivity;
Expand Down Expand Up @@ -75,7 +76,7 @@ public void onCreate(Bundle savedInstanceState) {

mDB = DBHelper.getReadableDatabase(this);
mSyncManager = new SyncManager(this);
ListView listView = findViewById(R.id.account_list);
ListView listView = findViewById(R.id.account_list_list);

// button footer
Button showDisabledBtn = new Button(this);
Expand Down Expand Up @@ -198,7 +199,7 @@ public void bindView(View view, Context context, Cursor cursor) {
int str = configured ?
R.string.accounts_category_connected :
R.string.accounts_category_unconnected;
sectionTitle.setText(getString(str));
sectionTitle.setText(str);
sectionTitle.setVisibility(View.VISIBLE);
}

Expand All @@ -223,12 +224,12 @@ public void bindView(View view, Context context, Cursor cursor) {
// service icon
int synchronizerIcon = synchronizer.getIconId();
if (synchronizerIcon == 0) {
Drawable circle = ContextCompat.getDrawable(context, R.drawable.circle_40dp);
circle.setColorFilter(getResources().getColor(synchronizer.getColorId()), PorterDuff.Mode.SRC_IN);
Drawable circle = AppCompatResources.getDrawable(context, R.drawable.circle_40dp);
circle.setColorFilter(ContextCompat.getColor(context, synchronizer.getColorId()), PorterDuff.Mode.SRC_IN);
accountIcon.setImageDrawable(circle);
accountIconText.setText(name.substring(0, 1));
} else {
accountIcon.setImageDrawable(ContextCompat.getDrawable(context, synchronizerIcon));
accountIcon.setImageDrawable(AppCompatResources.getDrawable(context, synchronizerIcon));
accountIconText.setText(null);
}

Expand Down Expand Up @@ -265,8 +266,8 @@ public View newView(Context context, Cursor cursor, ViewGroup parent) {
}

private void setCustomThumb(SwitchCompat switchCompat, int drawableId, Context context) {
switchCompat.setThumbDrawable(ContextCompat.getDrawable(context, drawableId));
switchCompat.setThumbTintList(ContextCompat.getColorStateList(context, R.color.switch_thumb));
switchCompat.setThumbDrawable(AppCompatResources.getDrawable(context, drawableId));
switchCompat.setThumbTintList(AppCompatResources.getColorStateList(context, R.color.switch_thumb));
switchCompat.setThumbTintMode(PorterDuff.Mode.MULTIPLY);
}

Expand Down
Loading

0 comments on commit 037e2aa

Please sign in to comment.