Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 12 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ def getGitHash = providers.exec {

android {
// Travis update separately
compileSdkVersion = 34
buildToolsVersion = '35.0.0'
compileSdkVersion = 35
buildToolsVersion = '36.0.0'
namespace "com.atrainingtracker"

compileOptions {
sourceCompatibility JavaVersion.toVersion("17")
targetCompatibility JavaVersion.toVersion("17")
}

defaultConfig {
minSdkVersion 26 // Android 8
targetSdkVersion 34 // Android 14
targetSdkVersion 35 // Android 15
multiDexEnabled true
versionName "4.2.99.1"
versionCode 217
Expand Down Expand Up @@ -73,14 +78,14 @@ dependencies {

implementation 'androidx.preference:preference:1.2.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.work:work-runtime:2.9.0'
implementation 'androidx.activity:activity:1.9.1'
implementation 'androidx.work:work-runtime:2.10.1'
implementation 'androidx.activity:activity:1.10.1'

implementation 'com.google.android.material:material:1.12.0'
implementation 'com.google.android.gms:play-services-maps:19.0.0'
implementation 'com.google.android.gms:play-services-maps:19.2.0'
implementation 'com.google.android.gms:play-services-location:21.3.0'

implementation platform('com.google.firebase:firebase-bom:33.1.2')
implementation platform('com.google.firebase:firebase-bom:33.14.0')
implementation 'com.google.firebase:firebase-analytics' // No version needed with BOM

implementation 'com.dropbox.core:dropbox-core-sdk:7.0.0'
Expand Down
13 changes: 12 additions & 1 deletion app/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.5.1" type="baseline" client="gradle" dependencies="false" name="AGP (8.5.1)" variant="all" version="8.5.1">
<issues format="6" by="lint 8.7.1" type="baseline" client="gradle" dependencies="false" name="AGP (8.7.1)" variant="all" version="8.7.1">

<issue
id="MissingPermission"
Expand Down Expand Up @@ -4628,6 +4628,17 @@
column="6"/>
</issue>

<issue
id="UnnecessaryRequiredFeature"
message="Consider whether this feature (`android.hardware.location.gps`) really is required for the app to function; you can set `android:required=&quot;false&quot;` to indicate that the feature is used but not required"
errorLine1=" &lt;uses-feature android:name=&quot;android.hardware.location.gps&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/AndroidManifest.xml"
line="22"
column="33"/>
</issue>

<issue
id="ClickableViewAccessibility"
message="`MultiSelectionSpinner#performClick` should call `super#performClick`"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" android:minSdkVersion="34"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" android:minSdkVersion="29"/>
<!-- <uses-permission android:name="android.permission.VIBRATE" /> -->
<uses-feature android:name="android.hardware.location.gps" />
<uses-feature android:name="android.hardware.location.gps"
android:required="true" />

<application
android:name=".trainingtracker.TrainingApplication"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,11 @@ public void onResume() {
mShowingDialog = true;
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getContext());
dialogBuilder.setIcon(mProtocol.getIconId());
requireActivity().getOnBackPressedDispatcher().addCallback(this,
new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
if (mShowingDialog && isEnabled()) {
cancelDialog(dialogBuilder.create());
requireActivity().finish();
}
}
}
);

dialogBuilder.setCancelable(false);
dialogBuilder.setTitle(R.string.select_device_type);

dialogBuilder.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
cancelDialog(dialog);
}
dialogBuilder.setNegativeButton(R.string.Cancel, (dialog, which) -> {
dialog.dismiss();
mShowingDialog = false;
});

final ArrayList<DeviceType> deviceTypeList = new ArrayList<>(Arrays.asList(DeviceType.getRemoteDeviceTypes(mProtocol)));
Expand Down Expand Up @@ -228,15 +213,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
return false;
}


private void cancelDialog(DialogInterface dialog) {
dialog.dismiss();
if (getActivity() != null) {
getActivity().onBackPressed();
}
mShowingDialog = false;
}

protected void setSectionsPagerAdapter() {
if (DEBUG) Log.w(TAG, "setSectionsPagerAdapter");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@

package com.atrainingtracker.trainingtracker.activities;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;

import androidx.core.graphics.Insets;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import com.atrainingtracker.R;
Expand Down Expand Up @@ -81,6 +89,22 @@ protected void onCreate(Bundle savedInstanceState) {
// supportAB.setHomeAsUpIndicator(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
// supportAB.setDisplayHomeAsUpEnabled(true);

View rootView = findViewById(R.id.main_activity_without_navigation_layout);

ViewCompat.setOnApplyWindowInsetsListener(
rootView,
new OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(
@NonNull View v, @NonNull WindowInsetsCompat windowInsets) {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(insets.left, 0, insets.right, insets.bottom);
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
mlp.topMargin = insets.top;
return WindowInsetsCompat.CONSUMED;
}
});
showMainFragment();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.Manifest;

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;

import android.annotation.SuppressLint;
Expand All @@ -45,6 +46,10 @@
import com.google.android.material.navigation.NavigationView;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.core.view.GravityCompat;
Expand All @@ -61,6 +66,8 @@
import android.provider.Settings;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -321,6 +328,20 @@ protected void onCreate(Bundle savedInstanceState) {
dialog.show();
}
}
ViewCompat.setOnApplyWindowInsetsListener(
mDrawerLayout,
new OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(
@NonNull View v, @NonNull WindowInsetsCompat windowInsets) {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(insets.left, 0, insets.right, insets.bottom);
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
mlp.topMargin = insets.top;
return WindowInsetsCompat.CONSUMED;
}
});

getOnBackPressedDispatcher().addCallback(this,
new OnBackPressedCallback(true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
import com.google.android.material.navigation.NavigationView;

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.core.graphics.Insets;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.core.view.GravityCompat;
Expand All @@ -35,6 +40,8 @@
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import com.atrainingtracker.R;
Expand Down Expand Up @@ -121,6 +128,21 @@ public void onCreate(Bundle savedInstanceState) {
// now, create and show the main fragment
onNavigationItemSelected(mNavigationView.getMenu().findItem(mSelectedFragmentId));

ViewCompat.setOnApplyWindowInsetsListener(
mDrawerLayout,
new OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(
@NonNull View v, @NonNull WindowInsetsCompat windowInsets) {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(insets.left, 0, insets.right, insets.bottom);
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
mlp.topMargin = insets.top;
return WindowInsetsCompat.CONSUMED;
}
});

getOnBackPressedDispatcher().addCallback(this,
new OnBackPressedCallback(true) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@
import com.google.android.material.navigation.NavigationView;

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.core.view.GravityCompat;
Expand All @@ -39,6 +44,7 @@
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import com.atrainingtracker.R;
Expand Down Expand Up @@ -141,6 +147,22 @@ public void onCreate(Bundle savedInstanceState) {
// now, calc the extrema values in the background
(new CalcExtremaValuesThread(this, findViewById(R.id.tvProgressMessage), mWorkoutID)).start();
}
// knappar beskärda

ViewCompat.setOnApplyWindowInsetsListener(
mDrawerLayout,
new OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(
@NonNull View v, @NonNull WindowInsetsCompat windowInsets) {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(insets.left, 0, insets.right, insets.bottom);
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
mlp.topMargin = insets.top;
return windowInsets;
}
});

getOnBackPressedDispatcher().addCallback(this,
new OnBackPressedCallback(true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public void run() {
}
};

// todo ondismiss()
alert.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
package com.atrainingtracker.trainingtracker.fragments;

import android.app.Activity;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import android.app.Dialog;
import android.content.BroadcastReceiver;
Expand All @@ -32,6 +35,10 @@
import android.os.Bundle;

import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.work.OneTimeWorkRequest;
import androidx.work.WorkManager;
Expand Down Expand Up @@ -374,7 +381,7 @@ public void onClick(View view) {
getActivity().setResult(Activity.RESULT_CANCELED, resultIntent);
}

getActivity().onBackPressed();
getActivity().getOnBackPressedDispatcher().onBackPressed();
}
});

Expand All @@ -396,15 +403,42 @@ public void onClick(View v) {
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (DEBUG) Log.d(TAG, "onActivityCreated");
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (DEBUG) Log.d(TAG, "onViewCreated");

// register receivers
ContextCompat.registerReceiver(getActivity(), mFinishedCalculatingExtremaValueReceiver, mFinishedCalculatingExtremaValueFilter, ContextCompat.RECEIVER_NOT_EXPORTED);
ContextCompat.registerReceiver(getActivity(), mFinishedGuessingCommuteAndTrainerReceiver, mFinishedGuessingCommuteAndTrainerFilter, ContextCompat.RECEIVER_NOT_EXPORTED);
ContextCompat.registerReceiver(getActivity(), mFinishedCalculatingFancyNameReceiver, mFinishedCalculatingFancyNameFilter, ContextCompat.RECEIVER_NOT_EXPORTED);
ViewCompat.setOnApplyWindowInsetsListener(view, new OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat windowInsets) {
Insets navBarInsets = windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars());
Insets imeInsets = windowInsets.getInsets(WindowInsetsCompat.Type.ime());
int bottomPadding = navBarInsets.bottom + imeInsets.bottom;
v.setPadding(
v.getPaddingLeft(),
v.getPaddingTop(),
v.getPaddingRight(),
bottomPadding
);
Insets systemGestureInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemGestures());
return WindowInsetsCompat.CONSUMED;
}
});

// Request initial insets apply in case the listener was set up after the first dispatch
// (though with setOnApplyWindowInsetsListener, it usually gets called immediately if insets are available)
ViewCompat.requestApplyInsets(view);

// register receivers (moved from onActivityCreated for modern Fragment lifecycle)
if (getActivity() != null) {
ContextCompat.registerReceiver(getActivity(), mFinishedCalculatingExtremaValueReceiver, mFinishedCalculatingExtremaValueFilter, ContextCompat.RECEIVER_NOT_EXPORTED);
ContextCompat.registerReceiver(getActivity(), mFinishedGuessingCommuteAndTrainerReceiver, mFinishedGuessingCommuteAndTrainerFilter, ContextCompat.RECEIVER_NOT_EXPORTED);
ContextCompat.registerReceiver(getActivity(), mFinishedCalculatingFancyNameReceiver, mFinishedCalculatingFancyNameFilter, ContextCompat.RECEIVER_NOT_EXPORTED);
}

// fill the views
// first, remove all TODO: still necessary?
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/edit_workout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/edit_workout_layout"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Expand Down
Loading