mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
Add edit Sport Summary Name. Add filtering by this name.
This commit is contained in:
parent
c990a4f6fc
commit
9b30369a88
@ -47,6 +47,10 @@ public abstract class AbstractListActivity<T> extends AbstractGBActivity {
|
||||
this.itemAdapter.setDateToFilter(date);
|
||||
}
|
||||
|
||||
public void setNameContainsFilter(String name){
|
||||
this.itemAdapter.setNameContainsFilter(name);
|
||||
}
|
||||
|
||||
public AbstractItemAdapter<T> getItemAdapter() {
|
||||
return itemAdapter;
|
||||
}
|
||||
|
@ -84,7 +84,11 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
int activityFilter=0;
|
||||
long dateFromFilter=0;
|
||||
long dateToFilter=0;
|
||||
String nameContainsFilter;
|
||||
boolean offscreen = true;
|
||||
static final int ACTIVITY_FILTER=1;
|
||||
static final int ACTIVITY_DETAIL=11;
|
||||
|
||||
|
||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@ -141,8 +145,9 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
bundle.putInt("activityFilter",activityFilter);
|
||||
bundle.putLong("dateFromFilter",dateFromFilter);
|
||||
bundle.putLong("dateToFilter",dateToFilter);
|
||||
bundle.putString("nameContainsFilter",nameContainsFilter);
|
||||
filterIntent.putExtras(bundle);
|
||||
startActivityForResult(filterIntent,1);
|
||||
startActivityForResult(filterIntent,ACTIVITY_FILTER);
|
||||
return true;
|
||||
case R.id.activity_action_calculate_summary_stats:
|
||||
processSummaryStatistics();
|
||||
@ -224,15 +229,21 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
@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);
|
||||
if (requestCode == ACTIVITY_FILTER && resultData != null) {
|
||||
activityFilter = resultData.getIntExtra("activityFilter", 0);
|
||||
dateFromFilter = resultData.getLongExtra("dateFromFilter", 0);
|
||||
dateToFilter = resultData.getLongExtra("dateToFilter", 0);
|
||||
nameContainsFilter = resultData.getStringExtra("nameContainsFilter");
|
||||
setActivityKindFilter(activityFilter);
|
||||
setDateFromFilter(dateFromFilter);
|
||||
setDateToFilter(dateToFilter);
|
||||
setNameContainsFilter(nameContainsFilter);
|
||||
refresh();
|
||||
}
|
||||
if (requestCode == ACTIVITY_DETAIL) {
|
||||
refresh();
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -249,7 +260,7 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setItemAdapter(new ActivitySummariesAdapter(this, mGBDevice,activityFilter,dateFromFilter,dateToFilter));
|
||||
setItemAdapter(new ActivitySummariesAdapter(this, mGBDevice,activityFilter,dateFromFilter,dateToFilter,nameContainsFilter));
|
||||
|
||||
getItemListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
@ -416,12 +427,14 @@ public class ActivitySummariesActivity extends AbstractListActivity<BaseActivity
|
||||
ActivitySummaryDetailIntent.putExtra("filter", activityFilter);
|
||||
ActivitySummaryDetailIntent.putExtra("dateFromFilter",dateFromFilter);
|
||||
ActivitySummaryDetailIntent.putExtra("dateToFilter",dateToFilter);
|
||||
ActivitySummaryDetailIntent.putExtra("nameContainsFilter",nameContainsFilter);
|
||||
|
||||
ActivitySummaryDetailIntent.putExtra(GBDevice.EXTRA_DEVICE, mGBDevice);
|
||||
startActivity(ActivitySummaryDetailIntent);
|
||||
|
||||
startActivityForResult(ActivitySummaryDetailIntent,ACTIVITY_DETAIL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void fetchTrackData() {
|
||||
if (mGBDevice.isInitialized() && !mGBDevice.isBusy()) {
|
||||
GBApplication.deviceService().onFetchRecordedData(RecordedDataTypes.TYPE_GPS_TRACKS);
|
||||
|
@ -16,13 +16,14 @@
|
||||
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.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.TypedValue;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -30,8 +31,8 @@ import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -48,7 +49,6 @@ 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;
|
||||
|
||||
|
||||
@ -59,6 +59,7 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
int activityFilter = 0;
|
||||
long dateFromFilter = 0;
|
||||
long dateToFilter = 0;
|
||||
String nameContainsFilter;
|
||||
HashMap<String, Integer> activityKindMap = new HashMap<>(1);
|
||||
int BACKGROUND_COLOR;
|
||||
|
||||
@ -78,12 +79,14 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
activityFilter = bundle.getInt("activityFilter", 0);
|
||||
dateFromFilter = bundle.getLong("dateFromFilter", 0);
|
||||
dateToFilter = bundle.getLong("dateToFilter", 0);
|
||||
nameContainsFilter = bundle.getString("nameContainsFilter");
|
||||
|
||||
Context appContext = this.getApplicationContext();
|
||||
if (appContext instanceof GBApplication) {
|
||||
setContentView(R.layout.sport_activity_filter);
|
||||
}
|
||||
BACKGROUND_COLOR = GBApplication.getBackgroundColor(appContext);;
|
||||
BACKGROUND_COLOR = GBApplication.getBackgroundColor(appContext);
|
||||
;
|
||||
|
||||
//get spinner ready - assign data, set selected item...
|
||||
final Spinner filterKindSpinner = findViewById(R.id.select_kind);
|
||||
@ -98,19 +101,39 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
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() {
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start,
|
||||
int count, int after) {
|
||||
}
|
||||
|
||||
public void onTextChanged(CharSequence s, int start,
|
||||
int before, int count) {
|
||||
nameContainsFilter = s.toString();
|
||||
update_filter_fields();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
reset_filter_button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
activityFilter = 0;
|
||||
dateFromFilter = 0;
|
||||
dateToFilter = 0;
|
||||
nameContainsFilter = "";
|
||||
filterKindSpinner.setSelection(0);
|
||||
update_filter_fields();
|
||||
}
|
||||
@ -119,10 +142,16 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
apply_filter_button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String text = nameContainsFilterdata.getText().toString();
|
||||
if (text != null && text.length() > 0) {
|
||||
nameContainsFilter = text;
|
||||
}
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("activityFilter", activityFilter);
|
||||
intent.putExtra("dateFromFilter", dateFromFilter);
|
||||
intent.putExtra("dateToFilter", dateToFilter);
|
||||
intent.putExtra("nameContainsFilter", nameContainsFilter);
|
||||
setResult(1, intent);
|
||||
finish();
|
||||
}
|
||||
@ -167,6 +196,7 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
TextView filterDateFromDataView = findViewById(R.id.textViewFromData);
|
||||
TextView filterDateToDataView = findViewById(R.id.textViewToData);
|
||||
Button reset_filter_button = findViewById(R.id.reset_filter_button);
|
||||
final EditText nameContainsFilterdata = findViewById(R.id.textViewNameData);
|
||||
|
||||
if (dateFromFilter > 0) {
|
||||
filterDateFromDataView.setText(DateTimeUtils.formatDate(new Date(dateFromFilter)));
|
||||
@ -187,8 +217,10 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
filterDateFromDataView.setBackgroundColor(BACKGROUND_COLOR);
|
||||
filterDateToDataView.setBackgroundColor(BACKGROUND_COLOR);
|
||||
}
|
||||
|
||||
if (dateToFilter != 0 || dateFromFilter != 0 || activityFilter != 0) {
|
||||
if (nameContainsFilter != null && !nameContainsFilter.equals(nameContainsFilterdata.getText().toString())) {
|
||||
nameContainsFilterdata.setText(nameContainsFilter);
|
||||
}
|
||||
if (dateToFilter != 0 || dateFromFilter != 0 || activityFilter != 0 || nameContainsFilterdata.length() > 0) {
|
||||
reset_filter_button.setBackgroundColor(this.getResources().getColor(R.color.accent));
|
||||
|
||||
} else {
|
||||
@ -220,6 +252,17 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
}, currentDate.get(Calendar.YEAR), currentDate.get(Calendar.MONTH), currentDate.get(Calendar.DATE)).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
// back button
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public class CustomOnItemSelectedListener implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||
@ -234,15 +277,4 @@ public class ActivitySummariesFilter extends AbstractGBActivity {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
// back button
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,11 +18,14 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.MenuItem;
|
||||
@ -30,6 +33,7 @@ import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TableLayout;
|
||||
@ -49,6 +53,7 @@ import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
@ -62,7 +67,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.SwipeEvents;
|
||||
|
||||
public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ActivitySummaryDetail.class);
|
||||
|
||||
private GBDevice gbDevice;
|
||||
|
||||
private boolean show_raw_data = false;
|
||||
BaseActivitySummary currentItem = null;
|
||||
@ -73,15 +78,20 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_summary_details);
|
||||
final Context appContext = this.getApplicationContext();
|
||||
if (appContext instanceof GBApplication) {
|
||||
setContentView(R.layout.activity_summary_details);
|
||||
}
|
||||
|
||||
Intent intent = getIntent();
|
||||
GBDevice gbDevice = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
||||
gbDevice = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
||||
final int filter = intent.getIntExtra("filter", 0);
|
||||
final int position = intent.getIntExtra("position", 0);
|
||||
final long dateFromFilter = intent.getLongExtra("dateFromFilter", 0);
|
||||
final long dateToFilter = intent.getLongExtra("dateToFilter", 0);
|
||||
final String nameContainsFilter = intent.getStringExtra("nameContainsFilter");
|
||||
|
||||
final ActivitySummaryItems items = new ActivitySummaryItems(this, gbDevice, filter, dateFromFilter, dateToFilter);
|
||||
final ActivitySummaryItems items = new ActivitySummaryItems(this, gbDevice, filter, dateFromFilter, dateToFilter, nameContainsFilter);
|
||||
final LinearLayout layout = findViewById(R.id.activity_summary_detail_relative_layout);
|
||||
alternateColor = getAlternateColor(this);
|
||||
|
||||
@ -113,10 +123,11 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
makeSummaryContent(currentItem);
|
||||
layout.startAnimation(animFadeRight);
|
||||
|
||||
}else{
|
||||
} else {
|
||||
layout.startAnimation(animBounceRight);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwipeLeft() {
|
||||
currentItem = items.getPrevItem();
|
||||
@ -124,7 +135,7 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
makeSummaryHeader(currentItem);
|
||||
makeSummaryContent(currentItem);
|
||||
layout.startAnimation(animFadeLeft);
|
||||
}else{
|
||||
} else {
|
||||
layout.startAnimation(animBounceLeft);
|
||||
}
|
||||
}
|
||||
@ -141,7 +152,7 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
ImageView activity_icon = findViewById(R.id.item_image);
|
||||
activity_icon.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
public boolean onLongClick(View v) {
|
||||
show_raw_data=!show_raw_data;
|
||||
show_raw_data = !show_raw_data;
|
||||
if (currentItem != null) {
|
||||
makeSummaryHeader(currentItem);
|
||||
makeSummaryContent(currentItem);
|
||||
@ -150,10 +161,45 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
}
|
||||
});
|
||||
|
||||
ImageView activity_summary_detail_edit_name_image = findViewById(R.id.activity_summary_detail_edit_name);
|
||||
activity_summary_detail_edit_name_image.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final EditText input = new EditText(ActivitySummaryDetail.this);
|
||||
input.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
String name = currentItem.getName();
|
||||
input.setText((name != null) ? name : "");
|
||||
|
||||
new AlertDialog.Builder(ActivitySummaryDetail.this) // TODO: very raw at this point, make better drawable layout, already started here: R.style.GadgetbridgeTheme_DialogTheme)
|
||||
.setView(input)
|
||||
.setCancelable(true)
|
||||
.setTitle(ActivitySummaryDetail.this.getString(R.string.activity_summary_edit_name_title))
|
||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
String name = input.getText().toString();
|
||||
currentItem.setName(name);
|
||||
currentItem.update();
|
||||
makeSummaryHeader(currentItem);
|
||||
makeSummaryContent(currentItem);
|
||||
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// do nothing
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void makeSummaryHeader(BaseActivitySummary item){
|
||||
private void makeSummaryHeader(BaseActivitySummary item) {
|
||||
//make view of data from main part of item
|
||||
final String gpxTrack = item.getGpxTrack();
|
||||
Button show_track_btn = findViewById(R.id.showTrack);
|
||||
@ -172,6 +218,7 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
});
|
||||
}
|
||||
String activitykindname = ActivityKind.asString(item.getActivityKind(), getApplicationContext());
|
||||
String activityname = item.getName();
|
||||
Date starttime = item.getStartTime();
|
||||
Date endtime = item.getEndTime();
|
||||
String starttimeS = DateTimeUtils.formatDateTime(starttime);
|
||||
@ -183,6 +230,10 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
|
||||
TextView activity_kind = findViewById(R.id.activitykind);
|
||||
activity_kind.setText(activitykindname);
|
||||
|
||||
TextView activity_name = findViewById(R.id.activityname);
|
||||
activity_name.setText(activityname);
|
||||
|
||||
TextView start_time = findViewById(R.id.starttime);
|
||||
start_time.setText(starttimeS);
|
||||
TextView end_time = findViewById(R.id.endtime);
|
||||
@ -239,7 +290,7 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
unit = "km_h";
|
||||
break;
|
||||
case "seconds_m":
|
||||
value = value * (1000/60);
|
||||
value = value * (1000 / 60);
|
||||
unit = "minutes_km";
|
||||
break;
|
||||
case "seconds_km":
|
||||
@ -277,8 +328,6 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static int getAlternateColor(Context context) {
|
||||
TypedValue typedValue = new TypedValue();
|
||||
Resources.Theme theme = context.getTheme();
|
||||
@ -289,10 +338,10 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
private String getStringResourceByName(String aString) {
|
||||
String packageName = getPackageName();
|
||||
int resId = getResources().getIdentifier(aString, "string", packageName);
|
||||
if (resId==0){
|
||||
if (resId == 0) {
|
||||
//LOG.warn("SportsActivity " + "Missing string in strings:" + aString);
|
||||
return aString;
|
||||
}else{
|
||||
} else {
|
||||
return getString(resId);
|
||||
}
|
||||
}
|
||||
@ -308,4 +357,5 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -71,6 +71,10 @@ public abstract class AbstractItemAdapter<T> extends ArrayAdapter<T> {
|
||||
this.setDateToFilter(date);
|
||||
}
|
||||
|
||||
public void setNameContainsFilter(String name){
|
||||
this.setNameContainsFilter(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup parent) {
|
||||
T item = getItem(position);
|
||||
|
@ -40,13 +40,15 @@ public class ActivitySummariesAdapter extends AbstractItemAdapter<BaseActivitySu
|
||||
private int activityKindFilter;
|
||||
long dateFromFilter=0;
|
||||
long dateToFilter=0;
|
||||
String nameContainsFilter;
|
||||
|
||||
public ActivitySummariesAdapter(Context context, GBDevice device, int activityKindFilter, long dateFromFilter, long dateToFilter) {
|
||||
public ActivitySummariesAdapter(Context context, GBDevice device, int activityKindFilter, long dateFromFilter, long dateToFilter, String nameContainsFilter) {
|
||||
super(context);
|
||||
this.device = device;
|
||||
this.activityKindFilter = activityKindFilter;
|
||||
this.dateFromFilter=dateFromFilter;
|
||||
this.dateToFilter=dateToFilter;
|
||||
this.nameContainsFilter=nameContainsFilter;
|
||||
loadItems();
|
||||
}
|
||||
|
||||
@ -74,6 +76,10 @@ public class ActivitySummariesAdapter extends AbstractItemAdapter<BaseActivitySu
|
||||
qb.where(
|
||||
BaseActivitySummaryDao.Properties.EndTime.lt(new Date(dateToFilter)));
|
||||
}
|
||||
if (nameContainsFilter !=null && nameContainsFilter.length() > 0) {
|
||||
qb.where(
|
||||
BaseActivitySummaryDao.Properties.Name.like("%" + nameContainsFilter + "%"));
|
||||
}
|
||||
|
||||
List<BaseActivitySummary> allSummaries = qb.build().list();
|
||||
setItems(allSummaries, true);
|
||||
@ -91,18 +97,26 @@ public class ActivitySummariesAdapter extends AbstractItemAdapter<BaseActivitySu
|
||||
public void setDateToFilter(long date){
|
||||
this.dateToFilter=date;
|
||||
}
|
||||
public void setNameContainsFilter(String name){
|
||||
this.nameContainsFilter=name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getName(BaseActivitySummary item) {
|
||||
|
||||
|
||||
|
||||
|
||||
String name = item.getName();
|
||||
if (name != null && name.length() > 0) {
|
||||
return name;
|
||||
if (name == null) name="";
|
||||
String gpxTrack = item.getGpxTrack();
|
||||
String hasGps = " ";
|
||||
if (gpxTrack != null) {
|
||||
hasGps=" 🛰️ ";
|
||||
}
|
||||
return ActivityKind.asString(item.getActivityKind(), getContext())+ hasGps + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDetails(BaseActivitySummary item) {
|
||||
|
||||
|
||||
Date startTime = item.getStartTime();
|
||||
Long duration = (item.getEndTime().getTime() - item.getStartTime().getTime());
|
||||
@ -111,21 +125,9 @@ public class ActivitySummariesAdapter extends AbstractItemAdapter<BaseActivitySu
|
||||
return DateTimeUtils.formatDateTime(startTime) + " (" + DateTimeUtils.formatDurationHoursMinutes(duration, TimeUnit.MILLISECONDS) + ")";
|
||||
}
|
||||
|
||||
|
||||
|
||||
return "Unknown activity";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDetails(BaseActivitySummary item) {
|
||||
String gpxTrack = item.getGpxTrack();
|
||||
String hasGps = "";
|
||||
if (gpxTrack != null) {
|
||||
hasGps=" 🛰️";
|
||||
}
|
||||
return ActivityKind.asString(item.getActivityKind(), getContext())+ hasGps;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIcon(BaseActivitySummary item) {
|
||||
return ActivityKind.getIconId(item.getActivityKind());
|
||||
|
@ -18,13 +18,12 @@ public class ActivitySummaryItems {
|
||||
long dateToFilter=0;
|
||||
|
||||
|
||||
public ActivitySummaryItems(Context context, GBDevice device, int activityKindFilter, long dateFromFilter, long dateToFilter) {
|
||||
public ActivitySummaryItems(Context context, GBDevice device, int activityKindFilter, long dateFromFilter, long dateToFilter, String nameContainsFilter) {
|
||||
this.device = device;
|
||||
this.activityKindFilter = activityKindFilter;
|
||||
this.dateFromFilter=dateFromFilter;
|
||||
this.dateToFilter=dateToFilter;
|
||||
this.itemsAdapter = new ActivitySummariesAdapter(context, device, activityKindFilter, dateFromFilter, dateToFilter);
|
||||
|
||||
this.itemsAdapter = new ActivitySummariesAdapter(context, device, activityKindFilter, dateFromFilter, dateToFilter, nameContainsFilter);
|
||||
}
|
||||
|
||||
public BaseActivitySummary getItem(int position){
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/activity_summary_detail_relative_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
@ -36,14 +37,42 @@
|
||||
android:paddingEnd="8dp">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/activitykind"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-black"
|
||||
android:maxLines="1"
|
||||
android:scrollHorizontally="false"
|
||||
android:textSize="18sp" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/activitykind"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-black"
|
||||
android:maxLines="1"
|
||||
android:paddingEnd="10dp"
|
||||
android:scrollHorizontally="false"
|
||||
android:textSize="18sp" />
|
||||
<TextView
|
||||
android:id="@+id/activityname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-black"
|
||||
android:maxLines="1"
|
||||
android:scrollHorizontally="false"
|
||||
android:textSize="18sp" />
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/activity_summary_detail_edit_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:layout_weight="0.1"
|
||||
android:scaleType="fitEnd"
|
||||
app:srcCompat="@android:drawable/ic_menu_edit" />
|
||||
</LinearLayout>
|
||||
|
||||
<TableLayout
|
||||
android:id="@+id/summaryHeader"
|
||||
|
@ -27,6 +27,41 @@
|
||||
android:spinnerMode="dropdown"
|
||||
android:textAlignment="gravity" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/filtername"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/abc_spinner_textfield_background_material"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:paddingBottom="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewNamelabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/activity_filter_name_contains"
|
||||
android:textAlignment="textStart"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/textViewNameData"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text"
|
||||
android:textAlignment="textStart"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/filterfrom"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -706,6 +706,7 @@
|
||||
<string name="activity_type_unknown">Unknown activity</string>
|
||||
<string name="activity_summaries">Sport Activities</string>
|
||||
<string name="activity_summary_detail">Sport Activity Detail</string>
|
||||
<string name="activity_summary_edit_name_title">Edit name</string>
|
||||
<string name="activity_type_biking">Biking</string>
|
||||
<string name="activity_type_treadmill">Treadmill</string>
|
||||
<string name="activity_type_exercise">Exercise</string>
|
||||
@ -982,8 +983,10 @@
|
||||
<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_name_contains">Name</string>
|
||||
<string name="activity_filter_apply_filter">Apply Filter</string>
|
||||
<string name="activity_summaries_statistics">Statistics</string>
|
||||
|
||||
<!-- swim styles -->
|
||||
<string name="breaststroke">Breaststroke</string>
|
||||
<string name="freestyle">Freestyle</string>
|
||||
|
@ -66,4 +66,20 @@
|
||||
<item name="android:windowBackground">@drawable/splash</item>
|
||||
</style>
|
||||
|
||||
<!-- initial start of work on a Dialog Alert popup, TODO: continue -->
|
||||
<style name="GadgetbridgeTheme.DialogTheme">
|
||||
<!-- Fill the screen -->
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
|
||||
<!-- No backgrounds, titles or window float
|
||||
<item name="android:windowBackground">@null</item>
|
||||
-->
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
|
||||
<!-- Just to prove it's working
|
||||
<item name="android:background">#ff0000</item>
|
||||
-->
|
||||
</style>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user