Merge pull request #8250 from osmandapp/config_location_icon
Fix layered icons on GPXLayer fix browse map name disable edit
This commit is contained in:
commit
8d146d42d9
4 changed files with 38 additions and 20 deletions
|
@ -6,6 +6,7 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
@ -51,7 +52,7 @@ public class TrackBitmapDrawer {
|
|||
private int trackColor;
|
||||
private int currentTrackColor;
|
||||
private Paint paint;
|
||||
private Bitmap selectedPoint;
|
||||
private LayerDrawable selectedPoint;
|
||||
private int defPointColor;
|
||||
private Paint paintIcon;
|
||||
private Bitmap pointSmall;
|
||||
|
@ -85,7 +86,7 @@ public class TrackBitmapDrawer {
|
|||
defPointColor = ContextCompat.getColor(app, R.color.gpx_color_point);
|
||||
paintIcon = new Paint();
|
||||
pointSmall = BitmapFactory.decodeResource(app.getResources(), R.drawable.map_white_shield_small);
|
||||
selectedPoint = BitmapFactory.decodeResource(app.getResources(), R.drawable.map_default_location_xml);
|
||||
selectedPoint = (LayerDrawable) app.getResources().getDrawable(R.drawable.map_default_location_xml);
|
||||
}
|
||||
|
||||
public void addListener(TrackBitmapDrawerListener l) {
|
||||
|
@ -283,7 +284,11 @@ public class TrackBitmapDrawer {
|
|||
paintIcon.setColorFilter(null);
|
||||
Bitmap bmp = mapTrackBitmap.copy(mapTrackBitmap.getConfig(), true);
|
||||
Canvas canvas = new Canvas(bmp);
|
||||
canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2, y - selectedPoint.getHeight() / 2, paintIcon);
|
||||
selectedPoint.setBounds((int) x - selectedPoint.getIntrinsicWidth() / 2,
|
||||
(int) y - selectedPoint.getIntrinsicHeight() / 2,
|
||||
(int) x + selectedPoint.getIntrinsicWidth() / 2,
|
||||
(int) y + selectedPoint.getIntrinsicHeight() / 2);
|
||||
selectedPoint.draw(canvas);
|
||||
return bmp;
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
@ -25,7 +25,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
@ -310,7 +309,6 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
|||
profileName.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
profileName.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
|
||||
profileName.setText(changedProfile.name);
|
||||
profileName.requestFocus();
|
||||
profileName.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
@ -332,7 +330,10 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
|||
}
|
||||
});
|
||||
if (getSelectedAppMode().equals(ApplicationMode.DEFAULT)) {
|
||||
profileName.setFocusableInTouchMode(false);
|
||||
profileName.setFocusable(false);
|
||||
} else {
|
||||
profileName.requestFocus();
|
||||
}
|
||||
profileNameOtfb = (OsmandTextFieldBoxes) holder.findViewById(R.id.profile_name_otfb);
|
||||
} else if (MASTER_PROFILE.equals(preference.getKey())) {
|
||||
|
@ -444,10 +445,16 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
|||
if (iconItems != null) {
|
||||
setIconNewColor(changedProfile.iconRes);
|
||||
}
|
||||
updateProfileNameAppearance();
|
||||
updateProfileButton();
|
||||
}
|
||||
|
||||
private void updateProfileNameAppearance() {
|
||||
if (profileName.isFocusable() && profileName.isFocusableInTouchMode()) {
|
||||
int selectedColor = ContextCompat.getColor(app, changedProfile.color.getColor(isNightMode()));
|
||||
profileNameOtfb.setPrimaryColor(selectedColor);
|
||||
profileName.getBackground().mutate().setColorFilter(selectedColor, PorterDuff.Mode.SRC_ATOP);
|
||||
updateProfileButton();
|
||||
}
|
||||
}
|
||||
|
||||
private View createIconItemView(final int iconRes, ViewGroup rootView) {
|
||||
|
@ -597,12 +604,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
|
|||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
View cf = activity.getCurrentFocus();
|
||||
if (cf != null) {
|
||||
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.hideSoftInputFromWindow(cf.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
AndroidUtils.hideSoftKeyboard(activity, cf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,11 +14,13 @@ import android.graphics.PorterDuff.Mode;
|
|||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.util.Pair;
|
||||
|
||||
import net.osmand.GPXUtilities;
|
||||
|
@ -77,7 +79,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
private Bitmap pointSmall;
|
||||
private int currentTrackColor;
|
||||
|
||||
private Bitmap selectedPoint;
|
||||
private LayerDrawable selectedPoint;
|
||||
private TrackChartPoints trackChartPoints;
|
||||
|
||||
private static final int startZoom = 7;
|
||||
|
@ -176,7 +178,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
|
||||
paintIcon = new Paint();
|
||||
pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small);
|
||||
selectedPoint = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_default_location_xml);
|
||||
selectedPoint = (LayerDrawable) view.getResources().getDrawable(R.drawable.map_default_location_xml);
|
||||
|
||||
contextMenuLayer = view.getLayerByClass(ContextMenuLayer.class);
|
||||
|
||||
|
@ -422,7 +424,11 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
float x = tileBox.getPixXFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.getLongitude());
|
||||
paintIcon.setColorFilter(null);
|
||||
canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2, y - selectedPoint.getHeight() / 2, paintIcon);
|
||||
selectedPoint.setBounds((int) x - selectedPoint.getIntrinsicWidth() / 2,
|
||||
(int) y - selectedPoint.getIntrinsicHeight() / 2,
|
||||
(int) x + selectedPoint.getIntrinsicWidth() / 2,
|
||||
(int) y + selectedPoint.getIntrinsicHeight() / 2);
|
||||
selectedPoint.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.graphics.Path;
|
|||
import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
@ -76,7 +77,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
|||
private Paint paintGridCircle;
|
||||
|
||||
private Paint paintIconSelected;
|
||||
private Bitmap selectedPoint;
|
||||
private LayerDrawable selectedPoint;
|
||||
private TrackChartPoints trackChartPoints;
|
||||
|
||||
private RenderingLineAttributes attrs;
|
||||
|
@ -134,7 +135,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
|||
wayContext = new GeometryWayContext(view.getContext(), density);
|
||||
|
||||
paintIconSelected = new Paint();
|
||||
selectedPoint = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_default_location_xml);
|
||||
selectedPoint = (LayerDrawable) view.getResources().getDrawable(R.drawable.map_default_location_xml);
|
||||
|
||||
paintGridCircle = new Paint();
|
||||
paintGridCircle.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
|
@ -196,7 +197,11 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
|||
&& highlightedPoint.getLongitude() <= latlonRect.right) {
|
||||
float x = tileBox.getPixXFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(highlightedPoint.getLatitude(), highlightedPoint.getLongitude());
|
||||
canvas.drawBitmap(selectedPoint, x - selectedPoint.getWidth() / 2f, y - selectedPoint.getHeight() / 2f, paintIconSelected);
|
||||
selectedPoint.setBounds((int) x - selectedPoint.getIntrinsicWidth() / 2,
|
||||
(int) y - selectedPoint.getIntrinsicHeight() / 2,
|
||||
(int) x + selectedPoint.getIntrinsicWidth() / 2,
|
||||
(int) y + selectedPoint.getIntrinsicHeight() / 2);
|
||||
selectedPoint.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue