Merge branch 'master' of git://github.com/osmandapp/Osmand into issue_175_osmedit_use_oauth
This commit is contained in:
commit
0f3070f160
9 changed files with 186 additions and 20 deletions
|
@ -942,4 +942,20 @@ public class Algorithms {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isValidMessageFormat(CharSequence sequence) {
|
||||||
|
if (!isEmpty(sequence)) {
|
||||||
|
int counter = 0;
|
||||||
|
for (int i = 0; i < sequence.length(); i++) {
|
||||||
|
char ch = sequence.charAt(i);
|
||||||
|
if (ch == '{') {
|
||||||
|
counter++;
|
||||||
|
} else if (ch == '}') {
|
||||||
|
counter--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return counter == 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -53,6 +53,9 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_CONFIGURE_PROFILE_ID;
|
||||||
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SWITCH_PROFILE_ID;
|
||||||
|
|
||||||
public class ContextMenuAdapter {
|
public class ContextMenuAdapter {
|
||||||
private static final Log LOG = PlatformUtil.getLog(ContextMenuAdapter.class);
|
private static final Log LOG = PlatformUtil.getLog(ContextMenuAdapter.class);
|
||||||
|
|
||||||
|
@ -134,6 +137,15 @@ public class ContextMenuAdapter {
|
||||||
Collections.sort(items, new Comparator<ContextMenuItem>() {
|
Collections.sort(items, new Comparator<ContextMenuItem>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(ContextMenuItem item1, ContextMenuItem item2) {
|
public int compare(ContextMenuItem item1, ContextMenuItem item2) {
|
||||||
|
if (DRAWER_SWITCH_PROFILE_ID.equals(item1.getId())) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (DRAWER_CONFIGURE_PROFILE_ID.equals(item1.getId()) && DRAWER_SWITCH_PROFILE_ID.equals(item2.getId())) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (DRAWER_CONFIGURE_PROFILE_ID.equals(item1.getId())) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
int order1 = item1.getOrder();
|
int order1 = item1.getOrder();
|
||||||
int order2 = item2.getOrder();
|
int order2 = item2.getOrder();
|
||||||
if (order1 < order2) {
|
if (order1 < order2) {
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package net.osmand.plus.mapcontextmenu.builders.cards;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
import net.osmand.AndroidNetworkUtils;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
public class IPFSImageCard extends ImageCard {
|
||||||
|
private static final String BASE_URL = "https://test.openplacereviews.org/api/ipfs/image-ipfs?cid=";
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(IPFSImageCard.class);
|
||||||
|
|
||||||
|
public IPFSImageCard(MapActivity mapActivity, JSONObject imageObject) {
|
||||||
|
super(mapActivity, imageObject);
|
||||||
|
String cid = "";
|
||||||
|
try {
|
||||||
|
cid = (String) imageObject.get("cid");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
LOG.error(e);
|
||||||
|
}
|
||||||
|
url = BASE_URL + cid;
|
||||||
|
imageHiresUrl = BASE_URL + cid;
|
||||||
|
imageUrl = BASE_URL + cid;
|
||||||
|
if (!Algorithms.isEmpty(getUrl())) {
|
||||||
|
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
openUrl(getMapActivity(), getMyApplication(), getTitle(), getUrl(),
|
||||||
|
isExternalLink() || Algorithms.isEmpty(getImageHiresUrl()),
|
||||||
|
!Algorithms.isEmpty(getImageHiresUrl()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (!Algorithms.isEmpty(buttonText)) {
|
||||||
|
onButtonClickListener = onClickListener;
|
||||||
|
} else {
|
||||||
|
this.onClickListener = onClickListener;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,9 @@ package net.osmand.plus.mapcontextmenu.builders.cards;
|
||||||
|
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.PointF;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.net.TrafficStats;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
@ -14,21 +16,28 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.AppCompatButton;
|
import androidx.appcompat.widget.AppCompatButton;
|
||||||
|
|
||||||
import net.osmand.AndroidNetworkUtils;
|
import com.google.gson.JsonArray;
|
||||||
import net.osmand.AndroidUtils;
|
import com.google.gson.JsonObject;
|
||||||
import net.osmand.Location;
|
import net.osmand.*;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.RotatedTileBox;
|
||||||
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
import net.osmand.plus.mapillary.MapillaryContributeCard;
|
import net.osmand.plus.mapillary.MapillaryContributeCard;
|
||||||
import net.osmand.plus.mapillary.MapillaryImageCard;
|
import net.osmand.plus.mapillary.MapillaryImageCard;
|
||||||
|
import net.osmand.plus.osmedit.OsmBugsLayer;
|
||||||
|
import net.osmand.plus.views.layers.ContextMenuLayer;
|
||||||
import net.osmand.plus.wikimedia.WikiImageHelper;
|
import net.osmand.plus.wikimedia.WikiImageHelper;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -36,18 +45,16 @@ import org.json.JSONObject;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.LinkedHashMap;
|
import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public abstract class ImageCard extends AbstractCard {
|
public abstract class ImageCard extends AbstractCard {
|
||||||
|
|
||||||
public static String TYPE_MAPILLARY_PHOTO = "mapillary-photo";
|
public static String TYPE_MAPILLARY_PHOTO = "mapillary-photo";
|
||||||
public static String TYPE_MAPILLARY_CONTRIBUTE = "mapillary-contribute";
|
public static String TYPE_MAPILLARY_CONTRIBUTE = "mapillary-contribute";
|
||||||
|
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(ImageCard.class);
|
||||||
protected String type;
|
protected String type;
|
||||||
// Image location
|
// Image location
|
||||||
protected LatLon location;
|
protected LatLon location;
|
||||||
|
@ -191,6 +198,14 @@ public abstract class ImageCard extends AbstractCard {
|
||||||
return imageCard;
|
return imageCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ImageCard createCardOpr(MapActivity mapActivity, JSONObject imageObject) {
|
||||||
|
ImageCard imageCard = null;
|
||||||
|
if (imageObject.has("cid")) {
|
||||||
|
imageCard = new IPFSImageCard(mapActivity, imageObject);
|
||||||
|
}
|
||||||
|
return imageCard;
|
||||||
|
}
|
||||||
|
|
||||||
public double getCa() {
|
public double getCa() {
|
||||||
return ca;
|
return ca;
|
||||||
}
|
}
|
||||||
|
@ -403,6 +418,7 @@ public abstract class ImageCard extends AbstractCard {
|
||||||
private Map<String, String> params;
|
private Map<String, String> params;
|
||||||
private GetImageCardsListener listener;
|
private GetImageCardsListener listener;
|
||||||
private List<ImageCard> result;
|
private List<ImageCard> result;
|
||||||
|
private static final int GET_IMAGE_CARD_THREAD_ID = 10104;
|
||||||
|
|
||||||
public interface GetImageCardsListener {
|
public interface GetImageCardsListener {
|
||||||
void onPostProcess(List<ImageCard> cardList);
|
void onPostProcess(List<ImageCard> cardList);
|
||||||
|
@ -411,7 +427,7 @@ public abstract class ImageCard extends AbstractCard {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetImageCardsTask(@NonNull MapActivity mapActivity, LatLon latLon,
|
public GetImageCardsTask(@NonNull MapActivity mapActivity, LatLon latLon,
|
||||||
@Nullable Map<String, String> params, GetImageCardsListener listener) {
|
@Nullable Map<String, String> params, GetImageCardsListener listener) {
|
||||||
this.mapActivity = mapActivity;
|
this.mapActivity = mapActivity;
|
||||||
this.app = mapActivity.getMyApplication();
|
this.app = mapActivity.getMyApplication();
|
||||||
this.latLon = latLon;
|
this.latLon = latLon;
|
||||||
|
@ -421,7 +437,14 @@ public abstract class ImageCard extends AbstractCard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<ImageCard> doInBackground(Void... params) {
|
protected List<ImageCard> doInBackground(Void... params) {
|
||||||
|
TrafficStats.setThreadStatsTag(GET_IMAGE_CARD_THREAD_ID);
|
||||||
List<ImageCard> result = new ArrayList<>();
|
List<ImageCard> result = new ArrayList<>();
|
||||||
|
Object o = mapActivity.getMapLayers().getContextMenuLayer().getSelectedObject();
|
||||||
|
if (o instanceof Amenity) {
|
||||||
|
Amenity am = (Amenity) o;
|
||||||
|
long amenityId = am.getId() >> 1;
|
||||||
|
getPicturesForPlace(result, amenityId);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
final Map<String, String> pms = new LinkedHashMap<>();
|
final Map<String, String> pms = new LinkedHashMap<>();
|
||||||
pms.put("lat", "" + (float) latLon.getLatitude());
|
pms.put("lat", "" + (float) latLon.getLatitude());
|
||||||
|
@ -482,6 +505,35 @@ public abstract class ImageCard extends AbstractCard {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getPicturesForPlace(List<ImageCard> result, long l) {
|
||||||
|
String url = "https://test.openplacereviews.org/api/objects-by-index?type=opr.place&index=osmid&limit=1&key=" + l;
|
||||||
|
String response = AndroidNetworkUtils.sendRequest(app, url, Collections.<String, String>emptyMap(),
|
||||||
|
"Requesting location images...", false, false);
|
||||||
|
try {
|
||||||
|
if (!Algorithms.isEmpty(response)) {
|
||||||
|
JSONArray obj = new JSONObject(response).getJSONArray("objects");
|
||||||
|
JSONArray images = ((JSONObject) ((JSONObject) obj.get(0)).get("images")).getJSONArray("outdoor");
|
||||||
|
if (images.length() > 0) {
|
||||||
|
for (int i = 0; i < images.length(); i++) {
|
||||||
|
try {
|
||||||
|
JSONObject imageObject = (JSONObject) images.get(i);
|
||||||
|
if (imageObject != JSONObject.NULL) {
|
||||||
|
ImageCard imageCard = ImageCard.createCardOpr(mapActivity, imageObject);
|
||||||
|
if (imageCard != null) {
|
||||||
|
result.add(imageCard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
LOG.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(List<ImageCard> cardList) {
|
protected void onPostExecute(List<ImageCard> cardList) {
|
||||||
result = cardList;
|
result = cardList;
|
||||||
|
|
|
@ -131,7 +131,14 @@ public class LiveMonitoringHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendData(LiveMonitoringData data) {
|
public void sendData(LiveMonitoringData data) {
|
||||||
String urlStr = getLiveUrl(data);
|
String baseUrl = app.getSettings().LIVE_MONITORING_URL.get();
|
||||||
|
String urlStr;
|
||||||
|
try {
|
||||||
|
urlStr = getLiveUrl(baseUrl, data);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.error("Could not construct live url from base url: " + baseUrl, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// Parse the URL and let the URI constructor handle proper encoding of special characters such as spaces
|
// Parse the URL and let the URI constructor handle proper encoding of special characters such as spaces
|
||||||
URL url = new URL(urlStr);
|
URL url = new URL(urlStr);
|
||||||
|
@ -172,12 +179,11 @@ public class LiveMonitoringHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getLiveUrl(LiveMonitoringData data) {
|
private String getLiveUrl(String baseUrl, LiveMonitoringData data) {
|
||||||
String st = app.getSettings().LIVE_MONITORING_URL.get();
|
|
||||||
List<String> prm = new ArrayList<String>();
|
List<String> prm = new ArrayList<String>();
|
||||||
int maxLen = 0;
|
int maxLen = 0;
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
boolean b = st.contains("{"+i+"}");
|
boolean b = baseUrl.contains("{"+i+"}");
|
||||||
if(b) {
|
if(b) {
|
||||||
maxLen = i;
|
maxLen = i;
|
||||||
}
|
}
|
||||||
|
@ -210,6 +216,6 @@ public class LiveMonitoringHelper {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return MessageFormat.format(st, prm.toArray());
|
return MessageFormat.format(baseUrl, prm.toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
|
import android.preference.EditTextPreference;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
|
@ -23,11 +24,11 @@ import android.view.Window;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmAndTaskManager.OsmAndTaskRunnable;
|
import net.osmand.plus.OsmAndTaskManager.OsmAndTaskRunnable;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -35,6 +36,8 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.SavingTrackHelper;
|
import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -172,8 +175,20 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
|
||||||
cat.setTitle(R.string.live_monitoring_m);
|
cat.setTitle(R.string.live_monitoring_m);
|
||||||
grp.addPreference(cat);
|
grp.addPreference(cat);
|
||||||
|
|
||||||
cat.addPreference(createEditTextPreference(settings.LIVE_MONITORING_URL, R.string.live_monitoring_url,
|
EditTextPreference urlPreference = createEditTextPreference(settings.LIVE_MONITORING_URL, R.string.live_monitoring_url,
|
||||||
R.string.live_monitoring_url_descr));
|
R.string.live_monitoring_url_descr);
|
||||||
|
urlPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
if (Algorithms.isValidMessageFormat((String) newValue)) {
|
||||||
|
return SettingsMonitoringActivity.super.onPreferenceChange(preference, newValue);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(SettingsMonitoringActivity.this, R.string.wrong_format, Toast.LENGTH_SHORT).show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cat.addPreference(urlPreference);
|
||||||
final CheckBoxPreference liveMonitoring = createCheckBoxPreference(settings.LIVE_MONITORING, R.string.live_monitoring_m,
|
final CheckBoxPreference liveMonitoring = createCheckBoxPreference(settings.LIVE_MONITORING, R.string.live_monitoring_m,
|
||||||
R.string.live_monitoring_m_descr);
|
R.string.live_monitoring_m_descr);
|
||||||
cat.addPreference(liveMonitoring);
|
cat.addPreference(liveMonitoring);
|
||||||
|
|
|
@ -51,6 +51,8 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.APP_PROFILES_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.APP_PROFILES_ID;
|
||||||
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_CONFIGURE_PROFILE_ID;
|
||||||
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SWITCH_PROFILE_ID;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MORE_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MORE_ID;
|
||||||
import static net.osmand.plus.settings.fragments.RearrangeMenuItemsAdapter.AdapterItemType.BUTTON;
|
import static net.osmand.plus.settings.fragments.RearrangeMenuItemsAdapter.AdapterItemType.BUTTON;
|
||||||
import static net.osmand.plus.settings.fragments.RearrangeMenuItemsAdapter.AdapterItemType.DESCRIPTION;
|
import static net.osmand.plus.settings.fragments.RearrangeMenuItemsAdapter.AdapterItemType.DESCRIPTION;
|
||||||
|
@ -183,7 +185,9 @@ public class ConfigureMenuItemsFragment extends BaseOsmAndFragment
|
||||||
public static List<ContextMenuItem> getCustomizableDefaultItems(List<ContextMenuItem> defItems) {
|
public static List<ContextMenuItem> getCustomizableDefaultItems(List<ContextMenuItem> defItems) {
|
||||||
List<ContextMenuItem> items = new ArrayList<>();
|
List<ContextMenuItem> items = new ArrayList<>();
|
||||||
for (ContextMenuItem item : defItems) {
|
for (ContextMenuItem item : defItems) {
|
||||||
if (!APP_PROFILES_ID.equals(item.getId())) {
|
if (!APP_PROFILES_ID.equals(item.getId())
|
||||||
|
&& !DRAWER_CONFIGURE_PROFILE_ID.equals(item.getId())
|
||||||
|
&& !DRAWER_SWITCH_PROFILE_ID.equals(item.getId())) {
|
||||||
items.add(item);
|
items.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.graphics.drawable.Drawable;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
import androidx.appcompat.widget.SwitchCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
@ -12,11 +13,12 @@ import androidx.preference.Preference;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.settings.preferences.EditTextPreferenceEx;
|
import net.osmand.plus.settings.preferences.EditTextPreferenceEx;
|
||||||
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import static net.osmand.plus.UiUtilities.CompoundButtonType.TOOLBAR;
|
import static net.osmand.plus.UiUtilities.CompoundButtonType.TOOLBAR;
|
||||||
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MAX_INTERVAL_TO_SEND_MINUTES;
|
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MAX_INTERVAL_TO_SEND_MINUTES;
|
||||||
|
@ -60,6 +62,19 @@ public class LiveMonitoringFragment extends BaseSettingsFragment {
|
||||||
updateToolbarSwitch();
|
updateToolbarSwitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
if (preference.getKey().equals(settings.LIVE_MONITORING_URL.getId())) {
|
||||||
|
if (Algorithms.isValidMessageFormat((String) newValue)) {
|
||||||
|
return super.onPreferenceChange(preference, newValue);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(app, R.string.wrong_format, Toast.LENGTH_SHORT).show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onPreferenceChange(preference, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateToolbarSwitch() {
|
private void updateToolbarSwitch() {
|
||||||
View view = getView();
|
View view = getView();
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
|
|
|
@ -135,6 +135,7 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
}
|
}
|
||||||
|
|
||||||
private LayerDrawable getPlaceholder(boolean history) {
|
private LayerDrawable getPlaceholder(boolean history) {
|
||||||
|
int colorDefault = ContextCompat.getColor(app, R.color.icon_color_default_light);
|
||||||
LayerDrawable res = (LayerDrawable) AppCompatResources.getDrawable(
|
LayerDrawable res = (LayerDrawable) AppCompatResources.getDrawable(
|
||||||
app, history
|
app, history
|
||||||
? R.drawable.wikivoyage_search_history_placeholder
|
? R.drawable.wikivoyage_search_history_placeholder
|
||||||
|
@ -145,6 +146,8 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
history ? R.drawable.ic_action_history : R.drawable.ic_action_placeholder_city,
|
history ? R.drawable.ic_action_history : R.drawable.ic_action_placeholder_city,
|
||||||
R.color.icon_color_default_light
|
R.color.icon_color_default_light
|
||||||
));
|
));
|
||||||
|
} else {
|
||||||
|
res.setTint(colorDefault);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue