Merge branch 'master' of https://github.com/osmandapp/Osmand into preferences_improvements

This commit is contained in:
Vitaliy 2020-01-02 16:55:47 +02:00
commit 1dd244eb7c
33 changed files with 2060 additions and 157 deletions

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View file

@ -2,4 +2,5 @@ armeabi/
x86/
armeabi-v7a/
mips/
arm64-v8a/
arm64-v8a/
x86_64/

View file

@ -1,5 +1,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/divider_color_dark" />

View file

@ -1,5 +1,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/divider_color_light" />

View file

@ -10,6 +10,7 @@
android:layout_marginLeft="24dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
android:textColor="?android:attr/textColorSecondary"
android:layout_marginBottom="8dp"
android:text="@string/animate_routing_gpx" />
@ -25,6 +26,7 @@
android:layout_marginLeft="24dp"
android:layout_marginTop="5dp"
android:layout_marginRight="16dp"
android:textColor="?android:attr/textColorSecondary"
android:gravity="left"
android:text="@string/select_animate_speedup" />
@ -47,6 +49,7 @@
android:id="@+id/MinSpeedup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorSecondary"
android:layout_weight="0.5"
android:gravity="left"
android:text="10" />
@ -55,6 +58,7 @@
android:id="@+id/MaxSpeedup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorSecondary"
android:layout_weight="0.5"
android:gravity="right"
android:text="15" />

View file

@ -24,7 +24,8 @@
android:layout_height="match_parent"
android:background="?attr/list_background_color"
android:clipToPadding="false"
android:paddingBottom="72dp" />
android:paddingBottom="72dp"
android:paddingTop="16dp"/>
<LinearLayout
android:layout_width="match_parent"

View file

@ -12,11 +12,11 @@
app:srcCompat="@drawable/circle_contour_bg_light" />
<ImageView
android:id="@+id/bckgroundCircle"
android:id="@+id/backgroundCircle"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="4dp"
app:srcCompat="@drawable/ic_action_circle" />
android:background="@drawable/circle_background_light" />
<ImageView
android:id="@+id/checkMark"
@ -31,5 +31,4 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="4dp" />
</FrameLayout>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
@ -10,22 +10,21 @@
<net.osmand.plus.widgets.OsmandTextFieldBoxes
android:id="@+id/profile_name_otfb"
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_margin="@dimen/list_content_padding"
android:layout_height="wrap_content"
android:layout_weight="1"
app:labelText="@string/profile_name_hint"
android:layout_margin="@dimen/list_content_padding"
app:primaryColor="@color/active_color_primary_dark"
app:secondaryColor="?android:textColorSecondary">
app:secondaryColor="?android:textColorSecondary"
app:labelText="@string/profile_name_hint">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/profile_name_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:inputType="textMultiLine"
android:scrollHorizontally="false"
android:maxLines="4"
tools:text="@string/lorem_ipsum" />
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
</LinearLayout>

View file

@ -3248,7 +3248,7 @@
<string name="profile_alert_need_save_title">حفظ التغييرات</string>
<string name="profile_alert_need_save_msg">احفظ التغييرات في ملف التعريف أولاً</string>
<string name="profile_alert_delete_title">حذف الملف الشخصي</string>
<string name="profile_alert_delete_msg">هل تريد بالتأكيد حذف ملف التعريف \"٪ s\"</string>
<string name="profile_alert_delete_msg">هل تريد بالتأكيد حذف ملف التعريف \"%s\"</string>
<string name="select_base_profile_dialog_title">حدد ملف تعريف أساسي</string>
<string name="select_base_profile_dialog_message">إسناد ملف التعريف المخصص الخاص بك إلى أحد ملفات تعريف التطبيق الافتراضية ، يحدد الإعداد الأساسي مثل الرؤية الافتراضية لعناصر واجهة المستخدم ووحدات السرعة والمسافة. وهذه هي ملفات تعريف التطبيق الافتراضية ، إلى جانب أمثلة لملفات تعريف مخصصة يمكن تمديدها إلى:</string>
<string name="select_nav_profile_dialog_title">حدد نوع الملاحة</string>

View file

@ -135,8 +135,8 @@
<string name="poi_tobacco">Tubaka pood</string>
<string name="poi_toys">Mänguasjapood</string>
<string name="poi_fuel_avia_type">Kütuse liik (avio)</string>
<string name="poi_payment_type">Makse tüüp</string>
<string name="poi_payment_fuel_type">Kütuse kaardid</string>
<string name="poi_payment_type">Makse liik</string>
<string name="poi_payment_fuel_type">Kütusekaardid</string>
<string name="poi_additional_type">Täiendav</string>
<string name="poi_internet_access_type">Interneti juurdepääsu tüüp</string>
<string name="poi_vending_type">Müügiautomaatide tüüp</string>
@ -152,4 +152,161 @@
<string name="poi_traffic_enforcement">Liikluspiirangud</string>
<string name="poi_transport_construction">Transpordi ehitus</string>
<string name="poi_seamark">Merendus</string>
<string name="poi_variety_store">Mitmesuguste kaupade pood</string>
<string name="poi_department_store">Kaubamaja</string>
<string name="poi_car">Automüüja</string>
<string name="poi_car_parts">Autoosad</string>
<string name="poi_marketplace">Turuplats</string>
<string name="poi_police">Politsei</string>
<string name="poi_fire_station">Tuletõrjedepoo</string>
<string name="poi_emergency_phone">Hädaabitelefon</string>
<string name="poi_fire_hydrant">Tuletõrjehüdrant</string>
<string name="poi_fire_extinguisher">Tulekustuti</string>
<string name="poi_fire_flapper">Tuletõrjeklapp</string>
<string name="poi_fire_hose">Tuletõrjevoolik</string>
<string name="poi_fire_water_pond">Tuletõrjevee tiik</string>
<string name="poi_grit_bin">Liivatuskast</string>
<string name="poi_ambulance_station">Kiirabi jaam</string>
<string name="poi_ses_station">SES jaam</string>
<string name="poi_emergency_access_point">Hädaabipunkt</string>
<string name="poi_ford">Koolmekoht</string>
<string name="poi_bed">Voodipesu pood</string>
<string name="poi_trade">Kauplemispunkt</string>
<string name="poi_vacuum_cleaner">Tolmuimejate pood</string>
<string name="poi_video">Video pood</string>
<string name="poi_window_blind">Aknakatete pood</string>
<string name="poi_electronics">Elektroonikapood</string>
<string name="poi_atv">Neljarattaliste pood</string>
<string name="poi_cosmetics">Kosmeetika</string>
<string name="poi_sewing">Kuivkaupade pood</string>
<string name="poi_tyres">Rehvipood</string>
<string name="poi_energy">Energialadu</string>
<string name="poi_watches">Kellapood</string>
<string name="poi_games">Mängud</string>
<string name="poi_model">Vähendatud mudelid</string>
<string name="poi_trophy">Trofeed, autasud</string>
<string name="poi_video_games">Videomängud</string>
<string name="poi_pyrotechnics">Pürotehnika</string>
<string name="poi_weapons">Relvapood</string>
<string name="poi_swimming_pool_shop">Basseinikaupade pood</string>
<string name="poi_perfumery">Parfümeeriapood</string>
<string name="poi_ford_stepping_stones">Samm-kivisild</string>
<string name="poi_honey">Meepood</string>
<string name="poi_religion">Religioossed kaubad</string>
<string name="poi_spices">Vürtsipood</string>
<string name="poi_fuel_type">Kütuse liik</string>
<string name="poi_shop_craft">Kunsti- ja käsitöötarvete pood</string>
<string name="poi_tactile_paving">Kombatav sillutis</string>
<string name="poi_service_car">Autoteenindus</string>
<string name="poi_brushless">Harjadeta</string>
<string name="poi_self_service">Iseteenindus</string>
<string name="poi_automated">Automaatne</string>
<string name="poi_parking_type">Liik</string>
<string name="poi_covered">Kaetud</string>
<string name="poi_subway_station_filter">Metroojaam</string>
<string name="poi_ferry_terminal_cargo">Lasti</string>
<string name="poi_bicycle_parking_type">Liik</string>
<string name="poi_aerialway_bicycle">Jalgrattavedu</string>
<string name="poi_aerialway_heating">Küte</string>
<string name="poi_pump">Pump</string>
<string name="poi_observatory_designation">Määramine</string>
<string name="poi_telescope_type">Liik</string>
<string name="poi_animal_training_type">Liik</string>
<string name="poi_embassy_type">Liik</string>
<string name="poi_city_capital">Pealinn</string>
<string name="poi_pharmacy_dispensing">Väljastamine</string>
<string name="poi_healthcare_alternative_types">Eriala</string>
<string name="poi_free_flying_characteristics">Iseloomulik</string>
<string name="poi_archaeological_site_type">Liik</string>
<string name="poi_star_rating">Tärnihinnang</string>
<string name="poi_denomination">Nimiväärtus</string>
<string name="poi_fee">Piletitasu</string>
<string name="poi_religion_type">Religioon</string>
<string name="poi_information_type">Liik</string>
<string name="poi_information_contents">Sisu</string>
<string name="poi_clock_option">Täiendav</string>
<string name="poi_scout_camp">Skaudilaager</string>
<string name="poi_backcountry">Tagamaa</string>
<string name="poi_resort_type">Liik</string>
<string name="poi_piste_difficulty">Nõlva raskusaste</string>
<string name="poi_piste_grooming">Nõlva hooldus</string>
<string name="poi_theatre_genre">Žanr</string>
<string name="poi_outdoor_seating">Istekohad õues</string>
<string name="poi_smoking">Suitsetamine</string>
<string name="poi_delivery">Kohaletoimetamine</string>
<string name="poi_drive_in">Sõida sisse</string>
<string name="poi_drive_through">Sõida läbi</string>
<string name="poi_takeaway">Buffee</string>
<string name="poi_cocktails">Kokteilid</string>
<string name="poi_microbrewery">Väikepruulikoda</string>
<string name="poi_beauty_salon_service">Teenus</string>
<string name="poi_recycling_type">Liik</string>
<string name="poi_recycling_accepted_waste">Vastuvõetud jäätmed</string>
<string name="poi_shelter_type">Liik</string>
<string name="poi_fireplace">Kamin</string>
<string name="poi_seasonal">Hooajaline</string>
<string name="poi_water_characteristic">Vee omadus</string>
<string name="poi_beach_surface_type">Pind</string>
<string name="poi_nudism">Nudistid</string>
<string name="poi_diet">Toitumine</string>
<string name="poi_health_specialty">Tervishoiu eriala</string>
<string name="poi_massage_type">Massaaži liik</string>
<string name="poi_tents">Telgid</string>
<string name="poi_washing_machine">Pesumasin</string>
<string name="poi_caravans">Haagissuvilad</string>
<string name="poi_power_supply">Toiteallikas</string>
<string name="poi_medical_system">Meditsiinisüsteem</string>
<string name="poi_home_visit">Koduvisiit</string>
<string name="poi_dish">Roog</string>
<string name="poi_payment_transport_type">Makse liik (transport)</string>
<string name="poi_social_facility_type">Liik</string>
<string name="poi_social_facility_for">Sihtrühm</string>
<string name="poi_compressed_air_filter">Suruõhk</string>
<string name="poi_vacuum_cleaner_filter">Tolmuimeja</string>
<string name="poi_free_flying_characteristic">Iseloomujoon</string>
<string name="poi_emergency_infrastructure">Hädaolukorras kasutatav infrastruktuur</string>
<string name="poi_cafeteria">Kohvik</string>
<string name="poi_zoo_type">Liik</string>
<string name="poi_motorcycle_services">Teenused</string>
<string name="poi_motorcycle_type">Mootorratta liik</string>
<string name="poi_animal_shelter_type">Loomad lubatud</string>
<string name="poi_animal_shelter_purpose">Eesmärk</string>
<string name="poi_boat_rental_type">Laenutatud paadid</string>
<string name="poi_operational_status">Tööseisund</string>
<string name="poi_water_supply_type">Veevarustuse liik</string>
<string name="poi_water_purification">Veepuhastus</string>
<string name="poi_water_place_access">Juurdepääs veekohale</string>
<string name="poi_climbing_style">Ronimisstiil</string>
<string name="poi_socket">Pistikupesa</string>
<string name="poi_socket_chademo_output_filter">CHAdeMO väljund</string>
<string name="poi_socket_type2_output_filter">2. liiki väljund</string>
<string name="poi_socket_type2_combo_output_filter">2. liiki liitväljund</string>
<string name="poi_socket_type3_output_filter">3. liiki väljund</string>
<string name="poi_socket_cee_blue_output_filter">CEE sinine väljund</string>
<string name="poi_socket_schuko_output_filter">Schuko väljund</string>
<string name="poi_service_general">Teenus</string>
<string name="poi_glacier_type">Liustiku liik</string>
<string name="poi_checkpoint_type">Kontrollpunkti liik</string>
<string name="poi_bulk_purchase">Hulgiost</string>
<string name="poi_substation_type">Liik</string>
<string name="poi_books_type">Raamatud</string>
<string name="poi_denotation">Tähistamine</string>
<string name="poi_park_ride">Pargi ja reisi</string>
<string name="poi_rtsa_scale_filter">Raskusastme kategooria</string>
<string name="poi_climbing_crag_filter">Ronimiskragi</string>
<string name="poi_climbing_crag">Jah</string>
<string name="poi_snowmobile_filter">Ligipääs mootorsaanidele</string>
<string name="poi_access_bus">Ligipääs bussidele</string>
<string name="poi_access_caravan">Ligipääs haagissuvilatele</string>
<string name="poi_access_motorhome">Ligipääs vagunelamutele</string>
<string name="poi_access_trailer">Ligipääs järelhaagistele</string>
<string name="poi_access_motorcycle">Ligipääs mootorratastele</string>
<string name="poi_access_moped">Ligipääs mopeedidele</string>
<string name="poi_access_mofa">Ligipääs mofadele</string>
<string name="poi_access_hgv">Ligipääs raskeveokitele</string>
<string name="poi_access_goods">Ligipääs kergetele kaubaveokitele</string>
<string name="poi_access_disabled">Ligipääs puuetega inimestele</string>
<string name="poi_cash_withdrawal_bank_card">Sularaha väljavõtmine</string>
<string name="poi_bath_type">Liik</string>
<string name="poi_bath_open_air">Vabaõhu</string>
</resources>

File diff suppressed because it is too large Load diff

View file

@ -3634,4 +3634,12 @@
<string name="poi_cash_withdrawal_migros_bank">Банк Migros</string>
<string name="poi_cash_withdrawal_girocard">Girocard</string>
<string name="poi_cash_withdrawal_postbank">Postbank</string>
<string name="poi_public_bookcase_type_phone_box">Тип: телефонная будка</string>
<string name="poi_public_bookcase_type_reading_box">Тип: читальная коробка</string>
<string name="poi_public_bookcase_type_wooden_cabinet">Тип: деревянный шкаф</string>
<string name="poi_public_bookcase_type_metal_cabinet">Тип: металлический шкаф</string>
<string name="poi_public_bookcase_type_shelf">Тип: полка</string>
<string name="poi_cuisine_buschenschank">Бушеншанк (изысканные австрийские вина)</string>
<string name="poi_cuisine_fine_dining">Изысканная кухня</string>
<string name="poi_network">Сеть</string>
</resources>

View file

@ -2909,7 +2909,7 @@
<string name="use_osm_live_public_transport_description">Увімкнути громадський транспорт із врахуванням авто-оновлень OsmAnd Live.</string>
<string name="use_osm_live_public_transport">Громадський транспорт OsmAnd Live</string>
<string name="step_by_step">По черзі</string>
<string name="routeInfo_road_types_name">Типи доріг</string>
<string name="routeInfo_road_types_name">Види доріг</string>
<string name="exit_at">Вихід на</string>
<string name="sit_on_the_stop">Посадка на зупинці</string>
<string name="shared_string_swap">Поміняти</string>
@ -2947,7 +2947,7 @@
<string name="quick_action_switch_day_mode">Денний режим</string>
<string name="quick_action_switch_night_mode">Нічний режим</string>
<string name="quick_action_day_night_switch_mode">Перемкнути Денний/Нічний режим</string>
<string name="routeInfo_roadClass_name">Тип дороги</string>
<string name="routeInfo_roadClass_name">Вид дороги</string>
<string name="routeInfo_surface_name">Поверхня</string>
<string name="routeInfo_smoothness_name">Рівність</string>
<string name="routeInfo_steepness_name">Крутість</string>
@ -2978,14 +2978,14 @@
<string name="rendering_attr_surface_paving_stones_name">Тротуарна плитка</string>
<string name="rendering_attr_surface_pebblestone_name">Галька</string>
<string name="rendering_attr_surface_stone_name">Камінь</string>
<string name="rendering_attr_surface_metal_name">Метал</string>
<string name="rendering_attr_surface_metal_name">Ковань</string>
<string name="rendering_attr_surface_wood_name">Дерево</string>
<string name="rendering_attr_surface_gravel_name">Гравій</string>
<string name="rendering_attr_surface_fine_gravel_name">Багатошаровий гравій</string>
<string name="rendering_attr_surface_compacted_name">Втрамбована</string>
<string name="rendering_attr_surface_compacted_name">Ущільнена</string>
<string name="rendering_attr_smoothness_excellent_name">Чудова</string>
<string name="rendering_attr_smoothness_good_name">Хороша</string>
<string name="rendering_attr_smoothness_intermediate_name">Середня</string>
<string name="rendering_attr_smoothness_intermediate_name">Посередньо</string>
<string name="rendering_attr_smoothness_bad_name">Погана</string>
<string name="rendering_attr_smoothness_very_bad_name">Дуже погана</string>
<string name="rendering_attr_smoothness_horrible_name">Жахлива</string>
@ -2995,7 +2995,7 @@
<string name="rendering_attr_highway_class_road_name">Дорога</string>
<string name="rendering_attr_highway_class_street_name">Вулиця</string>
<string name="rendering_attr_highway_class_service_name">Проїзд</string>
<string name="rendering_attr_highway_class_footway_name">Тротуар</string>
<string name="rendering_attr_highway_class_footway_name">Пішохідна доріжка</string>
<string name="rendering_attr_highway_class_steps_name">Сходи</string>
<string name="waiting_for_route_calculation">Розрахунок маршруту…</string>
<string name="shared_string_description">Опис</string>
@ -3029,7 +3029,7 @@
<string name="save_poi_value_exceed_length_title">Довжина значення \"%s\"</string>
<string name="rendering_attr_surface_cobblestone_name">Мостова</string>
<string name="rendering_attr_highway_class_state_road_name">Державна дорога</string>
<string name="rendering_attr_highway_class_track_name">Сільськогосподарська</string>
<string name="rendering_attr_highway_class_track_name">Трек</string>
<string name="rendering_attr_highway_class_bridleway_name">Кінна</string>
<string name="rendering_attr_highway_class_path_name">Стежка</string>
<string name="rendering_attr_highway_class_cycleway_name">Велодоріжка</string>

View file

@ -48,6 +48,7 @@ import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import android.widget.ImageButton;
@ -551,19 +552,40 @@ public class AndroidUtils {
return coordinates;
}
public static void enterToFullScreen(Activity activity) {
public static void enterToFullScreen(Activity activity, View view) {
if (Build.VERSION.SDK_INT >= 21) {
requestLayout(view);
activity.getWindow().getDecorView()
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}
public static void exitFromFullScreen(Activity activity) {
public static void exitFromFullScreen(Activity activity, View view) {
if (Build.VERSION.SDK_INT >= 21) {
requestLayout(view);
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}
}
private static void requestLayout(final View view) {
if (view != null) {
ViewTreeObserver vto = view.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
ViewTreeObserver obs = view.getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else {
obs.removeGlobalOnLayoutListener(this);
}
view.requestLayout();
}
});
}
}
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<K, V>>() {

View file

@ -4,11 +4,8 @@ package net.osmand.plus;
import android.app.Activity;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
@ -55,7 +52,9 @@ public class OsmAndLocationSimulation {
public void startStopRouteAnimation(final Activity ma, boolean useGpx, final Runnable runnable) {
if (!isRouteAnimating()) {
if (useGpx) {
AlertDialog.Builder builder = new AlertDialog.Builder(ma);
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ma, themeRes));
builder.setTitle(R.string.animate_route);
final View view = ma.getLayoutInflater().inflate(R.layout.animate_route, null);
@ -63,6 +62,7 @@ public class OsmAndLocationSimulation {
((TextView) view.findViewById(R.id.MaxSpeedup)).setText("4"); //$NON-NLS-1$
final SeekBar speedup = (SeekBar) view.findViewById(R.id.Speedup);
speedup.setMax(3);
UiUtilities.setupSeekBar(app, speedup, nightMode, true);
builder.setView(view);
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {

View file

@ -373,12 +373,12 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
mIsDestroyed = false;
}
public void exitFromFullScreen() {
AndroidUtils.exitFromFullScreen(this);
public void exitFromFullScreen(View view) {
AndroidUtils.exitFromFullScreen(this, view);
}
public void enterToFullScreen() {
AndroidUtils.enterToFullScreen(this);
AndroidUtils.enterToFullScreen(this, getLayout());
}
@Override
@ -1060,7 +1060,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
private BaseSettingsFragment getVisibleBaseSettingsFragment(int... ids) {
for (int id : ids) {
Fragment fragment = getSupportFragmentManager().findFragmentById(id);
if (fragment != null && !fragment.isRemoving() && fragment.isVisible() && fragment instanceof BaseSettingsFragment
if (fragment != null && !fragment.isRemoving() && fragment instanceof BaseSettingsFragment
&& ((BaseSettingsFragment) fragment).getStatusBarColorId() != -1) {
return (BaseSettingsFragment) fragment;
}

View file

@ -59,7 +59,6 @@ import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.profiles.SettingsProfileActivity;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
@ -706,9 +705,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
Intent intent = new Intent(app, SettingsProfileActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
app.startActivity(intent);
BaseSettingsFragment.showInstance(mapActivity, BaseSettingsFragment.SettingsScreenType.MAIN_SETTINGS);
return true;
}
})

View file

@ -1,6 +1,5 @@
package net.osmand.plus.base;
import android.annotation.TargetApi;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Build;
@ -14,13 +13,12 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.animation.Animation;
import android.widget.ImageView;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
@ -47,25 +45,7 @@ public class BaseOsmAndFragment extends Fragment implements TransitionAnimator {
}
}
if (!isFullScreenAllowed() && activity instanceof MapActivity) {
View view = getView();
if (view != null) {
ViewTreeObserver vto = view.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onGlobalLayout() {
View view = getView();
if (view != null) {
ViewTreeObserver obs = view.getViewTreeObserver();
obs.removeOnGlobalLayoutListener(this);
view.requestLayout();
}
}
});
}
((MapActivity) activity).exitFromFullScreen();
((MapActivity) activity).exitFromFullScreen(getView());
}
}
}

View file

@ -2,12 +2,10 @@ package net.osmand.plus.dialogs;
import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.widget.CompoundButtonCompat;
import android.support.v4.widget.NestedScrollView;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
@ -18,7 +16,6 @@ import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.Collator;
import net.osmand.OsmAndCollator;
import net.osmand.plus.OsmandApplication;
@ -222,7 +219,7 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
@ColorInt
private int getStyleTitleColor(boolean selected) {
int colorId = selected
? getMyApplication() != null ? getMyApplication().getSettings().APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode) : getActiveColorId()
? getActiveColorId()
: nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light;
return getResolvedColor(colorId);
}

View file

@ -68,7 +68,7 @@ import net.osmand.plus.measurementtool.command.ClearPointsCommand;
import net.osmand.plus.measurementtool.command.MovePointCommand;
import net.osmand.plus.measurementtool.command.RemovePointCommand;
import net.osmand.plus.measurementtool.command.ReorderPointCommand;
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback;
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;

View file

@ -20,7 +20,7 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback;
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
import java.util.Collections;
import java.util.List;

View file

@ -466,12 +466,15 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
final int[] minutes, final ValueHolder<Boolean> choice,
final ValueHolder<Integer> v,
final boolean showTrackSelection, boolean nightMode) {
int textColorPrimary = ContextCompat.getColor(app, nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
int textColorSecondary = ContextCompat.getColor(app, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light);
LinearLayout ll = new LinearLayout(uiCtx);
final int dp24 = AndroidUtils.dpToPx(uiCtx, 24f);
final int dp8 = AndroidUtils.dpToPx(uiCtx, 8f);
final TextView tv = new TextView(uiCtx);
tv.setPadding(dp24, dp8 * 2, dp24, dp8);
tv.setText(String.format(patternMsg, uiCtx.getString(R.string.int_continuosly)));
tv.setTextColor(textColorSecondary);
SeekBar sp = new SeekBar(uiCtx);
sp.setPadding(dp24 + dp8, dp8, dp24 + dp8, dp8);
@ -524,7 +527,6 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(tv);
ll.addView(sp);
int textColorPrimary = ContextCompat.getColor(app, nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
if (choice != null) {
final AppCompatCheckBox cb = new AppCompatCheckBox(uiCtx);
cb.setText(R.string.shared_string_remember_my_choice);

View file

@ -1,7 +1,6 @@
package net.osmand.plus.profiles;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@ -9,14 +8,11 @@ import android.view.ContextThemeWrapper;
import android.view.View;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import static net.osmand.plus.profiles.SettingsProfileFragment.IS_USER_PROFILE;
import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
import net.osmand.plus.settings.BaseSettingsFragment;
public abstract class AppModesBottomSheetDialogFragment<T extends AbstractProfileMenuAdapter> extends MenuBottomSheetDialogFragment
implements AbstractProfileMenuAdapter.ButtonPressedListener, AbstractProfileMenuAdapter.ProfilePressedListener {
@ -79,17 +75,13 @@ public abstract class AppModesBottomSheetDialogFragment<T extends AbstractProfil
@Override
public void onProfilePressed(ApplicationMode item) {
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
intent.putExtra(IS_USER_PROFILE, item.isCustomProfile());
startActivity(intent);
this.dismiss();
BaseSettingsFragment.showInstance(getActivity(), BaseSettingsFragment.SettingsScreenType.CONFIGURE_PROFILE, item);
}
@Override
public void onButtonPressed() {
OsmandApplication app = requiredMyApplication();
Intent intent = new Intent(app, SettingsProfileActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
app.startActivity(intent);
this.dismiss();
BaseSettingsFragment.showInstance(getActivity(), BaseSettingsFragment.SettingsScreenType.MAIN_SETTINGS);
}
}

View file

@ -29,6 +29,7 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
import java.util.ArrayList;
import java.util.Collections;
@ -47,6 +48,9 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
private EditProfilesAdapter adapter;
private boolean nightMode;
private boolean wasDrawerDisabled;
@Nullable
@Override
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@ -59,9 +63,9 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
appModesOrders.put(mode.getStringKey(), mode.getOrder());
}
}
View mainView = inflater.inflate(R.layout.edit_profiles_list_fragment, container, false);
AndroidUtils.addStatusBarPadding21v(getContext(), mainView);
nightMode = !app.getSettings().isLightContent();
View mainView =UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.edit_profiles_list_fragment, container, false);
ImageButton closeButton = mainView.findViewById(R.id.close_button);
closeButton.setImageResource(R.drawable.ic_action_remove_dark);
closeButton.setOnClickListener(new View.OnClickListener() {
@ -124,7 +128,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
recyclerView.setAdapter(adapter);
View cancelButton = mainView.findViewById(R.id.dismiss_button);
UiUtilities.setupDialogButton(false, cancelButton, UiUtilities.DialogButtonType.SECONDARY, R.string.shared_string_cancel);
UiUtilities.setupDialogButton(nightMode, cancelButton, UiUtilities.DialogButtonType.SECONDARY, R.string.shared_string_cancel);
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -138,7 +142,7 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
mainView.findViewById(R.id.buttons_divider).setVisibility(View.VISIBLE);
View applyButton = mainView.findViewById(R.id.right_bottom_button);
UiUtilities.setupDialogButton(false, applyButton, UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_apply);
UiUtilities.setupDialogButton(nightMode, applyButton, UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_apply);
applyButton.setVisibility(View.VISIBLE);
applyButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -179,6 +183,11 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
return mainView;
}
@Override
protected boolean isFullScreenAllowed() {
return false;
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
@ -186,6 +195,41 @@ public class EditProfilesFragment extends BaseOsmAndFragment {
outState.putStringArrayList(DELETED_APP_MODES_KEY, deletedModesKeys);
}
@Override
public void onResume() {
super.onResume();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
wasDrawerDisabled = mapActivity.isDrawerDisabled();
if (!wasDrawerDisabled) {
mapActivity.disableDrawer();
}
}
}
public void onPause() {
super.onPause();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null && !wasDrawerDisabled) {
mapActivity.enableDrawer();
}
}
@Override
public int getStatusBarColorId() {
return nightMode ? R.color.status_bar_color_dark : R.color.status_bar_color_light;
}
@Nullable
public MapActivity getMapActivity() {
FragmentActivity activity = getActivity();
if (activity instanceof MapActivity) {
return (MapActivity) activity;
} else {
return null;
}
}
public List<EditProfileDataObject> getProfiles(boolean deleted) {
List<EditProfileDataObject> profiles = new ArrayList<>();
for (ApplicationMode mode : ApplicationMode.allPossibleValues()) {

View file

@ -28,9 +28,9 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback;
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback.UnmovableItem;
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback.OnItemMoveCallback;
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback.UnmovableItem;
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback.OnItemMoveCallback;
import java.util.ArrayList;
import java.util.Collections;

View file

@ -20,7 +20,7 @@ import android.widget.TextView;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.SelectMapViewQuickActionsBottomSheet;
import net.osmand.plus.profiles.ReorderItemTouchHelperCallback;
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
import java.util.ArrayList;
import java.util.Collections;

View file

@ -19,7 +19,6 @@ import android.support.transition.Transition;
import android.support.transition.TransitionListenerAdapter;
import android.support.transition.TransitionManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.AppCompatImageView;
import android.view.View;
@ -71,7 +70,6 @@ import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenuFragment;
import net.osmand.plus.mapmarkers.MapMarkerSelectionFragment;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.profiles.AppModesBottomSheetDialogFragment;
import net.osmand.plus.profiles.AppModesBottomSheetDialogFragment.UpdateMapRouteMenuListener;
import net.osmand.plus.profiles.ConfigureAppModesBottomSheetDialogFragment;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter;
@ -798,14 +796,14 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
private void showProfileBottomSheetDialog() {
final AppModesBottomSheetDialogFragment fragment = new ConfigureAppModesBottomSheetDialogFragment();
fragment.setUsedOnMap(true);
fragment.setUpdateMapRouteMenuListener(new UpdateMapRouteMenuListener() {
fragment.setUpdateMapRouteMenuListener(new AppModesBottomSheetDialogFragment.UpdateMapRouteMenuListener() {
@Override
public void updateAppModeMenu() {
updateApplicationModes();
}
});
getMapActivity().getSupportFragmentManager().beginTransaction()
.add(fragment, ConfigureAppModesBottomSheetDialogFragment.TAG).commitAllowingStateLoss();
.add(fragment, ConfigureAppModesBottomSheetDialogFragment.TAG).commitAllowingStateLoss();
}
private void updateApplicationMode(ApplicationMode mode, ApplicationMode next) {

View file

@ -143,7 +143,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
updateTheme();
View view = super.onCreateView(inflater, container, savedInstanceState);
if (view != null) {
AndroidUtils.addStatusBarPadding21v(getContext(), view);
if (getPreferenceScreen() != null) {
PreferenceManager prefManager = getPreferenceManager();
PreferenceScreen preferenceScreen = prefManager.inflateFromResource(prefManager.getContext(), currentScreenType.preferencesResId, null);
@ -229,6 +228,9 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, colorId));
}
}
if (activity instanceof MapActivity) {
((MapActivity) activity).exitFromFullScreen(getView());
}
}
}
}
@ -237,17 +239,19 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
public void onPause() {
super.onPause();
MapActivity mapActivity = getMapActivity();
if (!wasDrawerDisabled && mapActivity != null) {
mapActivity.enableDrawer();
}
Activity activity = getActivity();
if (activity != null) {
if (!wasDrawerDisabled && activity instanceof MapActivity) {
((MapActivity) activity).enableDrawer();
}
if (Build.VERSION.SDK_INT >= 21) {
Activity activity = getActivity();
if (activity != null) {
if (Build.VERSION.SDK_INT >= 21) {
if (!(activity instanceof MapActivity) && statusBarColor != -1) {
activity.getWindow().setStatusBarColor(statusBarColor);
}
if (activity instanceof MapActivity) {
((MapActivity) activity).enterToFullScreen();
}
}
}
}
@ -748,4 +752,11 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
}
return false;
}
void updateRouteInfoMenu() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMapRouteInfoMenu().updateMenu();
}
}
}

