1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-24 19:06:53 +01:00

Make Filter be a normal activity. Fix s/m→m/km conversion

This commit is contained in:
vanous 2020-08-23 00:03:52 +02:00
parent 78745420ca
commit f8d22e9ec7
10 changed files with 54 additions and 25 deletions

View File

@ -427,9 +427,9 @@
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".activities.ActivitySummariesFilter"
android:excludeFromRecents="true"
android:launchMode="singleInstance"
android:theme="@style/Theme.AppCompat.Light.Dialog.Alert" />
android:label="@string/activity_filter_filter_title"
android:parentActivityName=".activities.ActivitySummariesActivity"
android:excludeFromRecents="true"/>
<activity
android:name=".activities.DbManagementActivity"

View File

@ -24,12 +24,14 @@ import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
@ -46,10 +48,11 @@ import java.util.Objects;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
public class ActivitySummariesFilter extends Activity implements View.OnClickListener {
public class ActivitySummariesFilter extends AbstractGBActivity implements View.OnClickListener {
private static final Logger LOG = LoggerFactory.getLogger(ActivitySummariesActivity.class);
private static final String DATE_FILTER_FROM = "dateFromFilter";
private static final String DATE_FILTER_TO = "dateToFilter";
@ -57,6 +60,7 @@ public class ActivitySummariesFilter extends Activity implements View.OnClickLis
long dateFromFilter = 0;
long dateToFilter = 0;
HashMap<String, Integer> activityKindMap = new HashMap<>(1);
int BACKGROUND_COLOR;
public static int getAlternateColor(Context context) {
TypedValue typedValue = new TypedValue();
@ -79,6 +83,7 @@ public class ActivitySummariesFilter extends Activity implements View.OnClickLis
if (appContext instanceof GBApplication) {
setContentView(R.layout.sport_activity_filter);
}
BACKGROUND_COLOR = GBApplication.getBackgroundColor(appContext);;
//get spinner ready - assign data, set selected item...
final Spinner filterKindSpinner = findViewById(R.id.select_kind);
@ -182,8 +187,8 @@ public class ActivitySummariesFilter extends Activity implements View.OnClickLis
filterDateFromDataView.setBackgroundColor(Color.RED);
filterDateToDataView.setBackgroundColor(Color.RED);
} else {
filterDateFromDataView.setBackgroundColor(Color.WHITE);
filterDateToDataView.setBackgroundColor(Color.WHITE);
filterDateFromDataView.setBackgroundColor(BACKGROUND_COLOR);
filterDateToDataView.setBackgroundColor(BACKGROUND_COLOR);
}
if (dateToFilter != 0 || dateFromFilter != 0 || activityFilter != 0) {
@ -232,4 +237,15 @@ public class ActivitySummariesFilter extends Activity implements View.OnClickLis
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// back button
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}

View File

@ -239,7 +239,7 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
unit = "km_h";
break;
case "seconds_m":
value = 3.6 / value;
value = value * (1000/60);
unit = "minutes_km";
break;
case "seconds_km":

View File

@ -129,6 +129,17 @@ public class AndroidUtils {
return colorToHex(color);
}
public static int getBackgroundColor(Context context) {
int color;
if (GBApplication.isDarkThemeEnabled()) {
color = context.getResources().getColor(R.color.cardview_dark_background);
} else {
color = context.getResources().getColor(R.color.cardview_light_background);
}
return color;
}
private static String colorToHex(int color) {
return "#"
+ Integer.toHexString(Color.red(color))

View File

@ -3,7 +3,6 @@
android:id="@+id/activity_summary_detail_relative_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="?android:attr/activatedBackgroundIndicator"
android:clickable="false"
android:focusable="auto"
android:orientation="vertical"
@ -13,6 +12,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/sports_activity_summary_background"
android:orientation="horizontal">
<ImageView

View File

@ -1,5 +1,6 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/sport_activity_filter_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@ -21,7 +22,6 @@
<Spinner
android:id="@+id/select_kind"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
@ -31,7 +31,6 @@
<LinearLayout
android:id="@+id/filterfrom"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
@ -64,7 +63,6 @@
<LinearLayout
android:id="@+id/filterto"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
@ -97,19 +95,21 @@
<Button
android:id="@+id/reset_filter_button"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.AppCompat.Button.Colored"
android:text="@string/activity_filter_reset_filter" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<Button
android:id="@+id/apply_filter_button"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.AppCompat.Button.Colored"
android:text="@string/activity_filter_apply_filter" />

View File

@ -9,4 +9,5 @@
<attr name="chart_activity" format="color" />
<attr name="chart_not_worn" format="color" />
<attr name="alternate_row_background" format="color" />
<attr name="sports_activity_summary_background" format="color" />
</resources>

View File

@ -32,7 +32,7 @@
<color name="chart_not_worn_light" type="color">#545254</color>
<color name="chart_not_worn_dark" type="color">#d8d9d8</color>
<color name="alternate_row_background_light">#ffd0d0d0</color>
<color name="alternate_row_background_light">#FFEDEDED</color>
<color name="alternate_row_background_dark">#545254</color>
</resources>

View File

@ -928,7 +928,6 @@
<string name="averageStrokeDistance">Average Stroke Distance</string>
<string name="averageStrokesPerSecond">Average Strokes</string>
<string name="averageLapPace">Average Lap Pace</string>
<string name="strokes">Strokes</string>
<string name="swolfIndex">swolfIndex</string>
<string name="swimStyle">swimStyle</string>
<string name="laps">Laps</string>

View File

@ -16,8 +16,8 @@
<item name="chart_light_sleep">@color/chart_light_sleep_light</item>
<item name="chart_activity">@color/chart_activity_light</item>
<item name="chart_not_worn">@color/chart_not_worn_light</item>
<item name="alternate_row_background">@color/alternate_row_background_light</item>
<item name="sports_activity_summary_background">@color/chart_heartrate_fill</item>
</style>
<style name="GadgetbridgeTheme.NoActionBar">
@ -43,6 +43,8 @@
<item name="chart_activity">@color/chart_activity_dark</item>
<item name="chart_not_worn">@color/chart_not_worn_dark</item>
<item name="alternate_row_background">@color/alternate_row_background_dark</item>
<item name="sports_activity_summary_background">@color/alternate_row_background_dark</item>
</style>
<style name="ButtonDark" parent="Widget.AppCompat.Button.Colored">