Merge pull request #8243 from osmandapp/plugins_preferences

Plugins preferences
This commit is contained in:
max-klaus 2020-01-17 12:04:38 +03:00 committed by GitHub
commit d5823ee21e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 1798 additions and 194 deletions

View file

@ -23,17 +23,38 @@
android:contentDescription="@string/access_shared_string_navigate_up"
android:src="@drawable/ic_action_mode_back" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:ellipsize="end"
android:maxLines="2"
android:textColor="?attr/app_bar_primary_item_color"
android:textSize="@dimen/dialog_header_text_size"
app:typeface="@string/font_roboto_medium"
tools:text="@string/routing_settings_2" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:textColor="?attr/pstsInactiveTextColor"
android:textSize="@dimen/default_desc_text_size"
android:visibility="gone"
app:typeface="@string/font_roboto_regular"
tools:text="Some description" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>

View file

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_vertical"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:maxLines="1"
android:minHeight="@dimen/bottom_sheet_title_height"
android:text="@string/login_and_pass"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_vertical"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:maxLines="1"
android:paddingBottom="@dimen/dialog_content_margin"
android:text="@string/open_street_map_login_descr"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_regular" />
<net.osmand.plus.widgets.OsmandTextFieldBoxes
android:id="@+id/name_text_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/content_padding"
osmand:labelText="@string/user_name">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/name_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1" />
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
<net.osmand.plus.widgets.OsmandTextFieldBoxes
android:id="@+id/password_text_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
osmand:labelText="@string/user_password">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/password_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:maxLines="1" />
</net.osmand.plus.widgets.OsmandTextFieldBoxes>
</LinearLayout>

View file

@ -48,7 +48,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?colorAccent"
android:textSize="@dimen/default_list_text_size"

View file

@ -41,7 +41,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"

View file

@ -38,7 +38,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"

View file

@ -48,7 +48,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"

View file

@ -38,7 +38,7 @@
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:maxLines="2"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" />

View file

@ -53,7 +53,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"

View file

@ -11,6 +11,23 @@
Thx - Hardy
-->
<string name="monitoring_prefs_descr">Navigation, logging accuracy</string>
<string name="multimedia_notes_prefs_descr">Picture size, audio and video quality</string>
<string name="osm_editing_prefs_descr">Login, password, offline editing</string>
<string name="accessibility_prefs_descr">Choose icon, color and name</string>
<string name="live_monitoring_descr">Allow you to share current location using trip recording.</string>
<string name="live_monitoring">Online tracking</string>
<string name="save_track_logging_accuracy">Logging accuracy</string>
<string name="tracks_view_descr">You can find all your recorded tracks in Menu — My place — Tracks or in OsmAd folder using file manager.</string>
<string name="multimedia_notes_view_descr">You can find all your notes in Menu — My places — Notes</string>
<string name="video_notes">Video notes</string>
<string name="photo_notes">Photo notes</string>
<string name="route_recalculation">Route recalculation</string>
<string name="accessibility_announce">Announce</string>
<string name="login_and_pass">Username and password</string>
<string name="plugin_global_prefs_info">This plugin settings are global, and apply to all profiles.</string>
<string name="osm_editing">OpenStreetMap Editing</string>
<string name="osm_edits_view_descr">You can view all your unuploaded edits or osm bugs in Menu — My places — OSM Edits. Uploaded points dont show in OsmAnd.</string>
<string name="app_mode_osm">OSM</string>
<string name="select_nav_icon_descr">You will see the icon only while navigation or while moving.</string>
<string name="select_map_icon_descr">Map icon appears only on the map, and changing while navigation to navigation icon.</string>

View file

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/shared_string_accessibility">
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:icon="@drawable/ic_action_android"
android:key="accessibility_mode"
android:layout="@layout/preference_with_descr"
android:title="@string/accessibility_mode"
tools:summary="@string/accessibility_default" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="speech_rate"
android:layout="@layout/preference_with_descr"
android:title="@string/speech_rate"
tools:icon="@drawable/ic_world_globe_dark"
tools:summary="50 %" />
<PreferenceCategory
android:key="announce"
android:layout="@layout/preference_category_with_descr"
android:title="@string/accessibility_announce" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="accessibility_smart_autoannounce"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/access_smart_autoannounce" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="accessibility_autoannounce_period"
android:layout="@layout/preference_with_descr"
android:title="@string/access_autoannounce_period"
tools:summary="10 seconds" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<PreferenceCategory
android:key="route_recalculation"
android:layout="@layout/preference_category_with_descr"
android:title="@string/route_recalculation" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="disable_offroute_recalc"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/access_disable_offroute_recalc" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="disable_wrong_direction_recalc"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/access_disable_wrong_direction_recalc" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="direction_style"
android:layout="@layout/preference_with_descr"
android:title="@string/settings_direction_style"
tools:summary="@string/direction_style_sidewise" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="direction_audio_feedback"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/access_direction_audio_feedback" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="direction_haptic_feedback"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/access_direction_haptic_feedback" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<Preference
android:key="copy_plugin_settings"
android:layout="@layout/preference_button"
android:persistent="false"
android:title="@string/copy_from_other_profile"
tools:icon="@drawable/ic_action_copy" />
<Preference
android:key="reset_to_default"
android:layout="@layout/preference_button"
android:persistent="false"
android:title="@string/reset_to_default"
tools:icon="@drawable/ic_action_reset_to_default_dark" />
</PreferenceScreen>

View file

@ -59,7 +59,6 @@
<PreferenceCategory
android:key="plugin_settings"
android:layout="@layout/preference_category_with_descr"
android:summary="@string/list_of_installed_plugins"
android:title="@string/plugins_settings" />
<Preference

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:key="proxy"
android:title="@string/live_monitoring">
<Preference
android:key="live_monitoring_info"
android:layout="@layout/preference_info"
android:persistent="false"
android:selectable="false"
android:title="@string/live_monitoring_descr" />
<net.osmand.plus.settings.preferences.EditTextPreferenceEx
android:key="live_monitoring_url"
android:layout="@layout/preference_with_descr"
android:title="@string/live_monitoring_url"
tools:icon="@drawable/ic_world_globe_dark"
tools:summary="@string/live_monitoring_m_descr" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="live_monitoring_interval"
android:layout="@layout/preference_with_descr"
android:title="@string/live_monitoring_interval"
tools:icon="@drawable/ic_action_time_span"
tools:summary="5 seconds" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="live_monitoring_maximum_interval_to_send"
android:layout="@layout/preference_with_descr"
android:title="@string/live_monitoring_max_interval_to_send"
tools:icon="@drawable/ic_action_time_span"
tools:summary="15 min" />
</PreferenceScreen>

View file

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen 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"
android:title="@string/monitoring_settings">
<PreferenceCategory
android:key="navigation"
android:layout="@layout/preference_category_with_descr"
android:title="@string/shared_string_navigation" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="save_track_to_gpx"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/save_track_to_gpx"
tools:icon="@drawable/ic_action_gdirections_dark" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="save_track_interval"
android:layout="@layout/preference_with_descr"
android:title="@string/save_track_interval"
tools:icon="@drawable/ic_action_time_span"
tools:summary="3 seconds" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<PreferenceCategory
android:key="logging_accuracy"
android:layout="@layout/preference_category_with_descr"
android:title="@string/save_track_logging_accuracy" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="save_track_min_distance"
android:layout="@layout/preference_with_descr"
android:title="@string/save_track_min_distance"
tools:summary="Not selected" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="save_track_precision"
android:layout="@layout/preference_with_descr"
android:title="@string/save_track_precision"
tools:summary="50 m" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="save_track_min_speed"
android:layout="@layout/preference_with_descr"
android:title="@string/save_track_min_speed"
tools:summary="Not selected" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="auto_split_recording"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/auto_split_recording_title" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="disable_recording_once_app_killed"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/disable_recording_once_app_killed" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="track_storage_directory"
android:layout="@layout/preference_with_descr"
android:title="@string/track_storage_directory"
tools:icon="@drawable/ic_action_folder"
tools:summary="Not selected" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="live_monitoring"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/live_monitoring"
app:fragment="net.osmand.plus.settings.LiveMonitoringFragment"
tools:icon="@drawable/ic_world_globe_dark" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<Preference
android:key="open_tracks_description"
android:layout="@layout/preference_info"
android:persistent="false"
android:selectable="false"
android:title="@string/tracks_view_descr" />
<Preference
android:key="open_tracks"
android:layout="@layout/preference_button"
android:persistent="false"
android:title="@string/shared_string_tracks"
tools:icon="@drawable/ic_action_folder" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<Preference
android:key="reset_to_default"
android:layout="@layout/preference_button"
android:persistent="false"
android:title="@string/reset_to_default"
tools:icon="@drawable/ic_action_reset_to_default_dark" />
<Preference
android:key="copy_plugin_settings"
android:layout="@layout/preference_button"
android:persistent="false"
android:title="@string/copy_from_other_profile"
tools:icon="@drawable/ic_action_copy" />
</PreferenceScreen>

View file

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/audionotes_plugin_name">
<PreferenceCategory
android:key="photo_notes"
android:layout="@layout/preference_category_with_descr"
android:title="@string/photo_notes" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="av_external_cam"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/av_use_external_camera"
tools:icon="@drawable/ic_action_photo_dark" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:icon="@drawable/ic_action_picture_size"
android:key="av_camera_picture_size"
android:layout="@layout/preference_with_descr"
android:title="@string/av_camera_pic_size"
tools:summary="4128x3096 (12.19 Mpx)" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:icon="@drawable/ic_action_camera_focus"
android:key="av_camera_focus_type"
android:layout="@layout/preference_with_descr"
android:title="@string/av_camera_focus"
tools:summary="@string/av_camera_focus_descr" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="av_photo_play_sound"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/av_photo_play_sound"
tools:icon="@drawable/ic_action_music_off" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<PreferenceCategory
android:key="audio_notes"
android:layout="@layout/preference_category_with_descr"
android:title="@string/map_widget_audionotes" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="av_audio_format"
android:layout="@layout/preference_with_descr"
android:title="@string/av_audio_format"
tools:summary="@string/av_audio_format_descr" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="av_audio_bitrate"
android:layout="@layout/preference_with_descr"
android:title="@string/av_audio_bitrate"
tools:summary="@string/av_audio_bitrate_descr" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<PreferenceCategory
android:key="video_notes"
android:layout="@layout/preference_category_with_descr"
android:title="@string/video_notes" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="av_external_recorder"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/av_use_external_recorder"
tools:icon="@drawable/ic_action_video_dark" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:icon="@drawable/ic_action_picture_size"
android:key="av_video_quality"
android:layout="@layout/preference_with_descr"
android:title="@string/av_video_quality"
tools:summary="4128x3096 (12.19 Mpx)" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:key="av_recorder_split"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/rec_split_title" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="av_rs_clip_length"
android:layout="@layout/preference_with_descr"
android:title="@string/rec_split_clip_length"
tools:summary="5 min" />
<net.osmand.plus.settings.preferences.ListPreferenceEx
android:key="av_rs_storage_size"
android:layout="@layout/preference_with_descr"
android:title="@string/rec_split_storage_size"
tools:icon="@drawable/ic_sdcard"
tools:summary="5 GB" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<Preference
android:key="open_notes_description"
android:layout="@layout/preference_info"
android:persistent="false"
android:selectable="false"
android:title="@string/multimedia_notes_view_descr" />
<Preference
android:key="open_notes"
android:layout="@layout/preference_button"
android:persistent="false"
android:title="@string/notes"
tools:icon="@drawable/ic_action_folder" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<Preference
android:key="reset_to_default"
android:layout="@layout/preference_button"
android:persistent="false"
android:title="@string/reset_to_default"
tools:icon="@drawable/ic_action_reset_to_default_dark" />
<Preference
android:key="copy_plugin_settings"
android:layout="@layout/preference_button"
android:persistent="false"
android:title="@string/copy_from_other_profile"
tools:icon="@drawable/ic_action_copy" />
</PreferenceScreen>

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:summary="@string/osm_editing"
android:title="@string/shared_string_settings">
<Preference
android:key="osm_editing_info"
android:layout="@layout/preference_info"
android:persistent="false"
android:selectable="false"
android:title="@string/plugin_global_prefs_info"
tools:icon="@drawable/ic_action_info_dark" />
<Preference
android:key="osm_login_data"
android:layout="@layout/preference_with_descr"
android:persistent="false"
android:title="@string/login_and_pass"
tools:icon="@drawable/ic_action_openstreetmap_logo"
tools:summary="@string/open_street_map_login_descr" />
<net.osmand.plus.settings.preferences.SwitchPreferenceEx
android:icon="@drawable/ic_action_offline"
android:key="offline_osm_editing"
android:layout="@layout/preference_with_descr_dialog_and_switch"
android:summaryOff="@string/shared_string_disabled"
android:summaryOn="@string/shared_string_enabled"
android:title="@string/offline_edition" />
<Preference
android:layout="@layout/simple_divider_item"
android:selectable="false" />
<Preference
android:key="osm_edits_description"
android:layout="@layout/preference_info"
android:persistent="false"
android:selectable="false"
android:title="@string/osm_edits_view_descr" />
<Preference
android:key="open_osm_edits"
android:layout="@layout/preference_button"
android:persistent="false"
android:title="@string/osm_edits"
tools:icon="@drawable/ic_action_folder" />
</PreferenceScreen>

View file

@ -1,9 +1,5 @@
package net.osmand.access;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import android.app.Activity;
import android.media.AudioManager;
import android.media.SoundPool;
@ -12,7 +8,11 @@ import android.support.annotation.NonNull;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.settings.BaseSettingsFragment;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class AccessibilityPlugin extends OsmandPlugin {
@ -55,16 +55,21 @@ public class AccessibilityPlugin extends OsmandPlugin {
return app.getString(R.string.shared_string_accessibility);
}
@Override
public void registerLayers(MapActivity activity) {
}
@Override
public Class<? extends Activity> getSettingsActivity() {
return SettingsAccessibilityActivity.class;
}
@Override
public Class<? extends BaseSettingsFragment> getSettingsFragment() {
return AccessibilitySettingsFragment.class;
}
@Override
public String getPrefsDescription() {
return app.getString(R.string.accessibility_prefs_descr);
}
@Override
public void disable(OsmandApplication app) {
if (sounds != null) {
@ -98,5 +103,4 @@ public class AccessibilityPlugin extends OsmandPlugin {
return 0;
}
}
}

View file

@ -0,0 +1,165 @@
package net.osmand.access;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import net.osmand.plus.R;
import net.osmand.plus.access.AccessibilityMode;
import net.osmand.plus.access.RelativeDirectionStyle;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.settings.OnPreferenceChanged;
import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
public class AccessibilitySettingsFragment extends BaseSettingsFragment implements OnPreferenceChanged {
private static final String COPY_PLUGIN_SETTINGS = "copy_plugin_settings";
private static final String RESET_TO_DEFAULT = "reset_to_default";
@Override
protected void setupPreferences() {
setupAccessibilityModePref();
setupSpeechRatePref();
setupSmartAutoAnnouncePref();
setupAutoAnnouncePeriodPref();
setupDisableOffRouteRecalculationPref();
setupDisableWrongDirectionRecalculationPref();
setupDirectionStylePref();
setupDirectionAudioFeedbackPref();
setupDirectionHapticFeedbackPref();
setupCopyProfileSettingsPref();
setupResetToDefaultPref();
updateAccessibilityOptions();
}
private void setupAccessibilityModePref() {
AccessibilityMode[] accessibilityModes = AccessibilityMode.values();
String[] entries = new String[accessibilityModes.length];
Integer[] entryValues = new Integer[accessibilityModes.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = accessibilityModes[i].toHumanString(app);
entryValues[i] = accessibilityModes[i].ordinal();
}
ListPreferenceEx accessibilityMode = (ListPreferenceEx) findPreference(settings.ACCESSIBILITY_MODE.getId());
accessibilityMode.setEntries(entries);
accessibilityMode.setEntryValues(entryValues);
accessibilityMode.setDescription(R.string.accessibility_mode_descr);
}
private void setupSpeechRatePref() {
Float[] entryValues = new Float[] {0.5f, 0.75f, 1f, 1.25f, 1.5f, 2f};
String[] entries = new String[entryValues.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = (int) (entryValues[i] * 100) + " %";
}
ListPreferenceEx speechRate = (ListPreferenceEx) findPreference(settings.SPEECH_RATE.getId());
speechRate.setEntries(entries);
speechRate.setEntryValues(entryValues);
speechRate.setIcon(getContentIcon(R.drawable.ic_world_globe_dark));
speechRate.setDescription(R.string.speech_rate_descr);
}
private void setupSmartAutoAnnouncePref() {
SwitchPreferenceEx smartAutoAnnounce = (SwitchPreferenceEx) findPreference(settings.ACCESSIBILITY_SMART_AUTOANNOUNCE.getId());
smartAutoAnnounce.setDescription(getString(R.string.access_smart_autoannounce_descr));
}
private void setupAutoAnnouncePeriodPref() {
int[] seconds = new int[] {5, 10, 15, 20, 30, 45, 60, 90};
int[] minutes = new int[] {2, 3, 5};
Integer[] entryValues = new Integer[seconds.length + minutes.length];
String[] entries = new String[entryValues.length];
int k = 0;
for (int second : seconds) {
entryValues[k] = second * 1000;
entries[k] = second + " " + getString(R.string.int_seconds);
k++;
}
for (int minute : minutes) {
entryValues[k] = (minute * 60) * 1000;
entries[k] = minute + " " + getString(R.string.int_min);
k++;
}
ListPreferenceEx autoAnnouncePeriod = (ListPreferenceEx) findPreference(settings.ACCESSIBILITY_AUTOANNOUNCE_PERIOD.getId());
autoAnnouncePeriod.setEntries(entries);
autoAnnouncePeriod.setEntryValues(entryValues);
autoAnnouncePeriod.setDescription(R.string.access_autoannounce_period_descr);
}
private void setupDisableOffRouteRecalculationPref() {
SwitchPreferenceEx disableOffRouteRecalculation = (SwitchPreferenceEx) findPreference(settings.DISABLE_OFFROUTE_RECALC.getId());
disableOffRouteRecalculation.setDescription(getString(R.string.access_disable_offroute_recalc_descr));
}
private void setupDisableWrongDirectionRecalculationPref() {
SwitchPreferenceEx disableWrongDirectionRecalculation = (SwitchPreferenceEx) findPreference(settings.DISABLE_WRONG_DIRECTION_RECALC.getId());
disableWrongDirectionRecalculation.setDescription(getString(R.string.access_disable_wrong_direction_recalc_descr));
}
private void setupDirectionStylePref() {
RelativeDirectionStyle[] relativeDirectionStyles = RelativeDirectionStyle.values();
String[] entries = new String[relativeDirectionStyles.length];
Integer[] entryValues = new Integer[relativeDirectionStyles.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = relativeDirectionStyles[i].toHumanString(app);
entryValues[i] = relativeDirectionStyles[i].ordinal();
}
ListPreferenceEx directionStyle = (ListPreferenceEx) findPreference(settings.DIRECTION_STYLE.getId());
directionStyle.setEntries(entries);
directionStyle.setEntryValues(entryValues);
directionStyle.setDescription(R.string.settings_direction_style_descr);
}
private void setupDirectionAudioFeedbackPref() {
SwitchPreferenceEx directionAudioFeedback = (SwitchPreferenceEx) findPreference(settings.DIRECTION_AUDIO_FEEDBACK.getId());
directionAudioFeedback.setDescription(getString(R.string.access_direction_audio_feedback_descr));
}
private void setupDirectionHapticFeedbackPref() {
SwitchPreferenceEx directionHapticFeedback = (SwitchPreferenceEx) findPreference(settings.DIRECTION_HAPTIC_FEEDBACK.getId());
directionHapticFeedback.setDescription(getString(R.string.access_direction_haptic_feedback_descr));
}
private void setupCopyProfileSettingsPref() {
Preference copyProfilePrefs = findPreference(COPY_PLUGIN_SETTINGS);
copyProfilePrefs.setIcon(getActiveIcon(R.drawable.ic_action_copy));
}
private void setupResetToDefaultPref() {
Preference resetToDefault = findPreference(RESET_TO_DEFAULT);
resetToDefault.setIcon(getActiveIcon(R.drawable.ic_action_reset_to_default_dark));
}
@Override
public void onPreferenceChanged(String prefId) {
if (settings.ACCESSIBILITY_MODE.getId().equals(prefId)) {
updateAccessibilityOptions();
}
}
private void updateAccessibilityOptions() {
boolean accessibilityEnabled = app.accessibilityEnabledForMode(getSelectedAppMode());
PreferenceScreen screen = getPreferenceScreen();
if (screen != null) {
for (int i = 0; i < screen.getPreferenceCount(); i++) {
Preference preference = screen.getPreference(i);
String prefId = preference.getKey();
if (!settings.ACCESSIBILITY_MODE.getId().equals(prefId) && !settings.SPEECH_RATE.getId().equals(prefId))
preference.setEnabled(accessibilityEnabled);
}
}
}
}

View file

@ -873,8 +873,12 @@ public class OsmandApplication extends MultiDexApplication {
}
public boolean accessibilityEnabled() {
final AccessibilityMode mode = getSettings().ACCESSIBILITY_MODE.get();
if(OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) == null) {
return accessibilityEnabledForMode(getSettings().APPLICATION_MODE.get());
}
public boolean accessibilityEnabledForMode(ApplicationMode appMode) {
final AccessibilityMode mode = getSettings().ACCESSIBILITY_MODE.getModeValue(appMode);
if (OsmandPlugin.getEnabledPlugin(AccessibilityPlugin.class) == null) {
return false;
}
if (mode == AccessibilityMode.ON) {

View file

@ -36,6 +36,7 @@ import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.skimapsplugin.SkiMapsPlugin;
import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.OsmandMapTileView;
@ -61,10 +62,10 @@ public abstract class OsmandPlugin {
public abstract String getId();
public abstract String getDescription();
public abstract String getName();
public abstract String getDescription();
public abstract int getAssetResourceName();
@DrawableRes
@ -72,7 +73,17 @@ public abstract class OsmandPlugin {
return R.drawable.ic_extension_dark;
}
public abstract Class<? extends Activity> getSettingsActivity();
public Class<? extends Activity> getSettingsActivity() {
return null;
}
public Class<? extends BaseSettingsFragment> getSettingsFragment() {
return null;
}
public String getPrefsDescription() {
return null;
}
public String getVersion() {
return "";

View file

@ -833,17 +833,23 @@ public class OsmandSettings {
}
@Override
protected Boolean getValue(Object prefs, Boolean defaultValue) {
return ctx.accessibilityEnabled() ?
super.getValue(prefs, defaultValue) :
defaultValue;
public Boolean get() {
return ctx.accessibilityEnabled() ? super.get() : getDefaultValue();
}
@Override
protected boolean setValue(Object prefs, Boolean val) {
return ctx.accessibilityEnabled() ?
super.setValue(prefs, val) :
false;
public Boolean getModeValue(ApplicationMode mode) {
return ctx.accessibilityEnabledForMode(mode) ? super.getModeValue(mode) : getDefaultValue();
}
@Override
public boolean set(Boolean obj) {
return ctx.accessibilityEnabled() && super.set(obj);
}
@Override
public boolean setModeValue(ApplicationMode mode, Boolean obj) {
return ctx.accessibilityEnabledForMode(mode) && super.setModeValue(mode, obj);
}
}
@ -1179,9 +1185,6 @@ public class OsmandSettings {
public final CommonPreference<Integer> NUMBER_OF_STARTS_FIRST_XMAS_SHOWN = new IntPreference("number_of_starts_first_xmas_shown", 0).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Boolean> USE_INTERNET_TO_DOWNLOAD_TILES = new BooleanPreference("use_internet_to_download_tiles", true).makeGlobal().cache();
public final OsmandPreference<String> AVAILABLE_APP_MODES = new StringPreference("available_application_modes", "car,bicycle,pedestrian,public_transport,").makeGlobal().cache();
public final OsmandPreference<String> LAST_FAV_CATEGORY_ENTERED = new StringPreference("last_fav_category", "").makeGlobal();
@ -1374,16 +1377,16 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
// cache of metrics constants as they are used very often
public final OsmandPreference<RelativeDirectionStyle> DIRECTION_STYLE = new EnumIntPreference<RelativeDirectionStyle>(
"direction_style", RelativeDirectionStyle.SIDEWISE, RelativeDirectionStyle.values()).makeGlobal().cache();
"direction_style", RelativeDirectionStyle.SIDEWISE, RelativeDirectionStyle.values()).makeProfile().cache();
// this value string is synchronized with settings_pref.xml preference name
// cache of metrics constants as they are used very often
public final OsmandPreference<AccessibilityMode> ACCESSIBILITY_MODE = new EnumIntPreference<AccessibilityMode>(
"accessibility_mode", AccessibilityMode.DEFAULT, AccessibilityMode.values()).makeGlobal().cache();
"accessibility_mode", AccessibilityMode.DEFAULT, AccessibilityMode.values()).makeProfile().cache();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Float> SPEECH_RATE =
new FloatPreference("speech_rate", 1f).makeGlobal();
new FloatPreference("speech_rate", 1f).makeProfile();
public final OsmandPreference<Float> ARRIVAL_DISTANCE_FACTOR =
new FloatPreference("arrival_distance_factor", 1f).makeProfile();
@ -1409,27 +1412,27 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> ACCESSIBILITY_SMART_AUTOANNOUNCE =
new BooleanAccessibilityPreference("accessibility_smart_autoannounce", true).makeGlobal();
new BooleanAccessibilityPreference("accessibility_smart_autoannounce", true).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
// cache of metrics constants as they are used very often
public final OsmandPreference<Integer> ACCESSIBILITY_AUTOANNOUNCE_PERIOD = new IntPreference("accessibility_autoannounce_period", 10000).makeGlobal().cache();
public final OsmandPreference<Integer> ACCESSIBILITY_AUTOANNOUNCE_PERIOD = new IntPreference("accessibility_autoannounce_period", 10000).makeProfile().cache();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> DISABLE_OFFROUTE_RECALC =
new BooleanAccessibilityPreference("disable_offroute_recalc", false).makeGlobal();
new BooleanAccessibilityPreference("disable_offroute_recalc", false).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> DISABLE_WRONG_DIRECTION_RECALC =
new BooleanAccessibilityPreference("disable_wrong_direction_recalc", false).makeGlobal();
new BooleanAccessibilityPreference("disable_wrong_direction_recalc", false).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> DIRECTION_AUDIO_FEEDBACK =
new BooleanAccessibilityPreference("direction_audio_feedback", false).makeGlobal();
new BooleanAccessibilityPreference("direction_audio_feedback", false).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> DIRECTION_HAPTIC_FEEDBACK =
new BooleanAccessibilityPreference("direction_haptic_feedback", false).makeGlobal();
new BooleanAccessibilityPreference("direction_haptic_feedback", false).makeProfile();
// magnetic field doesn'torkmost of the time on some phones
public final OsmandPreference<Boolean> USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", false).makeProfile().cache();

View file

@ -64,6 +64,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
@ -538,25 +539,25 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
this.app = app;
OsmandSettings settings = app.getSettings();
ApplicationMode.regWidgetVisibility("audionotes", (ApplicationMode[]) null);
AV_EXTERNAL_RECORDER = settings.registerBooleanPreference("av_external_recorder", false).makeGlobal();
AV_EXTERNAL_PHOTO_CAM = settings.registerBooleanPreference("av_external_cam", true).makeGlobal();
AV_VIDEO_FORMAT = settings.registerIntPreference("av_video_format", VIDEO_OUTPUT_MP4).makeGlobal();
AV_VIDEO_QUALITY = settings.registerIntPreference("av_video_quality", VIDEO_QUALITY_DEFAULT).makeGlobal();
AV_AUDIO_FORMAT = settings.registerIntPreference("av_audio_format", AUDIO_FORMAT_DEFAULT).makeGlobal();
AV_AUDIO_BITRATE = settings.registerIntPreference("av_audio_bitrate", AUDIO_BITRATE_DEFAULT).makeGlobal();
AV_DEFAULT_ACTION = settings.registerIntPreference("av_default_action", AV_DEFAULT_ACTION_CHOOSE).makeGlobal();
AV_EXTERNAL_RECORDER = settings.registerBooleanPreference("av_external_recorder", false);
AV_EXTERNAL_PHOTO_CAM = settings.registerBooleanPreference("av_external_cam", true);
AV_VIDEO_FORMAT = settings.registerIntPreference("av_video_format", VIDEO_OUTPUT_MP4);
AV_VIDEO_QUALITY = settings.registerIntPreference("av_video_quality", VIDEO_QUALITY_DEFAULT);
AV_AUDIO_FORMAT = settings.registerIntPreference("av_audio_format", AUDIO_FORMAT_DEFAULT);
AV_AUDIO_BITRATE = settings.registerIntPreference("av_audio_bitrate", AUDIO_BITRATE_DEFAULT);
AV_DEFAULT_ACTION = settings.registerIntPreference("av_default_action", AV_DEFAULT_ACTION_CHOOSE);
// camera picture size:
AV_CAMERA_PICTURE_SIZE = settings.registerIntPreference("av_camera_picture_size", AV_PHOTO_SIZE_DEFAULT).makeGlobal();
AV_CAMERA_PICTURE_SIZE = settings.registerIntPreference("av_camera_picture_size", AV_PHOTO_SIZE_DEFAULT);
// camera focus type:
AV_CAMERA_FOCUS_TYPE = settings.registerIntPreference("av_camera_focus_type", AV_CAMERA_FOCUS_AUTO).makeGlobal();
AV_CAMERA_FOCUS_TYPE = settings.registerIntPreference("av_camera_focus_type", AV_CAMERA_FOCUS_AUTO);
// camera sound:
AV_PHOTO_PLAY_SOUND = settings.registerBooleanPreference("av_photo_play_sound", true).makeGlobal();
AV_PHOTO_PLAY_SOUND = settings.registerBooleanPreference("av_photo_play_sound", true);
SHOW_RECORDINGS = settings.registerBooleanPreference("show_recordings", true).makeGlobal();
SHOW_RECORDINGS = settings.registerBooleanPreference("show_recordings", true);
AV_RECORDER_SPLIT = settings.registerBooleanPreference("av_recorder_split", false).makeGlobal();
AV_RS_CLIP_LENGTH = settings.registerIntPreference("av_rs_clip_length", CLIP_LENGTH_DEFAULT).makeGlobal();
AV_RS_STORAGE_SIZE = settings.registerIntPreference("av_rs_storage_size", STORAGE_SIZE_DEFAULT).makeGlobal();
AV_RECORDER_SPLIT = settings.registerBooleanPreference("av_recorder_split", false);
AV_RS_CLIP_LENGTH = settings.registerIntPreference("av_rs_clip_length", CLIP_LENGTH_DEFAULT);
AV_RS_STORAGE_SIZE = settings.registerIntPreference("av_rs_storage_size", STORAGE_SIZE_DEFAULT);
}
@Override
@ -1788,6 +1789,15 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
return SettingsAudioVideoActivity.class;
}
@Override
public Class<? extends BaseSettingsFragment> getSettingsFragment() {
return MultimediaNotesFragment.class;
}
@Override
public String getPrefsDescription() {
return app.getString(R.string.multimedia_notes_prefs_descr);
}
@Override
public void onMapActivityExternalResult(int requestCode, int resultCode, Intent data) {

View file

@ -0,0 +1,368 @@
package net.osmand.plus.audionotes;
import android.content.Intent;
import android.hardware.Camera;
import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import android.os.Build;
import android.os.StatFs;
import android.support.v7.preference.Preference;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import org.apache.commons.logging.Log;
import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AUDIO_BITRATE_DEFAULT;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_AUTO;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_CONTINUOUS;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_EDOF;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_HIPERFOCAL;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_INFINITY;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.AV_CAMERA_FOCUS_MACRO;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.NOTES_TAB;
import static net.osmand.plus.audionotes.AudioVideoNotesPlugin.cameraPictureSizeDefault;
public class MultimediaNotesFragment extends BaseSettingsFragment {
private static final Log log = PlatformUtil.getLog(MultimediaNotesFragment.class);
private static final String COPY_PLUGIN_SETTINGS = "copy_plugin_settings";
private static final String RESET_TO_DEFAULT = "reset_to_default";
private static final String OPEN_NOTES = "open_notes";
@Override
protected void setupPreferences() {
AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
if (plugin != null) {
Camera cam = openCamera();
if (cam != null) {
setupExternalPhotoCamPref(plugin);
setupCameraPictureSizePref(cam, plugin);
setupCameraFocusTypePref(cam, plugin);
setupPhotoPlaySoundPref(plugin);
cam.release();
}
setupAudioFormatPref(plugin);
setupAudioBitratePref(plugin);
setupExternalRecorderPref(plugin);
setupVideoQualityPref(plugin);
setupRecorderSplitPref(plugin);
setupClipLengthPref(plugin);
setupStorageSizePref(plugin);
setupOpenNotesDescrPref();
setupOpenNotesPref();
setupCopyProfileSettingsPref();
setupResetToDefaultPref();
}
}
private void setupExternalPhotoCamPref(AudioVideoNotesPlugin plugin) {
SwitchPreferenceEx externalPhotoCam = (SwitchPreferenceEx) findPreference(plugin.AV_EXTERNAL_PHOTO_CAM.getId());
externalPhotoCam.setDescription(getString(R.string.av_use_external_camera_descr));
externalPhotoCam.setIcon(getActiveIcon(R.drawable.ic_action_photo_dark));
}
private void setupCameraPictureSizePref(Camera cam, AudioVideoNotesPlugin plugin) {
Camera.Parameters parameters = cam.getParameters();
// Photo picture size
// get supported sizes
List<Camera.Size> psps = parameters.getSupportedPictureSizes();
// list of megapixels of each resolution
List<Integer> mpix = new ArrayList<Integer>();
// list of index each resolution in list, returned by getSupportedPictureSizes()
List<Integer> picSizesValues = new ArrayList<Integer>();
// fill lists for sort
for (int index = 0; index < psps.size(); index++) {
mpix.add((psps.get(index)).width * (psps.get(index)).height);
picSizesValues.add(index);
}
// sort list for max resolution in begining of list
for (int i = 0; i < mpix.size(); i++) {
for (int j = 0; j < mpix.size() - i - 1; j++) {
if (mpix.get(j) < mpix.get(j + 1)) {
// change elements
int tmp = mpix.get(j + 1);
mpix.set(j + 1, mpix.get(j));
mpix.set(j, tmp);
tmp = picSizesValues.get(j + 1);
picSizesValues.set(j + 1, picSizesValues.get(j));
picSizesValues.set(j, tmp);
}
}
}
// set default photo size to max resolution (set index of element with max resolution in List, returned by getSupportedPictureSizes() )
cameraPictureSizeDefault = picSizesValues.get(0);
log.debug("onCreate() set cameraPictureSizeDefault=" + cameraPictureSizeDefault);
List<String> itemsPicSizes = new ArrayList<String>();
String prefix;
for (int index = 0; index < psps.size(); index++) {
float px = (float) ((psps.get(picSizesValues.get(index))).width * (psps.get(picSizesValues.get(index))).height);
if (px > 102400) { // 100 K
px = px / 1048576;
prefix = "Mpx";
} else {
px = px / 1024;
prefix = "Kpx";
}
itemsPicSizes.add((psps.get(picSizesValues.get(index))).width
+ "x" + (psps.get(picSizesValues.get(index))).height
+ " ( " + String.format("%.2f", px) + " " + prefix + " )");
}
log.debug("onCreate() set default size: width=" + psps.get(cameraPictureSizeDefault).width + " height="
+ psps.get(cameraPictureSizeDefault).height + " index in ps=" + cameraPictureSizeDefault);
String[] entries = itemsPicSizes.toArray(new String[0]);
Integer[] entryValues = picSizesValues.toArray(new Integer[0]);
ListPreferenceEx cameraPictureSize = (ListPreferenceEx) findPreference(plugin.AV_CAMERA_PICTURE_SIZE.getId());
if (entries.length > 0) {
cameraPictureSize.setEntries(entries);
cameraPictureSize.setEntryValues(entryValues);
cameraPictureSize.setDescription(R.string.av_camera_pic_size_descr);
cameraPictureSize.setIcon(getActiveIcon(R.drawable.ic_action_picture_size));
} else {
cameraPictureSize.setVisible(false);
}
}
private void setupCameraFocusTypePref(Camera cam, AudioVideoNotesPlugin plugin) {
Camera.Parameters parameters = cam.getParameters();
// focus mode settings
// show in menu only suppoted modes
List<String> sfm = parameters.getSupportedFocusModes();
List<String> items = new ArrayList<String>();
List<Integer> itemsValues = new ArrayList<Integer>();
// filtering known types for translate and set index
for (int index = 0; index < sfm.size(); index++) {
if (sfm.get(index).equals("auto")) {
items.add(getString(R.string.av_camera_focus_auto));
itemsValues.add(AV_CAMERA_FOCUS_AUTO);
} else if (sfm.get(index).equals("fixed")) {
items.add(getString(R.string.av_camera_focus_hiperfocal));
itemsValues.add(AV_CAMERA_FOCUS_HIPERFOCAL);
} else if (sfm.get(index).equals("edof")) {
items.add(getString(R.string.av_camera_focus_edof));
itemsValues.add(AV_CAMERA_FOCUS_EDOF);
} else if (sfm.get(index).equals("infinity")) {
items.add(getString(R.string.av_camera_focus_infinity));
itemsValues.add(AV_CAMERA_FOCUS_INFINITY);
} else if (sfm.get(index).equals("macro")) {
items.add(getString(R.string.av_camera_focus_macro));
itemsValues.add(AV_CAMERA_FOCUS_MACRO);
} else if (sfm.get(index).equals("continuous-picture")) {
items.add(getString(R.string.av_camera_focus_continuous));
itemsValues.add(AV_CAMERA_FOCUS_CONTINUOUS);
}
}
String[] entries = items.toArray(new String[0]);
Integer[] entryValues = itemsValues.toArray(new Integer[0]);
ListPreferenceEx cameraFocusType = (ListPreferenceEx) findPreference(plugin.AV_CAMERA_FOCUS_TYPE.getId());
if (entries.length > 0) {
cameraFocusType.setEntries(entries);
cameraFocusType.setEntryValues(entryValues);
cameraFocusType.setDescription(R.string.av_camera_focus_descr);
cameraFocusType.setIcon(getActiveIcon(R.drawable.ic_action_camera_focus));
} else {
cameraFocusType.setVisible(false);
}
}
private void setupPhotoPlaySoundPref(AudioVideoNotesPlugin plugin) {
SwitchPreferenceEx photoPlaySound = (SwitchPreferenceEx) findPreference(plugin.AV_PHOTO_PLAY_SOUND.getId());
photoPlaySound.setDescription(getString(R.string.av_photo_play_sound_descr));
photoPlaySound.setIcon(getContentIcon(R.drawable.ic_action_music_off));
}
private void setupAudioFormatPref(AudioVideoNotesPlugin plugin) {
Integer[] entryValues = new Integer[] {MediaRecorder.AudioEncoder.DEFAULT, MediaRecorder.AudioEncoder.AAC};
String[] entries = new String[] {"Default", "AAC"};
ListPreferenceEx audioFormat = (ListPreferenceEx) findPreference(plugin.AV_AUDIO_FORMAT.getId());
audioFormat.setEntries(entries);
audioFormat.setEntryValues(entryValues);
audioFormat.setDescription(R.string.av_audio_format_descr);
}
private void setupAudioBitratePref(AudioVideoNotesPlugin plugin) {
Integer[] entryValues = new Integer[] {AUDIO_BITRATE_DEFAULT, 16 * 1024, 32 * 1024, 48 * 1024, 64 * 1024, 96 * 1024, 128 * 1024};
String[] entries = new String[] {"Default", "16 kbps", "32 kbps", "48 kbps", "64 kbps", "96 kbps", "128 kbps"};
ListPreferenceEx audioBitrate = (ListPreferenceEx) findPreference(plugin.AV_AUDIO_BITRATE.getId());
audioBitrate.setEntries(entries);
audioBitrate.setEntryValues(entryValues);
audioBitrate.setDescription(R.string.av_audio_bitrate_descr);
}
private void setupExternalRecorderPref(AudioVideoNotesPlugin plugin) {
SwitchPreferenceEx externalRecorder = (SwitchPreferenceEx) findPreference(plugin.AV_EXTERNAL_RECORDER.getId());
externalRecorder.setDescription(getString(R.string.av_use_external_recorder_descr));
externalRecorder.setIcon(getContentIcon(R.drawable.ic_action_video_dark));
}
private void setupVideoQualityPref(AudioVideoNotesPlugin plugin) {
List<String> qNames = new ArrayList<>();
List<Integer> qValues = new ArrayList<>();
if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_LOW)) {
qNames.add(getString(R.string.av_video_quality_low));
qValues.add(CamcorderProfile.QUALITY_LOW);
}
if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_480P)) {
qNames.add("720 x 480 (480p)");
qValues.add(CamcorderProfile.QUALITY_480P);
}
if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_720P)) {
qNames.add("1280 x 720 (720p)");
qValues.add(CamcorderProfile.QUALITY_720P);
}
if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_1080P)) {
qNames.add("1920 x 1080 (1080p)");
qValues.add(CamcorderProfile.QUALITY_1080P);
}
if (Build.VERSION.SDK_INT >= 21 && CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_2160P)) {
qNames.add("3840x2160 (2160p)");
qValues.add(CamcorderProfile.QUALITY_2160P);
}
if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_HIGH)) {
qNames.add(getString(R.string.av_video_quality_high));
qValues.add(CamcorderProfile.QUALITY_HIGH);
}
String[] entries = qNames.toArray(new String[0]);
Integer[] entryValues = qValues.toArray(new Integer[0]);
ListPreferenceEx videoQuality = (ListPreferenceEx) findPreference(plugin.AV_VIDEO_QUALITY.getId());
videoQuality.setEntries(entries);
videoQuality.setEntryValues(entryValues);
videoQuality.setDescription(R.string.av_video_quality_descr);
videoQuality.setIcon(getContentIcon(R.drawable.ic_action_picture_size));
}
private void setupRecorderSplitPref(AudioVideoNotesPlugin plugin) {
SwitchPreferenceEx recorderSplit = (SwitchPreferenceEx) findPreference(plugin.AV_RECORDER_SPLIT.getId());
recorderSplit.setDescription(getString(R.string.rec_split_desc));
}
private void setupClipLengthPref(AudioVideoNotesPlugin plugin) {
Integer[] entryValues = new Integer[] {1, 2, 3, 4, 5, 7, 10, 15, 20, 25, 30};
String[] entries = new String[entryValues.length];
int i = 0;
String minStr = getString(R.string.int_min);
for (int v : entryValues) {
entries[i++] = v + " " + minStr;
}
ListPreferenceEx clipLength = (ListPreferenceEx) findPreference(plugin.AV_RS_CLIP_LENGTH.getId());
clipLength.setEntries(entries);
clipLength.setEntryValues(entryValues);
clipLength.setDescription(R.string.rec_split_clip_length_desc);
}
private void setupStorageSizePref(AudioVideoNotesPlugin plugin) {
ListPreferenceEx storageSize = (ListPreferenceEx) findPreference(plugin.AV_RS_STORAGE_SIZE.getId());
File dir = app.getAppPath("").getParentFile();
long size = 0;
if (dir.canRead()) {
StatFs fs = new StatFs(dir.getAbsolutePath());
size = ((long) fs.getBlockSize() * (long) fs.getBlockCount()) / (1 << 30);
}
if (size > 0) {
int value = 1;
ArrayList<Integer> gbList = new ArrayList<>();
while (value < size) {
gbList.add(value);
if (value < 5) {
value++;
} else {
value += 5;
}
}
if (value != size) {
gbList.add((int) size);
}
MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US);
String[] entries = new String[gbList.size()];
Integer[] entryValues = new Integer[gbList.size()];
int i = 0;
for (int v : gbList) {
entryValues[i] = v;
entries[i] = formatGb.format(new Object[] {(float) v});
i++;
}
storageSize.setEntries(entries);
storageSize.setEntryValues(entryValues);
storageSize.setDescription(R.string.rec_split_storage_size_desc);
} else {
storageSize.setVisible(false);
}
}
private void setupOpenNotesDescrPref() {
Preference nameAndPasswordPref = findPreference("open_notes_description");
nameAndPasswordPref.setTitle(getText(R.string.multimedia_notes_view_descr));
}
private void setupOpenNotesPref() {
Preference openNotes = findPreference(OPEN_NOTES);
openNotes.setIcon(getActiveIcon(R.drawable.ic_action_folder));
}
private void setupCopyProfileSettingsPref() {
Preference copyProfilePrefs = findPreference(COPY_PLUGIN_SETTINGS);
copyProfilePrefs.setIcon(getActiveIcon(R.drawable.ic_action_copy));
}
private void setupResetToDefaultPref() {
Preference resetToDefault = findPreference(RESET_TO_DEFAULT);
resetToDefault.setIcon(getActiveIcon(R.drawable.ic_action_reset_to_default_dark));
}
@Override
public boolean onPreferenceClick(Preference preference) {
if (OPEN_NOTES.equals(preference.getKey())) {
OsmAndAppCustomization appCustomization = app.getAppCustomization();
Intent favorites = new Intent(preference.getContext(), appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
app.getSettings().FAVORITES_TAB.set(NOTES_TAB);
startActivity(favorites);
return true;
}
return super.onPreferenceClick(preference);
}
private Camera openCamera() {
try {
return Camera.open();
} catch (Exception e) {
log.error("Error open camera", e);
return null;
}
}
}

View file

@ -13,6 +13,7 @@ import net.osmand.plus.Version;
import net.osmand.plus.activities.ContributionVersionActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
@ -29,7 +30,6 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
//ApplicationMode.regWidgetVisibility("fps", new ApplicationMode[0]);
}
@Override
public String getId() {
return ID;

View file

@ -28,6 +28,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView;
@ -139,11 +140,6 @@ public class MapillaryPlugin extends OsmandPlugin {
}
}
@Override
public Class<? extends Activity> getSettingsActivity() {
return null;
}
@Override
public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.OnRowItemClick() {

View file

@ -127,8 +127,8 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
int dzoom = nzoom - TILE_ZOOM;
int div = (int) Math.pow(2.0, dzoom);
boolean useInternet = (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null || OsmandPlugin.getEnabledPlugin(MapillaryPlugin.class) != null) &&
settings.USE_INTERNET_TO_DOWNLOAD_TILES.get() && settings.isInternetConnectionAvailable() && map.couldBeDownloadedFromInternet();
boolean useInternet = (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null || OsmandPlugin.getEnabledPlugin(MapillaryPlugin.class) != null)
&& settings.isInternetConnectionAvailable() && map.couldBeDownloadedFromInternet();
Map<String, GeometryTile> tiles = new HashMap<>();
Map<QuadPointDouble, Map> visiblePoints = new HashMap<>();

View file

@ -0,0 +1,202 @@
package net.osmand.plus.monitoring;
import android.content.Intent;
import android.support.v4.app.FragmentManager;
import android.support.v7.preference.Preference;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.settings.bottomsheets.ChangeGeneralProfilesPrefBottomSheet;
import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import java.io.Serializable;
import static net.osmand.plus.OsmandSettings.DAILY_DIRECTORY;
import static net.osmand.plus.OsmandSettings.MONTHLY_DIRECTORY;
import static net.osmand.plus.OsmandSettings.REC_DIRECTORY;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS;
public class MonitoringSettingsFragment extends BaseSettingsFragment {
private static final String COPY_PLUGIN_SETTINGS = "copy_plugin_settings";
private static final String RESET_TO_DEFAULT = "reset_to_default";
private static final String OPEN_TRACKS = "open_tracks";
@Override
protected void setupPreferences() {
setupSaveTrackToGpxPref();
setupSaveTrackIntervalPref();
setupSaveTrackMinDistancePref();
setupSaveTrackPrecisionPref();
setupSaveTrackMinSpeedPref();
setupAutoSplitRecordingPref();
setupDisableRecordingOnceAppKilledPref();
setupTrackStorageDirectoryPref();
setupLiveMonitoringPref();
setupOpenNotesDescrPref();
setupOpenNotesPref();
setupCopyProfileSettingsPref();
setupResetToDefaultPref();
}
private void setupSaveTrackToGpxPref() {
SwitchPreferenceEx saveTrackToGpx = (SwitchPreferenceEx) findPreference(settings.SAVE_TRACK_TO_GPX.getId());
saveTrackToGpx.setDescription(getString(R.string.save_track_to_gpx_descrp));
saveTrackToGpx.setIcon(getContentIcon(R.drawable.ic_action_gdirections_dark));
}
private void setupSaveTrackIntervalPref() {
Integer[] entryValues = new Integer[SECONDS.length + MINUTES.length];
String[] entries = new String[entryValues.length];
int k = 0;
for (int second : SECONDS) {
entryValues[k] = second * 1000;
entries[k] = second + " " + getString(R.string.int_seconds);
k++;
}
for (int minute : MINUTES) {
entryValues[k] = (minute * 60) * 1000;
entries[k] = minute + " " + getString(R.string.int_min);
k++;
}
ListPreferenceEx saveTrackInterval = (ListPreferenceEx) findPreference(settings.SAVE_TRACK_INTERVAL.getId());
saveTrackInterval.setEntries(entries);
saveTrackInterval.setEntryValues(entryValues);
saveTrackInterval.setIcon(getActiveIcon(R.drawable.ic_action_time_span));
saveTrackInterval.setDescription(R.string.save_track_interval_descr);
}
private void setupSaveTrackMinDistancePref() {
Float[] entryValues = new Float[] {0.f, 2.0f, 5.0f, 10.0f, 20.0f, 30.0f, 50.0f};
String[] entries = new String[entryValues.length];
entries[0] = getString(R.string.shared_string_not_selected);
for (int i = 1; i < entryValues.length; i++) {
entries[i] = entryValues[i].intValue() + " " + getString(R.string.m);
}
ListPreferenceEx saveTrackMinDistance = (ListPreferenceEx) findPreference(settings.SAVE_TRACK_MIN_DISTANCE.getId());
saveTrackMinDistance.setEntries(entries);
saveTrackMinDistance.setEntryValues(entryValues);
saveTrackMinDistance.setDescription(R.string.save_track_min_distance_descr);
}
private void setupSaveTrackPrecisionPref() {
Float[] entryValues = new Float[] {0.f, 1.0f, 2.0f, 5.0f, 10.0f, 15.0f, 20.0f, 50.0f, 100.0f};
String[] entries = new String[entryValues.length];
entries[0] = getString(R.string.shared_string_not_selected);
for (int i = 1; i < entryValues.length; i++) {
entries[i] = entryValues[i].intValue() + " " + getString(R.string.m) + " (" + Math.round(entryValues[i] / 0.3048f) + " " + getString(R.string.foot) + ")";
}
ListPreferenceEx saveTrackPrecision = (ListPreferenceEx) findPreference(settings.SAVE_TRACK_PRECISION.getId());
saveTrackPrecision.setEntries(entries);
saveTrackPrecision.setEntryValues(entryValues);
saveTrackPrecision.setDescription(R.string.save_track_precision_descr);
}
private void setupSaveTrackMinSpeedPref() {
Float[] entryValues = new Float[] {0.f, 0.000001f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f};
String[] entries = new String[entryValues.length];
entries[0] = getString(R.string.shared_string_not_selected);
entries[1] = "> 0"; // This option for the GPS chipset motion detection
for (int i = 2; i < entryValues.length; i++) {
entries[i] = entryValues[i].intValue() + " " + getString(R.string.km_h);
entryValues[i] = entryValues[i] / 3.6f;
}
ListPreferenceEx saveTrackMinSpeed = (ListPreferenceEx) findPreference(settings.SAVE_TRACK_MIN_SPEED.getId());
saveTrackMinSpeed.setEntries(entries);
saveTrackMinSpeed.setEntryValues(entryValues);
saveTrackMinSpeed.setDescription(R.string.save_track_min_speed_descr);
}
private void setupAutoSplitRecordingPref() {
SwitchPreferenceEx autoSplitRecording = (SwitchPreferenceEx) findPreference(settings.AUTO_SPLIT_RECORDING.getId());
autoSplitRecording.setDescription(getString(R.string.auto_split_recording_descr));
}
private void setupDisableRecordingOnceAppKilledPref() {
SwitchPreferenceEx disableRecordingOnceAppKilled = (SwitchPreferenceEx) findPreference(settings.DISABLE_RECORDING_ONCE_APP_KILLED.getId());
disableRecordingOnceAppKilled.setDescription(getString(R.string.disable_recording_once_app_killed_descrp));
}
private void setupTrackStorageDirectoryPref() {
Integer[] entryValues = new Integer[] {REC_DIRECTORY, MONTHLY_DIRECTORY, DAILY_DIRECTORY};
String[] entries = new String[entryValues.length];
entries[0] = getString(R.string.store_tracks_in_rec_directory);
entries[1] = getString(R.string.store_tracks_in_monthly_directories);
entries[2] = getString(R.string.store_tracks_in_daily_directories);
ListPreferenceEx trackStorageDirectory = (ListPreferenceEx) findPreference(settings.TRACK_STORAGE_DIRECTORY.getId());
trackStorageDirectory.setEntries(entries);
trackStorageDirectory.setEntryValues(entryValues);
trackStorageDirectory.setDescription(R.string.track_storage_directory_descrp);
trackStorageDirectory.setIcon(getActiveIcon(R.drawable.ic_action_folder));
}
private void setupLiveMonitoringPref() {
SwitchPreferenceEx liveMonitoring = (SwitchPreferenceEx) findPreference(settings.LIVE_MONITORING.getId());
liveMonitoring.setDescription(getString(R.string.live_monitoring_m_descr));
liveMonitoring.setIcon(getContentIcon(R.drawable.ic_world_globe_dark));
}
private void setupOpenNotesDescrPref() {
Preference nameAndPasswordPref = findPreference("open_tracks_description");
nameAndPasswordPref.setTitle(getText(R.string.tracks_view_descr));
}
private void setupOpenNotesPref() {
Preference openNotes = findPreference(OPEN_TRACKS);
openNotes.setIcon(getActiveIcon(R.drawable.ic_action_folder));
}
private void setupCopyProfileSettingsPref() {
Preference copyProfilePrefs = findPreference(COPY_PLUGIN_SETTINGS);
copyProfilePrefs.setIcon(getActiveIcon(R.drawable.ic_action_copy));
}
private void setupResetToDefaultPref() {
Preference resetToDefault = findPreference(RESET_TO_DEFAULT);
resetToDefault.setIcon(getActiveIcon(R.drawable.ic_action_reset_to_default_dark));
}
@Override
public boolean onPreferenceClick(Preference preference) {
if (OPEN_TRACKS.equals(preference.getKey())) {
OsmAndAppCustomization appCustomization = app.getAppCustomization();
Intent favorites = new Intent(preference.getContext(), appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
app.getSettings().FAVORITES_TAB.set(FavoritesActivity.GPX_TAB);
startActivity(favorites);
return true;
}
return super.onPreferenceClick(preference);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String prefId = preference.getKey();
OsmandSettings.OsmandPreference pref = settings.getPreference(prefId);
if (pref instanceof OsmandSettings.CommonPreference && !((OsmandSettings.CommonPreference) pref).hasDefaultValueForMode(getSelectedAppMode())) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null && newValue instanceof Serializable) {
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, prefId,
(Serializable) newValue, this, false, getSelectedAppMode());
}
return false;
}
return true;
}
}

View file

@ -34,6 +34,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.SavingTrackHelper.SaveGpxResult;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
@ -146,7 +147,15 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
return SettingsMonitoringActivity.class;
}
@Override
public Class<? extends BaseSettingsFragment> getSettingsFragment() {
return MonitoringSettingsFragment.class;
}
@Override
public String getPrefsDescription() {
return app.getString(R.string.monitoring_prefs_descr);
}
/**
* creates (if it wasn't created previously) the control to be added on a MapInfoLayer that shows a monitoring state (recorded/stopped)

View file

@ -17,6 +17,7 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadResources;
import net.osmand.plus.settings.BaseSettingsFragment;
import java.util.Collections;
import java.util.List;
@ -120,9 +121,4 @@ public class NauticalMapsPlugin extends OsmandPlugin {
public String getId() {
return ID;
}
@Override
public Class<? extends Activity> getSettingsActivity() {
return null;
}
}

View file

@ -0,0 +1,90 @@
package net.osmand.plus.osmedit;
import android.content.Intent;
import android.support.v4.app.FragmentManager;
import android.support.v7.preference.Preference;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.R;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.settings.OnPreferenceChanged;
import net.osmand.plus.settings.bottomsheets.OsmLoginDataBottomSheet;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
public class OsmEditingFragment extends BaseSettingsFragment implements OnPreferenceChanged {
private static final String OPEN_OSM_EDITS = "open_osm_edits";
private static final String OSM_LOGIN_DATA = "osm_login_data";
@Override
protected void setupPreferences() {
Preference vehicleParametersInfo = findPreference("osm_editing_info");
vehicleParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
setupNameAndPasswordPref();
setupOfflineEditingPref();
setupOsmEditsDescrPref();
setupOsmEditsPref();
}
@Override
protected void createToolbar(LayoutInflater inflater, View view) {
super.createToolbar(inflater, view);
TextView toolbarSubtitle = view.findViewById(R.id.toolbar_subtitle);
toolbarSubtitle.setText(getPreferenceScreen().getSummary());
AndroidUiHelper.updateVisibility(toolbarSubtitle, true);
}
private void setupNameAndPasswordPref() {
Preference nameAndPasswordPref = findPreference(OSM_LOGIN_DATA);
nameAndPasswordPref.setSummary(settings.USER_NAME.get());
nameAndPasswordPref.setIcon(getContentIcon(R.drawable.ic_action_openstreetmap_logo));
}
private void setupOfflineEditingPref() {
SwitchPreferenceEx offlineEditingPref = (SwitchPreferenceEx) findPreference(settings.OFFLINE_EDITION.getId());
offlineEditingPref.setDescription(getString(R.string.offline_edition_descr));
}
private void setupOsmEditsDescrPref() {
Preference nameAndPasswordPref = findPreference("osm_edits_description");
nameAndPasswordPref.setTitle(getText(R.string.osm_edits_view_descr));
}
private void setupOsmEditsPref() {
Preference createProfile = findPreference(OPEN_OSM_EDITS);
createProfile.setIcon(getActiveIcon(R.drawable.ic_action_folder));
}
@Override
public boolean onPreferenceClick(Preference preference) {
if (OPEN_OSM_EDITS.equals(preference.getKey())) {
OsmAndAppCustomization appCustomization = app.getAppCustomization();
Intent favorites = new Intent(preference.getContext(), appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
app.getSettings().FAVORITES_TAB.set(R.string.osm_edits);
startActivity(favorites);
return true;
} else if (OSM_LOGIN_DATA.equals(preference.getKey())) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
OsmLoginDataBottomSheet.showInstance(fragmentManager, OSM_LOGIN_DATA, this, false, getSelectedAppMode());
return true;
}
}
return super.onPreferenceClick(preference);
}
@Override
public void onPreferenceChanged(String prefId) {
if (OSM_LOGIN_DATA.equals(prefId)) {
Preference nameAndPasswordPref = findPreference(OSM_LOGIN_DATA);
nameAndPasswordPref.setSummary(settings.USER_NAME.get());
}
}
}

View file

@ -40,6 +40,7 @@ import net.osmand.plus.myplaces.AvailableGPXFragment;
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.osmedit.OsmPoint.Action;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.Algorithms;
@ -190,6 +191,16 @@ public class OsmEditingPlugin extends OsmandPlugin {
return SettingsOsmEditingActivity.class;
}
@Override
public Class<? extends BaseSettingsFragment> getSettingsFragment() {
return OsmEditingFragment.class;
}
@Override
public String getPrefsDescription() {
return app.getString(R.string.osm_editing_prefs_descr);
}
@Override
public void registerMapContextMenuActions(final MapActivity mapActivity,
final double latitude,

View file

@ -95,7 +95,7 @@ public class SettingsOsmEditingActivity extends SettingsBaseActivity {
}
}
private static class ValidateOsmLoginDetailsTask extends AsyncTask<Void, Void, OsmBugsUtil.OsmBugResult> {
public static class ValidateOsmLoginDetailsTask extends AsyncTask<Void, Void, OsmBugsUtil.OsmBugResult> {
private final Context context;
public ValidateOsmLoginDetailsTask(Context context) {

View file

@ -31,6 +31,7 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
@ -518,11 +519,6 @@ public class ParkingPositionPlugin extends OsmandPlugin {
return parkingPlaceControl;
}
@Override
public Class<? extends Activity> getSettingsActivity() {
return null;
}
@Override
public int getAssetResourceName() {
return R.drawable.parking_position;

View file

@ -42,6 +42,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.RasterMapMenu;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.Algorithms;
@ -406,12 +407,6 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
}
}
@Override
public Class<? extends Activity> getSettingsActivity() {
return SettingsRasterMapsActivity.class;
}
public static void installMapLayers(final Activity activity, final ResultMatcher<TileSourceTemplate> result) {
final OsmandApplication app = (OsmandApplication) activity.getApplication();
final OsmandSettings settings = app.getSettings();

View file

@ -42,8 +42,6 @@ public class SettingsRasterMapsActivity extends SettingsBaseActivity {
// present on configure map
// addTileSourcePrefs(listener, cat);
cat.addPreference(createCheckBoxPreference(settings.USE_INTERNET_TO_DOWNLOAD_TILES,
R.string.use_internet, R.string.use_internet_to_download_tile));
// int startZoom = 1;
// int endZoom = 18;

View file

@ -40,6 +40,7 @@ import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibilitySettingsFragment;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
@ -48,6 +49,9 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
import net.osmand.plus.audionotes.MultimediaNotesFragment;
import net.osmand.plus.monitoring.MonitoringSettingsFragment;
import net.osmand.plus.osmedit.OsmEditingFragment;
import net.osmand.plus.profiles.SelectAppModesBottomSheetDialogFragment;
import net.osmand.plus.profiles.SelectAppModesBottomSheetDialogFragment.AppModeChangedListener;
import net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet;
@ -86,14 +90,19 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
MAIN_SETTINGS(MainSettingsFragment.TAG, false, R.xml.settings_main_screen, R.layout.global_preference_toolbar),
GLOBAL_SETTINGS(GlobalSettingsFragment.class.getName(), false, R.xml.global_settings, R.layout.global_preference_toolbar),
OPEN_STREET_MAP_EDITING(OsmEditingFragment.class.getName(), false, R.xml.osm_editing, R.layout.global_preference_toolbar),
CONFIGURE_PROFILE(ConfigureProfileFragment.class.getName(), true, R.xml.configure_profile, R.layout.profile_preference_toolbar_with_switch),
PROXY_SETTINGS(ProxySettingsFragment.class.getName(), false, R.xml.proxy_preferences, R.layout.global_preferences_toolbar_with_switch),
LIVE_MONITORING(LiveMonitoringFragment.class.getName(), false, R.xml.live_monitoring, R.layout.global_preferences_toolbar_with_switch),
GENERAL_PROFILE(GeneralProfileSettingsFragment.class.getName(), true, R.xml.general_profile_settings, R.layout.profile_preference_toolbar_big),
NAVIGATION(NavigationFragment.class.getName(), true, R.xml.navigation_settings_new, R.layout.profile_preference_toolbar),
COORDINATES_FORMAT(CoordinatesFormatFragment.class.getName(), true, R.xml.coordinates_format, R.layout.profile_preference_toolbar),
ROUTE_PARAMETERS(RouteParametersFragment.class.getName(), true, R.xml.route_parameters, R.layout.profile_preference_toolbar),
SCREEN_ALERTS(ScreenAlertsFragment.class.getName(), true, R.xml.screen_alerts, R.layout.profile_preference_toolbar_with_switch),
VOICE_ANNOUNCES(VoiceAnnouncesFragment.class.getName(), true, R.xml.voice_announces, R.layout.profile_preference_toolbar_with_switch),
ACCESSIBILITY_SETTINGS(AccessibilitySettingsFragment.class.getName(), true, R.xml.accessibility_settings, R.layout.profile_preference_toolbar_big),
MULTIMEDIA_NOTES(MultimediaNotesFragment.class.getName(), true, R.xml.multimedia_notes, R.layout.profile_preference_toolbar_big),
MONITORING_SETTINGS(MonitoringSettingsFragment.class.getName(), true, R.xml.monitoring_settings, R.layout.profile_preference_toolbar_big),
VEHICLE_PARAMETERS(VehicleParametersFragment.class.getName(), true, R.xml.vehicle_parameters, R.layout.profile_preference_toolbar),
MAP_DURING_NAVIGATION(MapDuringNavigationFragment.class.getName(), true, R.xml.map_during_navigation, R.layout.profile_preference_toolbar),
TURN_SCREEN_ON(TurnScreenOnFragment.class.getName(), true, R.xml.turn_screen_on, R.layout.profile_preference_toolbar_with_switch),

View file

@ -1,6 +1,5 @@
package net.osmand.plus.settings;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -20,7 +19,6 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceGroupAdapter;
import android.support.v7.preference.SwitchPreferenceCompat;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
@ -32,8 +30,6 @@ import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.aidl.ConnectedApp;
import net.osmand.aidl.OsmandAidlApi;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
@ -42,12 +38,10 @@ import net.osmand.plus.SettingsHelper;
import net.osmand.plus.SettingsHelper.ProfileSettingsItem;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.PluginActivity;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
import net.osmand.plus.profiles.SelectCopyAppModeBottomSheet;
import net.osmand.plus.settings.bottomsheets.ResetProfilePrefsBottomSheet;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import net.osmand.plus.skimapsplugin.SkiMapsPlugin;
import org.apache.commons.logging.Log;
@ -60,7 +54,6 @@ import static net.osmand.plus.profiles.EditProfileFragment.MAP_CONFIG;
import static net.osmand.plus.profiles.EditProfileFragment.OPEN_CONFIG_ON_MAP;
import static net.osmand.plus.profiles.EditProfileFragment.SCREEN_CONFIG;
import static net.osmand.plus.profiles.EditProfileFragment.SELECTED_ITEM;
import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KEY;
public class ConfigureProfileFragment extends BaseSettingsFragment {
@ -212,9 +205,6 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
setupProfileAppearancePref();
PreferenceCategory pluginSettings = (PreferenceCategory) findPreference(PLUGIN_SETTINGS);
pluginSettings.setIconSpaceReserved(false);
setupConnectedAppsPref(pluginSettings);
setupOsmandPluginsPref(pluginSettings);
PreferenceCategory settingsActions = (PreferenceCategory) findPreference(SETTINGS_ACTIONS);
@ -314,25 +304,6 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
}
}
private void setupConnectedAppsPref(PreferenceCategory preferenceCategory) {
OsmandApplication app = getMyApplication();
if (app == null) {
return;
}
List<ConnectedApp> connectedApps = app.getAidlApi().getConnectedApps();
for (ConnectedApp connectedApp : connectedApps) {
SwitchPreferenceCompat preference = new SwitchPreferenceCompat(app);
preference.setPersistent(false);
preference.setKey(connectedApp.getPack());
preference.setIcon(connectedApp.getIcon());
preference.setTitle(connectedApp.getName());
preference.setChecked(connectedApp.isEnabled());
preference.setLayoutResource(R.layout.preference_switch);
preferenceCategory.addPreference(preference);
}
}
private void setupOsmandPluginsPref(PreferenceCategory preferenceCategory) {
Context ctx = getContext();
if (ctx == null) {
@ -340,40 +311,22 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
}
List<OsmandPlugin> plugins = OsmandPlugin.getVisiblePlugins();
for (OsmandPlugin plugin : plugins) {
if (plugin instanceof SkiMapsPlugin || plugin instanceof NauticalMapsPlugin) {
if (plugin instanceof SkiMapsPlugin || plugin instanceof NauticalMapsPlugin || plugin.getSettingsFragment() == null) {
continue;
}
SwitchPreferenceEx preference = new SwitchPreferenceEx(ctx);
Preference preference = new Preference(ctx);
preference.setPersistent(false);
preference.setKey(plugin.getId());
preference.setTitle(plugin.getName());
preference.setChecked(plugin.isActive());
preference.setIcon(getPluginIcon(plugin));
preference.setIntent(getPluginIntent(plugin));
preference.setLayoutResource(R.layout.preference_dialog_and_switch);
preference.setSummary(plugin.getPrefsDescription());
preference.setIcon(getContentIcon(plugin.getLogoResourceId()));
preference.setLayoutResource(R.layout.preference_with_descr);
preference.setFragment(plugin.getSettingsFragment().getName());
preferenceCategory.addPreference(preference);
}
}
private Drawable getPluginIcon(OsmandPlugin plugin) {
int iconResId = plugin.getLogoResourceId();
return plugin.isActive() ? getActiveIcon(iconResId) : getIcon(iconResId, isNightMode() ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light);
}
private Intent getPluginIntent(OsmandPlugin plugin) {
Intent intent;
final Class<? extends Activity> settingsActivity = plugin.getSettingsActivity();
if (settingsActivity != null && !plugin.needsInstallation()) {
intent = new Intent(getContext(), settingsActivity);
intent.putExtra(PROFILE_STRING_KEY, getSelectedAppMode().getStringKey());
} else {
intent = new Intent(getContext(), PluginActivity.class);
intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, plugin.getId());
}
return intent;
}
@Override
public boolean onPreferenceClick(Preference preference) {
String prefId = preference.getKey();
@ -432,7 +385,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
return super.onPreferenceClick(preference);
}
void onDeleteProfileClick() {
private void onDeleteProfileClick() {
final ApplicationMode profile = getSelectedAppMode();
if (getActivity() != null) {
if (profile.getParent() != null) {
@ -465,32 +418,4 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
}
}
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
OsmandPlugin plugin = OsmandPlugin.getPlugin(key);
if (plugin != null) {
if (newValue instanceof Boolean) {
if ((plugin.isActive() || !plugin.needsInstallation())) {
if (OsmandPlugin.enablePlugin(getActivity(), app, plugin, (Boolean) newValue)) {
preference.setIcon(getPluginIcon(plugin));
return true;
}
} else if (plugin.needsInstallation() && preference.getIntent() != null) {
startActivity(preference.getIntent());
}
}
return false;
}
OsmandAidlApi aidlApi = app.getAidlApi();
ConnectedApp connectedApp = aidlApi.getConnectedApp(key);
if (connectedApp != null) {
return aidlApi.switchEnabled(connectedApp);
}
return super.onPreferenceChange(preference, newValue);
}
}

View file

@ -0,0 +1,150 @@
package net.osmand.plus.settings;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.preference.Preference;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.settings.bottomsheets.ChangeGeneralProfilesPrefBottomSheet;
import net.osmand.plus.settings.preferences.EditTextPreferenceEx;
import net.osmand.plus.settings.preferences.ListPreferenceEx;
import java.io.Serializable;
import static net.osmand.plus.UiUtilities.CompoundButtonType.TOOLBAR;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MAX_INTERVAL_TO_SEND_MINUTES;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS;
public class LiveMonitoringFragment extends BaseSettingsFragment {
@Override
protected void setupPreferences() {
setupLiveMonitoringUrlPref();
setupLiveMonitoringIntervalPref();
setupLiveMonitoringBufferPref();
enableDisablePreferences(settings.LIVE_MONITORING.getModeValue(getSelectedAppMode()));
}
@Override
protected void createToolbar(LayoutInflater inflater, View view) {
super.createToolbar(inflater, view);
view.findViewById(R.id.toolbar_switch_container).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ApplicationMode appMode = getSelectedAppMode();
boolean checked = !settings.LIVE_MONITORING.getModeValue(appMode);
settings.LIVE_MONITORING.setModeValue(appMode, checked);
updateToolbarSwitch();
enableDisablePreferences(checked);
}
});
TextView title = (TextView) view.findViewById(R.id.switchButtonText);
title.setTextColor(ContextCompat.getColor(app, isNightMode() ? R.color.active_color_primary_dark : R.color.active_color_primary_light));
}
@Override
protected void updateToolbar() {
super.updateToolbar();
updateToolbarSwitch();
}
private void updateToolbarSwitch() {
View view = getView();
if (view == null) {
return;
}
boolean checked = settings.LIVE_MONITORING.getModeValue(getSelectedAppMode());
int color = checked ? getActiveProfileColor() : ContextCompat.getColor(app, R.color.preference_top_switch_off);
View selectableView = view.findViewById(R.id.selectable_item);
View switchContainer = view.findViewById(R.id.toolbar_switch_container);
AndroidUtils.setBackground(switchContainer, new ColorDrawable(color));
SwitchCompat switchView = (SwitchCompat) selectableView.findViewById(R.id.switchWidget);
switchView.setChecked(checked);
UiUtilities.setupCompoundButton(switchView, isNightMode(), TOOLBAR);
TextView title = (TextView) selectableView.findViewById(R.id.switchButtonText);
title.setText(checked ? R.string.shared_string_enabled : R.string.shared_string_disabled);
title.setTextColor(ContextCompat.getColor(app, isNightMode() ? R.color.text_color_tab_active_dark : R.color.text_color_tab_active_light));
Drawable drawable = UiUtilities.getColoredSelectableDrawable(app, getActiveProfileColor(), 0.3f);
AndroidUtils.setBackground(selectableView, drawable);
}
private void setupLiveMonitoringUrlPref() {
EditTextPreferenceEx liveMonitoringUrl = (EditTextPreferenceEx) findPreference(settings.LIVE_MONITORING_URL.getId());
liveMonitoringUrl.setSummary(settings.LIVE_MONITORING_URL.getModeValue(getSelectedAppMode()));
liveMonitoringUrl.setDescription(R.string.live_monitoring_m_descr);
liveMonitoringUrl.setIcon(getContentIcon(R.drawable.ic_world_globe_dark));
}
private void setupLiveMonitoringIntervalPref() {
Integer[] entryValues = new Integer[SECONDS.length + MINUTES.length];
String[] entries = new String[entryValues.length];
int k = 0;
for (int second : SECONDS) {
entryValues[k] = second * 1000;
entries[k] = second + " " + getString(R.string.int_seconds);
k++;
}
for (int minute : MINUTES) {
entryValues[k] = (minute * 60) * 1000;
entries[k] = minute + " " + getString(R.string.int_min);
k++;
}
ListPreferenceEx liveMonitoringInterval = (ListPreferenceEx) findPreference(settings.LIVE_MONITORING_INTERVAL.getId());
liveMonitoringInterval.setEntries(entries);
liveMonitoringInterval.setEntryValues(entryValues);
liveMonitoringInterval.setIcon(getContentIcon(R.drawable.ic_action_time_span));
liveMonitoringInterval.setDescription(R.string.live_monitoring_interval_descr);
}
private void setupLiveMonitoringBufferPref() {
Integer[] entryValues = new Integer[MAX_INTERVAL_TO_SEND_MINUTES.length];
String[] entries = new String[entryValues.length];
for (int i = 0; i < MAX_INTERVAL_TO_SEND_MINUTES.length; i++) {
int minute = MAX_INTERVAL_TO_SEND_MINUTES[i];
entryValues[i] = (minute * 60) * 1000;
entries[i] = minute + " " + getString(R.string.int_min);
}
ListPreferenceEx liveMonitoringBuffer = (ListPreferenceEx) findPreference(settings.LIVE_MONITORING_MAX_INTERVAL_TO_SEND.getId());
liveMonitoringBuffer.setEntries(entries);
liveMonitoringBuffer.setEntryValues(entryValues);
liveMonitoringBuffer.setIcon(getContentIcon(R.drawable.ic_action_time_span));
liveMonitoringBuffer.setDescription(R.string.live_monitoring_max_interval_to_send_desrc);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String prefId = preference.getKey();
OsmandSettings.OsmandPreference pref = settings.getPreference(prefId);
if (pref instanceof OsmandSettings.CommonPreference && !((OsmandSettings.CommonPreference) pref).hasDefaultValueForMode(getSelectedAppMode())) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null && newValue instanceof Serializable) {
ChangeGeneralProfilesPrefBottomSheet.showInstance(fragmentManager, prefId,
(Serializable) newValue, this, false, getSelectedAppMode());
}
return false;
}
return true;
}
}

View file

@ -0,0 +1,114 @@
package net.osmand.plus.settings.bottomsheets;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.preference.Preference;
import android.view.View;
import android.widget.EditText;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.osmedit.SettingsOsmEditingActivity;
import net.osmand.plus.settings.OnPreferenceChanged;
public class OsmLoginDataBottomSheet extends BasePreferenceBottomSheet {
public static final String TAG = EditTextPreferenceBottomSheet.class.getSimpleName();
private static final String USER_NAME_KEY = "user_name_key";
private static final String PASSWORD_KEY = "password_key";
private EditText userNameEditText;
private EditText passwordEditText;
@Override
public void createMenuItems(Bundle savedInstanceState) {
Context context = getContext();
if (context == null) {
return;
}
OsmandApplication app = requiredMyApplication();
View view = UiUtilities.getInflater(context, nightMode).inflate(R.layout.osm_login_data, null);
userNameEditText = view.findViewById(R.id.name_edit_text);
passwordEditText = view.findViewById(R.id.password_edit_text);
String name = app.getSettings().USER_NAME.get();
String password = app.getSettings().USER_PASSWORD.get();
if (savedInstanceState != null) {
name = savedInstanceState.getString(USER_NAME_KEY, null);
password = savedInstanceState.getString(PASSWORD_KEY, null);
}
userNameEditText.setText(name);
passwordEditText.setText(password);
BaseBottomSheetItem titleItem = new SimpleBottomSheetItem.Builder()
.setCustomView(view)
.create();
items.add(titleItem);
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(USER_NAME_KEY, userNameEditText.getText().toString());
outState.putString(PASSWORD_KEY, passwordEditText.getText().toString());
}
@Override
protected int getDismissButtonTextId() {
return R.string.shared_string_cancel;
}
@Override
protected int getRightBottomButtonTextId() {
return R.string.shared_string_apply;
}
@Override
protected void onRightBottomButtonClick() {
OsmandApplication app = requiredMyApplication();
app.getSettings().USER_NAME.set(userNameEditText.getText().toString());
app.getSettings().USER_PASSWORD.set(passwordEditText.getText().toString());
new SettingsOsmEditingActivity.ValidateOsmLoginDetailsTask(app).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
Fragment target = getTargetFragment();
Preference preference = getPreference();
if (target instanceof OnPreferenceChanged && preference != null) {
((OnPreferenceChanged) target).onPreferenceChanged(preference.getKey());
}
dismiss();
}
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String key, Fragment target,
boolean usedOnMap, @Nullable ApplicationMode appMode) {
try {
Bundle args = new Bundle();
args.putString(PREFERENCE_ID, key);
OsmLoginDataBottomSheet fragment = new OsmLoginDataBottomSheet();
fragment.setArguments(args);
fragment.setUsedOnMap(usedOnMap);
fragment.setAppMode(appMode);
fragment.setTargetFragment(target, 0);
fragment.show(fragmentManager, TAG);
return true;
} catch (RuntimeException e) {
return false;
}
}
}

View file

@ -8,6 +8,7 @@ import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.settings.BaseSettingsFragment;
import java.util.Collections;
import java.util.List;
@ -88,9 +89,4 @@ public class SkiMapsPlugin extends OsmandPlugin {
public String getId() {
return ID;
}
@Override
public Class<? extends Activity> getSettingsActivity() {
return null;
}
}

View file

@ -29,6 +29,7 @@ import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.DownloadResources;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.render.RenderingRuleProperty;
import net.osmand.util.Algorithms;
@ -420,11 +421,6 @@ public class SRTMPlugin extends OsmandPlugin {
public void disable(OsmandApplication app) {
}
@Override
public Class<? extends Activity> getSettingsActivity() {
return null;
}
public static void refreshMapComplete(final MapActivity activity) {
activity.getMyApplication().getResourceManager().getRenderer().clearCache();
activity.updateMapSettings();

View file

@ -154,8 +154,8 @@ public class MapTileLayer extends BaseMapLayer {
int width = (int) Math.ceil(tilesRect.right - left);
int height = (int) Math.ceil(tilesRect.bottom + ellipticTileCorrection - top);
boolean useInternet = (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null || OsmandPlugin.getEnabledPlugin(MapillaryPlugin.class) != null) &&
settings.USE_INTERNET_TO_DOWNLOAD_TILES.get() && settings.isInternetConnectionAvailable() && map.couldBeDownloadedFromInternet();
boolean useInternet = (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null || OsmandPlugin.getEnabledPlugin(MapillaryPlugin.class) != null)
&& settings.isInternetConnectionAvailable() && map.couldBeDownloadedFromInternet();
int maxLevel = map.getMaximumZoomSupported();
int tileSize = map.getTileSize();
boolean oneTileShown = false;