small fixes

This commit is contained in:
Skalii 2021-03-15 18:37:04 +02:00
parent 1b75863569
commit 58b690ba7c
7 changed files with 33 additions and 34 deletions

View file

@ -92,12 +92,12 @@ public class AndroidUtils {
public static final MessageFormat formatKb = new MessageFormat("{0, number,##.#}", Locale.US);
public static final MessageFormat formatGb = new MessageFormat("{0, number,#.##}", Locale.US);
public static final MessageFormat formatMb = new MessageFormat("{0, number,##.#}", Locale.US);
/**
* @param context
* @return true if Hardware keyboard is available
*/
public static boolean isHardwareKeyboardAvailable(Context context) {
return context.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;
}
@ -480,6 +480,16 @@ public class AndroidUtils {
: ctx.getResources().getColor(R.color.text_color_secondary_light));
}
@ColorRes
public static int getPrimaryTextColorId(boolean nightMode) {
return nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light;
}
@ColorRes
public static int getSecondaryTextColorId(boolean nightMode) {
return nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light;
}
public static int getTextMaxWidth(float textSize, List<String> titles) {
int width = 0;
for (String title : titles) {
@ -761,7 +771,7 @@ public class AndroidUtils {
tv.setTextDirection(textDirection);
}
}
public static int getLayoutDirection(@NonNull Context ctx) {
Locale currentLocale = ctx.getResources().getConfiguration().locale;
return TextUtilsCompat.getLayoutDirectionFromLocale(currentLocale);
@ -909,7 +919,7 @@ public class AndroidUtils {
public static boolean isRTL() {
return TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_RTL;
}
public static String createNewFileName(String oldName) {
int firstDotIndex = oldName.indexOf('.');
String nameWithoutExt = oldName.substring(0, firstDotIndex);
@ -931,7 +941,7 @@ public class AndroidUtils {
i--;
} while (i >= 0);
int newNumberValue = Integer.parseInt(hasNameNumberSection ? numberSection.toString() : "0") + 1;
String newName;
if (newNumberValue == 1) {
newName = nameWithoutExt + " " + newNumberValue + ext;

View file

@ -25,17 +25,17 @@ import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import static net.osmand.AndroidUtils.getPrimaryTextColorId;
import static net.osmand.AndroidUtils.getSecondaryTextColorId;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getNameToDisplay;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLatestUpdateAvailable;
import static net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.LOCAL_INDEX_FILE_NAME;
import static net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.getPrimaryTextColorId;
import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.getSecondaryTextColorId;
public class LiveUpdatesClearDialogFragment extends MenuBottomSheetDialogFragment {
public static final String TAG = LiveUpdatesClearDialogFragment.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(LiveUpdatesClearDialogFragment.class);
private static final String LOCAL_INDEX_FILE_NAME = "local_index_file_name";
private OsmandApplication app;
private OsmandSettings settings;

View file

@ -72,6 +72,7 @@ import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import static net.osmand.AndroidUtils.getSecondaryTextColorId;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.formatShortDateTime;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getNameToDisplay;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent;
@ -86,7 +87,6 @@ import static net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.g
import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.getActiveTextColorId;
import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.getOsmandIconColorId;
import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.getSecondaryIconColorId;
import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.getSecondaryTextColorId;
public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements OnLiveUpdatesForLocalChange {
@ -614,7 +614,7 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
descriptionTime.setText(dest.format(parsed));
}
} catch (ParseException e) {
e.printStackTrace();
LOG.error(e.getMessage());
}
}
}
@ -630,13 +630,13 @@ public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements
final long lastUpdate = preferenceLatestUpdateAvailable(fileName, settings).get();
String lastUpdateString = formatShortDateTime(app, lastUpdate);
String description = app.getResources().getString(R.string.updated, lastUpdateString);
String description = app.getString(R.string.updated, lastUpdateString);
if (lastTimeChecked) {
final long lastCheck = preferenceLastCheck(fileName, settings).get();
String lastCheckString = formatShortDateTime(app, lastCheck);
if (!lastUpdateString.equals(app.getResources().getString(R.string.shared_string_never))) {
description = description.concat("\n" + app.getResources().getString(R.string.last_time_checked, lastCheckString));
if (!lastUpdateString.equals(app.getString(R.string.shared_string_never))) {
description = description.concat("\n" + app.getString(R.string.last_time_checked, lastCheckString));
}
}
return description;

View file

@ -48,10 +48,10 @@ import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceTimeOfDayT
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceUpdateFrequency;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.runLiveUpdate;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.setAlarmForPendingIntent;
import static net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.LOCAL_INDEX_FILE_NAME;
public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
private static final Log LOG = PlatformUtil.getLog(LiveUpdatesSettingsDialogFragment.class);
private static final String LOCAL_INDEX_FILE_NAME = "local_index_file_name";
private TextView sizeTextView;

View file

@ -53,6 +53,8 @@ import org.apache.commons.logging.Log;
import java.util.Arrays;
import static net.osmand.AndroidUtils.getPrimaryTextColorId;
import static net.osmand.AndroidUtils.getSecondaryTextColorId;
import static net.osmand.plus.UiUtilities.CompoundButtonType.TOOLBAR;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.formatHelpDateTime;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.formatShortDateTime;
@ -63,7 +65,6 @@ import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLatestUpdateAvailable;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceTimeOfDayToUpdate;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceUpdateFrequency;
import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.getSecondaryTextColorId;
import static net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.getCustomButtonView;
import static net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView;
@ -71,7 +72,7 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
public static final String TAG = LiveUpdatesSettingsDialogFragmentNew.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(LiveUpdatesSettingsDialogFragmentNew.class);
public static final String LOCAL_INDEX_FILE_NAME = "local_index_file_name";
private static final String LOCAL_INDEX_FILE_NAME = "local_index_file_name";
private OsmandApplication app;
private OsmandSettings settings;
@ -524,11 +525,6 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
return getString(isEnabled ? R.string.shared_string_enabled : R.string.shared_string_disabled);
}
@ColorRes
public static int getPrimaryTextColorId(boolean nightMode) {
return nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light;
}
@ColorRes
public static int getActiveTabTextColorId(boolean nightMode) {
return nightMode ? R.color.text_color_tab_active_dark : R.color.text_color_tab_active_light;

View file

@ -7,10 +7,8 @@ import net.osmand.plus.activities.LocalIndexHelper;
import net.osmand.plus.activities.LocalIndexInfo;
import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask;
import java.util.List;
public class LoadLiveMapsTask
extends AsyncTask<Void, LocalIndexInfo, List<LocalIndexInfo>>
extends AsyncTask<Void, LocalIndexInfo, Void>
implements AbstractLoadLocalIndexTask {
public interface LocalIndexInfoAdapter {
@ -21,7 +19,6 @@ public class LoadLiveMapsTask
void onDataUpdated();
}
//private List<LocalIndexInfo> result;
private final LocalIndexInfoAdapter adapter;
private final LocalIndexHelper helper;
@ -36,8 +33,9 @@ public class LoadLiveMapsTask
}
@Override
protected List<LocalIndexInfo> doInBackground(Void... params) {
return helper.getLocalFullMaps(this);
protected Void doInBackground(Void... params) {
helper.getLocalFullMaps(this);
return null;
}
@Override
@ -58,8 +56,7 @@ public class LoadLiveMapsTask
}
@Override
protected void onPostExecute(List<LocalIndexInfo> result) {
//this.result = result;
protected void onPostExecute(Void result) {
adapter.onDataUpdated();
}
}

View file

@ -65,6 +65,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static net.osmand.AndroidUtils.getSecondaryTextColorId;
import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT;
public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragment {
@ -612,11 +613,6 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
return nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
}
@ColorRes
public static int getSecondaryTextColorId(boolean nightMode) {
return nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light;
}
@ColorRes
public static int getActiveIconColorId(boolean nightMode) {
return nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light;