Fix problems and improve UI

This commit is contained in:
Nazar 2019-10-22 13:39:58 +03:00
parent 90a5ed5b76
commit e336c3b184
36 changed files with 408 additions and 277 deletions

View file

@ -9,7 +9,8 @@
<net.osmand.plus.widgets.OsmandTextFieldBoxes <net.osmand.plus.widgets.OsmandTextFieldBoxes
android:id="@+id/edit_text_otfb" android:id="@+id/edit_text_otfb"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dialog_button_ex_height" android:layout_height="wrap_content"
android:minHeight="@dimen/dialog_button_ex_height"
android:layout_marginTop="@dimen/text_margin_small" android:layout_marginTop="@dimen/text_margin_small"
android:paddingLeft="@dimen/content_padding" android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding" android:paddingRight="@dimen/content_padding"
@ -19,10 +20,11 @@
<studio.carbonylgroup.textfieldboxes.ExtendedEditText <studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/text" android:id="@+id/text"
android:inputType="textMultiLine|textNoSuggestions"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:maxLines="1" android:maxLines="10"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
tools:text="Folder path ... " /> tools:text="Folder path ... " />

View file

@ -2,46 +2,71 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:background="?attr/list_background_color"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/card_row_min_height" android:layout_height="wrap_content"
android:orientation="horizontal"> android:background="?attr/list_background_color"
android:orientation="vertical">
<android.support.v7.widget.AppCompatImageView <LinearLayout
android:id="@android:id/icon" android:layout_width="match_parent"
android:layout_width="@dimen/standard_icon_size" android:layout_height="@dimen/card_row_min_height">
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:src="@drawable/mm_storage_tank"
android:tint="?attr/default_icon_color"
tools:tint="?attr/default_icon_color" />
<net.osmand.plus.widgets.TextViewEx <android.support.v7.widget.AppCompatImageView
android:id="@android:id/title" android:id="@android:id/icon"
android:layout_width="0dp" android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:src="@drawable/mm_storage_tank"
android:tint="?attr/default_icon_color"
tools:tint="?attr/default_icon_color" />
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:paddingLeft="@dimen/content_padding"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"
tools:text="Internal application memory" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/memory"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:background="@null"
android:clickable="true"
android:focusable="true"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"
tools:text="6.7 GB" />
</LinearLayout>
<LinearLayout
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:background="?attr/list_background_color"
android:layout_weight="1" android:visibility="gone"
android:textColor="?android:textColorPrimary" android:orientation="vertical">
android:textSize="@dimen/default_desc_text_size"
android:paddingLeft="@dimen/content_padding"
osmand:typeface="@string/font_roboto_regular"
tools:text="Internal application memory" />
<net.osmand.plus.widgets.TextViewEx <View
android:id="@+id/memory" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="@dimen/content_padding_half" />
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" <View
android:background="@null" android:layout_width="match_parent"
android:clickable="true" android:layout_height="1dp"
android:focusable="true" android:background="?attr/dashboard_divider"
android:paddingLeft="@dimen/content_padding" android:focusable="false" />
android:paddingRight="@dimen/content_padding"
android:textSize="@dimen/default_desc_text_size" </LinearLayout>
osmand:typeface="@string/font_roboto_regular"
tools:text="6.7 GB" />
</LinearLayout> </LinearLayout>

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/list_background_color">
<View
android:id="@+id/topSpace"
android:layout_width="match_parent"
android:layout_height="@dimen/content_padding_half" />
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"
android:focusable="false" />
<View
android:id="@+id/bottomSpace"
android:layout_width="match_parent"
android:layout_height="@dimen/content_padding_half" />
</LinearLayout>

View file

@ -3290,8 +3290,6 @@
<string name="shared_string_by_default">Прадвызначана</string> <string name="shared_string_by_default">Прадвызначана</string>
<string name="change_data_storage_full_description">Перамясціць файлы даных OsmAnd у новае месца\? <string name="change_data_storage_full_description">Перамясціць файлы даных OsmAnd у новае месца\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • выкарыстоўваецца %2$s Гб</string>
<string name="data_storage_space_description">Вольна %1$s • %2$s / %3$s Гб</string>
<string name="enter_path_to_folder">Увядзіце шлях да каталога</string> <string name="enter_path_to_folder">Увядзіце шлях да каталога</string>
<string name="shared_string_select_folder">Абраць каталог</string> <string name="shared_string_select_folder">Абраць каталог</string>
</resources> </resources>

View file

@ -3268,8 +3268,6 @@ Abasta l\'àrea: %1$s x %2$s</string>
<string name="route_parameters">Paràmetres de la ruta</string> <string name="route_parameters">Paràmetres de la ruta</string>
<string name="change_data_storage_full_description">Voleu moure els arxius de dades OsmAnd a una nova destinació\? <string name="change_data_storage_full_description">Voleu moure els arxius de dades OsmAnd a una nova destinació\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • Usat %2$s GB</string>
<string name="data_storage_space_description">Lliure %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Introduïu el camí a la carpeta</string> <string name="enter_path_to_folder">Introduïu el camí a la carpeta</string>
<string name="shared_string_select_folder">Seleccioneu la carpeta</string> <string name="shared_string_select_folder">Seleccioneu la carpeta</string>
<string name="paste_Osmand_data_folder_path">Enganxa el camí a la carpeta amb les dades d\'OsmAnd</string> <string name="paste_Osmand_data_folder_path">Enganxa el camí a la carpeta amb les dades d\'OsmAnd</string>

View file

@ -3299,8 +3299,6 @@ Repræsenterer område: %1$s x %2$s</string>
<string name="download_detailed_map">Hent detaljeret %s kort, for at se området.</string> <string name="download_detailed_map">Hent detaljeret %s kort, for at se området.</string>
<string name="change_data_storage_full_description">Flyt datafiler til den nye destination\? <string name="change_data_storage_full_description">Flyt datafiler til den nye destination\?
\n%1$s&gt;%2$s</string> \n%1$s&gt;%2$s</string>
<string name="data_storage_preference_summary">%1$s • Anvendt %2$s GB</string>
<string name="data_storage_space_description">Tilgængeligt %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Indtast sti til mappen</string> <string name="enter_path_to_folder">Indtast sti til mappen</string>
<string name="shared_string_select_folder">Vælg mappe</string> <string name="shared_string_select_folder">Vælg mappe</string>
<string name="paste_Osmand_data_folder_path">Indsæt sti til mappen med data</string> <string name="paste_Osmand_data_folder_path">Indsæt sti til mappen med data</string>

View file

@ -3299,8 +3299,6 @@ Abgedeckte Fläche: %1$s x %2$s</string>
<string name="download_detailed_map">Laden Sie die detaillierte %s-Karte herunter, um diesen Bereich zu sehen.</string> <string name="download_detailed_map">Laden Sie die detaillierte %s-Karte herunter, um diesen Bereich zu sehen.</string>
<string name="change_data_storage_full_description">OsmAnd-Datendateien an das neue Ziel verschieben\? <string name="change_data_storage_full_description">OsmAnd-Datendateien an das neue Ziel verschieben\?
\n%1 s &gt; %2 s</string> \n%1 s &gt; %2 s</string>
<string name="data_storage_preference_summary">%1$s • Verwendet %2$s GB</string>
<string name="data_storage_space_description">Frei %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Geben Sie den Pfad zum Ordner ein</string> <string name="enter_path_to_folder">Geben Sie den Pfad zum Ordner ein</string>
<string name="shared_string_select_folder">Ordner auswählen</string> <string name="shared_string_select_folder">Ordner auswählen</string>
<string name="paste_Osmand_data_folder_path">Einfügen des Pfades zum Ordner mit OsmAnd-Daten</string> <string name="paste_Osmand_data_folder_path">Einfügen des Pfades zum Ordner mit OsmAnd-Daten</string>

View file

@ -3274,8 +3274,6 @@ Indikas lokon: %1$s x %2$s"</string>
<string name="download_detailed_map">Elŝutu la detalan mapon %s, por vidi tiun ĉi areon.</string> <string name="download_detailed_map">Elŝutu la detalan mapon %s, por vidi tiun ĉi areon.</string>
<string name="change_data_storage_full_description">Ĉu movi datumdosierojn OsmAnd al la nova loko\? <string name="change_data_storage_full_description">Ĉu movi datumdosierojn OsmAnd al la nova loko\?
\n%1$s → %2$s</string> \n%1$s → %2$s</string>
<string name="data_storage_preference_summary">%1$s • uzita: %2$s GB</string>
<string name="data_storage_space_description">Libera: %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Entajpu dosierindikon</string> <string name="enter_path_to_folder">Entajpu dosierindikon</string>
<string name="shared_string_select_folder">Elektu dosierujon</string> <string name="shared_string_select_folder">Elektu dosierujon</string>
<string name="paste_Osmand_data_folder_path">Algluu dosierindikon por dosierujo de OsmAnddatumoj</string> <string name="paste_Osmand_data_folder_path">Algluu dosierindikon por dosierujo de OsmAnddatumoj</string>

View file

@ -3293,8 +3293,6 @@ Lon %2$s</string>
<string name="download_detailed_map">Descarga el mapa detallado de «%s», para ver esta área.</string> <string name="download_detailed_map">Descarga el mapa detallado de «%s», para ver esta área.</string>
<string name="change_data_storage_full_description">¿Mover los archivos de datos de OsmAnd al nuevo destino\? <string name="change_data_storage_full_description">¿Mover los archivos de datos de OsmAnd al nuevo destino\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • Usado %2$s GB</string>
<string name="data_storage_space_description">Libre %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Ingresa la ruta a la carpeta</string> <string name="enter_path_to_folder">Ingresa la ruta a la carpeta</string>
<string name="shared_string_select_folder">Elegir carpeta</string> <string name="shared_string_select_folder">Elegir carpeta</string>
<string name="paste_Osmand_data_folder_path">Pegar la ruta a la carpeta con los datos de OsmAnd</string> <string name="paste_Osmand_data_folder_path">Pegar la ruta a la carpeta con los datos de OsmAnd</string>

View file

@ -3294,8 +3294,6 @@ Lon %2$s</string>
<string name="download_detailed_map">Descarga el mapa detallado de «%s», para ver esta área.</string> <string name="download_detailed_map">Descarga el mapa detallado de «%s», para ver esta área.</string>
<string name="change_data_storage_full_description">¿Mover los archivos de datos de OsmAnd al nuevo destino\? <string name="change_data_storage_full_description">¿Mover los archivos de datos de OsmAnd al nuevo destino\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • Usado %2$s GB</string>
<string name="data_storage_space_description">Libre %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Ingresa la ruta a la carpeta</string> <string name="enter_path_to_folder">Ingresa la ruta a la carpeta</string>
<string name="shared_string_select_folder">Elegir carpeta</string> <string name="shared_string_select_folder">Elegir carpeta</string>
<string name="paste_Osmand_data_folder_path">Pegar la ruta a la carpeta con los datos de OsmAnd</string> <string name="paste_Osmand_data_folder_path">Pegar la ruta a la carpeta con los datos de OsmAnd</string>

View file

@ -3309,8 +3309,6 @@
<string name="plugins_settings">Ajustes de plugin</string> <string name="plugins_settings">Ajustes de plugin</string>
<string name="shared_string_by_default">Por defecto</string> <string name="shared_string_by_default">Por defecto</string>
<string name="download_detailed_map">Descarga el mapa detallado de %s para ver este área.</string> <string name="download_detailed_map">Descarga el mapa detallado de %s para ver este área.</string>
<string name="data_storage_preference_summary">%1$s • Usado %2$s GB</string>
<string name="data_storage_space_description">Libre %1$s • %2$s / %3$s GB</string>
<string name="shared_string_select_folder">Seleccionar carpeta</string> <string name="shared_string_select_folder">Seleccionar carpeta</string>
<string name="move_maps_to_new_destination">Mover al nuevo destino</string> <string name="move_maps_to_new_destination">Mover al nuevo destino</string>
<string name="change_data_storage_folder">Cambiar la carpeta de almacenamiento de datos</string> <string name="change_data_storage_folder">Cambiar la carpeta de almacenamiento de datos</string>

View file

@ -3279,8 +3279,6 @@ Area honi dagokio: %1$s x %2$s</string>
<string name="download_detailed_map">Deskargatu %s(e)ko mapa xehetsua ingurune hau ikusteko.</string> <string name="download_detailed_map">Deskargatu %s(e)ko mapa xehetsua ingurune hau ikusteko.</string>
<string name="change_data_storage_full_description">Eraman OsmAnd datu fitxategiak xede berrira\? <string name="change_data_storage_full_description">Eraman OsmAnd datu fitxategiak xede berrira\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • Erabilita %2$s GB</string>
<string name="data_storage_space_description">Libre %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Sartu karpetara bidea</string> <string name="enter_path_to_folder">Sartu karpetara bidea</string>
<string name="shared_string_select_folder">Hautatu karpeta</string> <string name="shared_string_select_folder">Hautatu karpeta</string>
<string name="paste_Osmand_data_folder_path">Itsatsi OsmAnd datuak dituen karpetara bidea</string> <string name="paste_Osmand_data_folder_path">Itsatsi OsmAnd datuak dituen karpetara bidea</string>

View file

@ -3335,8 +3335,6 @@
<string name="download_detailed_map">برای دیدن این منطقه، نقشهٔ باجزئیات %s را دانلود کنید.</string> <string name="download_detailed_map">برای دیدن این منطقه، نقشهٔ باجزئیات %s را دانلود کنید.</string>
<string name="change_data_storage_full_description">فایل‌های دادهٔ OsmAnd را به مقصد جدید انتقال می‌دهید؟ <string name="change_data_storage_full_description">فایل‌های دادهٔ OsmAnd را به مقصد جدید انتقال می‌دهید؟
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • %2$s گ‌ب استفاده شده</string>
<string name="data_storage_space_description">خالی %1$s • %2$s از %3$s گ‌ب</string>
<string name="enter_path_to_folder">مسیر پوشه را وارد کنید</string> <string name="enter_path_to_folder">مسیر پوشه را وارد کنید</string>
<string name="shared_string_select_folder">انتخاب پوشه</string> <string name="shared_string_select_folder">انتخاب پوشه</string>
<string name="paste_Osmand_data_folder_path">مسیر پوشهٔ داده‌های OsmAnd را درج کنید</string> <string name="paste_Osmand_data_folder_path">مسیر پوشهٔ داده‌های OsmAnd را درج کنید</string>

View file

@ -3261,8 +3261,6 @@ représentant la zone : %1$s x %2$s</string>
<string name="download_detailed_map">Télécharger la carte détaillée %s pour voir cette zone.</string> <string name="download_detailed_map">Télécharger la carte détaillée %s pour voir cette zone.</string>
<string name="change_data_storage_full_description">Déplacer les fichiers de données OsmAnd vers la nouvelle destination \? <string name="change_data_storage_full_description">Déplacer les fichiers de données OsmAnd vers la nouvelle destination \?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • %2$s GB utilisés</string>
<string name="data_storage_space_description">Libre %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Saisissez le chemin du dossier</string> <string name="enter_path_to_folder">Saisissez le chemin du dossier</string>
<string name="shared_string_select_folder">Sélectionner le dossier</string> <string name="shared_string_select_folder">Sélectionner le dossier</string>
<string name="paste_Osmand_data_folder_path">Coller le chemin du dossier contenant les données OsmAnd</string> <string name="paste_Osmand_data_folder_path">Coller le chemin du dossier contenant les données OsmAnd</string>

View file

@ -3334,8 +3334,6 @@ Lon %2$s</string>
<string name="download_detailed_map">Baixa o mapa detallado de %s para ollar esta área.</string> <string name="download_detailed_map">Baixa o mapa detallado de %s para ollar esta área.</string>
<string name="change_data_storage_full_description">Mover os ficheiros de datos do OsmAnd ó novo destino\? <string name="change_data_storage_full_description">Mover os ficheiros de datos do OsmAnd ó novo destino\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • Empregado %2$s GB</string>
<string name="data_storage_space_description">Libre %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Insire a ruta do cartafol</string> <string name="enter_path_to_folder">Insire a ruta do cartafol</string>
<string name="shared_string_select_folder">Escoller cartafol</string> <string name="shared_string_select_folder">Escoller cartafol</string>
<string name="paste_Osmand_data_folder_path">Colar ou pegar a ruta do cartafol cos datos do OsmAnd</string> <string name="paste_Osmand_data_folder_path">Colar ou pegar a ruta do cartafol cos datos do OsmAnd</string>

View file

@ -3279,8 +3279,6 @@
<string name="routing_attr_freeride_policy_name">ללא מסלול</string> <string name="routing_attr_freeride_policy_name">ללא מסלול</string>
<string name="change_data_storage_full_description">להעביר את קובצי הנתונים של OsmAnd ליעד החדש\? <string name="change_data_storage_full_description">להעביר את קובצי הנתונים של OsmAnd ליעד החדש\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s ‏• %2$s ג״ב מנוצלים</string>
<string name="data_storage_space_description">%1$s פנויים • %2$s / %3$s ג״ב</string>
<string name="enter_path_to_folder">נא לספק נתיב לתיקייה</string> <string name="enter_path_to_folder">נא לספק נתיב לתיקייה</string>
<string name="shared_string_select_folder">בחירת תיקייה</string> <string name="shared_string_select_folder">בחירת תיקייה</string>
<string name="paste_Osmand_data_folder_path">נא להדביק את הנתיב לתיקייה עם הנתונים של OsmAnd</string> <string name="paste_Osmand_data_folder_path">נא להדביק את הנתיב לתיקייה עם הנתונים של OsmAnd</string>

View file

@ -3306,8 +3306,6 @@ Stendur fyrir svæði: %1$s x %2$s</string>
<string name="download_detailed_map">Sæktu nákvæma %s kortið til að skoða þetta svæði.</string> <string name="download_detailed_map">Sæktu nákvæma %s kortið til að skoða þetta svæði.</string>
<string name="change_data_storage_full_description">Færa gagnaskrár OsmAnd á nýjan stað\? <string name="change_data_storage_full_description">Færa gagnaskrár OsmAnd á nýjan stað\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • Notuð %2$s GB</string>
<string name="data_storage_space_description">Laust %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Settu inn slóð á möppu</string> <string name="enter_path_to_folder">Settu inn slóð á möppu</string>
<string name="shared_string_select_folder">Veldu möppu</string> <string name="shared_string_select_folder">Veldu möppu</string>
<string name="paste_Osmand_data_folder_path">Límdu slóð á möppuna með OsmAnd-gögnum</string> <string name="paste_Osmand_data_folder_path">Límdu slóð á möppuna með OsmAnd-gögnum</string>

View file

@ -28,8 +28,6 @@
<string name="configure_profile">ပရိုဖိုင်းကိုပြုပြင်မြည်</string> <string name="configure_profile">ပရိုဖိုင်းကိုပြုပြင်မြည်</string>
<string name="switch_profile">ပရိုဖိုင်းကိုပြောင်းလဲမည်</string> <string name="switch_profile">ပရိုဖိုင်းကိုပြောင်းလဲမည်</string>
<string name="change_data_storage_full_description">OsmAnd အချက်အလက်ဖိုင်များကိုနေရာအသစ်သို့ရွှေ့ပါ။ \n%1$s &gt; %2$s</string> <string name="change_data_storage_full_description">OsmAnd အချက်အလက်ဖိုင်များကိုနေရာအသစ်သို့ရွှေ့ပါ။ \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • သုံးပြီး %2$s GB</string>
<string name="data_storage_space_description">"နေရာလွပ် %1$s • %2$s / %3$s GB"</string>
<string name="enter_path_to_folder">folder ကိုရှိနေရာကိုရိုက်ထည့်ပါ</string> <string name="enter_path_to_folder">folder ကိုရှိနေရာကိုရိုက်ထည့်ပါ</string>
<string name="shared_string_select_folder">ဖိုလ်ဒါကိုရွေးပါ</string> <string name="shared_string_select_folder">ဖိုလ်ဒါကိုရွေးပါ</string>
<string name="paste_Osmand_data_folder_path">OsmAnd ဒေတာရှိသော ဖိုလ်ဒါနေရာကိုကူးထည့်ပါ</string> <string name="paste_Osmand_data_folder_path">OsmAnd ဒေတာရှိသော ဖိုလ်ဒါနေရာကိုကူးထည့်ပါ</string>

View file

@ -3299,8 +3299,6 @@ Reprezentuje obszar: %1$s x %2$s</string>
<string name="download_detailed_map">Pobierz szczegółową mapę %S, aby zobaczyć ten obszar.</string> <string name="download_detailed_map">Pobierz szczegółową mapę %S, aby zobaczyć ten obszar.</string>
<string name="change_data_storage_full_description">Przenieść pliki danych OsmAnd do nowego położenia\? <string name="change_data_storage_full_description">Przenieść pliki danych OsmAnd do nowego położenia\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">"%1$s • Użyto %2$s GB"</string>
<string name="data_storage_space_description">Wolne %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Proszę wprowadzić ścieżkę do katalogu</string> <string name="enter_path_to_folder">Proszę wprowadzić ścieżkę do katalogu</string>
<string name="shared_string_select_folder">Wybierz folder</string> <string name="shared_string_select_folder">Wybierz folder</string>
<string name="paste_Osmand_data_folder_path">Wklej ścieżkę do folderu z danymi OsmAnd</string> <string name="paste_Osmand_data_folder_path">Wklej ścieżkę do folderu z danymi OsmAnd</string>

View file

@ -3279,8 +3279,6 @@ Pôr do Sol: %2$s</string>
<string name="download_detailed_map">Faça o download do mapa %s detalhado, para visualizar esta área.</string> <string name="download_detailed_map">Faça o download do mapa %s detalhado, para visualizar esta área.</string>
<string name="change_data_storage_full_description">Mover arquivos de dados OsmAnd para o novo destino\? <string name="change_data_storage_full_description">Mover arquivos de dados OsmAnd para o novo destino\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • Usado %2$s GB</string>
<string name="data_storage_space_description">Livre %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Digite o caminho para a pasta</string> <string name="enter_path_to_folder">Digite o caminho para a pasta</string>
<string name="shared_string_select_folder">Selecionar pasta</string> <string name="shared_string_select_folder">Selecionar pasta</string>
<string name="paste_Osmand_data_folder_path">Cole o caminho para a pasta com os dados OsmAnd</string> <string name="paste_Osmand_data_folder_path">Cole o caminho para a pasta com os dados OsmAnd</string>

View file

@ -3290,8 +3290,6 @@
<string name="download_detailed_map">Descarregue o mapa detalhado de %s para ver esta área.</string> <string name="download_detailed_map">Descarregue o mapa detalhado de %s para ver esta área.</string>
<string name="change_data_storage_full_description">Mover ficheiros de dados OsmAnd para o novo destino\? <string name="change_data_storage_full_description">Mover ficheiros de dados OsmAnd para o novo destino\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • Usado %2$s GB</string>
<string name="data_storage_space_description">Livre %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Insira o caminho para a pasta</string> <string name="enter_path_to_folder">Insira o caminho para a pasta</string>
<string name="shared_string_select_folder">Selecionar pasta</string> <string name="shared_string_select_folder">Selecionar pasta</string>
<string name="paste_Osmand_data_folder_path">Colar caminho para a pasta com dados OsmAnd</string> <string name="paste_Osmand_data_folder_path">Colar caminho para a pasta com dados OsmAnd</string>

View file

@ -3300,8 +3300,6 @@ Pro praghere iscrie su còdighe intreu</string>
<string name="download_detailed_map">Iscàrriga sa mapa de %s fata a sa minuda pro pompiare cust\'àrea.</string> <string name="download_detailed_map">Iscàrriga sa mapa de %s fata a sa minuda pro pompiare cust\'àrea.</string>
<string name="change_data_storage_full_description">Tramudare sos datos de OsmAnd in sa destinatzione noa\? <string name="change_data_storage_full_description">Tramudare sos datos de OsmAnd in sa destinatzione noa\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • Impreados: %2$s GB</string>
<string name="data_storage_space_description">Lìberos: %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Inserta s\'àndala pro sa cartella</string> <string name="enter_path_to_folder">Inserta s\'àndala pro sa cartella</string>
<string name="shared_string_select_folder">Ischerta sa cartella</string> <string name="shared_string_select_folder">Ischerta sa cartella</string>
<string name="paste_Osmand_data_folder_path">Incolla s\'àndala pro sa cartella cun sos datos de OsmAnd</string> <string name="paste_Osmand_data_folder_path">Incolla s\'àndala pro sa cartella cun sos datos de OsmAnd</string>

View file

@ -3280,8 +3280,6 @@ Zodpovedá oblasti: %1$s x %2$s</string>
<string name="download_detailed_map">Pre zobrazenie tejto oblasti si stiahnite podrobnú mapu %s.</string> <string name="download_detailed_map">Pre zobrazenie tejto oblasti si stiahnite podrobnú mapu %s.</string>
<string name="change_data_storage_full_description">Presunúť dátové súbory OsmAnd do nového umiestnenia\? <string name="change_data_storage_full_description">Presunúť dátové súbory OsmAnd do nového umiestnenia\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • Použité %2$s GB</string>
<string name="data_storage_space_description">Voľné %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Zadajte cestu k priečinku</string> <string name="enter_path_to_folder">Zadajte cestu k priečinku</string>
<string name="shared_string_select_folder">Zvoľte priečinok</string> <string name="shared_string_select_folder">Zvoľte priečinok</string>
<string name="paste_Osmand_data_folder_path">Vložte cestu k priečinku s dátami OsmAnd</string> <string name="paste_Osmand_data_folder_path">Vložte cestu k priečinku s dátami OsmAnd</string>

View file

@ -3243,8 +3243,6 @@
\nHesaplama: %.1f sn, %d yol, %d döşeme)</string> \nHesaplama: %.1f sn, %d yol, %d döşeme)</string>
<string name="change_data_storage_full_description">OsmAnd veri dosyaları yeni hedefe taşınsın mı\? <string name="change_data_storage_full_description">OsmAnd veri dosyaları yeni hedefe taşınsın mı\?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • Kullanılan %2$s GB</string>
<string name="data_storage_space_description">Boş %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">Klasörün yolunu girin</string> <string name="enter_path_to_folder">Klasörün yolunu girin</string>
<string name="shared_string_select_folder">Klasör seç</string> <string name="shared_string_select_folder">Klasör seç</string>
<string name="paste_Osmand_data_folder_path">OsmAnd verilerinin bulunduğu klasörün yolunu yapıştırın</string> <string name="paste_Osmand_data_folder_path">OsmAnd verilerinin bulunduğu klasörün yolunu yapıştırın</string>

View file

@ -3282,8 +3282,6 @@
<string name="download_detailed_map">下載更詳細的 %s 地圖以檢視此區域。</string> <string name="download_detailed_map">下載更詳細的 %s 地圖以檢視此區域。</string>
<string name="change_data_storage_full_description">移動 OsmAnd 資料檔案到新目的地? <string name="change_data_storage_full_description">移動 OsmAnd 資料檔案到新目的地?
\n%1$s &gt; %2$s</string> \n%1$s &gt; %2$s</string>
<string name="data_storage_preference_summary">%1$s • 已使用 %2$s GB</string>
<string name="data_storage_space_description">剩餘 %1$s • %2$s / %3$s GB</string>
<string name="enter_path_to_folder">輸入到資料夾的路徑</string> <string name="enter_path_to_folder">輸入到資料夾的路徑</string>
<string name="shared_string_select_folder">選取資料夾</string> <string name="shared_string_select_folder">選取資料夾</string>
<string name="paste_Osmand_data_folder_path">貼上有 OsmAnd 資料的資料夾路徑</string> <string name="paste_Osmand_data_folder_path">貼上有 OsmAnd 資料的資料夾路徑</string>

View file

@ -11,6 +11,11 @@
Thx - Hardy Thx - Hardy
--> -->
<string name="shared_string_memory_used_tb_desc">Used %1$s TB</string>
<string name="shared_string_memory_used_gb_desc">Used %1$s GB</string>
<string name="shared_string_memory_used_mb_desc">Used %1$s MB</string>
<string name="shared_string_memory_used_kb_desc">Used %1$s KB</string>
<string name="contour_lines_and_hillshade">Contour lines and Hillshade</string>
<string name="shared_string_calculate">Calculate</string> <string name="shared_string_calculate">Calculate</string>
<string name="shared_string_osmand_usage">OsmAnd Usage</string> <string name="shared_string_osmand_usage">OsmAnd Usage</string>
<string name="shared_sting_tiles">Tiles</string> <string name="shared_sting_tiles">Tiles</string>
@ -24,8 +29,8 @@
<string name="rendering_attr_piste_difficulty_connection_name">Connection</string> <string name="rendering_attr_piste_difficulty_connection_name">Connection</string>
<string name="avoid_in_routing_descr_">Avoid certain routes and road types</string> <string name="avoid_in_routing_descr_">Avoid certain routes and road types</string>
<string name="change_data_storage_full_description">Move OsmAnd data files to the new destination?\n%1$s > %2$s</string> <string name="change_data_storage_full_description">Move OsmAnd data files to the new destination?\n%1$s > %2$s</string>
<string name="data_storage_preference_summary">%1$s • Used %2$s GB</string> <string name="data_storage_preference_summary">%1$s\t•\t%2$s</string>
<string name="data_storage_space_description">Free %1$s GBTotal %2$s GB</string> <string name="data_storage_space_description">Free %1$s GB\t•\tTotal %2$s GB</string>
<string name="enter_path_to_folder">Enter path to the folder</string> <string name="enter_path_to_folder">Enter path to the folder</string>
<string name="shared_string_select_folder">Select folder</string> <string name="shared_string_select_folder">Select folder</string>
<string name="paste_Osmand_data_folder_path">Paste path to the folder with OsmAnd data</string> <string name="paste_Osmand_data_folder_path">Paste path to the folder with OsmAnd data</string>

View file

@ -13,6 +13,12 @@
android:icon="@drawable/ic_map" android:icon="@drawable/ic_map"
android:title="@string/shared_string_maps"/> android:title="@string/shared_string_maps"/>
<Preference
android:key="contour_lines_and_hillshade_memory"
android:layout="@layout/data_storage_memory_used_item"
android:icon="@drawable/ic_map"
android:title="@string/contour_lines_and_hillshade"/>
<Preference <Preference
android:key="tracks_memory_used" android:key="tracks_memory_used"
android:layout="@layout/data_storage_memory_used_item" android:layout="@layout/data_storage_memory_used_item"
@ -36,9 +42,6 @@
android:layout="@layout/data_storage_memory_used_item" android:layout="@layout/data_storage_memory_used_item"
android:icon="@drawable/ic_action_folder" android:icon="@drawable/ic_action_folder"
android:title="@string/shared_string_other"/> android:title="@string/shared_string_other"/>
<Preference
android:layout="@layout/divider_padding_half" />
<PreferenceCategory <PreferenceCategory
android:key="application_profiles" android:key="application_profiles"

View file

@ -1985,6 +1985,7 @@ public class OsmandSettings {
public static final int EXTERNAL_STORAGE_TYPE_INTERNAL_FILE = 2; // ctx.getFilesDir() public static final int EXTERNAL_STORAGE_TYPE_INTERNAL_FILE = 2; // ctx.getFilesDir()
public static final int EXTERNAL_STORAGE_TYPE_OBB = 3; // ctx.getObbDirs public static final int EXTERNAL_STORAGE_TYPE_OBB = 3; // ctx.getObbDirs
public static final int EXTERNAL_STORAGE_TYPE_SPECIFIED = 4; public static final int EXTERNAL_STORAGE_TYPE_SPECIFIED = 4;
public final OsmandPreference<Long> OSMAND_USAGE_SPACE = new LongPreference("osmand_usage_space", 0).makeGlobal();
public void freezeExternalStorageDirectory() { public void freezeExternalStorageDirectory() {

View file

@ -128,6 +128,7 @@ import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType; import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
import net.osmand.plus.settings.BaseSettingsFragment; import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.settings.BaseSettingsFragment.SettingsScreenType; import net.osmand.plus.settings.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.settings.DataStorageFragment;
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint; import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapControlsLayer; import net.osmand.plus.views.MapControlsLayer;
@ -161,6 +162,9 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
import static net.osmand.plus.views.MapControlsLayer.REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION;
import static net.osmand.plus.views.MapControlsLayer.REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION;
import static net.osmand.plus.views.MapControlsLayer.REQUEST_LOCATION_FOR_NAVIGATION_PERMISSION;
public class MapActivity extends OsmandActionBarActivity implements DownloadEvents, public class MapActivity extends OsmandActionBarActivity implements DownloadEvents,
OnRequestPermissionsResultCallback, IRouteInformationListener, AMapPointUpdateListener, OnRequestPermissionsResultCallback, IRouteInformationListener, AMapPointUpdateListener,
@ -1864,11 +1868,21 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
OsmandPlugin.onRequestPermissionsResult(requestCode, permissions, grantResults); OsmandPlugin.onRequestPermissionsResult(requestCode, permissions, grantResults);
MapControlsLayer mcl = mapView.getLayerByClass(MapControlsLayer.class); MapControlsLayer mcl = mapView.getLayerByClass(MapControlsLayer.class);
if (mcl != null) { if (mcl != null && (requestCode == REQUEST_LOCATION_FOR_NAVIGATION_PERMISSION
|| requestCode == REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION
|| requestCode == REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION)) {
mcl.onRequestPermissionsResult(requestCode, permissions, grantResults); mcl.onRequestPermissionsResult(requestCode, permissions, grantResults);
} }
if (requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE if (requestCode == DataStorageFragment.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
&& grantResults.length > 0 && permissions.length > 0
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this,
R.string.missing_write_external_storage_permission,
Toast.LENGTH_LONG).show();
}
} else if (requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
&& grantResults.length > 0 && permissions.length > 0 && grantResults.length > 0 && permissions.length > 0
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) { && Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
permissionAsked = true; permissionAsked = true;

View file

@ -5,6 +5,7 @@ import android.annotation.SuppressLint;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
@ -27,6 +28,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.ProgressImplementation; import net.osmand.plus.ProgressImplementation;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandActionBarActivity; import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet; import net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet;
@ -43,16 +45,18 @@ import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
import static net.osmand.plus.settings.DataStorageItemsHolder.INTERNAL_STORAGE; import static net.osmand.plus.settings.DataStorageHelper.INTERNAL_STORAGE;
import static net.osmand.plus.settings.DataStorageItemsHolder.MANUALLY_SPECIFIED; import static net.osmand.plus.settings.DataStorageHelper.MANUALLY_SPECIFIED;
import static net.osmand.plus.settings.DataStorageItemsHolder.TILES_MEMORY; import static net.osmand.plus.settings.DataStorageHelper.OTHER_MEMORY;
import static net.osmand.plus.settings.DataStorageHelper.TILES_MEMORY;
import static net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet.CHOSEN_DIRECTORY; import static net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet.CHOSEN_DIRECTORY;
import static net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet.MOVE_DATA; import static net.osmand.plus.settings.bottomsheets.ChangeDataStorageBottomSheet.MOVE_DATA;
import static net.osmand.plus.settings.bottomsheets.SelectFolderBottomSheet.PATH_CHANGED; import static net.osmand.plus.settings.bottomsheets.SelectFolderBottomSheet.PATH_CHANGED;
import static net.osmand.plus.settings.bottomsheets.SelectFolderBottomSheet.NEW_PATH; import static net.osmand.plus.settings.bottomsheets.SelectFolderBottomSheet.NEW_PATH;
public class DataStorageFragment extends BaseSettingsFragment implements DataStorageItemsHolder.UpdateMemoryInfoUIAdapter { public class DataStorageFragment extends BaseSettingsFragment implements DataStorageHelper.UpdateMemoryInfoUIAdapter {
public final static int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 500;
private final static String CHANGE_DIRECTORY_BUTTON = "change_directory"; private final static String CHANGE_DIRECTORY_BUTTON = "change_directory";
private final static String OSMAND_USAGE = "osmand_usage"; private final static String OSMAND_USAGE = "osmand_usage";
private final static String CALCULATE_TILES_BTN_PRESSED = "calculate_tiles_btn_pressed"; private final static String CALCULATE_TILES_BTN_PRESSED = "calculate_tiles_btn_pressed";
@ -64,11 +68,11 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
private Preference changeButton; private Preference changeButton;
private DataStorageMenuItem currentDataStorage; private DataStorageMenuItem currentDataStorage;
private String tmpManuallySpecifiedPath; private String tmpManuallySpecifiedPath;
private DataStorageItemsHolder itemsHolder; private DataStorageHelper itemsHolder;
private boolean calculateTilesBtnPressed; private boolean calculateTilesBtnPressed;
private DataStorageItemsHolder.RefreshMemoryUsedInfo calculateMemoryTask; private DataStorageHelper.RefreshMemoryUsedInfo calculateMemoryTask;
private DataStorageItemsHolder.RefreshMemoryUsedInfo calculateTilesMemoryTask; private DataStorageHelper.RefreshMemoryUsedInfo calculateTilesMemoryTask;
private OsmandApplication app; private OsmandApplication app;
private OsmandActionBarActivity activity; private OsmandActionBarActivity activity;
@ -180,7 +184,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
&& !DownloadActivity.hasPermissionToWriteExternalStorage(activity)) { && !DownloadActivity.hasPermissionToWriteExternalStorage(activity)) {
ActivityCompat.requestPermissions(activity, ActivityCompat.requestPermissions(activity,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); DataStorageFragment.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
} else if (key.equals(MANUALLY_SPECIFIED)) { } else if (key.equals(MANUALLY_SPECIFIED)) {
showFolderSelectionDialog(); showFolderSelectionDialog();
} else { } else {
@ -212,6 +216,14 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
int activeColor = ContextCompat.getColor(app, activeColorResId); int activeColor = ContextCompat.getColor(app, activeColorResId);
int primaryTextColorResId = isNightMode() ? R.color.text_color_primary_dark : R.color.text_color_primary_light; int primaryTextColorResId = isNightMode() ? R.color.text_color_primary_dark : R.color.text_color_primary_light;
int primaryTextColor = ContextCompat.getColor(app, primaryTextColorResId); int primaryTextColor = ContextCompat.getColor(app, primaryTextColorResId);
String[] memoryUnitsFormats = new String[] {
getString(R.string.shared_string_memory_kb_desc),
getString(R.string.shared_string_memory_mb_desc),
getString(R.string.shared_string_memory_gb_desc),
getString(R.string.shared_string_memory_tb_desc)
};
final View itemView = holder.itemView; final View itemView = holder.itemView;
if (preference instanceof CheckBoxPreference) { if (preference instanceof CheckBoxPreference) {
DataStorageMenuItem item = itemsHolder.getStorage(key); DataStorageMenuItem item = itemsHolder.getStorage(key);
@ -243,7 +255,12 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
divider.setVisibility(View.VISIBLE); divider.setVisibility(View.VISIBLE);
secondPart.setVisibility(View.VISIBLE); secondPart.setVisibility(View.VISIBLE);
String space = getSpaceDescription(item.getDirectory()); String space = getSpaceDescription(item.getDirectory());
tvSummary.setText(space); if (!space.equals("")) {
tvSummary.setText(space);
tvSummary.setVisibility(View.VISIBLE);
} else {
tvSummary.setVisibility(View.GONE);
}
if (currentKey.equals(INTERNAL_STORAGE)) { if (currentKey.equals(INTERNAL_STORAGE)) {
tvAdditionalDescription.setText(item.getDescription()); tvAdditionalDescription.setText(item.getDescription());
} else { } else {
@ -259,12 +276,9 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
icon.setVisibility(View.INVISIBLE); icon.setVisibility(View.INVISIBLE);
title.setText(R.string.shared_string_change); title.setText(R.string.shared_string_change);
} else if(key.equals(OSMAND_USAGE)) { } else if(key.equals(OSMAND_USAGE)) {
long totalUsageBytes = 0; long totalUsageBytes = itemsHolder.getTotalUsedBytes();
for (DataStorageMemoryItem mi : memoryItems) {
totalUsageBytes += mi.getUsedMemoryBytes();
}
TextView tvSummary = itemView.findViewById(R.id.summary); TextView tvSummary = itemView.findViewById(R.id.summary);
tvSummary.setText(getFormattedMemoryUsedInfo(totalUsageBytes)); tvSummary.setText(DataStorageHelper.getFormattedMemoryInfo(totalUsageBytes, memoryUnitsFormats));
} else { } else {
for (DataStorageMemoryItem mi : memoryItems) { for (DataStorageMemoryItem mi : memoryItems) {
if (key.equals(mi.getKey())) { if (key.equals(mi.getKey())) {
@ -285,7 +299,13 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
} else { } else {
tvMemory.setOnClickListener(null); tvMemory.setOnClickListener(null);
color = primaryTextColor; color = primaryTextColor;
summary = getFormattedMemoryUsedInfo(mi.getUsedMemoryBytes()); summary = DataStorageHelper.getFormattedMemoryInfo(mi.getUsedMemoryBytes(), memoryUnitsFormats);
}
View divider = itemView.findViewById(R.id.divider);
if (mi.getKey().equals(OTHER_MEMORY)) {
divider.setVisibility(View.VISIBLE);
} else {
divider.setVisibility(View.GONE);
} }
tvMemory.setTextColor(color); tvMemory.setTextColor(color);
tvMemory.setText(summary); tvMemory.setText(summary);
@ -416,7 +436,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
app.setExternalStorageDirectory(type, newDirectory); app.setExternalStorageDirectory(type, newDirectory);
reloadData(); reloadData();
if (silentRestart) { if (silentRestart) {
android.os.Process.killProcess(android.os.Process.myPid()); MapActivity.doRestart(activity);
} else { } else {
app.restartApp(activity); app.restartApp(activity);
} }
@ -430,7 +450,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
private void refreshDataInfo() { private void refreshDataInfo() {
calculateTilesBtnPressed = false; calculateTilesBtnPressed = false;
itemsHolder = DataStorageItemsHolder.refreshInfo(app); itemsHolder = DataStorageHelper.refreshInfo(app);
calculateMemoryTask = itemsHolder.calculateMemoryUsedInfo(this); calculateMemoryTask = itemsHolder.calculateMemoryUsedInfo(this);
} }
@ -443,29 +463,14 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
} }
if (dir.exists()) { if (dir.exists()) {
DecimalFormat formatter = new DecimalFormat("#.##"); DecimalFormat formatter = new DecimalFormat("#.##");
float freeSpace = AndroidUtils.getFreeSpaceGb(dir);
float totalSpace = AndroidUtils.getTotalSpaceGb(dir);
if (freeSpace < 0 || totalSpace < 0) {
return "";
}
return String.format(getString(R.string.data_storage_space_description), return String.format(getString(R.string.data_storage_space_description),
formatter.format(AndroidUtils.getFreeSpaceGb(dir)), formatter.format(freeSpace),
formatter.format(AndroidUtils.getTotalSpaceGb(dir))); formatter.format(totalSpace));
}
return "";
}
private String getFormattedMemoryUsedInfo(long bytes) {
int type = 1;
double used = (double) bytes / 1024;
while (used > 1024) {
++type;
used = used / 1024;
}
String formattedUsed = new DecimalFormat("#.##").format(used);
if (type == 1) {
return String.format(getString(R.string.shared_string_memory_kb_desc), formattedUsed);
} else if (type == 2) {
return String.format(getString(R.string.shared_string_memory_mb_desc), formattedUsed);
} else if (type == 3){
return String.format(getString(R.string.shared_string_memory_gb_desc), formattedUsed);
} else if (type == 4){
return String.format(getString(R.string.shared_string_memory_tb_desc), formattedUsed);
} }
return ""; return "";
} }
@ -477,6 +482,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
@Override @Override
public void onMemoryInfoUpdate() { public void onMemoryInfoUpdate() {
updateAllSettings(); updateAllSettings();
app.getSettings().OSMAND_USAGE_SPACE.set(itemsHolder.getTotalUsedBytes());
} }
public static class MoveFilesToDifferentDirectory extends AsyncTask<Void, Void, Boolean> { public static class MoveFilesToDifferentDirectory extends AsyncTask<Void, Void, Boolean> {

View file

@ -12,9 +12,14 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import java.io.File; import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
public class DataStorageItemsHolder implements Parcelable { import static net.osmand.plus.settings.DataStorageMemoryItem.Directory;
import static net.osmand.plus.settings.DataStorageMemoryItem.EXTENSIONS;
import static net.osmand.plus.settings.DataStorageMemoryItem.PREFIX;
public class DataStorageHelper implements Parcelable {
public final static String INTERNAL_STORAGE = "internal_storage"; public final static String INTERNAL_STORAGE = "internal_storage";
public final static String EXTERNAL_STORAGE = "external_storage"; public final static String EXTERNAL_STORAGE = "external_storage";
public final static String SHARED_STORAGE = "shared_storage"; public final static String SHARED_STORAGE = "shared_storage";
@ -22,6 +27,7 @@ public class DataStorageItemsHolder implements Parcelable {
public final static String MANUALLY_SPECIFIED = "manually_specified"; public final static String MANUALLY_SPECIFIED = "manually_specified";
public final static String MAPS_MEMORY = "maps_memory_used"; public final static String MAPS_MEMORY = "maps_memory_used";
public final static String SRTM_AND_HILLSHADE_MEMORY = "contour_lines_and_hillshade_memory";
public final static String TRACKS_MEMORY = "tracks_memory_used"; public final static String TRACKS_MEMORY = "tracks_memory_used";
public final static String NOTES_MEMORY = "notes_memory_used"; public final static String NOTES_MEMORY = "notes_memory_used";
public final static String TILES_MEMORY = "tiles_memory_used"; public final static String TILES_MEMORY = "tiles_memory_used";
@ -33,6 +39,7 @@ public class DataStorageItemsHolder implements Parcelable {
private ArrayList<DataStorageMemoryItem> memoryItems = new ArrayList<>(); private ArrayList<DataStorageMemoryItem> memoryItems = new ArrayList<>();
private DataStorageMemoryItem mapsMemory; private DataStorageMemoryItem mapsMemory;
private DataStorageMemoryItem srtmAndHillshadeMemory;
private DataStorageMemoryItem tracksMemory; private DataStorageMemoryItem tracksMemory;
private DataStorageMemoryItem notesMemory; private DataStorageMemoryItem notesMemory;
private DataStorageMemoryItem tilesMemory; private DataStorageMemoryItem tilesMemory;
@ -41,12 +48,12 @@ public class DataStorageItemsHolder implements Parcelable {
private int currentStorageType; private int currentStorageType;
private String currentStoragePath; private String currentStoragePath;
private DataStorageItemsHolder(OsmandApplication app) { private DataStorageHelper(OsmandApplication app) {
prepareData(app); prepareData(app);
} }
public static DataStorageItemsHolder refreshInfo(OsmandApplication app) { public static DataStorageHelper refreshInfo(OsmandApplication app) {
return new DataStorageItemsHolder(app); return new DataStorageHelper(app);
} }
private void prepareData(OsmandApplication app) { private void prepareData(OsmandApplication app) {
@ -169,35 +176,47 @@ public class DataStorageItemsHolder implements Parcelable {
private void initMemoryUsed(OsmandApplication app) { private void initMemoryUsed(OsmandApplication app) {
mapsMemory = DataStorageMemoryItem.builder() mapsMemory = DataStorageMemoryItem.builder()
.setKey(MAPS_MEMORY) .setKey(MAPS_MEMORY)
.setExtensions(IndexConstants.BINARY_MAP_INDEX_EXT, IndexConstants.BINARY_MAP_INDEX_EXT_ZIP) .setExtensions(IndexConstants.BINARY_MAP_INDEX_EXT)
.setDirectories( .setDirectories(
app.getAppPath(IndexConstants.MAPS_PATH).getAbsolutePath(), new Directory(app.getAppPath(IndexConstants.MAPS_PATH).getAbsolutePath(), false, EXTENSIONS, false),
app.getAppPath(IndexConstants.ROADS_INDEX_DIR).getAbsolutePath(), new Directory(app.getAppPath(IndexConstants.ROADS_INDEX_DIR).getAbsolutePath(), true, EXTENSIONS, false),
app.getAppPath(IndexConstants.SRTM_INDEX_DIR).getAbsolutePath(), new Directory(app.getAppPath(IndexConstants.WIKI_INDEX_DIR).getAbsolutePath(), true, EXTENSIONS, false),
app.getAppPath(IndexConstants.WIKI_INDEX_DIR).getAbsolutePath(), new Directory(app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR).getAbsolutePath(), true, EXTENSIONS, false),
app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR).getAbsolutePath(), new Directory(app.getAppPath(IndexConstants.BACKUP_INDEX_DIR).getAbsolutePath(), true, EXTENSIONS, false))
app.getAppPath(IndexConstants.BACKUP_INDEX_DIR).getAbsolutePath())
.createItem(); .createItem();
memoryItems.add(mapsMemory); memoryItems.add(mapsMemory);
srtmAndHillshadeMemory = DataStorageMemoryItem.builder()
.setKey(SRTM_AND_HILLSHADE_MEMORY)
.setExtensions(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT)
.setDirectories(
new Directory(app.getAppPath(IndexConstants.SRTM_INDEX_DIR).getAbsolutePath(), true, EXTENSIONS, false),
new Directory(app.getAppPath(IndexConstants.TILES_INDEX_DIR).getAbsolutePath(), false, PREFIX, true))
.setPrefixes("Hillshade")
.createItem();
memoryItems.add(srtmAndHillshadeMemory);
tracksMemory = DataStorageMemoryItem.builder() tracksMemory = DataStorageMemoryItem.builder()
.setKey(TRACKS_MEMORY) .setKey(TRACKS_MEMORY)
// .setExtensions(".gpx", ".gpx.bz2") // .setExtensions(".gpx", ".gpx.bz2")
.setDirectories(app.getAppPath(IndexConstants.GPX_INDEX_DIR).getAbsolutePath()) .setDirectories(
new Directory(app.getAppPath(IndexConstants.GPX_INDEX_DIR).getAbsolutePath(), true, EXTENSIONS, false))
.createItem(); .createItem();
memoryItems.add(tracksMemory); memoryItems.add(tracksMemory);
notesMemory = DataStorageMemoryItem.builder() notesMemory = DataStorageMemoryItem.builder()
.setKey(NOTES_MEMORY) .setKey(NOTES_MEMORY)
// .setExtensions("") // .setExtensions("")
.setDirectories(app.getAppPath(IndexConstants.AV_INDEX_DIR).getAbsolutePath()) .setDirectories(
new Directory(app.getAppPath(IndexConstants.AV_INDEX_DIR).getAbsolutePath(), true, EXTENSIONS, false))
.createItem(); .createItem();
memoryItems.add(notesMemory); memoryItems.add(notesMemory);
tilesMemory = DataStorageMemoryItem.builder() tilesMemory = DataStorageMemoryItem.builder()
.setKey(TILES_MEMORY) .setKey(TILES_MEMORY)
// .setExtensions("") // .setExtensions("")
.setDirectories(app.getAppPath(IndexConstants.TILES_INDEX_DIR).getAbsolutePath()) .setDirectories(
new Directory(app.getAppPath(IndexConstants.TILES_INDEX_DIR).getAbsolutePath(), true, EXTENSIONS, false))
.createItem(); .createItem();
memoryItems.add(tilesMemory); memoryItems.add(tilesMemory);
@ -255,14 +274,14 @@ public class DataStorageItemsHolder implements Parcelable {
public RefreshMemoryUsedInfo calculateMemoryUsedInfo(UpdateMemoryInfoUIAdapter listener) { public RefreshMemoryUsedInfo calculateMemoryUsedInfo(UpdateMemoryInfoUIAdapter listener) {
File rootDir = new File(currentStoragePath); File rootDir = new File(currentStoragePath);
RefreshMemoryUsedInfo task = new RefreshMemoryUsedInfo(listener, otherMemory, rootDir, tilesMemory.getDirectories()); RefreshMemoryUsedInfo task = new RefreshMemoryUsedInfo(listener, otherMemory, rootDir, null, null);
task.execute(mapsMemory, tracksMemory, notesMemory); task.execute(mapsMemory, srtmAndHillshadeMemory, tracksMemory, notesMemory);
return task; return task;
} }
public RefreshMemoryUsedInfo calculateTilesMemoryUsed(UpdateMemoryInfoUIAdapter listener) { public RefreshMemoryUsedInfo calculateTilesMemoryUsed(UpdateMemoryInfoUIAdapter listener) {
File rootDir = new File(tilesMemory.getDirectories()[0]); File rootDir = new File(tilesMemory.getDirectories()[0].getAbsolutePath());
RefreshMemoryUsedInfo task = new RefreshMemoryUsedInfo(listener, otherMemory, rootDir); RefreshMemoryUsedInfo task = new RefreshMemoryUsedInfo(listener, otherMemory, rootDir, null, srtmAndHillshadeMemory.getPrefixes());
task.execute(tilesMemory); task.execute(tilesMemory);
return task; return task;
} }
@ -272,77 +291,123 @@ public class DataStorageItemsHolder implements Parcelable {
private File rootDir; private File rootDir;
private DataStorageMemoryItem otherMemory; private DataStorageMemoryItem otherMemory;
private String[] directoriesToAvoid; private String[] directoriesToAvoid;
private String[] prefixesToAvoid;
public RefreshMemoryUsedInfo(UpdateMemoryInfoUIAdapter listener, DataStorageMemoryItem otherMemory, File rootDir, String... directoriesToAvoid) { public RefreshMemoryUsedInfo(UpdateMemoryInfoUIAdapter listener, DataStorageMemoryItem otherMemory, File rootDir, String[] directoriesToAvoid, String[] prefixesToAvoid) {
this.listener = listener; this.listener = listener;
this.otherMemory = otherMemory; this.otherMemory = otherMemory;
this.rootDir = rootDir; this.rootDir = rootDir;
this.directoriesToAvoid = directoriesToAvoid; this.directoriesToAvoid = directoriesToAvoid;
this.prefixesToAvoid = prefixesToAvoid;
} }
@Override @Override
protected Void doInBackground(DataStorageMemoryItem... items) { protected Void doInBackground(DataStorageMemoryItem... items) {
if (items.length == 1) { if (rootDir.canRead()) {
DataStorageMemoryItem item = items[0]; calculateMultiTypes(rootDir, items);
item.addBytes(getDirectorySize(rootDir, item.getExtensions()));
} else {
calculateMultiTypes(items);
} }
return null; return null;
} }
private void calculateMultiTypes(DataStorageMemoryItem[] items) { private void calculateMultiTypes(File rootDir, DataStorageMemoryItem... items) {
File[] files = rootDir.listFiles(); File[] subFiles = rootDir.listFiles();
for (File f : files) { for (File file : subFiles) {
boolean matched = false; if (isCancelled()) {
if (f.isDirectory()) { break;
boolean avoid = false; }
for (String directoryToAvoid : directoriesToAvoid) { nextFile : {
if (f.getAbsolutePath().equals(directoryToAvoid)) { if (file.isDirectory()) {
avoid = true; //check current directory should be avoid
break; if (directoriesToAvoid != null) {
for (String directoryToAvoid : directoriesToAvoid) {
if (file.getAbsolutePath().equals(directoryToAvoid)) {
break nextFile;
}
}
} }
} //check current directory matched items type
if (!avoid) {
for (DataStorageMemoryItem item : items) { for (DataStorageMemoryItem item : items) {
String[] directories = item.getDirectories(); Directory[] directories = item.getDirectories();
if (directories != null) { if (directories == null) {
for (String directory : directories) { continue;
if (f.getAbsolutePath().equals(directory)) { }
item.addBytes(getDirectorySize(f, item.getExtensions())); for (Directory dir : directories) {
matched = true; if (file.getAbsolutePath().equals(dir.getAbsolutePath())
break; || (file.getAbsolutePath().startsWith(dir.getAbsolutePath()) && dir.isGoDeeper())) {
calculateMultiTypes(file, items);
break nextFile;
}
}
}
//current directory did not match to any type
otherMemory.addBytes(getDirectorySize(file));
} else if (file.isFile()) {
//check current file should be avoid
if (prefixesToAvoid != null) {
for (String prefixToAvoid : prefixesToAvoid) {
if (file.getName().toLowerCase().startsWith(prefixToAvoid.toLowerCase())) {
break nextFile;
}
}
}
//check current file matched items type
for (DataStorageMemoryItem item : items) {
Directory[] directories = item.getDirectories();
if (directories == null) {
continue;
}
for (Directory dir : directories) {
if (rootDir.getAbsolutePath().equals(dir.getAbsolutePath())
|| (rootDir.getAbsolutePath().startsWith(dir.getAbsolutePath()) && dir.isGoDeeper())) {
int checkingType = dir.getCheckingType();
switch (checkingType) {
case EXTENSIONS : {
String[] extensions = item.getExtensions();
if (extensions != null) {
for (String extension : extensions) {
if (file.getAbsolutePath().endsWith(extension)) {
item.addBytes(file.length());
break nextFile;
}
}
} else {
item.addBytes(file.length());
break nextFile;
}
break ;
}
case PREFIX : {
String[] prefixes = item.getPrefixes();
if (prefixes != null) {
for (String prefix : prefixes) {
if (file.getName().toLowerCase().startsWith(prefix.toLowerCase())) {
item.addBytes(file.length());
break nextFile;
}
}
} else {
item.addBytes(file.length());
break nextFile;
}
break ;
}
}
if (dir.isSkipOther()) {
break nextFile;
} }
} }
} }
} }
if (!matched) { //current file did not match any type
otherMemory.addBytes(getDirectorySize(f, null)); otherMemory.addBytes(file.length());
}
} }
} else if (f.isFile()) {
for (DataStorageMemoryItem item : items) {
String[] extensions = item.getExtensions();
if (extensions != null) {
for (String extension : extensions) {
if (f.getAbsolutePath().endsWith(extension)) {
item.addBytes(f.length());
matched = true;
break;
}
}
}
}
if (!matched) {
otherMemory.addBytes(f.length());
}
publishProgress();
} }
publishProgress();
} }
} }
private long getDirectorySize(File dir, String[] extensions) { private long getDirectorySize(File dir) {
long bytes = 0; long bytes = 0;
if (dir.isDirectory()) { if (dir.isDirectory()) {
File[] files = dir.listFiles(); File[] files = dir.listFiles();
@ -351,26 +416,9 @@ public class DataStorageItemsHolder implements Parcelable {
break; break;
} }
if (file.isDirectory()) { if (file.isDirectory()) {
bytes += getDirectorySize(file, extensions); bytes += getDirectorySize(file);
} else if (file.isFile()) { } else if (file.isFile()) {
//check file extension bytes += file.length();
boolean matched = false;
if (extensions != null) {
for (String extension : extensions) {
if (file.getName().endsWith(extension)) {
matched = true;
break;
}
}
} else {
matched = true;
}
if (matched) {
bytes += file.length();
} else {
otherMemory.addBytes(file.length());
}
publishProgress();
} }
} }
} }
@ -394,6 +442,28 @@ public class DataStorageItemsHolder implements Parcelable {
} }
} }
public long getTotalUsedBytes() {
long total = 0;
if (memoryItems != null && memoryItems.size() > 0) {
for (DataStorageMemoryItem mi : memoryItems) {
total += mi.getUsedMemoryBytes();
}
return total;
}
return -1;
}
public static String getFormattedMemoryInfo(long bytes, String[] formatStrings) {
int type = 0;
double memory = (double) bytes / 1024;
while (memory > 1024 && type < formatStrings.length) {
++type;
memory = memory / 1024;
}
String formattedUsed = new DecimalFormat("#.##").format(memory);
return String.format(formatStrings[type], formattedUsed);
}
public interface UpdateMemoryInfoUIAdapter { public interface UpdateMemoryInfoUIAdapter {
void onMemoryInfoUpdate(); void onMemoryInfoUpdate();
@ -405,7 +475,7 @@ public class DataStorageItemsHolder implements Parcelable {
return 0; return 0;
} }
private DataStorageItemsHolder(Parcel in) { private DataStorageHelper(Parcel in) {
menuItems = in.readArrayList(DataStorageMenuItem.class.getClassLoader()); menuItems = in.readArrayList(DataStorageMenuItem.class.getClassLoader());
currentDataStorage = in.readParcelable(DataStorageMenuItem.class.getClassLoader()); currentDataStorage = in.readParcelable(DataStorageMenuItem.class.getClassLoader());
memoryItems = in.readArrayList(DataStorageMemoryItem.class.getClassLoader()); memoryItems = in.readArrayList(DataStorageMemoryItem.class.getClassLoader());
@ -422,16 +492,16 @@ public class DataStorageItemsHolder implements Parcelable {
dest.writeString(currentStoragePath); dest.writeString(currentStoragePath);
} }
public static final Parcelable.Creator<DataStorageItemsHolder> CREATOR = new Parcelable.Creator<DataStorageItemsHolder>() { public static final Parcelable.Creator<DataStorageHelper> CREATOR = new Parcelable.Creator<DataStorageHelper>() {
@Override @Override
public DataStorageItemsHolder createFromParcel(Parcel source) { public DataStorageHelper createFromParcel(Parcel source) {
return new DataStorageItemsHolder(source); return new DataStorageHelper(source);
} }
@Override @Override
public DataStorageItemsHolder[] newArray(int size) { public DataStorageHelper[] newArray(int size) {
return new DataStorageItemsHolder[size]; return new DataStorageHelper[size];
} }
}; };
} }

View file

@ -4,14 +4,19 @@ import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
public class DataStorageMemoryItem implements Parcelable { public class DataStorageMemoryItem implements Parcelable {
public final static int EXTENSIONS = 0;
public final static int PREFIX = 1;
private String key; private String key;
private String[] extensions; private String[] extensions;
private String[] directories; private String[] prefixes;
private Directory[] directories;
private long usedMemoryBytes; private long usedMemoryBytes;
private DataStorageMemoryItem(String key, String[] extensions, long usedMemoryBytes, String[] directories) { private DataStorageMemoryItem(String key, String[] extensions, String[] prefixes, long usedMemoryBytes, Directory[] directories) {
this.key = key; this.key = key;
this.extensions = extensions; this.extensions = extensions;
this.prefixes = prefixes;
this.usedMemoryBytes = usedMemoryBytes; this.usedMemoryBytes = usedMemoryBytes;
this.directories = directories; this.directories = directories;
} }
@ -19,7 +24,8 @@ public class DataStorageMemoryItem implements Parcelable {
private DataStorageMemoryItem(Parcel in) { private DataStorageMemoryItem(Parcel in) {
key = in.readString(); key = in.readString();
in.readStringArray(extensions); in.readStringArray(extensions);
in.readStringArray(directories); in.writeStringArray(prefixes);
directories = (Directory[]) in.readArray(Directory.class.getClassLoader());
usedMemoryBytes = in.readLong(); usedMemoryBytes = in.readLong();
} }
@ -35,10 +41,6 @@ public class DataStorageMemoryItem implements Parcelable {
this.key = key; this.key = key;
} }
public void setUsedMemoryBytes(long usedMemoryBytes) {
this.usedMemoryBytes = usedMemoryBytes;
}
public static DataStorageMemoryItemBuilder builder() { public static DataStorageMemoryItemBuilder builder() {
return new DataStorageMemoryItemBuilder(); return new DataStorageMemoryItemBuilder();
} }
@ -47,16 +49,16 @@ public class DataStorageMemoryItem implements Parcelable {
return extensions; return extensions;
} }
public void setExtensions(String[] extensions) { public String[] getPrefixes() {
this.extensions = extensions; return prefixes;
} }
public String[] getDirectories() { public Directory[] getDirectories() {
return directories; return directories;
} }
public void setDirectories(String[] directories) { public void addBytes(long bytes) {
this.directories = directories; this.usedMemoryBytes += bytes;
} }
@Override @Override
@ -68,7 +70,8 @@ public class DataStorageMemoryItem implements Parcelable {
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeString(key); dest.writeString(key);
dest.writeStringArray(extensions); dest.writeStringArray(extensions);
dest.writeStringArray(directories); dest.writeStringArray(prefixes);
dest.writeArray(directories);
dest.writeLong(usedMemoryBytes); dest.writeLong(usedMemoryBytes);
} }
@ -88,7 +91,8 @@ public class DataStorageMemoryItem implements Parcelable {
public static class DataStorageMemoryItemBuilder { public static class DataStorageMemoryItemBuilder {
private String key; private String key;
private String[] extensions; private String[] extensions;
private String[] directories; private String[] prefixes;
private Directory[] directories;
private long usedMemoryBytes; private long usedMemoryBytes;
public DataStorageMemoryItemBuilder setKey(String key) { public DataStorageMemoryItemBuilder setKey(String key) {
@ -100,8 +104,13 @@ public class DataStorageMemoryItem implements Parcelable {
this.extensions = extensions; this.extensions = extensions;
return this; return this;
} }
public DataStorageMemoryItemBuilder setPrefixes(String ... prefixes) {
this.prefixes = prefixes;
return this;
}
public DataStorageMemoryItemBuilder setDirectories(String ... directories) { public DataStorageMemoryItemBuilder setDirectories(Directory ... directories) {
this.directories = directories; this.directories = directories;
return this; return this;
} }
@ -112,11 +121,70 @@ public class DataStorageMemoryItem implements Parcelable {
} }
public DataStorageMemoryItem createItem() { public DataStorageMemoryItem createItem() {
return new DataStorageMemoryItem(key, extensions, usedMemoryBytes, directories); return new DataStorageMemoryItem(key, extensions, prefixes, usedMemoryBytes, directories);
} }
} }
public void addBytes(long bytes) { public static class Directory implements Parcelable {
this.usedMemoryBytes += bytes; private String absolutePath;
private boolean goDeeper;
private int checkingType;
private boolean skipOther;
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(absolutePath);
dest.writeInt(goDeeper ? 1 : 0);
dest.writeInt(checkingType);
dest.writeInt(skipOther ? 1 : 0);
}
public Directory(String absolutePath, boolean goDeeper, int checkingType, boolean skipOther) {
this.absolutePath = absolutePath;
this.goDeeper = goDeeper;
this.checkingType = checkingType;
this.skipOther = skipOther;
}
public String getAbsolutePath() {
return absolutePath;
}
public boolean isGoDeeper() {
return goDeeper;
}
public int getCheckingType() {
return checkingType;
}
public boolean isSkipOther() {
return skipOther;
}
private Directory(Parcel in) {
absolutePath = in.readString();
goDeeper = in.readInt() == 1;
checkingType = in.readInt();
skipOther = in.readInt() == 1;
}
public static final Parcelable.Creator<Directory> CREATOR = new Parcelable.Creator<Directory>() {
@Override
public Directory createFromParcel(Parcel source) {
return new Directory(source);
}
@Override
public Directory[] newArray(int size) {
return new Directory[size];
}
};
} }
} }

View file

@ -7,7 +7,6 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.SwitchPreferenceCompat; import android.support.v7.preference.SwitchPreferenceCompat;
import android.util.Pair; import android.util.Pair;
import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -17,9 +16,6 @@ import net.osmand.plus.dialogs.SendAnalyticsBottomSheetDialogFragment;
import net.osmand.plus.settings.preferences.ListPreferenceEx; import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx; import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import java.io.File;
import java.text.DecimalFormat;
public class GlobalSettingsFragment extends BaseSettingsFragment implements SendAnalyticsBottomSheetDialogFragment.OnSendAnalyticsPrefsUpdate, OnPreferenceChanged { public class GlobalSettingsFragment extends BaseSettingsFragment implements SendAnalyticsBottomSheetDialogFragment.OnSendAnalyticsPrefsUpdate, OnPreferenceChanged {
@ -141,14 +137,24 @@ public class GlobalSettingsFragment extends BaseSettingsFragment implements Send
Preference externalStorageDir = (Preference) findPreference(OsmandSettings.EXTERNAL_STORAGE_DIR); Preference externalStorageDir = (Preference) findPreference(OsmandSettings.EXTERNAL_STORAGE_DIR);
externalStorageDir.setIcon(getContentIcon(R.drawable.ic_action_folder)); externalStorageDir.setIcon(getContentIcon(R.drawable.ic_action_folder));
DataStorageItemsHolder holder = DataStorageItemsHolder.refreshInfo(app); DataStorageHelper holder = DataStorageHelper.refreshInfo(app);
DataStorageMenuItem currentStorage = holder.getCurrentStorage(); DataStorageMenuItem currentStorage = holder.getCurrentStorage();
File dir = new File(currentStorage.getDirectory()); long totalUsed = app.getSettings().OSMAND_USAGE_SPACE.get();
DecimalFormat formatter = new DecimalFormat("#.##"); if (totalUsed > 0) {
String summary = String.format(getString(R.string.data_storage_preference_summary), String[] usedMemoryFormats = new String[] {
currentStorage.getTitle(), getString(R.string.shared_string_memory_used_kb_desc),
formatter.format(AndroidUtils.getUsedSpaceGb(dir))); getString(R.string.shared_string_memory_used_mb_desc),
externalStorageDir.setSummary(summary); getString(R.string.shared_string_memory_used_gb_desc),
getString(R.string.shared_string_memory_used_tb_desc)
};
String sTotalUsed = DataStorageHelper.getFormattedMemoryInfo(totalUsed, usedMemoryFormats);
String summary = String.format(getString(R.string.data_storage_preference_summary),
currentStorage.getTitle(),
sTotalUsed);
externalStorageDir.setSummary(summary);
} else {
externalStorageDir.setSummary(currentStorage.getTitle());
}
} }
private void setupSendAnonymousDataPref() { private void setupSendAnonymousDataPref() {

View file

@ -24,7 +24,7 @@ import org.apache.commons.logging.Log;
import java.io.File; import java.io.File;
import static net.osmand.plus.settings.DataStorageItemsHolder.MANUALLY_SPECIFIED; import static net.osmand.plus.settings.DataStorageHelper.MANUALLY_SPECIFIED;
public class ChangeDataStorageBottomSheet extends BasePreferenceBottomSheet { public class ChangeDataStorageBottomSheet extends BasePreferenceBottomSheet {

View file

@ -155,7 +155,7 @@ public class SelectFolderBottomSheet extends BasePreferenceBottomSheet {
protected void onRightBottomButtonClick() { protected void onRightBottomButtonClick() {
Fragment fragment = getTargetFragment(); Fragment fragment = getTargetFragment();
if (fragment instanceof BaseSettingsFragment) { if (fragment instanceof BaseSettingsFragment) {
String newPath = editText.getText().toString(); String newPath = editText.getText().toString().trim();
if (!newPath.equals("")) { if (!newPath.equals("")) {
boolean pathChanged = !newPath.equals(currentPath); boolean pathChanged = !newPath.equals(currentPath);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();

View file

@ -75,9 +75,9 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.ZOOM_OUT_HUD_ID;
public class MapControlsLayer extends OsmandMapLayer { public class MapControlsLayer extends OsmandMapLayer {
private static final int TIMEOUT_TO_SHOW_BUTTONS = 7000; private static final int TIMEOUT_TO_SHOW_BUTTONS = 7000;
private static final int REQUEST_LOCATION_FOR_NAVIGATION_PERMISSION = 200; public static final int REQUEST_LOCATION_FOR_NAVIGATION_PERMISSION = 200;
private static final int REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION = 201; public static final int REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION = 201;
private static final int REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION = 202; public static final int REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION = 202;
private static final int COMPASS_PRESSED_TIME_INTERVAL_MS = 5000; private static final int COMPASS_PRESSED_TIME_INTERVAL_MS = 5000;