Fix #8926 Default color of Favorites changed to black
This commit is contained in:
parent
aff82bec88
commit
beb6a1805f
11 changed files with 65 additions and 19 deletions
|
@ -46,7 +46,7 @@ public class GPXUtilities {
|
|||
private static final String ICON_NAME_EXTENSION = "icon";
|
||||
private static final String DEFAULT_ICON_NAME = "special_star";
|
||||
private static final String BACKGROUND_TYPE_EXTENSION = "background";
|
||||
private static final String DEFAULT_BACKGROUND_TYPE = "circle";
|
||||
private static final String DEFAULT_BACKGROUND_TYPE_NAME = "circle";
|
||||
|
||||
private final static String GPX_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; //$NON-NLS-1$
|
||||
private final static String GPX_TIME_FORMAT_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; //$NON-NLS-1$
|
||||
|
@ -294,7 +294,7 @@ public class GPXUtilities {
|
|||
public String getBackgroundType() {
|
||||
String backgroundType = getExtensionsToRead().get(BACKGROUND_TYPE_EXTENSION);
|
||||
if (backgroundType == null) {
|
||||
backgroundType = DEFAULT_BACKGROUND_TYPE;
|
||||
backgroundType = DEFAULT_BACKGROUND_TYPE_NAME;
|
||||
}
|
||||
return backgroundType;
|
||||
}
|
||||
|
|
|
@ -45,10 +45,10 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15
|
||||
targetSdkVersion 28
|
||||
versionCode 370
|
||||
versionCode 371
|
||||
versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
|
||||
multiDexEnabled true
|
||||
versionName "3.7.0"
|
||||
versionName "3.7.1"
|
||||
versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").toString(): versionName
|
||||
versionName System.getenv("APK_VERSION_SUFFIX")? versionName + System.getenv("APK_VERSION_SUFFIX").toString(): versionName
|
||||
// Stops the Gradle plugin’s automatic rasterization of vectors
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
|
@ -19,6 +20,8 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
|
||||
private static final String HIDDEN = "hidden";
|
||||
private static final String ADDRESS_EXTENSION = "address";
|
||||
public static final BackgroundType DEFAULT_BACKGROUND_TYPE = BackgroundType.CIRCLE;
|
||||
public static final int DEFAULT_UI_ICON_ID = R.drawable.mx_special_star;
|
||||
|
||||
protected String name = "";
|
||||
protected String description;
|
||||
|
@ -93,7 +96,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
}
|
||||
|
||||
public int getIconId() {
|
||||
return iconId == 0 ? R.drawable.mx_special_star : iconId;
|
||||
return iconId == 0 ? DEFAULT_UI_ICON_ID : iconId;
|
||||
}
|
||||
|
||||
public String getIconEntryName(Context ctx) {
|
||||
|
@ -198,7 +201,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
}
|
||||
|
||||
public BackgroundType getBackgroundType() {
|
||||
return backgroundType == null ? BackgroundType.CIRCLE : backgroundType;
|
||||
return backgroundType == null ? DEFAULT_BACKGROUND_TYPE : backgroundType;
|
||||
}
|
||||
|
||||
public void setBackgroundType(BackgroundType backgroundType) {
|
||||
|
@ -351,7 +354,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
if (iconName != null) {
|
||||
fp.setIconIdFromName(ctx, iconName);
|
||||
}
|
||||
BackgroundType backgroundType = BackgroundType.getByTypeName(pt.getBackgroundType(), BackgroundType.CIRCLE);
|
||||
BackgroundType backgroundType = BackgroundType.getByTypeName(pt.getBackgroundType(), DEFAULT_BACKGROUND_TYPE);
|
||||
fp.setBackgroundType(backgroundType);
|
||||
return fp;
|
||||
}
|
||||
|
@ -366,13 +369,13 @@ public class FavouritePoint implements Serializable, LocationPoint {
|
|||
if (isAddressSpecified()) {
|
||||
pt.getExtensionsToWrite().put(ADDRESS_EXTENSION, getAddress());
|
||||
}
|
||||
if (iconId != 0) {
|
||||
if (iconId != 0 && iconId != DEFAULT_UI_ICON_ID) {
|
||||
pt.setIconName(getIconEntryName(ctx).substring(3));
|
||||
}
|
||||
if(backgroundType != null) {
|
||||
if (backgroundType != null && backgroundType != DEFAULT_BACKGROUND_TYPE) {
|
||||
pt.setBackgroundType(backgroundType.typeName);
|
||||
}
|
||||
if (getColor() != 0) {
|
||||
if (getColor() != 0 && getColor() != ContextCompat.getColor(ctx, R.color.color_favorite)) {
|
||||
pt.setColor(getColor());
|
||||
}
|
||||
pt.name = getName();
|
||||
|
|
|
@ -228,8 +228,20 @@ public class AppInitializer implements IProgress {
|
|||
app.getSettings().migratePreferences();
|
||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_6).commit();
|
||||
}
|
||||
if (prevAppVersion < VERSION_3_7) {
|
||||
if (prevAppVersion < VERSION_3_7 || Version.getAppVersion(app).equals("3.7.1")) {
|
||||
app.getSettings().migrateEnumPreferences();
|
||||
addListener(new AppInitializeListener() {
|
||||
@Override
|
||||
public void onProgress(AppInitializer init, InitEvents event) {
|
||||
if (event.equals(InitEvents.FAVORITES_INITIALIZED)) {
|
||||
app.getFavorites().fixBlackBackground();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish(AppInitializer init) {
|
||||
}
|
||||
});
|
||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_7).commit();
|
||||
}
|
||||
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
||||
|
|
|
@ -183,6 +183,28 @@ public class FavouritesDbHelper {
|
|||
});
|
||||
}
|
||||
|
||||
void fixBlackBackground() {
|
||||
flatGroups.clear();
|
||||
favoriteGroups.clear();
|
||||
for (FavouritePoint fp : cachedFavoritePoints) {
|
||||
if (fp.getColor() == 0xFF000000) {
|
||||
fp.setColor(0);
|
||||
}
|
||||
FavoriteGroup group = getOrCreateGroup(fp, 0);
|
||||
group.points.add(fp);
|
||||
}
|
||||
sortAll();
|
||||
saveCurrentPointsIntoFile();
|
||||
context.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (FavoritesListener listener : listeners) {
|
||||
listener.onFavoritesLoaded();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public FavouritePoint getSpecialPoint(FavouritePoint.SpecialPointType pointType) {
|
||||
for (FavouritePoint fp : cachedFavoritePoints) {
|
||||
if (fp.getSpecialPointType() == pointType) {
|
||||
|
|
|
@ -68,6 +68,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
|
||||
import static net.osmand.plus.myplaces.FavoritesActivity.FAV_TAB;
|
||||
import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID;
|
||||
|
||||
|
@ -964,7 +965,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
? app.getFavorites().getColorWithCategory(model, getResources().getColor(R.color.color_favorite))
|
||||
: ContextCompat.getColor(app, disabledIconColor);
|
||||
int iconSize = (int) getResources().getDimension(R.dimen.favorites_icon_size);
|
||||
if(model.getBackgroundType().equals(FavouritePoint.BackgroundType.CIRCLE)){
|
||||
if (model.getBackgroundType().equals(DEFAULT_BACKGROUND_TYPE)) {
|
||||
icon.setImageDrawable(UiUtilities.createTintedDrawable(getActivity(), model.getIconId(), color));
|
||||
iconSize = (int) getResources().getDimension(R.dimen.standard_icon_size);
|
||||
}else {
|
||||
|
|
|
@ -23,6 +23,9 @@ import net.osmand.plus.UiUtilities;
|
|||
|
||||
import java.util.TreeMap;
|
||||
|
||||
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
|
||||
import static net.osmand.data.FavouritePoint.DEFAULT_UI_ICON_ID;
|
||||
|
||||
public class FavoriteImageDrawable extends Drawable {
|
||||
|
||||
private boolean withShadow;
|
||||
|
@ -55,7 +58,7 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
uiIconId = overlayIconId;
|
||||
} else {
|
||||
favIcon = res.getDrawable(R.drawable.mm_special_star);
|
||||
uiIconId = R.drawable.mx_special_star;
|
||||
uiIconId = DEFAULT_UI_ICON_ID;
|
||||
}
|
||||
int col = color == 0 ? res.getColor(R.color.color_favorite) : color;
|
||||
uiListIcon = uiUtilities.getIcon(uiIconId, R.color.color_white);
|
||||
|
@ -217,7 +220,7 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
if (pt != null) {
|
||||
point = new FavouritePoint(pt.getLatitude(), pt.getLongitude(), pt.name, pt.category);
|
||||
point.setIconIdFromName(a, pt.getIconName());
|
||||
point.setBackgroundType(BackgroundType.getByTypeName(pt.getBackgroundType(), BackgroundType.CIRCLE));
|
||||
point.setBackgroundType(BackgroundType.getByTypeName(pt.getBackgroundType(), DEFAULT_BACKGROUND_TYPE));
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
|
|
@ -86,6 +86,7 @@ import static net.osmand.IndexConstants.GPX_FILE_EXT;
|
|||
import static net.osmand.IndexConstants.OSMAND_SETTINGS_FILE_EXT;
|
||||
import static net.osmand.IndexConstants.RENDERER_INDEX_EXT;
|
||||
import static net.osmand.IndexConstants.ROUTING_FILE_EXT;
|
||||
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
|
||||
import static net.osmand.plus.AppInitializer.loadRoutingFiles;
|
||||
import static net.osmand.plus.myplaces.FavoritesActivity.FAV_TAB;
|
||||
import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB;
|
||||
|
@ -1190,7 +1191,7 @@ public class ImportHelper {
|
|||
}
|
||||
fp.setColor(p.getColor(0));
|
||||
fp.setIconIdFromName(app, p.getIconName());
|
||||
fp.setBackgroundType(BackgroundType.getByTypeName(p.getBackgroundType(), BackgroundType.CIRCLE));
|
||||
fp.setBackgroundType(BackgroundType.getByTypeName(p.getBackgroundType(), DEFAULT_BACKGROUND_TYPE));
|
||||
favourites.add(fp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ import net.osmand.util.Algorithms;
|
|||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
|
||||
|
||||
public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
||||
|
||||
@Nullable
|
||||
|
@ -45,7 +47,7 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
private int color;
|
||||
private int iconId;
|
||||
@NonNull
|
||||
private BackgroundType backgroundType = BackgroundType.CIRCLE;
|
||||
private BackgroundType backgroundType = DEFAULT_BACKGROUND_TYPE;
|
||||
|
||||
@Nullable
|
||||
private FavouritesDbHelper helper;
|
||||
|
|
|
@ -78,7 +78,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
|
|||
private int selectedIcon;
|
||||
@ColorInt
|
||||
private int selectedColor;
|
||||
private BackgroundType selectedShape = BackgroundType.CIRCLE;
|
||||
private BackgroundType selectedShape = DEFAULT_BACKGROUND_TYPE;
|
||||
private ImageView nameIcon;
|
||||
private GroupAdapter groupListAdapter;
|
||||
private int scrollViewY;
|
||||
|
|
|
@ -37,6 +37,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
|
||||
|
||||
public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
||||
|
||||
@Nullable
|
||||
|
@ -54,7 +56,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
|||
protected boolean skipDialog;
|
||||
private String iconName;
|
||||
@NonNull
|
||||
private String backgroundTypeName = BackgroundType.CIRCLE.getTypeName();
|
||||
private String backgroundTypeName = DEFAULT_BACKGROUND_TYPE.getTypeName();
|
||||
|
||||
private Map<String, Integer> categoriesMap;
|
||||
private OsmandApplication app;
|
||||
|
@ -432,7 +434,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew {
|
|||
|
||||
@Override
|
||||
public BackgroundType getBackgroundType() {
|
||||
return BackgroundType.getByTypeName(backgroundTypeName, BackgroundType.CIRCLE);
|
||||
return BackgroundType.getByTypeName(backgroundTypeName, DEFAULT_BACKGROUND_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue