mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Activity details: Refactor header
This commit is contained in:
parent
98775b752b
commit
427b7c7557
@ -22,7 +22,6 @@ import static nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries.
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@ -31,6 +30,7 @@ import android.graphics.Typeface;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
|
import android.text.format.DateUtils;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -44,6 +44,7 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.gridlayout.widget.GridLayout;
|
import androidx.gridlayout.widget.GridLayout;
|
||||||
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -102,7 +103,6 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(ActivitySummaryDetail.class);
|
private static final Logger LOG = LoggerFactory.getLogger(ActivitySummaryDetail.class);
|
||||||
BaseActivitySummary currentItem = null;
|
BaseActivitySummary currentItem = null;
|
||||||
private GBDevice gbDevice;
|
private GBDevice gbDevice;
|
||||||
private int alternateColor;
|
|
||||||
private Menu mOptionsMenu;
|
private Menu mOptionsMenu;
|
||||||
List<String> filesGpxList = new ArrayList<>();
|
List<String> filesGpxList = new ArrayList<>();
|
||||||
int selectedGpxIndex;
|
int selectedGpxIndex;
|
||||||
@ -155,7 +155,6 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
final ActivitySummaryItems items = new ActivitySummaryItems(this, gbDevice, activityFilter, dateFromFilter, dateToFilter, nameContainsFilter, deviceFilter, itemsFilter);
|
final ActivitySummaryItems items = new ActivitySummaryItems(this, gbDevice, activityFilter, dateFromFilter, dateToFilter, nameContainsFilter, deviceFilter, itemsFilter);
|
||||||
final ScrollView layout = findViewById(R.id.activity_summary_detail_scroll_layout);
|
final ScrollView layout = findViewById(R.id.activity_summary_detail_scroll_layout);
|
||||||
//final LinearLayout layout = findViewById(R.id.activity_summary_detail_relative_layout);
|
//final LinearLayout layout = findViewById(R.id.activity_summary_detail_relative_layout);
|
||||||
alternateColor = getAlternateColor(this);
|
|
||||||
|
|
||||||
final Animation animFadeRight;
|
final Animation animFadeRight;
|
||||||
final Animation animFadeLeft;
|
final Animation animFadeLeft;
|
||||||
@ -227,99 +226,6 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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 : "");
|
|
||||||
FrameLayout container = new FrameLayout(ActivitySummaryDetail.this);
|
|
||||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
||||||
params.leftMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
|
|
||||||
params.rightMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
|
|
||||||
input.setLayoutParams(params);
|
|
||||||
container.addView(input);
|
|
||||||
|
|
||||||
new MaterialAlertDialogBuilder(ActivitySummaryDetail.this)
|
|
||||||
.setView(container)
|
|
||||||
.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();
|
|
||||||
if (name.length() < 1) name = null;
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ImageView activity_summary_detail_edit_gps = findViewById(R.id.activity_summary_detail_edit_gps);
|
|
||||||
activity_summary_detail_edit_gps.setOnClickListener(new View.OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
export_path = get_path();
|
|
||||||
filesGpxList = get_gpx_file_list();
|
|
||||||
|
|
||||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(ActivitySummaryDetail.this);
|
|
||||||
builder.setTitle(R.string.activity_summary_detail_select_gpx_track);
|
|
||||||
ArrayAdapter<String> directory_listing = new ArrayAdapter<String>(ActivitySummaryDetail.this, android.R.layout.simple_list_item_1, filesGpxList);
|
|
||||||
builder.setSingleChoiceItems(directory_listing, 0, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
selectedGpxIndex = which;
|
|
||||||
selectedGpxFile = export_path + "/" + filesGpxList.get(selectedGpxIndex);
|
|
||||||
String message = String.format("%s %s?", getString(R.string.set), filesGpxList.get(selectedGpxIndex));
|
|
||||||
if (selectedGpxIndex == 0) {
|
|
||||||
selectedGpxFile = null;
|
|
||||||
message = String.format("%s?", getString(R.string.activity_summary_detail_clear_gpx_track));
|
|
||||||
}
|
|
||||||
|
|
||||||
new MaterialAlertDialogBuilder(ActivitySummaryDetail.this)
|
|
||||||
.setCancelable(true)
|
|
||||||
.setIcon(R.drawable.ic_warning)
|
|
||||||
.setTitle(R.string.activity_summary_detail_editing_gpx_track)
|
|
||||||
.setMessage(message)
|
|
||||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
currentItem.setGpxTrack(selectedGpxFile);
|
|
||||||
currentItem.update();
|
|
||||||
if (itemHasGps()) {
|
|
||||||
showGpsCanvas();
|
|
||||||
activitySummariesGpsFragment.set_data(getTrackFile());
|
|
||||||
} else {
|
|
||||||
hideGpsCanvas();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show();
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
AlertDialog dialog = builder.create();
|
|
||||||
dialog.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeSummaryHeader(BaseActivitySummary item) {
|
private void makeSummaryHeader(BaseActivitySummary item) {
|
||||||
@ -328,32 +234,45 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
String activityname = item.getName();
|
String activityname = item.getName();
|
||||||
Date starttime = item.getStartTime();
|
Date starttime = item.getStartTime();
|
||||||
Date endtime = item.getEndTime();
|
Date endtime = item.getEndTime();
|
||||||
String starttimeS = String.format("%s, %s", DateTimeUtils.formatDate(starttime), DateTimeUtils.formatTime(starttime.getHours(), starttime.getMinutes()));
|
|
||||||
String endtimeS = String.format("%s, %s", DateTimeUtils.formatDate(endtime), DateTimeUtils.formatTime(endtime.getHours(), endtime.getMinutes()));
|
|
||||||
String durationhms = DateTimeUtils.formatDurationHoursMinutes((endtime.getTime() - starttime.getTime()), TimeUnit.MILLISECONDS);
|
String durationhms = DateTimeUtils.formatDurationHoursMinutes((endtime.getTime() - starttime.getTime()), TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
ImageView activity_icon = findViewById(R.id.item_image);
|
ImageView activity_icon = findViewById(R.id.item_image);
|
||||||
activity_icon.setImageResource(ActivityKind.fromCode(item.getActivityKind()).getIcon());
|
activity_icon.setImageResource(ActivityKind.fromCode(item.getActivityKind()).getIcon());
|
||||||
|
|
||||||
TextView activity_kind = findViewById(R.id.activitykind);
|
final ActionBar actionBar = getSupportActionBar();
|
||||||
activity_kind.setText(activitykindname);
|
if (actionBar != null) {
|
||||||
|
actionBar.setTitle(activitykindname);
|
||||||
|
}
|
||||||
|
|
||||||
TextView activity_name = findViewById(R.id.activityname);
|
TextView activity_name = findViewById(R.id.activityname);
|
||||||
activity_name.setText(activityname);
|
activity_name.setText(activityname);
|
||||||
|
|
||||||
if (StringUtils.isBlank(activityname)) {
|
if (StringUtils.isBlank(activityname)) {
|
||||||
activity_name.setVisibility(View.GONE);
|
activity_name.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
activity_name.setVisibility(View.VISIBLE);
|
activity_name.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView start_time = findViewById(R.id.starttime);
|
TextView activityDateTextView = findViewById(R.id.activitydate);
|
||||||
start_time.setText(starttimeS);
|
|
||||||
TextView end_time = findViewById(R.id.endtime);
|
|
||||||
end_time.setText(endtimeS);
|
|
||||||
TextView activity_duration = findViewById(R.id.duration);
|
|
||||||
activity_duration.setText(durationhms);
|
|
||||||
|
|
||||||
|
final Context context = activityDateTextView.getContext();
|
||||||
|
final String timeString;
|
||||||
|
if (DateTimeUtils.isSameDay(starttime, endtime)) {
|
||||||
|
timeString = context.getString(
|
||||||
|
R.string.date_placeholders__start_time__end_time,
|
||||||
|
DateTimeUtils.formatDateTimeRelative(context, starttime),
|
||||||
|
DateTimeUtils.formatTime(endtime.getHours(), endtime.getMinutes())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
timeString = context.getString(
|
||||||
|
R.string.date_placeholders__start_time__end_time,
|
||||||
|
DateTimeUtils.formatDateTimeRelative(context, starttime),
|
||||||
|
DateTimeUtils.formatDateTimeRelative(context, endtime)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
activityDateTextView.setText(timeString);
|
||||||
|
|
||||||
|
TextView activityTimeTextView = findViewById(R.id.activityduration);
|
||||||
|
activityTimeTextView.setText(durationhms);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshFromCurrentItem() {
|
private void refreshFromCurrentItem() {
|
||||||
@ -439,7 +358,7 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
TextView label_field = new TextView(ActivitySummaryDetail.this);
|
TextView label_field = new TextView(ActivitySummaryDetail.this);
|
||||||
label_field.setId(View.generateViewId());
|
label_field.setId(View.generateViewId());
|
||||||
label_field.setTextSize(18);
|
label_field.setTextSize(18);
|
||||||
label_field.setPadding(dpToPx(8), dpToPx(20), 0, dpToPx(20));
|
label_field.setPaddingRelative(dpToPx(16), dpToPx(16), 0, dpToPx(16));
|
||||||
label_field.setTypeface(null, Typeface.BOLD);
|
label_field.setTypeface(null, Typeface.BOLD);
|
||||||
label_field.setText(workoutValueFormatter.getStringResourceByName(groupKey));
|
label_field.setText(workoutValueFormatter.getStringResourceByName(groupKey));
|
||||||
label_row.addView(label_field);
|
label_row.addView(label_field);
|
||||||
@ -534,10 +453,86 @@ public class ActivitySummaryDetail extends AbstractGBActivity {
|
|||||||
} else if (itemId == R.id.activity_action_dev_share_json_details) {
|
} else if (itemId == R.id.activity_action_dev_share_json_details) {
|
||||||
shareJsonDetails(ActivitySummaryDetail.this, currentItem);
|
shareJsonDetails(ActivitySummaryDetail.this, currentItem);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (itemId == R.id.activity_summary_detail_action_edit_name) {
|
||||||
|
editLabel();
|
||||||
|
return true;
|
||||||
|
} else if (itemId == R.id.activity_summary_detail_action_edit_gps) {
|
||||||
|
editGps();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void editLabel() {
|
||||||
|
final EditText input = new EditText(ActivitySummaryDetail.this);
|
||||||
|
input.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||||
|
String name = currentItem.getName();
|
||||||
|
input.setText((name != null) ? name : "");
|
||||||
|
FrameLayout container = new FrameLayout(ActivitySummaryDetail.this);
|
||||||
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
params.leftMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
|
||||||
|
params.rightMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin);
|
||||||
|
input.setLayoutParams(params);
|
||||||
|
container.addView(input);
|
||||||
|
|
||||||
|
new MaterialAlertDialogBuilder(ActivitySummaryDetail.this)
|
||||||
|
.setView(container)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setTitle(ActivitySummaryDetail.this.getString(R.string.activity_summary_edit_name_title))
|
||||||
|
.setPositiveButton(R.string.ok, (dialog, which) -> {
|
||||||
|
String name1 = input.getText().toString();
|
||||||
|
if (name1.isEmpty()) name1 = null;
|
||||||
|
currentItem.setName(name1);
|
||||||
|
currentItem.update();
|
||||||
|
makeSummaryHeader(currentItem);
|
||||||
|
makeSummaryContent(currentItem);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.Cancel, (dialog, which) -> {
|
||||||
|
// do nothing
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editGps() {
|
||||||
|
export_path = get_path();
|
||||||
|
filesGpxList = get_gpx_file_list();
|
||||||
|
|
||||||
|
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(ActivitySummaryDetail.this);
|
||||||
|
builder.setTitle(R.string.activity_summary_detail_select_gpx_track);
|
||||||
|
ArrayAdapter<String> directory_listing = new ArrayAdapter<>(ActivitySummaryDetail.this, android.R.layout.simple_list_item_1, filesGpxList);
|
||||||
|
builder.setSingleChoiceItems(directory_listing, 0, (dialog, which) -> {
|
||||||
|
selectedGpxIndex = which;
|
||||||
|
selectedGpxFile = export_path + "/" + filesGpxList.get(selectedGpxIndex);
|
||||||
|
String message = String.format("%s %s?", getString(R.string.set), filesGpxList.get(selectedGpxIndex));
|
||||||
|
if (selectedGpxIndex == 0) {
|
||||||
|
selectedGpxFile = null;
|
||||||
|
message = String.format("%s?", getString(R.string.activity_summary_detail_clear_gpx_track));
|
||||||
|
}
|
||||||
|
|
||||||
|
new MaterialAlertDialogBuilder(ActivitySummaryDetail.this)
|
||||||
|
.setCancelable(true)
|
||||||
|
.setIcon(R.drawable.ic_warning)
|
||||||
|
.setTitle(R.string.activity_summary_detail_editing_gpx_track)
|
||||||
|
.setMessage(message)
|
||||||
|
.setPositiveButton(R.string.ok, (dialog1, which1) -> {
|
||||||
|
currentItem.setGpxTrack(selectedGpxFile);
|
||||||
|
currentItem.update();
|
||||||
|
if (itemHasGps()) {
|
||||||
|
showGpsCanvas();
|
||||||
|
activitySummariesGpsFragment.set_data(getTrackFile());
|
||||||
|
} else {
|
||||||
|
hideGpsCanvas();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.Cancel, (dialog2, which2) -> {
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
private void take_share_screenshot(Context context) {
|
private void take_share_screenshot(Context context) {
|
||||||
final ScrollView layout = findViewById(R.id.activity_summary_detail_scroll_layout);
|
final ScrollView layout = findViewById(R.id.activity_summary_detail_scroll_layout);
|
||||||
final int width = layout.getChildAt(0).getWidth();
|
final int width = layout.getChildAt(0).getWidth();
|
||||||
|
@ -131,7 +131,7 @@ public class ActivityListItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (date != null) {
|
if (date != null) {
|
||||||
dateLabel.setText(formatDate(date));
|
dateLabel.setText(DateTimeUtils.formatDateTimeRelative(rootView.getContext(), date));
|
||||||
dateLabel.setVisibility(View.VISIBLE);
|
dateLabel.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
dateLabel.setVisibility(View.GONE);
|
dateLabel.setVisibility(View.GONE);
|
||||||
@ -162,23 +162,6 @@ public class ActivityListItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatDate(final Date date) {
|
|
||||||
if (date != null) {
|
|
||||||
final String activityDay;
|
|
||||||
if (DateUtils.isToday(date.getTime())) {
|
|
||||||
activityDay = rootView.getContext().getString(R.string.activity_summary_today);
|
|
||||||
} else if (DateTimeUtils.isYesterday(date)) {
|
|
||||||
activityDay = rootView.getContext().getString(R.string.activity_summary_yesterday);
|
|
||||||
} else {
|
|
||||||
activityDay = DateTimeUtils.formatDate(date, DateUtils.FORMAT_SHOW_WEEKDAY);
|
|
||||||
}
|
|
||||||
final String activityTime = DateTimeUtils.formatTime(date.getHours(), date.getMinutes());
|
|
||||||
return String.format("%s, %s", activityDay, activityTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rootView.getContext().getString(R.string.unknown);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getThemedColor(Context context, int resid) {
|
public static int getThemedColor(Context context, int resid) {
|
||||||
TypedValue typedValue = new TypedValue();
|
TypedValue typedValue = new TypedValue();
|
||||||
Resources.Theme theme = context.getTheme();
|
Resources.Theme theme = context.getTheme();
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.util;
|
package nodomain.freeyourgadget.gadgetbridge.util;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
|
|
||||||
import com.github.pfichtner.durationformatter.DurationFormatter;
|
import com.github.pfichtner.durationformatter.DurationFormatter;
|
||||||
@ -34,6 +35,7 @@ import java.util.TimeZone;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
|
||||||
public class DateTimeUtils {
|
public class DateTimeUtils {
|
||||||
private static SimpleDateFormat DAY_STORAGE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
|
private static SimpleDateFormat DAY_STORAGE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
|
||||||
@ -256,6 +258,22 @@ public class DateTimeUtils {
|
|||||||
&& calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH);
|
&& calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether two Date instances are on the same day
|
||||||
|
*
|
||||||
|
* @param date1 The first date to compare
|
||||||
|
* @param date2 The second date to compare
|
||||||
|
* @return true if the Date instances are on the same day
|
||||||
|
*/
|
||||||
|
public static boolean isSameDay(Date date1, Date date2) {
|
||||||
|
final Calendar calendar1 = GregorianCalendar.getInstance();
|
||||||
|
calendar1.setTime(date1);
|
||||||
|
final Calendar calendar2 = GregorianCalendar.getInstance();
|
||||||
|
calendar2.setTime(date2);
|
||||||
|
|
||||||
|
return isSameDay(calendar1, calendar2);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether two Calendar instances are in the same month
|
* Determine whether two Calendar instances are in the same month
|
||||||
*
|
*
|
||||||
@ -267,4 +285,24 @@ public class DateTimeUtils {
|
|||||||
return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR)
|
return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR)
|
||||||
&& calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH);
|
&& calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String formatDateRelative(final Context context, final Date date) {
|
||||||
|
if (DateUtils.isToday(date.getTime())) {
|
||||||
|
return context.getString(R.string.activity_summary_today);
|
||||||
|
} else if (DateTimeUtils.isYesterday(date)) {
|
||||||
|
return context.getString(R.string.activity_summary_yesterday);
|
||||||
|
} else {
|
||||||
|
return DateTimeUtils.formatDate(date, DateUtils.FORMAT_SHOW_WEEKDAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String formatDateTimeRelative(final Context context, final Date date) {
|
||||||
|
if (date != null) {
|
||||||
|
final String activityDay = formatDateRelative(context, date);
|
||||||
|
final String activityTime = DateTimeUtils.formatTime(date.getHours(), date.getMinutes());
|
||||||
|
return context.getString(R.string.date_placeholders__date__time, activityDay, activityTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
return context.getString(R.string.unknown);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/activity_summary_detail_scroll_layout"
|
android:id="@+id/activity_summary_detail_scroll_layout"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
@ -9,155 +10,75 @@
|
|||||||
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="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
>
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:background="?attr/sports_activity_summary_background"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
>
|
android:layout_marginBottom="8dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
<ImageView
|
|
||||||
android:id="@+id/item_image"
|
|
||||||
android:layout_width="48dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:contentDescription="@string/icon_placeholder" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/top_layout"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:foregroundGravity="top"
|
|
||||||
android:gravity="top"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingStart="8dp"
|
android:paddingStart="8dp"
|
||||||
android:paddingEnd="8dp">
|
android:paddingEnd="8dp">
|
||||||
|
|
||||||
|
|
||||||
<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:scrollHorizontally="false"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:layout_weight="0.1" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/activity_summary_detail_edit_name"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:layout_weight="0"
|
|
||||||
android:contentDescription="@string/icon_placeholder"
|
|
||||||
android:scaleType="fitEnd"
|
|
||||||
app:srcCompat="@drawable/ic_edit" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/activity_summary_detail_edit_gps"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:layout_weight="0"
|
|
||||||
android:contentDescription="@string/icon_placeholder"
|
|
||||||
android:scaleType="fitEnd"
|
|
||||||
app:srcCompat="@drawable/ic_gps_edit" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/activityname"
|
android:id="@+id/activityname"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="2dp"
|
||||||
android:fontFamily="sans-serif-black"
|
android:fontFamily="sans-serif-black"
|
||||||
android:scrollHorizontally="false"
|
android:scrollHorizontally="false"
|
||||||
android:singleLine="true"
|
android:text="Activity Name"
|
||||||
android:textSize="18sp" />
|
android:textSize="16sp"
|
||||||
|
tools:ignore="HardcodedText" />
|
||||||
|
|
||||||
<TableLayout
|
<TextView
|
||||||
android:id="@+id/summaryHeader"
|
android:id="@+id/activitydate"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="2dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:text="Today, 10:00 - 12:00"
|
||||||
|
tools:ignore="HardcodedText" />
|
||||||
|
|
||||||
<TableRow
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/activityduration"
|
||||||
android:layout_height="match_parent">
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
<TextView
|
android:layout_weight="1"
|
||||||
android:id="@+id/starttime_label"
|
android:gravity="end"
|
||||||
android:layout_width="wrap_content"
|
android:text="30min"
|
||||||
android:layout_height="wrap_content"
|
tools:ignore="HardcodedText" />
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="start"
|
|
||||||
android:text="@string/activity_detail_start_label" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/starttime"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="end" />
|
|
||||||
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/endtime_label"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="start"
|
|
||||||
android:text="@string/activity_detail_end_label" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/endtime"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="end" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/duration_label"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="start"
|
|
||||||
android:text="@string/activity_detail_duration_label" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/duration"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="end" />
|
|
||||||
</TableRow>
|
|
||||||
</TableLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/top_layout2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:foregroundGravity="top"
|
||||||
|
android:gravity="end"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingEnd="8dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/item_image"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:contentDescription="@string/icon_placeholder"
|
||||||
|
app:srcCompat="@drawable/ic_activity_unknown" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/bottom_layout"
|
android:id="@+id/bottom_layout"
|
||||||
@ -165,21 +86,26 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="2dp"
|
||||||
|
android:background="@color/gauge_line_color" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/summaryDetails"
|
android:id="@+id/summaryDetails"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"/>
|
android:orientation="vertical" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/chartsFragmentHolder"
|
android:id="@+id/chartsFragmentHolder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="300dp"></FrameLayout>
|
android:layout_height="300dp" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/gpsFragmentHolder"
|
android:id="@+id/gpsFragmentHolder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="300dp"></FrameLayout>
|
android:layout_height="300dp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -2,6 +2,28 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/activity_detail_overflowMenu2"
|
||||||
|
android:icon="@drawable/ic_edit"
|
||||||
|
android:title="@string/appmanager_app_edit"
|
||||||
|
app:iconTint="?attr/actionmenu_icon_color"
|
||||||
|
app:showAsAction="ifRoom">
|
||||||
|
|
||||||
|
<menu>
|
||||||
|
<item
|
||||||
|
android:id="@+id/activity_summary_detail_action_edit_name"
|
||||||
|
android:icon="@drawable/ic_edit"
|
||||||
|
android:title="@string/activity_summary_edit_name_title"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/activity_summary_detail_action_edit_gps"
|
||||||
|
android:icon="@drawable/ic_gps_edit"
|
||||||
|
android:title="@string/activity_summary_detail_select_gpx_track"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
</menu>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/activity_detail_overflowMenu"
|
android:id="@+id/activity_detail_overflowMenu"
|
||||||
android:icon="@drawable/ic_share"
|
android:icon="@drawable/ic_share"
|
||||||
@ -54,5 +76,3 @@
|
|||||||
</menu>
|
</menu>
|
||||||
</item>
|
</item>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1012,6 +1012,8 @@
|
|||||||
<string name="sleep_colored_stats_awake_avg">Awake AVG</string>
|
<string name="sleep_colored_stats_awake_avg">Awake AVG</string>
|
||||||
<string name="stats_empty_value">-</string>
|
<string name="stats_empty_value">-</string>
|
||||||
<string name="time_empty_value" translatable="false">--:--</string>
|
<string name="time_empty_value" translatable="false">--:--</string>
|
||||||
|
<string name="date_placeholders__date__time">%1s, %1s</string>
|
||||||
|
<string name="date_placeholders__start_time__end_time">%1s - %2s</string>
|
||||||
<string name="stats_lowest_hr">Lowest HR</string>
|
<string name="stats_lowest_hr">Lowest HR</string>
|
||||||
<string name="stats_highest_hr">Highest HR</string>
|
<string name="stats_highest_hr">Highest HR</string>
|
||||||
<string name="transition">Transition</string>
|
<string name="transition">Transition</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user