mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
Ensure that Sports Activity Filter has correct first item. Make Sports Filter buttons follow default theme
This commit is contained in:
parent
6cd59fbd24
commit
4c1208400e
@ -384,10 +384,10 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
|
||||
private LinkedHashMap fillKindMap(){
|
||||
LinkedHashMap<String , Integer> newMap = new LinkedHashMap<>(1); //reset
|
||||
newMap.put("All Activities", 0);
|
||||
newMap.put(getString(R.string.activity_summaries_all_activities), 0);
|
||||
for (BaseActivitySummary item : getItemAdapter().getItems()) {
|
||||
String activityName = ActivityKind.asString(item.getActivityKind(), this);
|
||||
if (!newMap.containsKey(item.getActivityKind())) {
|
||||
if (!newMap.containsKey(activityName)) {
|
||||
newMap.put(activityName, item.getActivityKind());
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.LightingColorFilter;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
@ -63,13 +64,6 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
HashMap<String, Integer> activityKindMap = new HashMap<>(1);
|
||||
int BACKGROUND_COLOR;
|
||||
|
||||
public static int getAlternateColor(Context context) {
|
||||
TypedValue typedValue = new TypedValue();
|
||||
Resources.Theme theme = context.getTheme();
|
||||
theme.resolveAttribute(R.attr.alternate_row_background, typedValue, true);
|
||||
return typedValue.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -86,11 +80,14 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
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);
|
||||
ArrayList<String> spinnerArray = new ArrayList<>(activityKindMap.keySet());
|
||||
//ensure that all items is always first in the list
|
||||
spinnerArray.remove(getString(R.string.activity_summaries_all_activities));
|
||||
spinnerArray.add(0, getString(R.string.activity_summaries_all_activities));
|
||||
|
||||
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
|
||||
android.R.layout.simple_spinner_dropdown_item, spinnerArray);
|
||||
filterKindSpinner.setAdapter(dataAdapter);
|
||||
@ -98,15 +95,12 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
addListenerOnSpinnerItemSelection();
|
||||
|
||||
final LinearLayout filterfrom = findViewById(R.id.filterfrom);
|
||||
final TextView filterfromlabel = findViewById(R.id.textViewFromData);
|
||||
final LinearLayout filterto = findViewById(R.id.filterto);
|
||||
final TextView filtertolabel = findViewById(R.id.textViewToData);
|
||||
final EditText nameContainsFilterdata = findViewById(R.id.textViewNameData);
|
||||
nameContainsFilterdata.setBackgroundDrawable(null);
|
||||
|
||||
final Button reset_filter_button = findViewById(R.id.reset_filter_button);
|
||||
final Button apply_filter_button = findViewById(R.id.apply_filter_button);
|
||||
apply_filter_button.setBackgroundColor(this.getResources().getColor(R.color.accent));
|
||||
|
||||
|
||||
nameContainsFilterdata.addTextChangedListener(new TextWatcher() {
|
||||
@ -221,10 +215,10 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
nameContainsFilterdata.setText(nameContainsFilter);
|
||||
}
|
||||
if (dateToFilter != 0 || dateFromFilter != 0 || activityFilter != 0 || nameContainsFilterdata.length() > 0) {
|
||||
reset_filter_button.setBackgroundColor(this.getResources().getColor(R.color.accent));
|
||||
reset_filter_button.getBackground().clearColorFilter();
|
||||
|
||||
} else {
|
||||
reset_filter_button.setBackgroundColor(this.getResources().getColor(R.color.secondarytext));
|
||||
reset_filter_button.getBackground().setColorFilter(new LightingColorFilter(0x0, 0x00888888));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,6 @@
|
||||
android:viewportWidth="30"
|
||||
android:viewportHeight="30">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:fillColor="@color/secondarytext"
|
||||
android:pathData="M14.06 9.02l0.92 0.92L5.92 19H5v-0.92l9.06-9.06M17.66 3c-0.25 0-0.51 0.1-0.7 0.29l-1.83 1.83 3.75 3.75 1.83-1.83c0.39-0.39 0.39-1.02 0-1.41l-2.34-2.34C18.17 3.09 17.92 3 17.66 3zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z" />
|
||||
</vector>
|
||||
|
@ -988,6 +988,7 @@
|
||||
<string name="activity_filter_name_contains">Label</string>
|
||||
<string name="activity_filter_apply_filter">Apply Filter</string>
|
||||
<string name="activity_summaries_statistics">Statistics</string>
|
||||
<string name="activity_summaries_all_activities">All Activities</string>
|
||||
|
||||
<!-- swim styles -->
|
||||
<string name="breaststroke">Breaststroke</string>
|
||||
|
Loading…
Reference in New Issue
Block a user