Merge branch 'master' of https://github.com/osmandapp/Osmand
BIN
OsmAnd-telegram/res/drawable-hdpi/ic_action_background_work.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
OsmAnd-telegram/res/drawable-hdpi/ic_device_picture.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
OsmAnd-telegram/res/drawable-mdpi/ic_action_background_work.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
OsmAnd-telegram/res/drawable-mdpi/ic_device_picture.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd-telegram/res/drawable-xhdpi/ic_action_background_work.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd-telegram/res/drawable-xhdpi/ic_device_picture.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.5 KiB |
BIN
OsmAnd-telegram/res/drawable-xxhdpi/ic_device_picture.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
2
OsmAnd-telegram/res/values-az/strings.xml
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources></resources>
|
18
OsmAnd-telegram/res/values-ru/strings.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources><string name="not_sent_yet">Не отправлено</string>
|
||||
<string name="not_found_yet">Не найдено</string>
|
||||
<string name="re_send_location">Отправить местоположение</string>
|
||||
<string name="last_sent_location">Последнее отправление</string>
|
||||
<string name="last_available_location">Последнее местоположение</string>
|
||||
<string name="sharing_status">Статус отправки</string>
|
||||
<string name="sharing_enabled">Отправка: включена</string>
|
||||
<string name="shared_string_status">Статус</string>
|
||||
<string name="no_gps_connection">Отсутствует GPS</string>
|
||||
<string name="sharing_success">Отправлено успешно</string>
|
||||
<string name="not_possible_to_send_to_chats">Нет возможности отправить в:</string>
|
||||
<string name="no_internet_connection">Отсутствует интернет</string>
|
||||
<string name="shared_string_disable">Отключить</string>
|
||||
<string name="shared_string_save">Сохранить</string>
|
||||
<string name="device_id">Устройство</string>
|
||||
<string name="add_device">Добавить устройство</string>
|
||||
</resources>
|
|
@ -3,7 +3,7 @@
|
|||
<item>
|
||||
<nine-patch android:src="@drawable/bg_card_shadow" />
|
||||
</item>
|
||||
<item>
|
||||
<item android:id="@+id/color_bg">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/discount_bar_bg" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
|
|
|
@ -154,4 +154,6 @@
|
|||
<string name="poi_operational_status_open">Açıq</string>
|
||||
<string name="poi_operational_status_closed">Bağlı</string>
|
||||
<string name="poi_water_place_access_family">Ailə</string>
|
||||
<string name="poi_service_vehicle_batteries_yes">Batareyalar</string>
|
||||
<string name="poi_checkpoint_type_code">Kod</string>
|
||||
</resources>
|
||||
|
|
|
@ -970,7 +970,7 @@
|
|||
<string name="subscribe_email_desc">Proqramın endirimləri haqqında e-poçt siyahımıza abunə olun və əlavə 3 xəritə endirməsi əldə edin!</string>
|
||||
<string name="sea_depth_thanks">“Dəniz dərinliyi konturları”nı aldığınız üçün təşəkkür edirik</string>
|
||||
<string name="index_item_depth_contours_osmand_ext">Dəniz dərinliyi konturları</string>
|
||||
<string name="index_item_depth_points_southern_hemisphere">Dəniz dərinliyi cənub yarımkürəsində göstərilir</string>
|
||||
<string name="index_item_depth_points_southern_hemisphere">Cənub yarımkürəsinin dəniz dərinliyi nöqtələri</string>
|
||||
<string name="download_depth_countours">Dəniz dərinliyi konturları</string>
|
||||
<string name="nautical_maps">Dəniz xəritələri</string>
|
||||
<string name="do_not_send_anonymous_app_usage">Anonim proqram istifadəsi statistikalarını göndərmə</string>
|
||||
|
@ -1018,7 +1018,7 @@
|
|||
<string name="shared_string_target_points">Təyinat nöqtələri</string>
|
||||
<string name="amenity_type_user_defined">İstifadəçi müəyyənləşdirib</string>
|
||||
<string name="mapillary">Mapillary</string>
|
||||
<string name="private_access_routing_req">Təyinat nöqtəniz xüsusi girişi olan ərazidə yerləşir. Bu səyahət üçün xüsusi yollara giriş icazəsi vermək istəyirsiniz?</string>
|
||||
<string name="private_access_routing_req">Təyinat nöqtəniz xüsusi girişi olan ərazidə yerləşir. Bu səyahət üçün xüsusi yollara girişə icazə verilsin\?</string>
|
||||
<string name="shared_string_plugin">Qoşma</string>
|
||||
<string name="srtm_purchase_header">Xəritədə kontur xətlərini görmək üçün “Kontur xətləri” qoşmasını alıb quraşdırmalısınız</string>
|
||||
<string name="plugin_settings">Qoşmalar</string>
|
||||
|
@ -1552,7 +1552,7 @@
|
|||
<string name="accessibility_options">Xüsusi imkanlar seçimləri</string>
|
||||
<string name="accessibility_mode">Xüsusi imkanlar rejimi</string>
|
||||
<string name="accessibility_mode_descr">Xüsusi imkanlar xüsusiyyətlərini aktivləşdirir.</string>
|
||||
<string name="index_item_depth_points_northern_hemisphere">Dəniz dərinliyi şimal yarımkürəsində göstərilir</string>
|
||||
<string name="index_item_depth_points_northern_hemisphere">Şimal yarımkürəsinin dəniz dərinliyi nöqtələri</string>
|
||||
<string name="no_waypoints_found">Yol nöqtələri tapılmadı</string>
|
||||
<string name="context_menu_item_delete_waypoint">GPX yol nöqtəsi silinsin?</string>
|
||||
<string name="context_menu_item_edit_waypoint">GPX nöqtəsinə düzəliş et</string>
|
||||
|
@ -1781,7 +1781,7 @@
|
|||
<string name="go_to_next_field">Növbəti sahə</string>
|
||||
<string name="rename_marker">İşarəni yenidən adlandır</string>
|
||||
<string name="import_as_gpx">GPX fayl kimi idxal et</string>
|
||||
<string name="import_as_favorites">Favorit kimi idxal et</string>
|
||||
<string name="import_as_favorites">Favoritlər kimi idxal et</string>
|
||||
<string name="import_file">Fayl idxal et</string>
|
||||
<string name="wrong_input">Yanlış daxiletmə</string>
|
||||
<string name="waypoints_added_to_map_markers">Yol nöqtələri xəritə işarələrinə əlavə edildi</string>
|
||||
|
@ -1894,7 +1894,7 @@
|
|||
<string name="poi_namefinder_query_empty">POI tapmaq üçün yazın</string>
|
||||
<string name="quick_action_category_descr">Favoriti yadda saxlamaq üçün kateqoriya seçin.</string>
|
||||
<string name="quick_action_sh_poi_descr">Xəritədə göstərmək üçün bir və ya bir neçə POI kateqoriyası əlavə edin.</string>
|
||||
<string name="quick_action_empty_param_error">Parametrlər boş olmamalıdır</string>
|
||||
<string name="quick_action_empty_param_error">Bütün parametrləri doldurun</string>
|
||||
<string name="quick_action_map_overlay">Xəritə örtüyünü dəyiş</string>
|
||||
<string name="quick_action_map_overlay_title">Xəritə örtükləri</string>
|
||||
<string name="quick_action_map_overlay_action">Örtük əlavə et</string>
|
||||
|
@ -1978,7 +1978,7 @@
|
|||
<string name="map_imported_successfully">Xəritə idxal edildi</string>
|
||||
<string name="empty_state_my_tracks">GPX faylları əlavə et</string>
|
||||
<string name="empty_state_my_tracks_desc">GPX faylları idxal edin və ya izlər qeyd edin.</string>
|
||||
<string name="enter_the_file_name">Fayl adını daxil edin.</string>
|
||||
<string name="enter_the_file_name">Fayl adını yazın.</string>
|
||||
<string name="distance_indication_descr">Aktiv işarələrə qədər məsafənin necə göstəriləcəyini seçin.</string>
|
||||
<string name="tunnel_warning">İrəlidə tunel</string>
|
||||
<string name="show_guide_line_descr">Mövqeyinizdən aktiv işarə məkanlarına istiqamət xəttini göstər.</string>
|
||||
|
|
|
@ -3838,4 +3838,6 @@
|
|||
<string name="poi_hill">Kopec</string>
|
||||
|
||||
<string name="poi_atm">Bankomat</string>
|
||||
</resources>
|
||||
<string name="poi_shoe_repair">Oprava obuvi</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -3965,4 +3965,6 @@
|
|||
<string name="poi_hill">Bakke</string>
|
||||
|
||||
<string name="poi_atm">Pengeautomat</string>
|
||||
</resources>
|
||||
<string name="poi_shoe_repair">Skoreparation</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -3890,4 +3890,6 @@
|
|||
<string name="poi_hill">Monteto</string>
|
||||
|
||||
<string name="poi_atm">Bankaŭtomato</string>
|
||||
</resources>
|
||||
<string name="poi_shoe_repair">Ŝu-riparejo</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -3872,4 +3872,7 @@
|
|||
|
||||
<string name="poi_hill">Muinoa</string>
|
||||
|
||||
<string name="poi_atm">Kutxazain automatikoa</string>
|
||||
<string name="poi_shoe_repair">Zapaten konponketa</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -3171,12 +3171,18 @@ représentant la zone : %1$s x %2$s</string>
|
|||
<string name="search_no_results_feedback">Aucun résultat pour cette recherche ?
|
||||
\nSignalez-le nous.</string>
|
||||
<string name="test_voice_desrc">Appuyez sur un bouton pour écoutez l\'annonce vocale correspondante afin d\'identifier les annonces erronées ou manquantes.</string>
|
||||
<string name="release_3_2_pre">• Correction du plantage au démarrage si la carte contient des caractères non-latin
|
||||
\n
|
||||
\n • Amélioration de la vitesse de rendu sur les appareils Android 8.0
|
||||
\n
|
||||
\n • Support de la modification des polygones (greffon de Contribution à OSM)
|
||||
<string name="release_3_2_pre">• Correction du plantage au démarrage survenant pour certains appareils
|
||||
\n
|
||||
\n• Marques : affichage des marques traversées
|
||||
\n
|
||||
\n• L\'historique de recherche affiche désormais la dernière catégorie utilisée
|
||||
\n
|
||||
\n• Correction du plantage au démarrage si la carte contient des caractères non-latin
|
||||
\n
|
||||
\n• Amélioration de la vitesse de rendu sur les appareils Android 8.0
|
||||
\n
|
||||
\n• Support de la modification des polygones (greffon de Contribution à OSM)
|
||||
\n
|
||||
\n• Mesure de distance : ajout de Mesurer dans le menu contextuel des actions</string>
|
||||
<string name="commiting_way">Envoi de la direction…</string>
|
||||
<string name="ask_for_location_permission">Afin de continuer, veuillez accorder à OsmAnd l\'autorisation d’utiliser votre position.</string>
|
||||
|
|
|
@ -3865,4 +3865,7 @@
|
|||
|
||||
<string name="poi_hill">Hæð</string>
|
||||
|
||||
<string name="poi_atm">Hraðbanki</string>
|
||||
<string name="poi_shoe_repair">Skóviðgerðir</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1788,7 +1788,7 @@
|
|||
<string name="edit_group">Редактировать группу</string>
|
||||
<string name="plugin_install_needs_network">Вам необходимо Интернет соединение для установки этого плагина.</string>
|
||||
<string name="shared_string_enable">Включить</string>
|
||||
<string name="shared_string_disable">Выключить</string>
|
||||
<string name="shared_string_disable">Отключить</string>
|
||||
<string name="get_plugin">Получить</string>
|
||||
<string name="plugin_ski_name">Лыжные карты</string>
|
||||
<string name="plugin_nautical_name">Морские карты</string>
|
||||
|
|
|
@ -3899,4 +3899,6 @@
|
|||
<string name="poi_hill">Montigru</string>
|
||||
|
||||
<string name="poi_atm">Bancomat</string>
|
||||
</resources>
|
||||
<string name="poi_shoe_repair">Acontzu de iscarpas</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -2586,7 +2586,7 @@ Koda predstavlja območje: %1$s x %2$s</string>
|
|||
<string name="download_depth_countours">Navtični relief globine</string>
|
||||
<string name="route_is_too_long_v2">Preračunavanje poti je lahko zelo dolgotrajno. V kolikor izračun ne bo končan v 10 minutah, vstavite nekaj vmesnih točk.</string>
|
||||
<string name="open_mapillary">Odpri Mapillary</string>
|
||||
<string name="hillshade_menu_download_descr">Za prikaz senčenja reliefa na zemljevidu, je treba namestiti prekrivno plast senčenja za to območje.</string>
|
||||
<string name="hillshade_menu_download_descr">Za prikaz senčenja reliefa na zemljevidu je treba namestiti prekrivno plast senčenja za to območje.</string>
|
||||
<string name="hillshade_purchase_header">Za prikaz senčenja reliefa na zemljevidu, je treba kupiti in namestiti vstavek Izohipse.</string>
|
||||
<string name="hide_from_zoom_level">Skrij od ravni približanja</string>
|
||||
<string name="srtm_menu_download_descr">Za prikaz izohips reliefa na zemljevidu, je treba prejeti zemljevid reliefa za to območje.</string>
|
||||
|
@ -2873,7 +2873,7 @@ Koda predstavlja območje: %1$s x %2$s</string>
|
|||
<string name="map_import_error">Uvoz zemljevida je spodletel</string>
|
||||
<string name="map_imported_successfully">Zemljevid je uvožen.</string>
|
||||
<string name="distance_farthest">Razdalja: najdlje najprej</string>
|
||||
<string name="distance_nearest">Razdalja: Najbližje najprej</string>
|
||||
<string name="distance_nearest">Razdalja: najbližje najprej</string>
|
||||
<string name="enter_lon">Vpišite zemljepisno širino</string>
|
||||
<string name="enter_lat">Vpišite zemljepisno dolžino</string>
|
||||
<string name="enter_lat_and_lon">Vpišite zemljepisno širino in dolžino</string>
|
||||
|
|
|
@ -2,9 +2,15 @@ package net.osmand.plus.helpers;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
|
@ -20,6 +26,7 @@ import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControll
|
|||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -33,10 +40,7 @@ public class DiscountHelper {
|
|||
//private static final String DISCOUNT_JSON = "discount.json";
|
||||
|
||||
private static long mLastCheckTime;
|
||||
private static String mTitle;
|
||||
private static String mDescription;
|
||||
private static String mIcon;
|
||||
private static String mUrl;
|
||||
private static ControllerData mData;
|
||||
private static boolean mBannerVisible;
|
||||
private static final String URL = "https://osmand.net/api/motd";
|
||||
private static final String INAPP_PREFIX = "osmand-in-app:";
|
||||
|
@ -49,7 +53,7 @@ public class DiscountHelper {
|
|||
return;
|
||||
}
|
||||
if (mBannerVisible) {
|
||||
showDiscountBanner(mapActivity, mTitle, mDescription, mIcon, mUrl);
|
||||
showDiscountBanner(mapActivity, mData);
|
||||
}
|
||||
if (System.currentTimeMillis() - mLastCheckTime < 1000 * 60 * 60 * 24
|
||||
|| !settings.isInternetConnectionAvailable()) {
|
||||
|
@ -58,7 +62,7 @@ public class DiscountHelper {
|
|||
mLastCheckTime = System.currentTimeMillis();
|
||||
final Map<String, String> pms = new LinkedHashMap<>();
|
||||
pms.put("version", Version.getFullVersion(app));
|
||||
pms.put("nd", app.getAppInitializer().getFirstInstalledDays() +"");
|
||||
pms.put("nd", app.getAppInitializer().getFirstInstalledDays() + "");
|
||||
pms.put("ns", app.getAppInitializer().getNumberOfStarts() + "");
|
||||
pms.put("lang", app.getLanguage() + "");
|
||||
try {
|
||||
|
@ -71,9 +75,8 @@ public class DiscountHelper {
|
|||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
try {
|
||||
String res = AndroidNetworkUtils.sendRequest(mapActivity.getMyApplication(),
|
||||
return AndroidNetworkUtils.sendRequest(mapActivity.getMyApplication(),
|
||||
URL, pms, "Requesting discount info...", false, false);
|
||||
return res;
|
||||
} catch (Exception e) {
|
||||
logError("Requesting discount info error: ", e);
|
||||
return null;
|
||||
|
@ -95,10 +98,7 @@ public class DiscountHelper {
|
|||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
|
||||
JSONObject obj = new JSONObject(response);
|
||||
String message = obj.getString("message");
|
||||
String description = obj.getString("description");
|
||||
String icon = obj.getString("icon");
|
||||
String url = parseUrl(app, obj.getString("url"));
|
||||
ControllerData data = ControllerData.parse(app, obj);
|
||||
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm");
|
||||
Date start = df.parse(obj.getString("start"));
|
||||
Date end = df.parse(obj.getString("end"));
|
||||
|
@ -107,8 +107,8 @@ public class DiscountHelper {
|
|||
int maxTotalShow = obj.getInt("max_total_show");
|
||||
JSONObject application = obj.getJSONObject("application");
|
||||
|
||||
if (url.startsWith(INAPP_PREFIX) && url.length() > INAPP_PREFIX.length()) {
|
||||
String inAppSku = url.substring(INAPP_PREFIX.length());
|
||||
if (data.url.startsWith(INAPP_PREFIX) && data.url.length() > INAPP_PREFIX.length()) {
|
||||
String inAppSku = data.url.substring(INAPP_PREFIX.length());
|
||||
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
|
||||
if (purchaseHelper != null
|
||||
&& (purchaseHelper.isPurchased(inAppSku) || InAppPurchaseHelper.isSubscribedToLiveUpdates(app))) {
|
||||
|
@ -122,7 +122,7 @@ public class DiscountHelper {
|
|||
&& date.after(start) && date.before(end)) {
|
||||
|
||||
OsmandSettings settings = app.getSettings();
|
||||
int discountId = getDiscountId(message, description, start, end);
|
||||
int discountId = getDiscountId(data.message, start);
|
||||
boolean discountChanged = settings.DISCOUNT_ID.get() != discountId;
|
||||
if (discountChanged) {
|
||||
settings.DISCOUNT_TOTAL_SHOW.set(0);
|
||||
|
@ -130,13 +130,13 @@ public class DiscountHelper {
|
|||
// show after every N (getNumberOfStarts()) starts or show after every N (double show_day_frequency) frequency
|
||||
if (discountChanged
|
||||
|| (app.getAppInitializer().getNumberOfStarts() - settings.DISCOUNT_SHOW_NUMBER_OF_STARTS.get() >= showStartFrequency
|
||||
|| System.currentTimeMillis() - settings.DISCOUNT_SHOW_DATETIME_MS.get() > 1000L * 60 * 60 * 24 * showDayFrequency) ) {
|
||||
if(settings.DISCOUNT_TOTAL_SHOW.get() < maxTotalShow){
|
||||
|| System.currentTimeMillis() - settings.DISCOUNT_SHOW_DATETIME_MS.get() > 1000L * 60 * 60 * 24 * showDayFrequency)) {
|
||||
if (settings.DISCOUNT_TOTAL_SHOW.get() < maxTotalShow) {
|
||||
settings.DISCOUNT_ID.set(discountId);
|
||||
settings.DISCOUNT_TOTAL_SHOW.set(settings.DISCOUNT_TOTAL_SHOW.get() + 1);
|
||||
settings.DISCOUNT_SHOW_NUMBER_OF_STARTS.set(app.getAppInitializer().getNumberOfStarts());
|
||||
settings.DISCOUNT_SHOW_DATETIME_MS.set(System.currentTimeMillis());
|
||||
showDiscountBanner(mapActivity, message, description, icon, url);
|
||||
showDiscountBanner(mapActivity, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,42 +156,43 @@ public class DiscountHelper {
|
|||
return url;
|
||||
}
|
||||
|
||||
private static int getDiscountId(String message, String description, Date start, Date end) {
|
||||
private static int getDiscountId(String message, Date start) {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((message == null) ? 0 : message.hashCode());
|
||||
result = prime * result + ((start == null) ? 0 : start.hashCode());
|
||||
// result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
// result = prime * result + ((end == null) ? 0 : end.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void showDiscountBanner(final MapActivity mapActivity, final String title,
|
||||
final String description, final String icon, final String url) {
|
||||
private static void showDiscountBanner(final MapActivity mapActivity, final ControllerData data) {
|
||||
int iconId = mapActivity.getResources().getIdentifier(data.iconId, "drawable", mapActivity.getMyApplication().getPackageName());
|
||||
final DiscountBarController toolbarController = new DiscountBarController();
|
||||
toolbarController.setTitle(title);
|
||||
toolbarController.setDescription(description);
|
||||
int iconId = mapActivity.getResources().getIdentifier(icon, "drawable", mapActivity.getMyApplication().getPackageName());
|
||||
if (data.bgColor != -1) {
|
||||
LayerDrawable bgLand = (LayerDrawable) ContextCompat.getDrawable(mapActivity, R.drawable.discount_bar_bg_land);
|
||||
if (bgLand != null) {
|
||||
((GradientDrawable) bgLand.findDrawableByLayerId(R.id.color_bg)).setColor(data.bgColor);
|
||||
}
|
||||
ColorDrawable bg = new ColorDrawable(data.bgColor);
|
||||
toolbarController.setBgs(bg, bg, bgLand, bgLand);
|
||||
}
|
||||
toolbarController.setTitle(data.message);
|
||||
toolbarController.setTitleTextClrs(data.titleColor, data.titleColor);
|
||||
toolbarController.setDescription(data.description);
|
||||
toolbarController.setDescrTextClrs(data.descrColor, data.descrColor);
|
||||
toolbarController.setBackBtnIconIds(iconId, iconId);
|
||||
if (!Algorithms.isEmpty(url)) {
|
||||
toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
|
||||
toolbarController.setBackBtnIconClrs(data.iconColor, data.iconColor);
|
||||
if (!Algorithms.isEmpty(data.url)) {
|
||||
View.OnClickListener clickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.getMyApplication().logEvent(mapActivity, "motd_click");
|
||||
mBannerVisible = false;
|
||||
mapActivity.hideTopToolbar(toolbarController);
|
||||
openUrl(mapActivity, url);
|
||||
openUrl(mapActivity, data.url);
|
||||
}
|
||||
});
|
||||
toolbarController.setOnTitleClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.getMyApplication().logEvent(mapActivity, "motd_click");
|
||||
mBannerVisible = false;
|
||||
mapActivity.hideTopToolbar(toolbarController);
|
||||
openUrl(mapActivity, url);
|
||||
}
|
||||
});
|
||||
};
|
||||
toolbarController.setOnBackButtonClickListener(clickListener);
|
||||
toolbarController.setOnTitleClickListener(clickListener);
|
||||
}
|
||||
toolbarController.setOnCloseButtonClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -202,10 +203,7 @@ public class DiscountHelper {
|
|||
}
|
||||
});
|
||||
|
||||
mTitle = title;
|
||||
mDescription = description;
|
||||
mIcon = icon;
|
||||
mUrl = url;
|
||||
mData = data;
|
||||
mBannerVisible = true;
|
||||
|
||||
mapActivity.showTopToolbar(toolbarController);
|
||||
|
@ -220,7 +218,7 @@ public class DiscountHelper {
|
|||
if (purchaseHelper != null) {
|
||||
purchaseHelper.purchaseFullVersion(mapActivity);
|
||||
}
|
||||
} else if (url.contains(InAppPurchaseHelper.SKU_LIVE_UPDATES)){
|
||||
} else if (url.contains(InAppPurchaseHelper.SKU_LIVE_UPDATES)) {
|
||||
ChoosePlanDialogFragment.showOsmLiveInstance(mapActivity.getSupportFragmentManager());
|
||||
}
|
||||
} else {
|
||||
|
@ -230,9 +228,47 @@ public class DiscountHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private static class ControllerData {
|
||||
|
||||
String message;
|
||||
String description;
|
||||
String iconId;
|
||||
String url;
|
||||
|
||||
@ColorInt
|
||||
int iconColor = -1;
|
||||
@ColorInt
|
||||
int bgColor = -1;
|
||||
@ColorInt
|
||||
int titleColor = -1;
|
||||
@ColorInt
|
||||
int descrColor = -1;
|
||||
|
||||
static ControllerData parse(OsmandApplication app, JSONObject obj) throws JSONException {
|
||||
ControllerData res = new ControllerData();
|
||||
res.message = obj.getString("message");
|
||||
res.description = obj.getString("description");
|
||||
res.iconId = obj.getString("icon");
|
||||
res.url = parseUrl(app, obj.getString("url"));
|
||||
res.iconColor = parseColor("icon_color", obj);
|
||||
res.bgColor = parseColor("bg_color", obj);
|
||||
res.titleColor = parseColor("title_color", obj);
|
||||
res.descrColor = parseColor("description_color", obj);
|
||||
return res;
|
||||
}
|
||||
|
||||
private static int parseColor(String key, JSONObject obj) {
|
||||
String color = obj.optString(key);
|
||||
if (!color.isEmpty()) {
|
||||
return Color.parseColor(color);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private static class DiscountBarController extends TopToolbarController {
|
||||
|
||||
public DiscountBarController() {
|
||||
DiscountBarController() {
|
||||
super(TopToolbarControllerType.DISCOUNT);
|
||||
setSingleLineTitle(false);
|
||||
setBackBtnIconClrIds(0, 0);
|
||||
|
@ -244,10 +280,6 @@ public class DiscountHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private static void logError(String msg) {
|
||||
Log.e(TAG, msg);
|
||||
}
|
||||
|
||||
private static void logError(String msg, Throwable e) {
|
||||
Log.e(TAG, "Error: " + msg, e);
|
||||
}
|
||||
|
|
|
@ -688,6 +688,19 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
return filteredRoutes;
|
||||
}
|
||||
|
||||
private List<TransportStopRoute> filterNearbyTransportRoutes(List<TransportStopRoute> routes, List<TransportStopRoute> filterFromRoutes) {
|
||||
if (filterFromRoutes == null) {
|
||||
return routes;
|
||||
}
|
||||
List<TransportStopRoute> filteredRoutes = new ArrayList<>();
|
||||
for (TransportStopRoute route : routes) {
|
||||
if (!containsRef(filterFromRoutes, route.route)) {
|
||||
filteredRoutes.add(route);
|
||||
}
|
||||
}
|
||||
return filteredRoutes;
|
||||
}
|
||||
|
||||
private boolean containsRef(List<TransportStopRoute> routes, TransportRoute transportRoute) {
|
||||
for (TransportStopRoute route : routes) {
|
||||
if (route.route.getRef().equals(transportRoute.getRef())) {
|
||||
|
@ -1297,7 +1310,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
updateLocalRoutesBadges(localFilteredTransportStopRoutes, localColumnsPerRow);
|
||||
}
|
||||
if (nearbyTransportStopRoutes != null) {
|
||||
updateNearbyRoutesBadges(maxLocalRows, filterTransportRoutes(nearbyTransportStopRoutes));
|
||||
updateNearbyRoutesBadges(maxLocalRows, filterNearbyTransportRoutes(nearbyTransportStopRoutes, localTransportStopRoutes));
|
||||
}
|
||||
transportBadgesCreated = true;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package net.osmand.plus.views.mapwidgets;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
|
@ -215,25 +219,53 @@ public class MapInfoWidgetsFactory {
|
|||
public static class TopToolbarController {
|
||||
private TopToolbarControllerType type;
|
||||
|
||||
@ColorRes
|
||||
int bgLightId = R.color.bg_color_light;
|
||||
@ColorRes
|
||||
int bgDarkId = R.color.bg_color_dark;
|
||||
@DrawableRes
|
||||
int bgLightLandId = R.drawable.btn_round;
|
||||
@DrawableRes
|
||||
int bgDarkLandId = R.drawable.btn_round_night;
|
||||
@Nullable
|
||||
Drawable bgLight = null;
|
||||
@Nullable
|
||||
Drawable bgDark = null;
|
||||
@Nullable
|
||||
Drawable bgLightLand = null;
|
||||
@Nullable
|
||||
Drawable bgDarkLand = null;
|
||||
|
||||
@DrawableRes
|
||||
int backBtnIconLightId = R.drawable.ic_arrow_back;
|
||||
@DrawableRes
|
||||
int backBtnIconDarkId = R.drawable.ic_arrow_back;
|
||||
@ColorRes
|
||||
int backBtnIconClrLightId = R.color.icon_color;
|
||||
@ColorRes
|
||||
int backBtnIconClrDarkId = 0;
|
||||
@ColorInt
|
||||
int backBtnIconClrLight = -1;
|
||||
@ColorInt
|
||||
int backBtnIconClrDark = -1;
|
||||
|
||||
@DrawableRes
|
||||
int closeBtnIconLightId = R.drawable.ic_action_remove_dark;
|
||||
@DrawableRes
|
||||
int closeBtnIconDarkId = R.drawable.ic_action_remove_dark;
|
||||
@ColorRes
|
||||
int closeBtnIconClrLightId = R.color.icon_color;
|
||||
@ColorRes
|
||||
int closeBtnIconClrDarkId = 0;
|
||||
boolean closeBtnVisible = true;
|
||||
|
||||
@DrawableRes
|
||||
int refreshBtnIconLightId = R.drawable.ic_action_refresh_dark;
|
||||
@DrawableRes
|
||||
int refreshBtnIconDarkId = R.drawable.ic_action_refresh_dark;
|
||||
@ColorRes
|
||||
int refreshBtnIconClrLightId = R.color.icon_color;
|
||||
@ColorRes
|
||||
int refreshBtnIconClrDarkId = 0;
|
||||
|
||||
boolean refreshBtnVisible = false;
|
||||
|
@ -241,10 +273,22 @@ public class MapInfoWidgetsFactory {
|
|||
protected boolean topBarSwitchVisible = false;
|
||||
protected boolean topBarSwitchChecked = false;
|
||||
|
||||
@ColorRes
|
||||
int titleTextClrLightId = R.color.primary_text_light;
|
||||
@ColorRes
|
||||
int titleTextClrDarkId = R.color.primary_text_dark;
|
||||
@ColorRes
|
||||
int descrTextClrLightId = R.color.primary_text_light;
|
||||
@ColorRes
|
||||
int descrTextClrDarkId = R.color.primary_text_dark;
|
||||
@ColorInt
|
||||
int titleTextClrLight = -1;
|
||||
@ColorInt
|
||||
int titleTextClrDark = -1;
|
||||
@ColorInt
|
||||
int descrTextClrLight = -1;
|
||||
@ColorInt
|
||||
int descrTextClrDark = -1;
|
||||
|
||||
boolean singleLineTitle = true;
|
||||
|
||||
|
@ -301,6 +345,13 @@ public class MapInfoWidgetsFactory {
|
|||
this.bgDarkLandId = bgDarkLandId;
|
||||
}
|
||||
|
||||
public void setBgs(Drawable bgLight, Drawable bgDark, Drawable bgLightLand, Drawable bgDarkLand) {
|
||||
this.bgLight = bgLight;
|
||||
this.bgDark = bgDark;
|
||||
this.bgLightLand = bgLightLand;
|
||||
this.bgDarkLand = bgDarkLand;
|
||||
}
|
||||
|
||||
public void setBackBtnIconIds(int backBtnIconLightId, int backBtnIconDarkId) {
|
||||
this.backBtnIconLightId = backBtnIconLightId;
|
||||
this.backBtnIconDarkId = backBtnIconDarkId;
|
||||
|
@ -311,6 +362,11 @@ public class MapInfoWidgetsFactory {
|
|||
this.backBtnIconClrDarkId = backBtnIconClrDarkId;
|
||||
}
|
||||
|
||||
public void setBackBtnIconClrs(int backBtnIconClrLight, int backBtnIconClrDark) {
|
||||
this.backBtnIconClrLight = backBtnIconClrLight;
|
||||
this.backBtnIconClrDark = backBtnIconClrDark;
|
||||
}
|
||||
|
||||
public void setCloseBtnIconIds(int closeBtnIconLightId, int closeBtnIconDarkId) {
|
||||
this.closeBtnIconLightId = closeBtnIconLightId;
|
||||
this.closeBtnIconDarkId = closeBtnIconDarkId;
|
||||
|
@ -360,11 +416,21 @@ public class MapInfoWidgetsFactory {
|
|||
this.titleTextClrDarkId = titleTextClrDarkId;
|
||||
}
|
||||
|
||||
public void setTitleTextClrs(int titleTextClrLight, int titleTextClrDark) {
|
||||
this.titleTextClrLight = titleTextClrLight;
|
||||
this.titleTextClrDark = titleTextClrDark;
|
||||
}
|
||||
|
||||
public void setDescrTextClrIds(int descrTextClrLightId, int descrTextClrDarkId) {
|
||||
this.descrTextClrLightId = descrTextClrLightId;
|
||||
this.descrTextClrDarkId = descrTextClrDarkId;
|
||||
}
|
||||
|
||||
public void setDescrTextClrs(int descrTextClrLight, int descrTextClrDark) {
|
||||
this.descrTextClrLight = descrTextClrLight;
|
||||
this.descrTextClrDark = descrTextClrDark;
|
||||
}
|
||||
|
||||
public void setOnBackButtonClickListener(OnClickListener onBackButtonClickListener) {
|
||||
this.onBackButtonClickListener = onBackButtonClickListener;
|
||||
}
|
||||
|
@ -596,56 +662,57 @@ public class MapInfoWidgetsFactory {
|
|||
public void updateColors(TopToolbarController controller) {
|
||||
OsmandApplication app = map.getMyApplication();
|
||||
controller.nightMode = nightMode;
|
||||
if (nightMode) {
|
||||
topBarLayout.setBackgroundResource(AndroidUiHelper.isOrientationPortrait(map) ? controller.bgDarkId : controller.bgDarkLandId);
|
||||
if (controller.backBtnIconDarkId == 0) {
|
||||
backButton.setImageDrawable(null);
|
||||
} else {
|
||||
backButton.setImageDrawable(app.getUIUtilities().getIcon(controller.backBtnIconDarkId, controller.backBtnIconClrDarkId));
|
||||
}
|
||||
if (controller.closeBtnIconDarkId == 0) {
|
||||
closeButton.setImageDrawable(null);
|
||||
} else {
|
||||
closeButton.setImageDrawable(app.getUIUtilities().getIcon(controller.closeBtnIconDarkId, controller.closeBtnIconClrDarkId));
|
||||
}
|
||||
if (controller.refreshBtnIconDarkId == 0) {
|
||||
refreshButton.setImageDrawable(null);
|
||||
} else {
|
||||
refreshButton.setImageDrawable(app.getUIUtilities().getIcon(controller.refreshBtnIconDarkId, controller.refreshBtnIconClrDarkId));
|
||||
}
|
||||
int titleColor = map.getResources().getColor(controller.titleTextClrDarkId);
|
||||
int descrColor = map.getResources().getColor(controller.descrTextClrDarkId);
|
||||
titleView.setTextColor(titleColor);
|
||||
descrView.setTextColor(descrColor);
|
||||
saveView.setTextColor(titleColor);
|
||||
|
||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(map);
|
||||
int bgId = portrait
|
||||
? nightMode ? controller.bgDarkId : controller.bgLightId
|
||||
: nightMode ? controller.bgDarkLandId : controller.bgLightLandId;
|
||||
Drawable bg = portrait
|
||||
? nightMode ? controller.bgDark : controller.bgLight
|
||||
: nightMode ? controller.bgDarkLand : controller.bgLightLand;
|
||||
int backBtnIconId = nightMode ? controller.backBtnIconDarkId : controller.backBtnIconLightId;
|
||||
int backBtnIconClr = nightMode ? controller.backBtnIconClrDark : controller.backBtnIconClrLight;
|
||||
int backBtnIconClrId = nightMode ? controller.backBtnIconClrDarkId : controller.backBtnIconClrLightId;
|
||||
int closeBtnIconId = nightMode ? controller.closeBtnIconDarkId : controller.closeBtnIconLightId;
|
||||
int closeBtnIconClrId = nightMode ? controller.closeBtnIconClrDarkId : controller.closeBtnIconClrLightId;
|
||||
int refreshBtnIconId = nightMode ? controller.refreshBtnIconDarkId : controller.refreshBtnIconLightId;
|
||||
int refreshBtnIconClrId = nightMode ? controller.refreshBtnIconClrDarkId : controller.refreshBtnIconClrLightId;
|
||||
int titleTextClr = nightMode ? controller.titleTextClrDark : controller.titleTextClrLight;
|
||||
int titleTextClrId = nightMode ? controller.titleTextClrDarkId : controller.titleTextClrLightId;
|
||||
int descrTextClr = nightMode ? controller.descrTextClrDark : controller.descrTextClrLight;
|
||||
int descrTextClrId = nightMode ? controller.descrTextClrDarkId : controller.descrTextClrLightId;
|
||||
|
||||
if (bg != null) {
|
||||
topBarLayout.setBackgroundDrawable(bg);
|
||||
} else {
|
||||
topBarLayout.setBackgroundResource(AndroidUiHelper.isOrientationPortrait(map) ? controller.bgLightId : controller.bgLightLandId);
|
||||
if (controller.backBtnIconLightId == 0) {
|
||||
backButton.setImageDrawable(null);
|
||||
} else {
|
||||
backButton.setImageDrawable(app.getUIUtilities().getIcon(controller.backBtnIconLightId, controller.backBtnIconClrLightId));
|
||||
}
|
||||
if (controller.closeBtnIconLightId == 0) {
|
||||
closeButton.setImageDrawable(null);
|
||||
} else {
|
||||
closeButton.setImageDrawable(app.getUIUtilities().getIcon(controller.closeBtnIconLightId, controller.closeBtnIconClrLightId));
|
||||
}
|
||||
if (controller.refreshBtnIconLightId == 0) {
|
||||
refreshButton.setImageDrawable(null);
|
||||
} else {
|
||||
refreshButton.setImageDrawable(app.getUIUtilities().getIcon(controller.refreshBtnIconLightId, controller.refreshBtnIconClrLightId));
|
||||
}
|
||||
int titleColor = map.getResources().getColor(controller.titleTextClrLightId);
|
||||
int descrColor = map.getResources().getColor(controller.descrTextClrLightId);
|
||||
titleView.setTextColor(titleColor);
|
||||
descrView.setTextColor(descrColor);
|
||||
saveView.setTextColor(titleColor);
|
||||
topBarLayout.setBackgroundResource(bgId);
|
||||
}
|
||||
if (controller.singleLineTitle) {
|
||||
titleView.setSingleLine(true);
|
||||
if (backBtnIconId == 0) {
|
||||
backButton.setImageDrawable(null);
|
||||
} else {
|
||||
titleView.setSingleLine(false);
|
||||
if (backBtnIconClr != -1) {
|
||||
backButton.setImageDrawable(app.getUIUtilities().getPaintedIcon(backBtnIconId, backBtnIconClr));
|
||||
} else {
|
||||
backButton.setImageDrawable(app.getUIUtilities().getIcon(backBtnIconId, backBtnIconClrId));
|
||||
}
|
||||
}
|
||||
if (closeBtnIconId == 0) {
|
||||
closeButton.setImageDrawable(null);
|
||||
} else {
|
||||
closeButton.setImageDrawable(app.getUIUtilities().getIcon(closeBtnIconId, closeBtnIconClrId));
|
||||
}
|
||||
if (refreshBtnIconId == 0) {
|
||||
refreshButton.setImageDrawable(null);
|
||||
} else {
|
||||
refreshButton.setImageDrawable(app.getUIUtilities().getIcon(refreshBtnIconId, refreshBtnIconClrId));
|
||||
}
|
||||
int titleColor = titleTextClr != -1 ? titleTextClr : map.getResources().getColor(titleTextClrId);
|
||||
int descrColor = descrTextClr != -1 ? descrTextClr : map.getResources().getColor(descrTextClrId);
|
||||
titleView.setTextColor(titleColor);
|
||||
descrView.setTextColor(descrColor);
|
||||
saveView.setTextColor(titleColor);
|
||||
|
||||
titleView.setSingleLine(controller.singleLineTitle);
|
||||
|
||||
if (controller.closeBtnVisible) {
|
||||
if (closeButton.getVisibility() == View.GONE) {
|
||||
|
|