View file

@ -123,6 +123,12 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
}
}
@Override
public void onPause() {
updateRouteInfoMenu();
super.onPause();
}
private void updateToolbarSwitch() {
View view = getView();
if (view == null) {

View file

@ -38,7 +38,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
private static final String APP_PROFILES = "app_profiles";
private static final String SELECTED_PROFILE = "selected_profile";
private static final String CREATE_PROFILE = "create_profile";
private static final String IMPORT_PROFILE = "import_profile";
// private static final String IMPORT_PROFILE = "import_profile";
private static final String REORDER_PROFILES = "reorder_profiles";
private List<ApplicationMode> allAppModes;
@ -136,7 +136,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
Preference createProfile = findPreference(CREATE_PROFILE);
createProfile.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_plus,
isNightMode() ? R.color.active_color_primary_dark : R.color.active_color_primary_light));
Preference importProfile = findPreference(IMPORT_PROFILE);
// Preference importProfile = findPreference(IMPORT_PROFILE);
// importProfile.setIcon(app.getUIUtilities().getIcon(R.drawable.ic_action_import,
// isNightMode() ? R.color.active_color_primary_dark : R.color.active_color_primary_light));
Preference reorderProfiles = findPreference(REORDER_PROFILES);
@ -198,4 +198,10 @@ public class MainSettingsFragment extends BaseSettingsFragment {
}
return selectProfileListener;
}
@Override
public void onPause() {
updateRouteInfoMenu();
super.onPause();
}
}

