many fixes
This commit is contained in:
parent
d379b6cf4a
commit
e1ea331bfb
6 changed files with 94 additions and 95 deletions
|
@ -843,8 +843,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}).createItem());
|
}).createItem());
|
||||||
|
|
||||||
final OsmandMonitoringPlugin monitoringPlugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
|
final OsmandMonitoringPlugin monitoringPlugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
|
||||||
boolean isTripRecordingPluginOn = monitoringPlugin != null;
|
if (monitoringPlugin != null) {
|
||||||
if (isTripRecordingPluginOn) {
|
|
||||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_widget_monitoring, mapActivity)
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_widget_monitoring, mapActivity)
|
||||||
.setId(DRAWER_TRIP_RECORDING_ID)
|
.setId(DRAWER_TRIP_RECORDING_ID)
|
||||||
.setIcon(R.drawable.ic_action_track_recordable)
|
.setIcon(R.drawable.ic_action_track_recordable)
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
private SelectedGpxFile currentTrack;
|
private SelectedGpxFile currentTrack;
|
||||||
private int points;
|
private int points;
|
||||||
private int trkPoints = 0;
|
private int trkPoints = 0;
|
||||||
public long time;
|
private long lastTimeFileSaved;
|
||||||
|
|
||||||
public SavingTrackHelper(OsmandApplication ctx) {
|
public SavingTrackHelper(OsmandApplication ctx) {
|
||||||
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
|
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
|
@ -256,7 +256,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
GPXTrackAnalysis analysis = gpx.getAnalysis(fout.lastModified());
|
GPXTrackAnalysis analysis = gpx.getAnalysis(fout.lastModified());
|
||||||
GpxDataItem item = new GpxDataItem(fout, analysis);
|
GpxDataItem item = new GpxDataItem(fout, analysis);
|
||||||
ctx.getGpxDbHelper().add(item);
|
ctx.getGpxDbHelper().add(item);
|
||||||
time = fout.lastModified();
|
lastTimeFileSaved = fout.lastModified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -732,6 +732,14 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||||
return lastTimeUpdated;
|
return lastTimeUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getLastTimeFileSaved() {
|
||||||
|
return lastTimeFileSaved;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastTimeFileSaved(long lastTimeFileSaved) {
|
||||||
|
this.lastTimeFileSaved = lastTimeFileSaved;
|
||||||
|
}
|
||||||
|
|
||||||
public GPXFile getCurrentGpx() {
|
public GPXFile getCurrentGpx() {
|
||||||
return currentTrack.getGpxFile();
|
return currentTrack.getGpxFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,9 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF
|
||||||
params.setMargins(horizontal, 0, horizontal, 0);
|
params.setMargins(horizontal, 0, horizontal, 0);
|
||||||
button.setLayoutParams(params);
|
button.setLayoutParams(params);
|
||||||
|
|
||||||
|
if (type.getTitleId() != null) {
|
||||||
UiUtilities.setupDialogButton(nightMode, button, type.getEffect(), type.getTitleId());
|
UiUtilities.setupDialogButton(nightMode, button, type.getEffect(), type.getTitleId());
|
||||||
|
}
|
||||||
|
|
||||||
TextViewEx title = button.findViewById(R.id.button_text);
|
TextViewEx title = button.findViewById(R.id.button_text);
|
||||||
int margin = context.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_medium);
|
int margin = context.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_medium);
|
||||||
|
@ -97,7 +99,9 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF
|
||||||
colorRes = nightMode ? R.color.dlg_btn_secondary_text_dark : R.color.dlg_btn_secondary_text_light;
|
colorRes = nightMode ? R.color.dlg_btn_secondary_text_dark : R.color.dlg_btn_secondary_text_light;
|
||||||
}
|
}
|
||||||
AppCompatImageView icon = button.findViewById(R.id.icon);
|
AppCompatImageView icon = button.findViewById(R.id.icon);
|
||||||
|
if (type.getIconId() != null) {
|
||||||
icon.setImageDrawable(getIcon(type.getIconId(), colorRes));
|
icon.setImageDrawable(getIcon(type.getIconId(), colorRes));
|
||||||
|
}
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,9 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm
|
||||||
params.setMargins(horizontal, 0, horizontal, 0);
|
params.setMargins(horizontal, 0, horizontal, 0);
|
||||||
button.setLayoutParams(params);
|
button.setLayoutParams(params);
|
||||||
|
|
||||||
|
if (type.getTitleId() != null) {
|
||||||
UiUtilities.setupDialogButton(nightMode, button, type.getEffect(), type.getTitleId());
|
UiUtilities.setupDialogButton(nightMode, button, type.getEffect(), type.getTitleId());
|
||||||
|
}
|
||||||
|
|
||||||
TextViewEx title = button.findViewById(R.id.button_text);
|
TextViewEx title = button.findViewById(R.id.button_text);
|
||||||
int margin = context.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_medium);
|
int margin = context.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_medium);
|
||||||
|
@ -134,7 +136,9 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm
|
||||||
colorRes = nightMode ? R.color.dlg_btn_secondary_text_dark : R.color.dlg_btn_secondary_text_light;
|
colorRes = nightMode ? R.color.dlg_btn_secondary_text_dark : R.color.dlg_btn_secondary_text_light;
|
||||||
}
|
}
|
||||||
AppCompatImageView icon = button.findViewById(R.id.icon);
|
AppCompatImageView icon = button.findViewById(R.id.icon);
|
||||||
|
if (type.getIconId() != null) {
|
||||||
icon.setImageDrawable(getIcon(type.getIconId(), colorRes));
|
icon.setImageDrawable(getIcon(type.getIconId(), colorRes));
|
||||||
|
}
|
||||||
|
|
||||||
if (type == ItemType.STOP_AND_DISCARD) {
|
if (type == ItemType.STOP_AND_DISCARD) {
|
||||||
int size = context.getResources().getDimensionPixelSize(R.dimen.map_widget_height);
|
int size = context.getResources().getDimensionPixelSize(R.dimen.map_widget_height);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package net.osmand.plus.monitoring;
|
package net.osmand.plus.monitoring;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
@ -14,7 +14,6 @@ import android.util.TypedValue;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
@ -29,6 +28,7 @@ import androidx.appcompat.content.res.AppCompatResources;
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
import androidx.appcompat.widget.SwitchCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
@ -69,6 +69,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
public static final String TAG = TripRecordingActiveBottomSheet.class.getSimpleName();
|
public static final String TAG = TripRecordingActiveBottomSheet.class.getSimpleName();
|
||||||
private static final Log log = PlatformUtil.getLog(TripRecordingActiveBottomSheet.class);
|
private static final Log log = PlatformUtil.getLog(TripRecordingActiveBottomSheet.class);
|
||||||
private static final String UPDATE_CURRENT_GPX_FILE = "update_current_gpx_file";
|
private static final String UPDATE_CURRENT_GPX_FILE = "update_current_gpx_file";
|
||||||
|
private static final int GENERAL_UPDATE_INTERVAL = 1000;
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
|
@ -100,7 +101,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasTrackMonitored() {
|
public boolean wasTrackMonitored() {
|
||||||
return settings != null && settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
|
return settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showInstance(@NonNull FragmentManager fragmentManager, SelectedGpxFile selectedGpxFile) {
|
public static void showInstance(@NonNull FragmentManager fragmentManager, SelectedGpxFile selectedGpxFile) {
|
||||||
|
@ -154,7 +155,10 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
|
|
||||||
final LinearLayout buttonShow = showTrackContainer.findViewById(R.id.basic_item_body);
|
final LinearLayout buttonShow = showTrackContainer.findViewById(R.id.basic_item_body);
|
||||||
TextView showTrackTitle = buttonShow.findViewById(R.id.title);
|
TextView showTrackTitle = buttonShow.findViewById(R.id.title);
|
||||||
showTrackTitle.setText(ItemType.SHOW_TRACK.getTitleId());
|
Integer showTitle = ItemType.SHOW_TRACK.getTitleId();
|
||||||
|
if (showTitle != null) {
|
||||||
|
showTrackTitle.setText(showTitle);
|
||||||
|
}
|
||||||
showTrackTitle.setTextColor(ContextCompat.getColor(app, getActiveIconColorId(nightMode)));
|
showTrackTitle.setTextColor(ContextCompat.getColor(app, getActiveIconColorId(nightMode)));
|
||||||
showTrackTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.default_desc_text_size));
|
showTrackTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.default_desc_text_size));
|
||||||
Typeface typeface = FontCache.getFont(app, app.getResources().getString(R.string.font_roboto_medium));
|
Typeface typeface = FontCache.getFont(app, app.getResources().getString(R.string.font_roboto_medium));
|
||||||
|
@ -194,15 +198,18 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
createItem(buttonAppearance, ItemType.APPEARANCE, showTrackOnMapButton.isChecked(), null);
|
createItem(buttonAppearance, ItemType.APPEARANCE, showTrackOnMapButton.isChecked(), null);
|
||||||
setShowOnMapBackgroundInactive(buttonShow, app, showTrackOnMapButton.isChecked(), nightMode);
|
setShowOnMapBackground(buttonShow, app, showTrackOnMapButton.isChecked(), nightMode);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
buttonShow.setBackgroundTintList(null);
|
||||||
|
}
|
||||||
buttonShow.setOnClickListener(new View.OnClickListener() {
|
buttonShow.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
boolean checked = !showTrackOnMapButton.isChecked();
|
boolean checked = !showTrackOnMapButton.isChecked();
|
||||||
showTrackOnMapButton.setChecked(checked);
|
showTrackOnMapButton.setChecked(checked);
|
||||||
app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false);
|
app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false);
|
||||||
setShowOnMapBackgroundInactive(buttonShow, app, checked, nightMode);
|
|
||||||
createItem(buttonAppearance, ItemType.APPEARANCE, checked, null);
|
createItem(buttonAppearance, ItemType.APPEARANCE, checked, null);
|
||||||
|
setShowOnMapBackground(buttonShow, app, checked, nightMode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -248,7 +255,6 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
boolean wasTrackMonitored = !wasTrackMonitored();
|
boolean wasTrackMonitored = !wasTrackMonitored();
|
||||||
createItem(buttonPause, wasTrackMonitored ? ItemType.PAUSE : ItemType.RESUME, true, null);
|
|
||||||
if (!wasTrackMonitored) {
|
if (!wasTrackMonitored) {
|
||||||
blockStatisticsBuilder.stopUpdatingStatBlocks();
|
blockStatisticsBuilder.stopUpdatingStatBlocks();
|
||||||
} else {
|
} else {
|
||||||
|
@ -256,6 +262,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
}
|
}
|
||||||
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(wasTrackMonitored);
|
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(wasTrackMonitored);
|
||||||
updateStatus();
|
updateStatus();
|
||||||
|
createItem(buttonPause, wasTrackMonitored ? ItemType.PAUSE : ItemType.RESUME, true, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -300,14 +307,14 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
|
|
||||||
AppCompatImageView icon = view.findViewById(R.id.icon);
|
AppCompatImageView icon = view.findViewById(R.id.icon);
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
setTintedIcon(icon, app, enabled, false, nightMode, type);
|
setTintedIcon(icon, enabled, nightMode, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView title = view.findViewById(R.id.button_text);
|
TextView title = view.findViewById(R.id.button_text);
|
||||||
Integer titleId = type.getTitleId();
|
Integer titleId = type.getTitleId();
|
||||||
if (title != null && titleId != null) {
|
if (title != null && titleId != null) {
|
||||||
title.setText(titleId);
|
title.setText(titleId);
|
||||||
setTextColor(title, app, enabled, false, nightMode, type);
|
setTextColor(title, enabled, nightMode, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextViewEx desc = view.findViewById(R.id.desc);
|
TextViewEx desc = view.findViewById(R.id.desc);
|
||||||
|
@ -319,16 +326,15 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
UiUtilities.setMargins(title, 0, marginDesc, 0, marginDesc);
|
UiUtilities.setMargins(title, 0, marginDesc, 0, marginDesc);
|
||||||
}
|
}
|
||||||
desc.setText(description);
|
desc.setText(description);
|
||||||
setTextColor(desc, app, false, false, nightMode, type);
|
setTextColor(desc, false, nightMode, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
setItemBackgroundInactive(button != null ? button : (LinearLayout) view, app, nightMode);
|
setItemBackground(button != null ? button : (LinearLayout) view, enabled);
|
||||||
changeOnTouch(button != null ? button : (LinearLayout) view, icon, title, app, enabled, nightMode, type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTimeTrackSaved() {
|
private String getTimeTrackSaved() {
|
||||||
if (helper.time != 0) {
|
long timeTrackSaved = helper.getLastTimeFileSaved();
|
||||||
long timeTrackSaved = helper.time;
|
if (timeTrackSaved != 0) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
CharSequence time = DateUtils.getRelativeTimeSpanString(timeTrackSaved, now, DateUtils.MINUTE_IN_MILLIS);
|
CharSequence time = DateUtils.getRelativeTimeSpanString(timeTrackSaved, now, DateUtils.MINUTE_IN_MILLIS);
|
||||||
return String.valueOf(time);
|
return String.valueOf(time);
|
||||||
|
@ -363,7 +369,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
public void run() {
|
public void run() {
|
||||||
int interval = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get();
|
int interval = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get();
|
||||||
updateStatus();
|
updateStatus();
|
||||||
handler.postDelayed(this, Math.max(1000, interval));
|
handler.postDelayed(this, Math.max(GENERAL_UPDATE_INTERVAL, interval));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
handler.post(updatingGPS);
|
handler.post(updatingGPS);
|
||||||
|
@ -379,7 +385,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
public void run() {
|
public void run() {
|
||||||
String time = getTimeTrackSaved();
|
String time = getTimeTrackSaved();
|
||||||
createItem(buttonSave, ItemType.SAVE, hasDataToSave(), !Algorithms.isEmpty(time) ? time : null);
|
createItem(buttonSave, ItemType.SAVE, hasDataToSave(), !Algorithms.isEmpty(time) ? time : null);
|
||||||
handler.postDelayed(this, 60000);
|
handler.postDelayed(this, GENERAL_UPDATE_INTERVAL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
handler.post(updatingTimeTrackSaved);
|
handler.post(updatingTimeTrackSaved);
|
||||||
|
@ -449,36 +455,6 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setItemBackgroundActive(LinearLayout view, Context context,
|
|
||||||
boolean nightMode) {
|
|
||||||
Drawable background = AppCompatResources.getDrawable(context,
|
|
||||||
nightMode ? R.drawable.btn_background_active_dark : R.drawable.btn_background_active_light);
|
|
||||||
view.setBackgroundDrawable(background);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setItemBackgroundInactive(LinearLayout view, Context context,
|
|
||||||
boolean nightMode) {
|
|
||||||
Drawable background = AppCompatResources.getDrawable(context,
|
|
||||||
nightMode ? R.drawable.btn_background_inactive_dark : R.drawable.btn_background_inactive_light);
|
|
||||||
view.setBackgroundDrawable(background);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setShowOnMapBackgroundActive(LinearLayout view, Context context,
|
|
||||||
boolean checked, boolean nightMode) {
|
|
||||||
Drawable background = AppCompatResources.getDrawable(context,
|
|
||||||
nightMode ? checked ? R.drawable.btn_background_active_dark : R.drawable.btn_background_stroked_active_dark
|
|
||||||
: checked ? R.drawable.btn_background_active_light : R.drawable.btn_background_stroked_active_light);
|
|
||||||
view.setBackgroundDrawable(background);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setShowOnMapBackgroundInactive(LinearLayout view, Context context,
|
|
||||||
boolean checked, boolean nightMode) {
|
|
||||||
Drawable background = AppCompatResources.getDrawable(context,
|
|
||||||
nightMode ? checked ? R.drawable.btn_background_inactive_dark : R.drawable.btn_background_stroked_inactive_dark
|
|
||||||
: checked ? R.drawable.btn_background_inactive_light : R.drawable.btn_background_stroked_inactive_light);
|
|
||||||
view.setBackgroundDrawable(background);
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ItemType {
|
public enum ItemType {
|
||||||
SHOW_TRACK(R.string.shared_string_show_on_map, null, null),
|
SHOW_TRACK(R.string.shared_string_show_on_map, null, null),
|
||||||
APPEARANCE(null, null, null),
|
APPEARANCE(null, null, null),
|
||||||
|
@ -523,24 +499,50 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextColor(TextView tv, Context context, boolean enabled, boolean pressed, boolean nightMode, ItemType type) {
|
private void setItemBackground(LinearLayout view, boolean enabled) {
|
||||||
|
Drawable background = AppCompatResources.getDrawable(app, R.drawable.btn_background_inactive_light);
|
||||||
|
if (background != null && enabled) {
|
||||||
|
ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList(
|
||||||
|
app, getInactiveButtonColorId(nightMode), getActiveButtonColorId(nightMode)
|
||||||
|
);
|
||||||
|
DrawableCompat.setTintList(background, iconColorStateList);
|
||||||
|
} else {
|
||||||
|
UiUtilities.tintDrawable(background, ContextCompat.getColor(app, getInactiveButtonColorId(nightMode)));
|
||||||
|
}
|
||||||
|
view.setBackgroundDrawable(background);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setShowOnMapBackground(LinearLayout view, Context context, boolean checked, boolean nightMode) {
|
||||||
|
Drawable background = AppCompatResources.getDrawable(context,
|
||||||
|
nightMode ? checked ? R.drawable.btn_background_inactive_dark : R.drawable.btn_background_stroked_inactive_dark
|
||||||
|
: checked ? R.drawable.btn_background_inactive_light : R.drawable.btn_background_stroked_inactive_light);
|
||||||
|
view.setBackgroundDrawable(background);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextColor(TextView tv, boolean enabled, boolean nightMode, ItemType type) {
|
||||||
if (tv != null) {
|
if (tv != null) {
|
||||||
tv.setTextColor(ContextCompat.getColor(context,
|
ColorStateList textColorStateList = AndroidUtils.createPressedColorStateList(
|
||||||
enabled ? pressed ? getPressedColorId(nightMode)
|
app, enabled ? type == ItemType.CLEAR_DATA ? R.color.color_osm_edit_delete
|
||||||
: type == ItemType.CLEAR_DATA ? R.color.color_osm_edit_delete
|
: getActiveTextColorId(nightMode) : getSecondaryTextColorId(nightMode),
|
||||||
: getActiveTextColorId(nightMode) : getSecondaryTextColorId(nightMode)));
|
getPressedColorId(nightMode)
|
||||||
|
);
|
||||||
|
tv.setTextColor(textColorStateList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTintedIcon(AppCompatImageView iv, Context context, boolean enabled, boolean pressed, boolean nightMode, ItemType type) {
|
public void setTintedIcon(AppCompatImageView iv, boolean enabled, boolean nightMode, ItemType type) {
|
||||||
Integer iconId = type.getIconId();
|
Integer iconId = type.getIconId();
|
||||||
if (iv != null && iconId != null) {
|
if (iv != null && iconId != null) {
|
||||||
Drawable icon = AppCompatResources.getDrawable(context, iconId);
|
Drawable icon = AppCompatResources.getDrawable(app, iconId);
|
||||||
int iconColor = enabled ? pressed ? getPressedColorId(nightMode)
|
ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList(
|
||||||
: type == ItemType.CLEAR_DATA ? R.color.color_osm_edit_delete
|
app, enabled ? type == ItemType.CLEAR_DATA ? R.color.color_osm_edit_delete
|
||||||
: getActiveIconColorId(nightMode) : getSecondaryIconColorId(nightMode);
|
: getActiveIconColorId(nightMode) : getSecondaryIconColorId(nightMode),
|
||||||
Drawable tintedIcon = UiUtilities.tintDrawable(icon, ContextCompat.getColor(context, iconColor));
|
getPressedColorId(nightMode)
|
||||||
iv.setImageDrawable(tintedIcon);
|
);
|
||||||
|
if (icon != null) {
|
||||||
|
DrawableCompat.setTintList(icon, iconColorStateList);
|
||||||
|
}
|
||||||
|
iv.setImageDrawable(icon);
|
||||||
if (type == ItemType.STOP) {
|
if (type == ItemType.STOP) {
|
||||||
int stopSize = iv.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin_large);
|
int stopSize = iv.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin_large);
|
||||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(stopSize, stopSize);
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(stopSize, stopSize);
|
||||||
|
@ -549,34 +551,6 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
|
||||||
private void changeOnTouch(final LinearLayout button, @Nullable final AppCompatImageView iv, @Nullable final TextView tv,
|
|
||||||
final Context context, final boolean enabled, final boolean nightMode, final ItemType type) {
|
|
||||||
button.setOnTouchListener(new View.OnTouchListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
|
||||||
if (enabled) {
|
|
||||||
switch (event.getAction()) {
|
|
||||||
case MotionEvent.ACTION_DOWN: {
|
|
||||||
setItemBackgroundActive(button, context, nightMode);
|
|
||||||
setTintedIcon(iv, context, true, true, nightMode, type);
|
|
||||||
setTextColor(tv, context, true, true, nightMode, type);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MotionEvent.ACTION_UP:
|
|
||||||
case MotionEvent.ACTION_CANCEL: {
|
|
||||||
setItemBackgroundInactive(button, context, nightMode);
|
|
||||||
setTintedIcon(iv, context, true, false, nightMode, type);
|
|
||||||
setTextColor(tv, context, true, false, nightMode, type);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@ColorRes
|
@ColorRes
|
||||||
private static int getActiveTextColorId(boolean nightMode) {
|
private static int getActiveTextColorId(boolean nightMode) {
|
||||||
return nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
return nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||||
|
@ -597,6 +571,16 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
return nightMode ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light;
|
return nightMode ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ColorRes
|
||||||
|
private static int getActiveButtonColorId(boolean nightMode) {
|
||||||
|
return nightMode ? R.color.active_buttons_and_links_bg_pressed_dark : R.color.active_buttons_and_links_bg_pressed_light;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorRes
|
||||||
|
private static int getInactiveButtonColorId(boolean nightMode) {
|
||||||
|
return nightMode ? R.color.inactive_buttons_and_links_bg_dark : R.color.inactive_buttons_and_links_bg_light;
|
||||||
|
}
|
||||||
|
|
||||||
@ColorRes
|
@ColorRes
|
||||||
private static int getOsmandIconColorId(boolean nightMode) {
|
private static int getOsmandIconColorId(boolean nightMode) {
|
||||||
return nightMode ? R.color.icon_color_osmand_dark : R.color.icon_color_osmand_light;
|
return nightMode ? R.color.icon_color_osmand_dark : R.color.icon_color_osmand_light;
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class SaveCurrentTrackTask extends AsyncTask<Void, Void, Boolean> {
|
||||||
for (final String f : files.keySet()) {
|
for (final String f : files.keySet()) {
|
||||||
File fout = new File(dir, f + IndexConstants.GPX_FILE_EXT);
|
File fout = new File(dir, f + IndexConstants.GPX_FILE_EXT);
|
||||||
GPXUtilities.writeGpxFile(fout, gpx);
|
GPXUtilities.writeGpxFile(fout, gpx);
|
||||||
app.getSavingTrackHelper().time = fout.lastModified();
|
app.getSavingTrackHelper().setLastTimeFileSaved(fout.lastModified());
|
||||||
}
|
}
|
||||||
return shouldClearPath;
|
return shouldClearPath;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue