mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
Make Filter be a normal activity. Fix s/m→m/km conversion
This commit is contained in:
parent
78745420ca
commit
f8d22e9ec7
@ -427,9 +427,9 @@
|
|||||||
android:windowSoftInputMode="stateHidden" />
|
android:windowSoftInputMode="stateHidden" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.ActivitySummariesFilter"
|
android:name=".activities.ActivitySummariesFilter"
|
||||||
android:excludeFromRecents="true"
|
android:label="@string/activity_filter_filter_title"
|
||||||
android:launchMode="singleInstance"
|
android:parentActivityName=".activities.ActivitySummariesActivity"
|
||||||
android:theme="@style/Theme.AppCompat.Light.Dialog.Alert" />
|
android:excludeFromRecents="true"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.DbManagementActivity"
|
android:name=".activities.DbManagementActivity"
|
||||||
|
@ -24,12 +24,14 @@ import android.content.res.Resources;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.DatePicker;
|
import android.widget.DatePicker;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ScrollView;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@ -46,10 +48,11 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
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 Logger LOG = LoggerFactory.getLogger(ActivitySummariesActivity.class);
|
||||||
private static final String DATE_FILTER_FROM = "dateFromFilter";
|
private static final String DATE_FILTER_FROM = "dateFromFilter";
|
||||||
private static final String DATE_FILTER_TO = "dateToFilter";
|
private static final String DATE_FILTER_TO = "dateToFilter";
|
||||||
@ -57,6 +60,7 @@ public class ActivitySummariesFilter extends Activity implements View.OnClickLis
|
|||||||
long dateFromFilter = 0;
|
long dateFromFilter = 0;
|
||||||
long dateToFilter = 0;
|
long dateToFilter = 0;
|
||||||
HashMap<String, Integer> activityKindMap = new HashMap<>(1);
|
HashMap<String, Integer> activityKindMap = new HashMap<>(1);
|
||||||
|
int BACKGROUND_COLOR;
|
||||||
|
|
||||||
public static int getAlternateColor(Context context) {
|
public static int getAlternateColor(Context context) {
|
||||||
TypedValue typedValue = new TypedValue();
|
TypedValue typedValue = new TypedValue();
|
||||||
@ -79,6 +83,7 @@ public class ActivitySummariesFilter extends Activity implements View.OnClickLis
|
|||||||
if (appContext instanceof GBApplication) {
|
if (appContext instanceof GBApplication) {
|
||||||
setContentView(R.layout.sport_activity_filter);
|
setContentView(R.layout.sport_activity_filter);
|
||||||
}
|
}
|
||||||
|
BACKGROUND_COLOR = GBApplication.getBackgroundColor(appContext);;
|
||||||
|
|
||||||
//get spinner ready - assign data, set selected item...
|
//get spinner ready - assign data, set selected item...
|
||||||
final Spinner filterKindSpinner = findViewById(R.id.select_kind);
|
final Spinner filterKindSpinner = findViewById(R.id.select_kind);
|
||||||
@ -182,8 +187,8 @@ public class ActivitySummariesFilter extends Activity implements View.OnClickLis
|
|||||||
filterDateFromDataView.setBackgroundColor(Color.RED);
|
filterDateFromDataView.setBackgroundColor(Color.RED);
|
||||||
filterDateToDataView.setBackgroundColor(Color.RED);
|
filterDateToDataView.setBackgroundColor(Color.RED);
|
||||||
} else {
|
} else {
|
||||||
filterDateFromDataView.setBackgroundColor(Color.WHITE);
|
filterDateFromDataView.setBackgroundColor(BACKGROUND_COLOR);
|
||||||
filterDateToDataView.setBackgroundColor(Color.WHITE);
|
filterDateToDataView.setBackgroundColor(BACKGROUND_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dateToFilter != 0 || dateFromFilter != 0 || activityFilter != 0) {
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
unit = "km_h";
|
unit = "km_h";
|
||||||
break;
|
break;
|
||||||
case "seconds_m":
|
case "seconds_m":
|
||||||
value = 3.6 / value;
|
value = value * (1000/60);
|
||||||
unit = "minutes_km";
|
unit = "minutes_km";
|
||||||
break;
|
break;
|
||||||
case "seconds_km":
|
case "seconds_km":
|
||||||
|
@ -129,6 +129,17 @@ public class AndroidUtils {
|
|||||||
return colorToHex(color);
|
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) {
|
private static String colorToHex(int color) {
|
||||||
return "#"
|
return "#"
|
||||||
+ Integer.toHexString(Color.red(color))
|
+ Integer.toHexString(Color.red(color))
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/activity_summary_detail_relative_layout"
|
android:id="@+id/activity_summary_detail_relative_layout"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:background="?android:attr/activatedBackgroundIndicator"
|
android:clickable="false"
|
||||||
android:clickable="false"
|
android:focusable="auto"
|
||||||
android:focusable="auto"
|
android:orientation="vertical"
|
||||||
android:orientation="vertical"
|
android:padding="8dp">
|
||||||
android:padding="8dp">
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/sports_activity_summary_background"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -143,4 +143,4 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/sport_activity_filter_background"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
@ -21,7 +22,6 @@
|
|||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/select_kind"
|
android:id="@+id/select_kind"
|
||||||
style="@style/Widget.AppCompat.Spinner.Underlined"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/filterfrom"
|
android:id="@+id/filterfrom"
|
||||||
style="@style/Widget.AppCompat.Spinner.Underlined"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="bottom"
|
android:gravity="bottom"
|
||||||
@ -64,7 +63,6 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/filterto"
|
android:id="@+id/filterto"
|
||||||
style="@style/Widget.AppCompat.Spinner.Underlined"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="bottom"
|
android:gravity="bottom"
|
||||||
@ -97,19 +95,21 @@
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/reset_filter_button"
|
android:id="@+id/reset_filter_button"
|
||||||
|
style="@style/Widget.AppCompat.Button.Colored"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@style/Widget.AppCompat.Button.Colored"
|
|
||||||
android:text="@string/activity_filter_reset_filter" />
|
android:text="@string/activity_filter_reset_filter" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/apply_filter_button"
|
android:id="@+id/apply_filter_button"
|
||||||
|
style="@style/Widget.AppCompat.Button.Colored"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@style/Widget.AppCompat.Button.Colored"
|
|
||||||
android:text="@string/activity_filter_apply_filter" />
|
android:text="@string/activity_filter_apply_filter" />
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,4 +9,5 @@
|
|||||||
<attr name="chart_activity" format="color" />
|
<attr name="chart_activity" format="color" />
|
||||||
<attr name="chart_not_worn" format="color" />
|
<attr name="chart_not_worn" format="color" />
|
||||||
<attr name="alternate_row_background" format="color" />
|
<attr name="alternate_row_background" format="color" />
|
||||||
|
<attr name="sports_activity_summary_background" format="color" />
|
||||||
</resources>
|
</resources>
|
@ -32,7 +32,7 @@
|
|||||||
<color name="chart_not_worn_light" type="color">#545254</color>
|
<color name="chart_not_worn_light" type="color">#545254</color>
|
||||||
<color name="chart_not_worn_dark" type="color">#d8d9d8</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>
|
<color name="alternate_row_background_dark">#545254</color>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -928,7 +928,6 @@
|
|||||||
<string name="averageStrokeDistance">Average Stroke Distance</string>
|
<string name="averageStrokeDistance">Average Stroke Distance</string>
|
||||||
<string name="averageStrokesPerSecond">Average Strokes</string>
|
<string name="averageStrokesPerSecond">Average Strokes</string>
|
||||||
<string name="averageLapPace">Average Lap Pace</string>
|
<string name="averageLapPace">Average Lap Pace</string>
|
||||||
<string name="strokes">Strokes</string>
|
|
||||||
<string name="swolfIndex">swolfIndex</string>
|
<string name="swolfIndex">swolfIndex</string>
|
||||||
<string name="swimStyle">swimStyle</string>
|
<string name="swimStyle">swimStyle</string>
|
||||||
<string name="laps">Laps</string>
|
<string name="laps">Laps</string>
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
<item name="chart_light_sleep">@color/chart_light_sleep_light</item>
|
<item name="chart_light_sleep">@color/chart_light_sleep_light</item>
|
||||||
<item name="chart_activity">@color/chart_activity_light</item>
|
<item name="chart_activity">@color/chart_activity_light</item>
|
||||||
<item name="chart_not_worn">@color/chart_not_worn_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="alternate_row_background">@color/alternate_row_background_light</item>
|
||||||
|
<item name="sports_activity_summary_background">@color/chart_heartrate_fill</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="GadgetbridgeTheme.NoActionBar">
|
<style name="GadgetbridgeTheme.NoActionBar">
|
||||||
@ -43,6 +43,8 @@
|
|||||||
<item name="chart_activity">@color/chart_activity_dark</item>
|
<item name="chart_activity">@color/chart_activity_dark</item>
|
||||||
<item name="chart_not_worn">@color/chart_not_worn_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="alternate_row_background">@color/alternate_row_background_dark</item>
|
||||||
|
<item name="sports_activity_summary_background">@color/alternate_row_background_dark</item>
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ButtonDark" parent="Widget.AppCompat.Button.Colored">
|
<style name="ButtonDark" parent="Widget.AppCompat.Button.Colored">
|
||||||
|
Loading…
Reference in New Issue
Block a user