mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-04 01:09:47 +01:00
More WIP with live activity charts
This commit is contained in:
parent
5f993c0049
commit
bc3c0760d0
@ -473,7 +473,8 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
|||||||
BarData data = new BarData(xLabels, dataSets);
|
BarData data = new BarData(xLabels, dataSets);
|
||||||
data.setGroupSpace(0);
|
data.setGroupSpace(0);
|
||||||
|
|
||||||
chart.setDescription(getString(R.string.sleep_activity_date_range, dateStringFrom, dateStringTo));
|
chart.setDescription("");
|
||||||
|
// chart.setDescription(getString(R.string.sleep_activity_date_range, dateStringFrom, dateStringTo));
|
||||||
// chart.setDescriptionPosition(?, ?);
|
// chart.setDescriptionPosition(?, ?);
|
||||||
|
|
||||||
setupLegend(chart);
|
setupLegend(chart);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.activities.charts;
|
package nodomain.freeyourgadget.gadgetbridge.activities.charts;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -21,6 +22,7 @@ import android.widget.TextView;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
@ -43,6 +45,32 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
|||||||
private Date mStartDate;
|
private Date mStartDate;
|
||||||
private Date mEndDate;
|
private Date mEndDate;
|
||||||
|
|
||||||
|
private static class ShowDurationDialog extends Dialog {
|
||||||
|
private final String mDuration;
|
||||||
|
private TextView durationLabel;
|
||||||
|
|
||||||
|
public ShowDurationDialog(String duration, Context context) {
|
||||||
|
super(context);
|
||||||
|
mDuration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_charts_durationdialog);
|
||||||
|
|
||||||
|
durationLabel = (TextView) findViewById(R.id.charts_duration_label);
|
||||||
|
setDuration(mDuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDuration(String duration) {
|
||||||
|
if (mDuration != null) {
|
||||||
|
durationLabel.setText(duration);
|
||||||
|
} else {
|
||||||
|
durationLabel.setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
@ -98,6 +126,14 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
|||||||
viewPager.setAdapter(getPagerAdapter());
|
viewPager.setAdapter(getPagerAdapter());
|
||||||
|
|
||||||
dateBar = (ViewGroup) findViewById(R.id.charts_date_bar);
|
dateBar = (ViewGroup) findViewById(R.id.charts_date_bar);
|
||||||
|
mDateControl = (TextView) findViewById(R.id.charts_text_date);
|
||||||
|
mDateControl.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
String detailedDuration = formatDetailedDuration();
|
||||||
|
new ShowDurationDialog(detailedDuration, ChartsActivity.this).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mProgressBar = (ProgressBar) findViewById(R.id.charts_progress);
|
mProgressBar = (ProgressBar) findViewById(R.id.charts_progress);
|
||||||
mPrevButton = (Button) findViewById(R.id.charts_previous);
|
mPrevButton = (Button) findViewById(R.id.charts_previous);
|
||||||
@ -114,8 +150,14 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
|
|||||||
handleNextButtonClicked();
|
handleNextButtonClicked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
mDateControl = (TextView) findViewById(R.id.charts_text_date);
|
private String formatDetailedDuration() {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||||
|
String dateStringFrom = dateFormat.format(getStartDate());
|
||||||
|
String dateStringTo = dateFormat.format(getEndDate());
|
||||||
|
|
||||||
|
return getString(R.string.sleep_activity_date_range, dateStringFrom, dateStringTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initDates() {
|
protected void initDates() {
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsActivity">
|
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsActivity">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
android:id="@+id/charts_date_bar"
|
android:id="@+id/charts_date_bar"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
12
app/src/main/res/layout/activity_charts_durationdialog.xml
Normal file
12
app/src/main/res/layout/activity_charts_durationdialog.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical" android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/charts_duration_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user