View file

@ -53,10 +53,12 @@ public class NavigationFragment extends BaseSettingsFragment {
SwitchPreferenceCompat turnScreenOn = (SwitchPreferenceCompat) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId());
SwitchPreferenceEx animateMyLocation = (SwitchPreferenceEx) findPreference(settings.ANIMATE_MY_LOCATION.getId());
if (getSelectedAppMode().getRoutingProfile() != null) {
GeneralRouter gr = app.getRoutingConfig().getRouter(getSelectedAppMode().getRoutingProfile());
RoutingProfilesResources routingProfilesResources = RoutingProfilesResources.valueOf(gr.getProfileName().toUpperCase());
navigationType.setSummary(routingProfilesResources.getStringRes());
navigationType.setIcon(getContentIcon(routingProfilesResources.getIconRes()));
GeneralRouter routingProfile = app.getRoutingConfig().getRouter(getSelectedAppMode().getRoutingProfile());
if (routingProfile != null) {
RoutingProfilesResources routingProfilesResources = RoutingProfilesResources.valueOf(routingProfile.getProfileName().toUpperCase());
navigationType.setSummary(routingProfilesResources.getStringRes());
navigationType.setIcon(getContentIcon(routingProfilesResources.getIconRes()));
}
}
routeParameters.setIcon(getContentIcon(R.drawable.ic_action_route_distance));
showRoutingAlarms.setIcon(getContentIcon(R.drawable.ic_action_alert));

View file

