mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-01 03:55:47 +02:00
Charts: Add button to pick date
This commit is contained in:
parent
b43c109903
commit
fbfbae808f
@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities.charts;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -37,6 +38,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -273,6 +275,15 @@ public abstract class AbstractChartsActivity extends AbstractGBFragmentActivity
|
||||
if (itemId == R.id.charts_fetch_activity_data) {
|
||||
fetchRecordedData();
|
||||
return true;
|
||||
} else if (itemId == R.id.charts_set_date) {
|
||||
final Calendar currentDate = Calendar.getInstance();
|
||||
currentDate.setTime(getEndDate());
|
||||
new DatePickerDialog(this, (view, year, monthOfYear, dayOfMonth) -> {
|
||||
currentDate.set(year, monthOfYear, dayOfMonth);
|
||||
setEndDate(currentDate.getTime());
|
||||
setStartDate(DateTimeUtils.shiftByDays(getEndDate(), -1));
|
||||
LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(REFRESH));
|
||||
}, currentDate.get(Calendar.YEAR), currentDate.get(Calendar.MONTH), currentDate.get(Calendar.DATE)).show();
|
||||
} else if (itemId == R.id.prefs_charts_menu) {
|
||||
Intent settingsIntent = new Intent(this, ChartsPreferencesActivity.class);
|
||||
startActivityForResult(settingsIntent, REQUEST_CODE_PREFERENCES);
|
||||
|
@ -4,16 +4,20 @@
|
||||
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.charts.ActivityChartsActivity">
|
||||
<item
|
||||
android:id="@+id/charts_fetch_activity_data"
|
||||
android:title="@string/controlcenter_fetch_activity_data"
|
||||
android:icon="@drawable/ic_refresh"
|
||||
android:title="@string/controlcenter_fetch_activity_data"
|
||||
app:iconTint="?attr/actionmenu_icon_color"
|
||||
app:showAsAction="ifRoom"
|
||||
/>
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/charts_set_date"
|
||||
android:icon="@drawable/ic_calendar_from"
|
||||
android:title="@string/menuitem_calendar"
|
||||
app:iconTint="?attr/actionmenu_icon_color"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/prefs_charts_menu"
|
||||
android:title="@string/pref_header_charts"
|
||||
android:icon="@drawable/ic_settings"
|
||||
android:title="@string/pref_header_charts"
|
||||
app:iconTint="?attr/actionmenu_icon_color"
|
||||
app:showAsAction="ifRoom"
|
||||
/>
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
||||
|
Loading…
Reference in New Issue
Block a user