mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-11 09:31:59 +01:00
Add better Sport Activities Filering
This commit is contained in:
parent
164c73c955
commit
03b45d1071
@ -425,6 +425,11 @@
|
||||
android:parentActivityName=".activities.ActivitySummariesActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden" />
|
||||
<activity
|
||||
android:name=".activities.ActivitySummariesFilter"
|
||||
android:excludeFromRecents="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:theme="@style/Theme.AppCompat.Light.Dialog.Alert" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.DbManagementActivity"
|
||||
|
@ -39,6 +39,14 @@ public abstract class AbstractListActivity<T> extends AbstractGBActivity {
|
||||
this.itemAdapter.setActivityKindFilter(activityKind);
|
||||
}
|
||||
|
||||
public void setDateFromFilter(long date){
|
||||
this.itemAdapter.setDateFromFilter(date);
|
||||
}
|
||||
|
||||
public void setDateToFilter(long date){
|
||||
this.itemAdapter.setDateToFilter(date);
|
||||
}
|
||||
|
||||
public AbstractItemAdapter<T> getItemAdapter() {
|
||||
return itemAdapter;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@ -45,22 +46,22 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AppManagerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.adapter.ActivitySummariesAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySummary;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -71,8 +72,10 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ActivitySummariesActivity.class);
|
||||
private GBDevice mGBDevice;
|
||||
private SwipeRefreshLayout swipeLayout;
|
||||
LinkedHashMap<String , Integer> activityKindMap = new LinkedHashMap<>(1);
|
||||
HashMap<String , Integer> activityKindMap = new HashMap<>(1);
|
||||
int activityFilter=0;
|
||||
long dateFromFilter=0;
|
||||
long dateToFilter=0;
|
||||
|
||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@ -113,10 +116,33 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
resetFetchTimestampToChosenDate();
|
||||
processed = true;
|
||||
break;
|
||||
case R.id.activity_action_filter:
|
||||
Intent filterIntent = new Intent(this, ActivitySummariesFilter.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("activityKindMap",activityKindMap);
|
||||
bundle.putInt("activityFilter",activityFilter);
|
||||
bundle.putLong("dateFromFilter",dateFromFilter);
|
||||
bundle.putLong("dateToFilter",dateToFilter);
|
||||
filterIntent.putExtras(bundle);
|
||||
startActivityForResult(filterIntent,1);
|
||||
return true;
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
|
||||
super.onActivityResult(requestCode, resultCode, resultData);
|
||||
if (requestCode == 1 && resultData!=null) {
|
||||
activityFilter= resultData.getIntExtra("activityFilter",0);
|
||||
dateFromFilter = resultData.getLongExtra("dateFromFilter",0);
|
||||
dateToFilter = resultData.getLongExtra("dateToFilter",0);
|
||||
setActivityKindFilter((int) activityFilter);
|
||||
setDateFromFilter((long) dateFromFilter);
|
||||
setDateToFilter((long) dateToFilter);
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Bundle extras = getIntent().getExtras();
|
||||
@ -132,7 +158,7 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setItemAdapter(new ActivitySummariesAdapter(this, mGBDevice,activityFilter));
|
||||
setItemAdapter(new ActivitySummariesAdapter(this, mGBDevice,activityFilter,dateFromFilter,dateToFilter));
|
||||
|
||||
getItemListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
@ -242,8 +268,7 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
});
|
||||
|
||||
activityKindMap = fillKindMap();
|
||||
addItemsOnSpinner();
|
||||
addListenerOnSpinnerItemSelection();
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -260,34 +285,6 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
return newMap;
|
||||
}
|
||||
|
||||
public void addListenerOnSpinnerItemSelection() {
|
||||
Spinner spinner = (Spinner) findViewById(R.id.select_kind);
|
||||
spinner.setOnItemSelectedListener(new CustomOnItemSelectedListener());
|
||||
}
|
||||
|
||||
public class CustomOnItemSelectedListener implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int pos,long id) {
|
||||
activityFilter=activityKindMap.get(parent.getItemAtPosition(pos));
|
||||
setActivityKindFilter(activityFilter);
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addItemsOnSpinner() {
|
||||
Spinner spinner = (Spinner) findViewById(R.id.select_kind);
|
||||
ArrayList<String> spinnerArray = new ArrayList<>(activityKindMap.keySet());
|
||||
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
|
||||
android.R.layout.simple_spinner_dropdown_item, spinnerArray);
|
||||
spinner.setAdapter(dataAdapter);
|
||||
}
|
||||
|
||||
public void resetFetchTimestampToChosenDate() {
|
||||
final Calendar currentDate = Calendar.getInstance();
|
||||
new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
|
||||
@ -323,6 +320,9 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
Intent ActivitySummaryDetailIntent = new Intent(this, ActivitySummaryDetail.class);
|
||||
ActivitySummaryDetailIntent.putExtra("position", position);
|
||||
ActivitySummaryDetailIntent.putExtra("filter", activityFilter);
|
||||
ActivitySummaryDetailIntent.putExtra("dateFromFilter",dateFromFilter);
|
||||
ActivitySummaryDetailIntent.putExtra("dateToFilter",dateToFilter);
|
||||
|
||||
ActivitySummaryDetailIntent.putExtra(GBDevice.EXTRA_DEVICE, mGBDevice);
|
||||
startActivity(ActivitySummaryDetailIntent);
|
||||
|
||||
|
@ -0,0 +1,235 @@
|
||||
/* Copyright (C) 2019-2020 vanous
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.util.TypedValue;
|
||||
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.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
|
||||
|
||||
public class ActivitySummariesFilter extends Activity 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";
|
||||
int activityFilter = 0;
|
||||
long dateFromFilter = 0;
|
||||
long dateToFilter = 0;
|
||||
HashMap<String, Integer> activityKindMap = new HashMap<>(1);
|
||||
|
||||
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);
|
||||
Bundle bundle = this.getIntent().getExtras();
|
||||
|
||||
activityKindMap = (HashMap<String, Integer>) bundle.getSerializable("activityKindMap");
|
||||
activityFilter = bundle.getInt("activityFilter", 0);
|
||||
dateFromFilter = bundle.getLong("dateFromFilter", 0);
|
||||
dateToFilter = bundle.getLong("dateToFilter", 0);
|
||||
|
||||
Context appContext = this.getApplicationContext();
|
||||
if (appContext instanceof GBApplication) {
|
||||
setContentView(R.layout.sport_activity_filter);
|
||||
}
|
||||
|
||||
//get spinner ready - assign data, set selected item...
|
||||
final Spinner filterKindSpinner = findViewById(R.id.select_kind);
|
||||
ArrayList<String> spinnerArray = new ArrayList<>(activityKindMap.keySet());
|
||||
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
|
||||
android.R.layout.simple_spinner_dropdown_item, spinnerArray);
|
||||
filterKindSpinner.setAdapter(dataAdapter);
|
||||
filterKindSpinner.setSelection(dataAdapter.getPosition(getKeyByValue(activityFilter)));
|
||||
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 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));
|
||||
|
||||
|
||||
reset_filter_button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
activityFilter = 0;
|
||||
dateFromFilter = 0;
|
||||
dateToFilter = 0;
|
||||
filterKindSpinner.setSelection(0);
|
||||
update_filter_fields();
|
||||
}
|
||||
});
|
||||
|
||||
apply_filter_button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("activityFilter", activityFilter);
|
||||
intent.putExtra("dateFromFilter", dateFromFilter);
|
||||
intent.putExtra("dateToFilter", dateToFilter);
|
||||
setResult(1, intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
//set current values coming from parent
|
||||
update_filter_fields();
|
||||
|
||||
filterfrom.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getDate(DATE_FILTER_FROM, dateFromFilter);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
filterto.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getDate(DATE_FILTER_TO, dateToFilter);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public String getKeyByValue(Integer value) {
|
||||
for (Map.Entry<String, Integer> entry : activityKindMap.entrySet()) {
|
||||
if (Objects.equals(value, entry.getValue())) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
}
|
||||
|
||||
public void addListenerOnSpinnerItemSelection() {
|
||||
Spinner spinner = findViewById(R.id.select_kind);
|
||||
spinner.setOnItemSelectedListener(new CustomOnItemSelectedListener());
|
||||
}
|
||||
|
||||
public void update_filter_fields() {
|
||||
TextView filterDateFromDataView = findViewById(R.id.textViewFromData);
|
||||
TextView filterDateToDataView = findViewById(R.id.textViewToData);
|
||||
Button reset_filter_button = findViewById(R.id.reset_filter_button);
|
||||
|
||||
if (dateFromFilter > 0) {
|
||||
filterDateFromDataView.setText(DateTimeUtils.formatDate(new Date(dateFromFilter)));
|
||||
} else {
|
||||
filterDateFromDataView.setText("");
|
||||
}
|
||||
|
||||
if (dateToFilter > 0) {
|
||||
filterDateToDataView.setText(DateTimeUtils.formatDate(new Date(dateToFilter)));
|
||||
} else {
|
||||
filterDateToDataView.setText("");
|
||||
}
|
||||
|
||||
if (dateToFilter < dateFromFilter && dateToFilter > 0) {
|
||||
filterDateFromDataView.setBackgroundColor(Color.RED);
|
||||
filterDateToDataView.setBackgroundColor(Color.RED);
|
||||
} else {
|
||||
filterDateFromDataView.setBackgroundColor(Color.WHITE);
|
||||
filterDateToDataView.setBackgroundColor(Color.WHITE);
|
||||
}
|
||||
|
||||
if (dateToFilter != 0 || dateFromFilter != 0 || activityFilter != 0) {
|
||||
reset_filter_button.setBackgroundColor(this.getResources().getColor(R.color.accent));
|
||||
|
||||
} else {
|
||||
reset_filter_button.setBackgroundColor(this.getResources().getColor(R.color.secondarytext));
|
||||
}
|
||||
}
|
||||
|
||||
public void getDate(final String filter, long currentDatemillis) {
|
||||
Calendar currentDate = Calendar.getInstance();
|
||||
if (currentDatemillis > 0) {
|
||||
currentDate = GregorianCalendar.getInstance();
|
||||
currentDate.setTimeInMillis(currentDatemillis);
|
||||
}
|
||||
|
||||
new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
|
||||
Calendar date = Calendar.getInstance();
|
||||
|
||||
if (filter == DATE_FILTER_FROM) {
|
||||
date.set(year, monthOfYear, dayOfMonth, 0, 0);
|
||||
dateFromFilter = date.getTimeInMillis();
|
||||
} else {
|
||||
date.set(year, monthOfYear, dayOfMonth, 23, 59);
|
||||
dateToFilter = date.getTimeInMillis();
|
||||
}
|
||||
update_filter_fields();
|
||||
}
|
||||
}, currentDate.get(Calendar.YEAR), currentDate.get(Calendar.MONTH), currentDate.get(Calendar.DATE)).show();
|
||||
}
|
||||
|
||||
public class CustomOnItemSelectedListener implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||
activityFilter = activityKindMap.get(parent.getItemAtPosition(pos));
|
||||
update_filter_fields();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -37,6 +37,8 @@ import android.widget.TableRow;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@ -67,6 +69,7 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
private boolean show_raw_data = false;
|
||||
BaseActivitySummary currentItem = null;
|
||||
private int alternateColor;
|
||||
//private Object BottomSheetBehavior;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
@ -77,7 +80,10 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
GBDevice gbDevice = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
||||
final int filter = intent.getIntExtra("filter", 0);
|
||||
final int position = intent.getIntExtra("position", 0);
|
||||
final ActivitySummaryItems items = new ActivitySummaryItems(this, gbDevice, filter);
|
||||
final long dateFromFilter = intent.getLongExtra("dateFromFilter", 0);
|
||||
final long dateToFilter = intent.getLongExtra("dateToFilter", 0);
|
||||
|
||||
final ActivitySummaryItems items = new ActivitySummaryItems(this, gbDevice, filter, dateFromFilter, dateToFilter);
|
||||
final RelativeLayout layout = findViewById(R.id.activity_summary_detail_relative_layout);
|
||||
alternateColor = getAlternateColor(this);
|
||||
|
||||
|
@ -63,6 +63,14 @@ public abstract class AbstractItemAdapter<T> extends ArrayAdapter<T> {
|
||||
this.setActivityKindFilter(activityKind);
|
||||
}
|
||||
|
||||
public void setDateFromFilter(long date){
|
||||
this.setDateFromFilter(date);
|
||||
}
|
||||
|
||||
public void setDateToFilter(long date){
|
||||
this.setDateToFilter(date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup parent) {
|
||||
T item = getItem(position);
|
||||
|
@ -38,11 +38,15 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
public class ActivitySummariesAdapter extends AbstractItemAdapter<BaseActivitySummary> {
|
||||
private final GBDevice device;
|
||||
private int activityKindFilter;
|
||||
long dateFromFilter=0;
|
||||
long dateToFilter=0;
|
||||
|
||||
public ActivitySummariesAdapter(Context context, GBDevice device, int activityKindFilter) {
|
||||
public ActivitySummariesAdapter(Context context, GBDevice device, int activityKindFilter, long dateFromFilter, long dateToFilter) {
|
||||
super(context);
|
||||
this.device = device;
|
||||
this.activityKindFilter = activityKindFilter;
|
||||
this.dateFromFilter=dateFromFilter;
|
||||
this.dateToFilter=dateToFilter;
|
||||
loadItems();
|
||||
}
|
||||
|
||||
@ -53,15 +57,22 @@ public class ActivitySummariesAdapter extends AbstractItemAdapter<BaseActivitySu
|
||||
Device dbDevice = DBHelper.findDevice(device, handler.getDaoSession());
|
||||
|
||||
QueryBuilder<BaseActivitySummary> qb = summaryDao.queryBuilder();
|
||||
if (activityKindFilter !=0){
|
||||
qb.where(
|
||||
BaseActivitySummaryDao.Properties.DeviceId.eq(
|
||||
dbDevice.getId())).orderDesc(BaseActivitySummaryDao.Properties.StartTime);
|
||||
|
||||
if (activityKindFilter !=0) {
|
||||
qb.where(
|
||||
BaseActivitySummaryDao.Properties.DeviceId.eq(dbDevice.getId()),
|
||||
BaseActivitySummaryDao.Properties.ActivityKind.eq(activityKindFilter))
|
||||
.orderDesc(BaseActivitySummaryDao.Properties.StartTime);
|
||||
}else{
|
||||
BaseActivitySummaryDao.Properties.ActivityKind.eq(activityKindFilter));
|
||||
}
|
||||
|
||||
if (dateFromFilter !=0) {
|
||||
qb.where(
|
||||
BaseActivitySummaryDao.Properties.DeviceId.eq(
|
||||
dbDevice.getId())).orderDesc(BaseActivitySummaryDao.Properties.StartTime);
|
||||
BaseActivitySummaryDao.Properties.StartTime.gt(new Date(dateFromFilter)));
|
||||
}
|
||||
if (dateToFilter !=0) {
|
||||
qb.where(
|
||||
BaseActivitySummaryDao.Properties.EndTime.lt(new Date(dateToFilter)));
|
||||
}
|
||||
|
||||
List<BaseActivitySummary> allSummaries = qb.build().list();
|
||||
@ -74,6 +85,13 @@ public class ActivitySummariesAdapter extends AbstractItemAdapter<BaseActivitySu
|
||||
public void setActivityKindFilter(int filter){
|
||||
this.activityKindFilter=filter;
|
||||
}
|
||||
public void setDateFromFilter(long date){
|
||||
this.dateFromFilter=date;
|
||||
}
|
||||
public void setDateToFilter(long date){
|
||||
this.dateToFilter=date;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getName(BaseActivitySummary item) {
|
||||
|
@ -14,11 +14,17 @@ public class ActivitySummaryItems {
|
||||
List<BaseActivitySummary> allItems;
|
||||
ActivitySummariesAdapter itemsAdapter;
|
||||
private int current_position = 0;
|
||||
long dateFromFilter=0;
|
||||
long dateToFilter=0;
|
||||
|
||||
public ActivitySummaryItems(Context context, GBDevice device, int activityKindFilter) {
|
||||
|
||||
public ActivitySummaryItems(Context context, GBDevice device, int activityKindFilter, long dateFromFilter, long dateToFilter) {
|
||||
this.device = device;
|
||||
this.activityKindFilter = activityKindFilter;
|
||||
this.itemsAdapter = new ActivitySummariesAdapter(context, device, activityKindFilter);
|
||||
this.dateFromFilter=dateFromFilter;
|
||||
this.dateToFilter=dateToFilter;
|
||||
this.itemsAdapter = new ActivitySummariesAdapter(context, device, activityKindFilter, dateFromFilter, dateToFilter);
|
||||
|
||||
}
|
||||
|
||||
public BaseActivitySummary getItem(int position){
|
||||
|
10
app/src/main/res/drawable/ic_filter.xml
Normal file
10
app/src/main/res/drawable/ic_filter.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z"/>
|
||||
</vector>
|
@ -1,5 +1,6 @@
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal">
|
||||
@ -9,11 +10,13 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/select_kind"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:spinnerMode="dialog" />
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/list_activity_swipe_layout"
|
||||
|
@ -114,6 +114,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/activity_detail_show_gps_label" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
117
app/src/main/res/layout/sport_activity_filter.xml
Normal file
117
app/src/main/res/layout/sport_activity_filter.xml
Normal file
@ -0,0 +1,117 @@
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp"
|
||||
tools:viewBindingIgnore="true">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-black"
|
||||
android:text="@string/activity_filter_filter_title" />
|
||||
|
||||
<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"
|
||||
android:paddingLeft="0dp"
|
||||
android:spinnerMode="dropdown"
|
||||
android:textAlignment="gravity" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/filterfrom"
|
||||
style="@style/Widget.AppCompat.Spinner.Underlined"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="bottom"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:paddingBottom="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewFromLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/activity_filter_date_from"
|
||||
android:textAlignment="textStart"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewFromData"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingEnd="30dp"
|
||||
android:textAlignment="textStart"
|
||||
android:textSize="18sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/filterto"
|
||||
style="@style/Widget.AppCompat.Spinner.Underlined"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="bottom"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:paddingBottom="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewTolabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/activity_filter_date_to"
|
||||
android:textAlignment="textStart"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewToData"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingEnd="30dp"
|
||||
android:textAlignment="textStart"
|
||||
android:textSize="18sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/reset_filter_button"
|
||||
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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:text="@string/activity_filter_apply_filter" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
@ -7,4 +7,11 @@
|
||||
android:icon="@drawable/ic_reset"
|
||||
android:title="@string/reset_index"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/activity_action_filter"
|
||||
android:icon="@drawable/ic_filter"
|
||||
android:title="@string/pref_header_filter"
|
||||
app:iconTint="@color/primarytext_dark"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
@ -976,6 +976,12 @@
|
||||
<string name="prefs_events_forwarding_startnonwear_broadcast_default_value" translatable="false">nodomain.freeyourgadget.gadgetbridge.StartNonWear</string>
|
||||
<string name="prefs_events_forwarding_broadcast_title">Broadcast message</string>
|
||||
<string name="prefs_events_forwarding_action_title">Run action</string>
|
||||
<string name="pref_header_filter">Sports Activities Filter</string>
|
||||
<string name="activity_filter_date_from">From:</string>
|
||||
<string name="activity_filter_date_to">To:</string>
|
||||
<string name="activity_filter_reset_filter">Reset Filter</string>
|
||||
<string name="activity_filter_filter_title">Filter</string>
|
||||
<string name="activity_filter_apply_filter">Apply Filter</string>
|
||||
|
||||
|
||||
<plurals name="widget_alarm_target_hours">
|
||||
|
Loading…
Reference in New Issue
Block a user