@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.PorterDuff;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
@ -14,6 +15,7 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
@ -74,6 +76,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
private EditText profileName;
private FlowLayout colorItems;
private FlowLayout iconItems;
private OsmandTextFieldBoxes profileNameOtfb;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -93,7 +96,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
if (baseModeForNewProfile != null) {
profile.stringKey = baseModeForNewProfile.getStringKey() + "_" + System.currentTimeMillis();
profile.parent = baseModeForNewProfile;
profile.name = baseModeForNewProfile.toHumanString(getContext());
profile.name = baseModeForNewProfile.toHumanString(app);
profile.color = baseModeForNewProfile.getIconColorInfo();
profile.iconRes = baseModeForNewProfile.getIconRes();
profile.routingProfile = baseModeForNewProfile.getRoutingProfile();
@ -113,7 +116,11 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
} else {
changedProfile.stringKey = profile.stringKey;
changedProfile.parent = profile.parent;
changedProfile.name = profile.name;
if (baseModeForNewProfile != null) {
changedProfile.name = createNonDuplicateName(baseModeForNewProfile.toHumanString(app));
} else {
changedProfile.name = profile.name;
}
changedProfile.color = profile.color;
changedProfile.iconRes = profile.iconRes;
changedProfile.routingProfile = profile.routingProfile;
@ -121,6 +128,39 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
}
}
private String createNonDuplicateName(String oldName) {
int suffix = 0;
int i = oldName.length() - 1;
do {
try {
if (oldName.charAt(i) == ' ' || oldName.charAt(i) == '-') {
throw new NumberFormatException();
}
suffix = Integer.parseInt(oldName.substring(i));
} catch (NumberFormatException e) {
break;
}
i--;
} while (i >= 0);
String newName;
String divider = suffix == 0 ? " " : "";
do {
suffix++;
newName = oldName.substring(0, i + 1) + divider + suffix;
}
while (hasProfileWithName(newName));
return newName;
}
private boolean hasProfileWithName(String newName) {
for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
if (m.toHumanString(app).equals(newName)) {
return true;
}
}
return false;
}
@Override
protected void setupPreferences() {
findPreference(SELECT_COLOR).setIconSpaceReserved(false);
@ -147,8 +187,8 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
AndroidUtils.setBackground(getContext(), buttonsContainer, isNightMode(), R.color.list_background_color_light, R.color.list_background_color_dark);
UiUtilities.setupDialogButton(false, cancelButton, DialogButtonType.SECONDARY, R.string.shared_string_cancel);
UiUtilities.setupDialogButton(false, saveButton, DialogButtonType.PRIMARY, R.string.shared_string_save);
UiUtilities.setupDialogButton(isNightMode(), cancelButton, DialogButtonType.SECONDARY, R.string.shared_string_cancel);
UiUtilities.setupDialogButton(isNightMode(), saveButton, DialogButtonType.PRIMARY, R.string.shared_string_save);
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -162,10 +202,13 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
@Override
public void onClick(View v) {
if (getActivity() != null) {
hideKeyboard();
if (isChanged()) {
if (saveNewProfile()) {
profile = changedProfile;
getActivity().onBackPressed();
ProfileAppearanceFragment.this.dismiss();
BaseSettingsFragment.showInstance(getMapActivity(), SettingsScreenType.CONFIGURE_PROFILE,
ApplicationMode.valueOfStringKey(changedProfile.stringKey, null));
}
}
}
@ -240,6 +283,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
if (PROFILE_NAME.equals(preference.getKey())) {
profileName = (EditText) holder.findViewById(R.id.profile_name_et);
profileName.setImeOptions(EditorInfo.IME_ACTION_DONE);
profileName.setRawInputType(InputType.TYPE_CLASS_TEXT);
profileName.setText(changedProfile.name);
profileName.requestFocus();
profileName.addTextChangedListener(new TextWatcher() {
@ -256,8 +300,10 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
changedProfile.name = s.toString();
}
});
profileNameOtfb = (OsmandTextFieldBoxes) holder.findViewById(R.id.profile_name_otfb);
} else if (MASTER_PROFILE.equals(preference.getKey())) {
baseProfileName = (EditText) holder.findViewById(R.id.master_profile_et);
baseProfileName.setFocusable(false);
baseProfileName.setText(changedProfile.parent != null
? changedProfile.parent.toHumanString(getContext())
: getSelectedAppMode().toHumanString(getContext()));
@ -318,8 +364,9 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
private View createColorItemView(final ApplicationMode.ProfileIconColors colorRes, ViewGroup rootView) {
FrameLayout colorItemView = (FrameLayout) UiUtilities.getInflater(getContext(), isNightMode())
.inflate(R.layout.preference_circle_item, rootView, false);
ImageView coloredCircle = colorItemView.findViewById(R.id.bckgroundCircle);
coloredCircle.setImageDrawable(getPaintedIcon(R.drawable.circle_background_light,
ImageView coloredCircle = colorItemView.findViewById(R.id.backgroundCircle);
AndroidUtils.setBackground(coloredCircle,
UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.circle_background_light),
ContextCompat.getColor(app, colorRes.getColor(isNightMode()))));
coloredCircle.setOnClickListener(new View.OnClickListener() {
@Override
@ -344,6 +391,10 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
if (iconItems != null) {
setIconNewColor(changedProfile.iconRes);
}
int selectedColor = ContextCompat.getColor(app,
changedProfile.color.getColor(isNightMode()));
profileNameOtfb.setPrimaryColor(selectedColor);
profileName.getBackground().mutate().setColorFilter(selectedColor, PorterDuff.Mode.SRC_ATOP);
updateProfileButton();
}
@ -352,8 +403,9 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
.inflate(R.layout.preference_circle_item, rootView, false);
ImageView checkMark = iconItemView.findViewById(R.id.checkMark);
checkMark.setImageDrawable(app.getUIUtilities().getIcon(iconRes, R.color.icon_color_default_light));
ImageView coloredCircle = iconItemView.findViewById(R.id.bckgroundCircle);
coloredCircle.setImageDrawable(getPaintedIcon(R.drawable.circle_background_light,
ImageView coloredCircle = iconItemView.findViewById(R.id.backgroundCircle);
AndroidUtils.setBackground(coloredCircle,
UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.circle_background_light),
UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, R.color.icon_color_default_light), 0.1f)));
coloredCircle.setOnClickListener(new View.OnClickListener() {
@Override
@ -373,8 +425,8 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
iconItem.findViewById(R.id.outlineCircle).setVisibility(View.GONE);
ImageView checkMark = iconItem.findViewById(R.id.checkMark);
checkMark.setImageDrawable(app.getUIUtilities().getIcon(changedProfile.iconRes, R.color.icon_color_default_light));
ImageView coloredCircle = iconItem.findViewById(R.id.bckgroundCircle);
coloredCircle.setImageDrawable(getPaintedIcon(R.drawable.circle_background_light,
AndroidUtils.setBackground(iconItem.findViewById(R.id.backgroundCircle),
UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.circle_background_light),
UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, R.color.icon_color_default_light), 0.1f)));
changedProfile.iconRes = iconRes;
updateProfileButton();
@ -385,8 +437,8 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
app.getDaynightHelper().isNightModeForMapControls()));
View iconItem = iconItems.findViewWithTag(iconRes);
if (iconItem != null) {
ImageView coloredCircle = iconItem.findViewById(R.id.bckgroundCircle);
coloredCircle.setImageDrawable(getPaintedIcon(R.drawable.circle_background_light,
AndroidUtils.setBackground(iconItem.findViewById(R.id.backgroundCircle),
UiUtilities.tintDrawable(ContextCompat.getDrawable(app, R.drawable.circle_background_light),
UiUtilities.getColorWithAlpha(ContextCompat.getColor(app, changedProfile.color.getColor(isNightMode())), 0.1f)));
ImageView outlineCircle = iconItem.findViewById(R.id.outlineCircle);
GradientDrawable circleContourDrawable = (GradientDrawable) ContextCompat.getDrawable(app, R.drawable.circle_contour_bg_light);
@ -493,10 +545,11 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
}
public boolean isProfileAppearanceChanged(final MapActivity mapActivity) {
hideKeyboard();
if (isChanged()) {
AlertDialog.Builder dismissDialog = createWarningDialog(getActivity(),
R.string.shared_string_dismiss, R.string.exit_without_saving, R.string.shared_string_cancel);
dismissDialog.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
dismissDialog.setPositiveButton(R.string.shared_string_exit, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
changedProfile = profile;

View file

@ -1,4 +1,4 @@
package net.osmand.plus.profiles;
package net.osmand.plus.views.controls;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;