Merge pull request #3375 from brainbeanapps/master

Quick Actions
This commit is contained in:
vshcherb 2017-01-06 20:05:04 +01:00 committed by GitHub
commit d4ad5ebd12
70 changed files with 7093 additions and 85 deletions

View file

@ -350,6 +350,7 @@ repositories {
artifact "ivy/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
}
}
jcenter()
// mavenCentral()
}
@ -357,27 +358,27 @@ def analytics = (System.getenv("APP_FEATURES") && System.getenv("APP_FEATURES").
System.getenv("PACKAGE_TO_BUILT").equals("net.osmand") ) || System.getenv("USE_FIREBASE")
dependencies {
compile project(path: ':OsmAnd-java', configuration: 'android')
if(analytics) {
compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-config:9.8.0'
if (analytics) {
compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-config:9.8.0'
}
// compile project(':eclipse-compile:design')
// compile project(':eclipse-compile:cardview')
// compile project(':eclipse-compile:gridlayout')
compile 'com.android.support:gridlayout-v7:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:design:23.3.0'
compile fileTree(include: ['*.jar'], exclude: ['QtAndroid-bundled.jar', 'QtAndroidAccessibility-bundled.jar', 'OsmAndCore_android.jar', 'OsmAndCore_wrapper.jar', 'android-support-multidex.jar'], dir: 'libs')
legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar"
qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar"
qtcoredebugCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
qtcoreCompile "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar"
qtcoreCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
compile ("com.getkeepsafe.taptargetview:taptargetview:1.6.1"){
exclude group: 'com.android.support'
}
}
if(analytics) {
println "Apply GMS plugin"

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false">
<shape android:shape="rectangle">
<solid android:color="@color/fab_color" />
<corners android:bottomRightRadius="2dp"
android:bottomLeftRadius="2dp"
android:topRightRadius="2dp"
android:topLeftRadius="2dp"/>
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/fab_color_pressed" />
<corners android:bottomRightRadius="2dp"
android:bottomLeftRadius="2dp"
android:topRightRadius="2dp"
android:topLeftRadius="2dp"/>
</shape>
</item>
</selector>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#c8202020"
android:endColor="@color/color_transparent" android:angle="-90"/>
</shape>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?attr/dashboard_divider" />
<corners android:bottomLeftRadius="2dp" android:bottomRightRadius="2dp"/>
</shape>

View file

@ -6,7 +6,37 @@
android:layout_gravity="bottom"
android:orientation="vertical">
<!--
<net.osmand.plus.quickaction.QuickActionsWidget
android:id="@+id/quick_action_widget"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
<FrameLayout
android:id="@+id/map_quick_actions_button_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:padding="8dp"
android:animateLayoutChanges="true">
<ImageButton
android:id="@+id/map_quick_actions_button"
android:layout_width="@dimen/map_button_size"
android:layout_height="@dimen/map_button_size"
android:background="@drawable/btn_circle_blue"
android:contentDescription="@string/zoomIn"
android:layout_gravity="bottom|right"
android:visibility="gone"
tools:visibility="visible"
tools:src="@drawable/ic_action_test_light"/>
</FrameLayout>
-->
<LinearLayout
android:id="@+id/bottom_controls_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/quick_action_background">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@drawable/bg_card_light"
android:clickable="true"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="200dp" />
<LinearLayout
android:id="@+id/controls"
android:layout_width="match_parent"
android:layout_height="24dp"
android:background="@drawable/quick_action_controls_background"
android:orientation="horizontal">
<ImageButton
android:id="@+id/btnPrev"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?android:selectableItemBackground"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
<LinearLayout
android:id="@+id/dots"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" />
<ImageButton
android:id="@+id/btnNext"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?android:selectableItemBackground"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:grid="http://schemas.android.com/apk/res-auto"
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
grid:orientation="horizontal"
grid:alignmentMode="alignMargins"
grid:columnCount="6"/>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:background="?attr/selectableItemBackground"
android:textColor="?android:textColorPrimary"
android:singleLine="true"
android:textSize="@dimen/default_list_text_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:ellipsize="marquee"
android:textAlignment="inherit"/>

View file

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:orientation="vertical">
<include layout="@layout/card_bottom_divider"/>
<View
android:layout_width="match_parent"
android:layout_height="12dp"/>
<include layout="@layout/card_top_divider"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="bottom"
android:background="?attr/bg_color"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:visibility="gone"
android:paddingRight="16dp">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
style="@style/TextAppearance.ListItemCategoryTitle"
tools:text="Live updates"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible"/>
</LinearLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="gone"
android:background="?attr/dashboard_divider"/>
</LinearLayout>

View file

@ -47,6 +47,8 @@
<include layout="@layout/map_hud_top"/>
<include layout="@layout/map_hud_bottom"/>
<include layout="@layout/map_hud_quick_actions"/>
</FrameLayout>
<FrameLayout

View file

@ -6,7 +6,36 @@
android:layout_gravity="bottom"
android:orientation="vertical">
<!--<net.osmand.plus.quickaction.QuickActionsWidget
android:id="@+id/quick_action_widget"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:visibility="visible"
android:visibility="gone"/>
<FrameLayout
android:id="@+id/map_quick_actions_button_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:padding="8dp"
android:animateLayoutChanges="true">
<ImageButton
android:id="@+id/map_quick_actions_button"
android:layout_width="@dimen/map_button_size"
android:layout_height="@dimen/map_button_size"
android:background="@drawable/btn_circle_blue"
android:contentDescription="@string/zoomIn"
android:layout_gravity="bottom|right"
android:visibility="gone"
tools:visibility="visible"
tools:src="@drawable/ic_action_test_light"/>
</FrameLayout>-->
<FrameLayout
android:id="@+id/bottom_controls_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:padding="@dimen/map_button_margin">
<ImageButton
android:id="@+id/map_quick_actions_button"
android:layout_width="@dimen/map_button_size"
android:layout_height="@dimen/map_button_size"
android:background="@drawable/btn_circle_blue"
android:contentDescription="@string/zoomIn"
android:layout_gravity="bottom|right"
android:visibility="gone"
tools:visibility="visible"
tools:src="@drawable/ic_action_test_light"/>
</FrameLayout>
<net.osmand.plus.quickaction.QuickActionsWidget
android:id="@+id/quick_action_widget"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:visibility="visible"
android:visibility="gone"/>
</FrameLayout>

View file

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="horizontal"
android:background="?attr/bg_color">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:layout_gravity="center"
android:text="@string/quick_action_favorite_dialog"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:layout_weight="1"
android:id="@+id/textView3" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/dialogSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:layout_marginTop="16dp"
android:src="@drawable/bg_shadow_list_top" />
<LinearLayout
android:id="@+id/title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/name_caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="@string/quick_action_bug_message"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<EditText
android:id="@+id/message_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="16dp"
android:imeOptions="actionDone"
android:inputType="text"
android:textColor="?android:textColorPrimary"
android:textColorHint="?android:textColorSecondary"/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="@string/quick_action_bug_discr"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
android:layout_marginBottom="16dp"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
</LinearLayout>

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/bg_color"
android:paddingTop="24dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dialog_add_action_title"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:textSize="@dimen/dialog_header_text_size"
android:textColor="?android:textColorPrimary"
android:layout_marginBottom="8dp"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_weight="1"
app:layoutManager="LinearLayoutManager"
android:layout_width="match_parent"
android:scrollbars="vertical"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/btnDismiss"
android:layout_marginTop="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:text="@string/btn_dismiss"
android:layout_gravity="right"
android:background="?android:selectableItemBackground"
android:textColor="@color/dashboard_blue"
android:textAllCaps="true"/>
</LinearLayout>

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="?attr/bg_color">
<TextView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
tools:text="Screen 1"/>
<View android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
</FrameLayout>

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/searchListItemLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:paddingRight="24dp"
android:paddingLeft="24dp"
android:background="?android:selectableItemBackground"
android:orientation="horizontal">
<ImageView
android:id="@+id/image"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:scaleType="centerInside"
android:tint="?attr/primary_icon_color"
android:src="@drawable/ic_action_flag_dark" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="Add marker" />
</LinearLayout>

View file

@ -0,0 +1,209 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="horizontal"
android:background="?attr/bg_color">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:layout_gravity="center"
android:text="@string/quick_action_favorite_dialog"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:layout_weight="1"
android:id="@+id/textView3" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/saveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_gravity="top"
android:layout_marginTop="16dp"
android:src="@drawable/bg_shadow_list_top"/>
<LinearLayout
android:id="@+id/title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:layout_width="42dp"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/name_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="2dp"
android:scaleType="centerInside"
android:tint="?attr/primary_icon_color"
android:src="@drawable/ic_action_fav_dark"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/name_caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/favourites_edit_dialog_name"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<android.support.v7.widget.AppCompatEditText
android:id="@+id/name_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:imeOptions="actionDone"
android:inputType="text"
android:textColor="?android:textColorPrimary"
android:textColorHint="?android:textColorSecondary"
tools:text="Name"/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="68dp"
android:layout_marginRight="16dp"
android:text="@string/quick_action_fav_name_discr"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
android:layout_marginBottom="16dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="16dp"
android:background="@color/shadow_color"
android:layout_marginLeft="68dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:layout_width="42dp"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/category_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="2dp"
android:scaleType="centerInside"
android:tint="?attr/primary_icon_color"
android:src="@drawable/ic_action_folder"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/category_caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/favourites_edit_dialog_category"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<net.osmand.plus.widgets.AutoCompleteTextViewEx
android:id="@+id/category_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:focusable="false"
android:text="@string/shared_string_favorites"
android:drawableRight="@drawable/ic_action_arrow_drop_down"
android:editable="false"/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="68dp"
android:layout_marginRight="16dp"
android:text="@string/quick_action_category_discr"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
android:layout_marginBottom="16dp"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
</LinearLayout>

View file

@ -0,0 +1,209 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="horizontal"
android:background="?attr/bg_color">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:layout_gravity="center"
android:text="@string/quick_action_gpx_dialog"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:layout_weight="1"
android:id="@+id/textView3" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/saveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_gravity="top"
android:layout_marginTop="16dp"
android:src="@drawable/bg_shadow_list_top"/>
<LinearLayout
android:id="@+id/title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:layout_width="42dp"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/name_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="2dp"
android:scaleType="centerInside"
android:tint="?attr/primary_icon_color"
android:src="@drawable/ic_action_fav_dark"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/name_caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/favourites_edit_dialog_name"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<android.support.v7.widget.AppCompatEditText
android:id="@+id/name_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:imeOptions="actionDone"
android:inputType="text"
android:textColor="?android:textColorPrimary"
android:textColorHint="?android:textColorSecondary"
tools:text="Name"/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="68dp"
android:layout_marginRight="16dp"
android:text="Leave field blank and OsmAnd will use the address or name of a place for the favorite point"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
android:layout_marginBottom="16dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="16dp"
android:background="@color/shadow_color"
android:layout_marginLeft="68dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:layout_width="42dp"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/category_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_marginTop="2dp"
android:scaleType="centerInside"
android:tint="?attr/primary_icon_color"
android:src="@drawable/ic_action_folder"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/category_caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:text="@string/favourites_edit_dialog_category"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<net.osmand.plus.widgets.AutoCompleteTextViewEx
android:id="@+id/category_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:focusable="false"
android:text="@string/shared_string_favorites"
android:drawableRight="@drawable/ic_action_arrow_drop_down"
android:editable="false"/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="68dp"
android:layout_marginRight="16dp"
android:text="@string/quick_action_gpx_category_discr"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
android:layout_marginBottom="16dp"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
</LinearLayout>

View file

@ -0,0 +1,175 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
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="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:theme="?attr/new_app_theme">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="?attr/bg_color"
android:orientation="horizontal">
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:padding="16dp"
android:text="@string/quick_action_add_poi_dialog"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/saveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="16dp"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_top"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:paddingTop="16dp"
android:paddingBottom="8dp"
osmand:layout_scrollFlags="scroll">
<!--android:layout_marginLeft="72dp"-->
<!--<ImageButton-->
<!--android:id="@+id/poiTypeButton"-->
<!--android:contentDescription="@string/poi_dialog_poi_type"-->
<!--android:layout_width="48dp"-->
<!--android:layout_height="48dp"-->
<!--android:layout_gravity="bottom"-->
<!--android:background="@null"-->
<!--android:src="@drawable/ic_action_label"/>-->
<android.support.design.widget.TextInputLayout
android:id="@+id/poiTypeTextInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_weight="1">
<AutoCompleteTextView
android:id="@+id/poiTypeEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:completionThreshold="1"
android:drawableTint="@color/osmand_orange"
android:drawableRight="@drawable/ic_action_arrow_drop_down"
android:hint="@string/poi_dialog_poi_type"
android:imeOptions="actionSend"
android:inputType="text"
android:layout_marginLeft="-4dp"
tools:text="@string/lorem_ipsum"/>
</android.support.design.widget.TextInputLayout>
<ImageButton
android:id="@+id/onlineDocumentationButton"
android:contentDescription="@string/shared_string_help"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="bottom"
android:background="@null"
android:src="@drawable/ic_action_help"/>
</LinearLayout>
<!--<ImageView-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="top"-->
<!--android:scaleType="fitXY"-->
<!--android:src="@drawable/bg_shadow_list_bottom"/>-->
<!--<ImageView-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="top"-->
<!--android:layout_marginTop="16dp"-->
<!--android:scaleType="fitXY"-->
<!--android:src="@drawable/bg_shadow_list_top"/>-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:paddingBottom="16dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/editTagsList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:saveEnabled="false"/>
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/addTagButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:background="@drawable/bg_orange_rounded_coners"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/add_tag"
android:textColor="@color/color_white"
android:textSize="@dimen/default_sub_text_size"
osmand:typeface="@string/font_roboto_medium"/>
<!--<net.osmand.plus.widgets.ButtonEx-->
<!--android:id="@+id/addTypeButton"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_marginLeft="16dp"-->
<!--android:layout_marginTop="16dp"-->
<!--android:background="@drawable/bg_orange_rounded_coners"-->
<!--android:paddingLeft="16dp"-->
<!--android:paddingRight="16dp"-->
<!--android:text="Add type test"-->
<!--android:textColor="@color/color_white"-->
<!--android:textSize="@dimen/default_sub_text_size"-->
<!--osmand:typeface="@string/font_roboto_medium"/>-->
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>

View file

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="56dp">-->
<!--<ImageButton-->
<!--android:id="@+id/btnBack"-->
<!--android:layout_width="56dp"-->
<!--android:layout_height="56dp"-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_marginLeft="16dp"-->
<!--android:layout_marginRight="16dp"-->
<!--android:scaleType="centerInside"-->
<!--android:tint="@color/color_white"-->
<!--android:background="?android:selectableItemBackground"-->
<!--android:src="@drawable/ic_action_flag_dark" />-->
<!---->
<!--</LinearLayout>-->
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:contentInsetStart="72dp"
android:contentInsetLeft="72dp"
app:contentInsetLeft="72dp"
app:contentInsetStart="72dp"
android:background="?attr/actionModeBackground"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="72dp"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:background="?attr/actionModeBackground">
<ImageView
android:id="@+id/image"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:scaleType="centerInside"
android:tint="@color/color_white"
android:layout_marginTop="24dp"
android:src="@drawable/ic_action_flag_dark" />
<android.support.v7.widget.AppCompatEditText
android:id="@+id/name"
android:theme="@style/WhiteControls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="@color/color_white"
android:textColorHint="@color/white_80_transparent"
android:textSize="@dimen/default_list_text_size_large"
android:hint="@string/quick_action_name_hint"
android:maxLines="1"
android:layout_marginLeft="-4dp"
android:layout_marginRight="16dp"
android:layout_alignLeft="@+id/title"
android:layout_below="@+id/title"/>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="@color/white_50_transparent"
android:textSize="@dimen/default_sub_text_size"
android:text="@string/text_name"
android:layout_marginRight="16dp"
android:maxLines="1"
android:layout_marginLeft="32dp"
android:layout_toEndOf="@+id/image"
android:layout_toRightOf="@+id/image" />
</RelativeLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/spinnerListBackground"
android:layout_marginBottom="56dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container"/>
</ScrollView>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_gravity="top"
android:src="@drawable/bg_shadow_list_bottom"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_gravity="bottom"
android:layout_marginBottom="56dp"
android:src="@drawable/bg_shadow_list_top"/>
<Button
android:id="@+id/btnApply"
android:layout_width="match_parent"
android:layout_height="56dp"
android:text="Apply"
android:textAllCaps="true"
android:textColor="@color/color_white"
android:textSize="@dimen/default_list_text_size"
android:gravity="center"
android:layout_gravity="bottom"
android:foreground="?android:selectableItemBackground"
android:background="@color/dashboard_blue"/>
</FrameLayout>
</LinearLayout>

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<LinearLayout
android:id="@+id/searchListItemLayout"
android:layout_width="match_parent"
android:clickable="true"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:minHeight="60dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/icon"
android:layout_width="56dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginRight="4dp"
android:focusable="false"
android:tint="?attr/secondary_icon_color"
android:scaleType="centerInside"
android:src="@drawable/ic_action_reorder"/>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="16dp"
android:layout_gravity="center"
android:maxLines="1"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="Add marker"/>
<ImageView
android:id="@+id/delete"
android:layout_width="56dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:background="?android:selectableItemBackground"
android:scaleType="centerInside"
android:tint="?attr/secondary_icon_color"
android:src="@drawable/ic_action_remove_dark"/>
</LinearLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="72dp"
android:background="?attr/dashboard_divider"/>
</LinearLayout>

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/spinnerListBackground"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/custom_toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="?attr/actionModeBackground"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/custom_toolbar"
android:clipToPadding="false"
android:paddingTop="16dp"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:src="@drawable/ic_action_plus"
app:backgroundTint="@color/dashboard_blue"/>
</RelativeLayout>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:background="?attr/bg_color">
<TextView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
tools:text="Screen 1"/>
</FrameLayout>

View file

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<LinearLayout
android:id="@+id/searchListItemLayout"
android:layout_width="match_parent"
android:clickable="true"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:minHeight="60dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/handle_view"
android:layout_width="56dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginRight="4dp"
android:focusable="false"
android:scaleType="centerInside"
android:tint="?attr/secondary_icon_color"
android:src="@drawable/ic_action_reorder"/>
<ImageView
android:id="@+id/imageView"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="8dp"
android:scaleType="centerInside"
android:tint="?attr/primary_icon_color"
android:src="@drawable/ic_action_flag_dark"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp"
android:layout_weight="1"
android:orientation="vertical"
android:paddingBottom="8dp"
android:paddingTop="8dp">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="16dp"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="Add marker"/>
<TextView
android:id="@+id/subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
tools:text="Action 1"/>
</LinearLayout>
<ImageView
android:id="@+id/closeImageButton"
android:layout_width="56dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:background="?android:selectableItemBackground"
android:scaleType="centerInside"
android:tint="?attr/secondary_icon_color"
android:src="@drawable/ic_action_remove_dark"/>
</LinearLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
</LinearLayout>

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/quick_action_poi_list"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_sub_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/quick_action_sh_poi_discrp"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
app:layoutManager="LinearLayoutManager"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btnAddCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_transparent"
android:padding="16dp"
android:layout_marginLeft="56dp"
android:gravity="left"
android:text="@string/quick_action_add_category"
android:textAllCaps="true"
android:textColor="@color/dashboard_blue"
android:textSize="@dimen/default_list_text_size" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
</LinearLayout>

View file

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/textDscrTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/quick_action_map_styles"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_sub_text_size"/>
<TextView
android:id="@+id/textDscrHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/quick_action_map_style_discrp"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
app:layoutManager="LinearLayoutManager"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btnAdd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_transparent"
android:padding="16dp"
android:layout_marginLeft="56dp"
android:gravity="left"
android:text="@string/quick_action_map_style_action"
android:textAllCaps="true"
android:textColor="@color/dashboard_blue"
android:textSize="@dimen/default_list_text_size" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
</LinearLayout>

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<LinearLayout
android:id="@+id/searchListItemLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:minHeight="60dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/handle_view"
android:layout_width="56dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginRight="4dp"
android:focusable="false"
android:scaleType="centerInside"
android:src="@drawable/ic_action_reorder"
android:tint="?attr/secondary_icon_color" />
<ImageView
android:id="@+id/imageView"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:scaleType="centerInside"
android:tint="?attr/primary_icon_color"
android:src="@drawable/ic_map" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:paddingRight="16dp"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="Add marker" />
<ImageView
android:id="@+id/closeImageButton"
android:layout_width="56dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:background="?android:selectableItemBackground"
android:scaleType="centerInside"
android:src="@drawable/ic_action_remove_dark"
android:tint="?attr/secondary_icon_color" />
</LinearLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="72dp"
android:background="?attr/dashboard_divider" />
</LinearLayout>

View file

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/quick_action_background">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@drawable/bg_card_light"
android:clickable="true"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="200dp" />
<LinearLayout
android:id="@+id/controls"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/quick_action_controls_background"
android:orientation="horizontal">
<ImageButton
android:id="@+id/btnPrev"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?android:selectableItemBackground"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
<LinearLayout
android:id="@+id/dots"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" />
<ImageButton
android:id="@+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?android:selectableItemBackground"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="4dp"
android:layout_width="4dp"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"/>

View file

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:grid="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="0dp"
android:layout_height="100dp"
android:animateLayoutChanges="true"
android:background="?android:selectableItemBackground"
grid:layout_columnWeight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_horizontal"
android:tint="?attr/primary_icon_color"
android:scaleType="centerInside"/>
<ImageView
android:id="@+id/imageSlash"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerInside"/>
</FrameLayout>
<TextView
android:id="@+id/title"
android:textAlignment="center"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="12dp"
android:maxLines="2"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_sub_text_size"
tools:text="Add marker"/>
</LinearLayout>
<View
android:id="@+id/dividerRight"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="?attr/dashboard_divider"
android:visibility="gone"/>
<View
android:id="@+id/dividerBot"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom"
android:background="?attr/dashboard_divider"
android:visibility="gone"/>
</FrameLayout>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:grid="http://schemas.android.com/apk/res-auto"
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
grid:orientation="horizontal"
grid:alignmentMode="alignMargins"
grid:columnCount="3"/>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:padding="16dp"
android:text="@string/quick_action_showhides_favorites_discr"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
</LinearLayout>

View file

@ -2,4 +2,7 @@
<resources>
<dimen name="first_usage_title_margin">50dp</dimen>
<dimen name="first_usage_title_text_size">30sp</dimen>
<dimen name="quick_action_widget_height_big">100dp</dimen>
<dimen name="quick_action_widget_height_small">100dp</dimen>
</resources>

View file

@ -52,6 +52,8 @@
<attr name="color_dialog_buttons" format="color"/>
<attr name="secondary_icon_color" format="color"/>
<attr name="primary_icon_color" format="color"/>
<attr name="light_icon_color" format="color"/>
</declare-styleable>
<declare-styleable name="PagerSlidingTabStrip">

View file

@ -99,6 +99,7 @@
<color name="icon_color">#727272</color>
<color name="icon_color_light">#ccc</color>
<color name="icon_color_dark">#ff4f4f4f</color>
<color name="on_map_icon_color">#505050</color>

View file

@ -7,4 +7,7 @@
<dimen name="first_usage_title_margin_bottom">56dp</dimen>
<dimen name="first_usage_title_text_size">52sp</dimen>
<dimen name="first_usage_subtitle_text_size">18sp</dimen>
<dimen name="quick_action_widget_height_big">200dp</dimen>
<dimen name="quick_action_widget_height_small">100dp</dimen>
</resources>

View file

@ -140,12 +140,12 @@
<string name="city_type_district">District</string>
<string name="city_type_neighbourhood">Neighbourhood</string>
<string name="map_widget_search">Search</string>
<string name="shared_string_is_open_24_7">Open 24/7</string>
<string name="shared_string_is_open_24_7">Open 24/7</string>
<string name="storage_directory_card">Memory card</string>
<string name="coords_format">Coordinate format</string>
<string name="coords_format_descr">Format for the geographical coordinates</string>
<string name="app_mode_bus">Bus</string>
<string name="app_mode_train">Train</string>
<string name="app_mode_bus">Bus</string>
<string name="app_mode_train">Train</string>
<string name="current_track">Current track</string>
<string name="map_widget_battery">Battery level</string>
<string name="change_markers_position">Change marker\'s position</string>
@ -157,7 +157,7 @@
<string name="access_direction_haptic_feedback">Direction haptic feedback</string>
<string name="access_direction_haptic_feedback_descr">Indicate target point direction by vibration</string>
<string name="use_osm_live_routing_description">Enable navigation for OSM Live changes (Beta)</string>
<string name="use_osm_live_routing">OSM Live navigation</string>
<string name="use_osm_live_routing">OSM Live navigation</string>
<string name="access_no_destination">Destination is not set</string>
<string name="map_widget_magnetic_bearing">Magnetic bearing</string>
<string name="map_widget_bearing">Relative bearing</string>
@ -2464,4 +2464,88 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="number_of_edits">Number of edits</string>
<string name="reports_for">Report for</string>
<string name="file_name_containes_illegal_char">File name contains illegal character</string>
<string name="configure_screen_quick_action">Quick action</string>
<string name="quick_action_item_action">Action %d</string>
<string name="quick_action_item_screen">Screen %d</string>
<string name="quick_action_add_marker">Add marker</string>
<string name="quick_action_add_poi">Add POI</string>
<string name="quick_action_map_style">Change map style</string>
<string name="quick_action_map_style_switch">Map style has been changed to the \"%s\".</string>
<string name="quick_action_take_audio_note">Take audio note</string>
<string name="quick_action_take_video_note">Take video note</string>
<string name="quick_action_take_photo_note">Take photo note</string>
<string name="quick_action_add_osm_bug">Add OSM bug</string>
<string name="quick_action_navigation_voice">Voice On/Off</string>
<string name="quick_action_navigation_voice_off">Voice Off</string>
<string name="quick_action_navigation_voice_on">Voice On</string>
<string name="quick_action_add_gpx">Add GPX waypoint</string>
<string name="quick_action_add_parking">Add Parking place</string>
<string name="quick_action_new_action">Add action</string>
<string name="quick_action_edit_action">Edit action</string>
<string name="quick_action_add_favorite">Add favorite</string>
<string name="dialog_add_action_title">Add Action</string>
<string name="quick_actions_delete">Delete Action</string>
<string name="quick_actions_delete_text">Are you sure you want to delete \"%s\" Action?</string>
<string name="btn_dismiss">Dismiss</string>
<string name="quick_favorites_show_favorites_dialog">Show favorites dialog</string>
<string name="quick_favorites_name_preset">Name preset</string>
<string name="quick_favorites_name_description">Leave field blank and OsmAnd will use the address or name of a place for the favorite point</string>
<string name="quick_action_name_hint">Action name</string>
<string name="text_name">Name</string>
<string name="quick_action_add_marker_discr">Tap on action will add marker to the specified location.</string>
<string name="quick_action_add_gpx_discr">Tap on action will add GPX waypiont to the specified location.</string>
<string name="quick_action_take_audio_note_discr">Tap on action will add audio note to the specified location.</string>
<string name="quick_action_take_video_note_discr">Tap on action will add video note to the specified location.</string>
<string name="quick_action_take_photo_note_discr">Tap on action will add photo note to the specified location.</string>
<string name="quick_action_add_osm_bug_discr">Tap on action will add OSM bug note to the specified location.</string>
<string name="quick_action_add_poi_discr">Tap on action will add POI to the specified location.</string>
<string name="quick_action_navigation_voice_discr">Tap on action will disable or enable voice during navigation.</string>
<string name="quick_action_add_parking_discr">Tap on action will add Parking place to the specified location.</string>
<string name="quick_action_favorite_dialog">Show favorite dialog</string>
<string name="quick_action_add_poi_dialog">Show add POI dialog</string>
<string name="quick_action_gpx_dialog">Show GPX waypoint dialog</string>
<string name="favorite_autofill_toast_text">" is saved to "</string>
<string name="favorite_empty_place_name">Place</string>
<string name="quick_action_duplicates">Specified quick action name already in use, was changed to %1$s to avoid duplication.</string>
<string name="quick_action_duplicate">Quick action name duplicate</string>
<string name="quick_action_showhides_favorites_discr">Tap on action will Show or Hide favorites points on map.</string>
<string name="quick_action_showhides_poi_discr">Tap on action will Show or Hide POI points on map.</string>
<string name="quick_action_showhide_favorites_title">Show/Hide Favorites</string>
<string name="quick_action_favorites_show">Show Favorites</string>
<string name="quick_action_favorites_hide">Hide Favorites</string>
<string name="quick_action_showhide_poi_title">Show/Hide POI</string>
<string name="quick_action_poi_show">Show %1$s</string>
<string name="quick_action_poi_hide">Hide %1$s</string>
<string name="quick_action_add_category">Add category</string>
<string name="quick_action_add_create_items">Create items</string>
<string name="quick_action_add_configure_map">Configure map</string>
<string name="quick_action_add_navigation">Navigation</string>
<string name="quick_action_fav_name_discr">Leave field blank and OsmAnd will use the address or name of a place for the favorite point</string>
<string name="quick_action_bug_discr">This message will be auto-completed in the comment field.</string>
<string name="quick_action_bug_message">Message</string>
<string name="quick_action_category_discr">You can select a category to save favorite point.</string>
<string name="quick_action_gpx_category_discr">You can select a category to save GPX waypoint point.</string>
<string name="quick_action_poi_list">POI list</string>
<string name="quick_action_sh_poi_discrp">You can add few POI categories to display on the map.</string>
<string name="quick_action_map_style_discrp">Tap on the action button will toggle the map style, from the list order.</string>
<string name="quick_action_map_style_action">Add map style</string>
<string name="quick_action_empty_param_error">Parameters should not be empty</string>
<string name="quick_action_map_styles">Map styles</string>
<string name="quick_action_map_overlay">Change map overlay</string>
<string name="quick_action_map_overlay_title">Map overlays</string>
<string name="quick_action_map_overlay_dscr">Tap on the action button will toggle the map overlay, from the list order.</string>
<string name="quick_action_map_overlay_action">Add Overlay</string>
<string name="quick_action_map_underlay">Change map underlay</string>
<string name="quick_action_map_underlay_title">Map underlays</string>
<string name="quick_action_map_underlay_dscr">Tap on the action button will toggle the map underlay, from the list order.</string>
<string name="quick_action_map_underlay_action">Add Underlay</string>
<string name="quick_action_map_source">Change map source</string>
<string name="quick_action_map_source_title">Map sources</string>
<string name="quick_action_map_source_dscr">Tap on the action button will toggle the map source, from the list order.</string>
<string name="quick_action_map_source_action">Add Source</string>
<string name="quick_action_map_source_switch">Map source has been changed to the \"%s\".</string>
<string name="quick_action_poi_add">Add</string>
<string name="quck_action_btn_tutorial_title">Change button position</string>
<string name="quick_action_btn_tutorial_description">Long tap and drag button on the screen to change position</string>
</resources>

View file

@ -130,6 +130,7 @@
<item name="colorPrimary">@color/osmand_orange</item>
<item name="colorPrimaryDark">@color/osmand_orange_dark</item>
<item name="colorAccent">@color/dashboard_blue</item>
<item name="android:actionModeBackground">@color/actionbar_light_color</item>
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBarLight</item>
@ -139,6 +140,7 @@
<item name="dialog_inactive_text_color">@color/icon_color_light</item>
<item name="secondary_icon_color">@color/icon_color_light</item>
<item name="primary_icon_color">@color/icon_color</item>
<item name="appbar_layout_theme">@style/OsmandLightTheme.DarkActionbar</item>
<item name="search_tabbar_layout_theme">@style/OsmandLightTheme.SearchTabbar</item>
<item name="toolbar_theme">@style/OsmandLightTheme.Toolbar</item>
@ -288,6 +290,7 @@
<item name="dialog_inactive_text_color">@color/dialog_inactive_text_color_dark</item>
<item name="secondary_icon_color">@color/dialog_inactive_text_color_dark</item>
<item name="primary_icon_color">@color/color_white</item>
<item name="appbar_layout_theme">@style/OsmandDarkTheme.DarkActionbar</item>
<item name="search_tabbar_layout_theme">@style/OsmandDarkTheme.SearchTabbar</item>
<item name="toolbar_theme">@style/OsmandDarkTheme</item>
@ -439,4 +442,28 @@
<item name="android:background">@color/xmas_blue</item>
</style>
<style name="Dialog90Light" parent="Base.Theme.AppCompat.Light.Dialog">
<item name="android:windowMinWidthMajor">90%</item>
<item name="android:windowMinWidthMinor">90%</item>
<item name="secondary_icon_color">@color/icon_color_light</item>
<item name="primary_icon_color">@color/icon_color</item>
</style>
<style name="Dialog90Dark" parent="Base.Theme.AppCompat.Dialog">
<item name="android:windowMinWidthMajor">90%</item>
<item name="android:windowMinWidthMinor">90%</item>
<item name="secondary_icon_color">@color/dialog_inactive_text_color_dark</item>
<item name="primary_icon_color">@color/color_white</item>
</style>
<style name="WhiteControls" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorControlNormal">@color/color_white</item>
<item name="colorControlActivated">@color/color_white</item>
<item name="colorControlHighlight">@color/color_white</item>
</style>
</resources>

View file

@ -478,7 +478,7 @@ public class FavouritesDbHelper {
private void recalculateCachedFavPoints(){
public void recalculateCachedFavPoints(){
ArrayList<FavouritePoint> temp = new ArrayList<FavouritePoint>();
for(FavoriteGroup f : favoriteGroups){
temp.addAll(f.points);

View file

@ -14,6 +14,8 @@ import android.os.Environment;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v4.util.Pair;
import net.osmand.IndexConstants;
import net.osmand.StateChangedListener;
import net.osmand.ValueHolder;
@ -2443,6 +2445,47 @@ public class OsmandSettings {
return mImpassableRoadsStorage.movePoint(latLonEx, latLonNew);
}
/**
* quick actions prefs
*/
public static final String QUICK_FAB_MARGIN_X_PORTRAIT_MARGIN = "quick_fab_margin_x_portrait_margin";
public static final String QUICK_FAB_MARGIN_Y_PORTRAIT_MARGIN = "quick_fab_margin_y_portrait_margin";
public static final String QUICK_FAB_MARGIN_X_LANDSCAPE_MARGIN = "quick_fab_margin_x_landscape_margin";
public static final String QUICK_FAB_MARGIN_Y_LANDSCAPE_MARGIN = "quick_fab_margin_y_landscape_margin";
public final CommonPreference<String> QUICK_ACTION = new StringPreference("quick_action_new", "").makeGlobal();
public final CommonPreference<String> QUICK_ACTION_LIST = new StringPreference("quick_action_list", "").makeGlobal();
public final CommonPreference<Boolean> IS_QUICK_ACTION_TUTORIAL_SHOWN = new BooleanPreference("quick_action_tutorial", false).makeGlobal();
public boolean setPortraitFabMargin(int x, int y) {
return settingsAPI.edit(globalPreferences).putInt(QUICK_FAB_MARGIN_X_PORTRAIT_MARGIN, x)
.putInt(QUICK_FAB_MARGIN_Y_PORTRAIT_MARGIN, y).commit();
}
public boolean setLandscapeFabMargin(int x, int y) {
return settingsAPI.edit(globalPreferences).putInt(QUICK_FAB_MARGIN_X_LANDSCAPE_MARGIN, x)
.putInt(QUICK_FAB_MARGIN_Y_LANDSCAPE_MARGIN, y).commit();
}
public Pair<Integer, Integer> getPortraitFabMargin() {
if (settingsAPI.contains(globalPreferences, QUICK_FAB_MARGIN_X_PORTRAIT_MARGIN) && settingsAPI.contains(globalPreferences, QUICK_FAB_MARGIN_Y_PORTRAIT_MARGIN)) {
return new Pair<>(settingsAPI.getInt(globalPreferences, QUICK_FAB_MARGIN_X_PORTRAIT_MARGIN, 0),
settingsAPI.getInt(globalPreferences, QUICK_FAB_MARGIN_Y_PORTRAIT_MARGIN, 0));
}
return null;
}
public Pair<Integer, Integer> getLandscapeFabMargin() {
if (settingsAPI.contains(globalPreferences, QUICK_FAB_MARGIN_X_LANDSCAPE_MARGIN) && settingsAPI.contains(globalPreferences, QUICK_FAB_MARGIN_Y_LANDSCAPE_MARGIN)) {
return new Pair<>(settingsAPI.getInt(globalPreferences, QUICK_FAB_MARGIN_X_LANDSCAPE_MARGIN, 0),
settingsAPI.getInt(globalPreferences, QUICK_FAB_MARGIN_Y_LANDSCAPE_MARGIN, 0));
}
return null;
}
/**
* the location of a parked car
*/

View file

@ -89,6 +89,9 @@ import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenuFragment;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionFactory;
import net.osmand.plus.quickaction.QuickActionsWidget;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.routing.RoutingHelper;
@ -98,6 +101,7 @@ import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.MapQuickActionLayer;
import net.osmand.plus.views.OsmAndMapLayersView;
import net.osmand.plus.views.OsmAndMapSurfaceView;
import net.osmand.plus.views.OsmandMapLayer;
@ -452,9 +456,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
}
this.startActivity(prevActivityIntent);
prevActivityIntent = null;
} else {
super.onBackPressed();
return;
}
if (getMapView().getLayerByClass(MapQuickActionLayer.class).onBackPressed())
return;
super.onBackPressed();
}
@Override
@ -973,6 +981,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
if (mapLayers.getMapInfoLayer() != null) {
mapLayers.getMapInfoLayer().recreateControls();
}
if (mapLayers.getMapQuickActionLayer() != null) {
mapLayers.getMapQuickActionLayer().refreshLayer();
}
mapLayers.updateLayers(mapView);
mapActions.updateDrawerMenu();
mapView.setComplexZoom(mapView.getZoom(), mapView.getSettingsMapDensity());

View file

@ -30,6 +30,7 @@ import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.poi.PoiFiltersHelper;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.quickaction.QuickActionRegistry;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.render.MapVectorLayer;
import net.osmand.plus.render.RenderingIcons;
@ -42,6 +43,7 @@ import net.osmand.plus.views.ImpassableRoadsLayer;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.MapMarkersLayer;
import net.osmand.plus.views.MapQuickActionLayer;
import net.osmand.plus.views.MapTextLayer;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView;
@ -80,14 +82,21 @@ public class MapActivityLayers {
private MapTextLayer mapTextLayer;
private ContextMenuLayer contextMenuLayer;
private MapControlsLayer mapControlsLayer;
private MapQuickActionLayer mapQuickActionLayer;
private DownloadedRegionsLayer downloadedRegionsLayer;
private MapWidgetRegistry mapWidgetRegistry;
private QuickActionRegistry quickActionRegistry;
private StateChangedListener<Integer> transparencyListener;
public MapActivityLayers(MapActivity activity) {
this.activity = activity;
this.mapWidgetRegistry = new MapWidgetRegistry(activity.getMyApplication().getSettings());
this.quickActionRegistry = new QuickActionRegistry(activity.getMyApplication().getSettings());
}
public QuickActionRegistry getQuickActionRegistry() {
return quickActionRegistry;
}
public MapWidgetRegistry getMapWidgetRegistry() {
@ -160,6 +169,11 @@ public class MapActivityLayers {
// 11. route info layer
mapControlsLayer = new MapControlsLayer(activity);
mapView.addLayer(mapControlsLayer, 11);
// 12. quick actions layer
mapQuickActionLayer = new MapQuickActionLayer(activity, contextMenuLayer);
mapView.addLayer(mapQuickActionLayer, 12);
contextMenuLayer.setMapQuickActionLayer(mapQuickActionLayer);
mapControlsLayer.setMapQuickActionLayer(mapQuickActionLayer);
transparencyListener = new StateChangedListener<Integer>() {
@Override
@ -579,6 +593,10 @@ public class MapActivityLayers {
return mapControlsLayer;
}
public MapQuickActionLayer getMapQuickActionLayer() {
return mapQuickActionLayer;
}
public MapMarkersLayer getMapMarkersLayer() {
return mapMarkersLayer;
}

View file

@ -587,6 +587,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public void onSingleTapOnMap() {
if (menuController == null || !menuController.handleSingleTapOnMap()) {
hide();
if (mapActivity.getMapLayers().getMapQuickActionLayer().isLayerOn())
mapActivity.getMapLayers().getMapQuickActionLayer().refreshLayer();
}
}
@ -671,6 +673,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
close();
}
public void buttonFavoritePressed() {
if (object != null && object instanceof FavouritePoint) {
getFavoritePointEditor().edit((FavouritePoint) object);
@ -758,12 +762,44 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
}
public void addWptPt(LatLon latLon, String title, String categoryName, int categoryColor, boolean skipDialog){
final List<SelectedGpxFile> list
= mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
if (list.isEmpty() || (list.size() == 1 && list.get(0).getGpxFile().showCurrentTrack)) {
GPXFile gpxFile = mapActivity.getMyApplication().getSavingTrackHelper().getCurrentGpx();
getWptPtPointEditor().add(gpxFile, latLon, title, categoryName, categoryColor, skipDialog);
} else {
addNewWptToGPXFile(latLon, title, categoryName, categoryColor, skipDialog);
}
}
public void editWptPt() {
if (object != null && object instanceof WptPt) {
getWptPtPointEditor().edit((WptPt) object);
}
}
public AlertDialog addNewWptToGPXFile(final LatLon latLon, final String title,
final String categoryName,
final int categoryColor, final boolean skipDialog) {
CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {
@Override
public boolean processResult(GPXFile[] result) {
GPXFile gpxFile;
if (result != null && result.length > 0) {
gpxFile = result[0];
} else {
gpxFile = mapActivity.getMyApplication().getSavingTrackHelper().getCurrentGpx();
}
getWptPtPointEditor().add(gpxFile, latLon, title, categoryName, categoryColor, skipDialog);
return true;
}
};
return GpxUiHelper.selectSingleGPXFile(mapActivity, true, callbackWithObject);
}
public AlertDialog addNewWptToGPXFile(final String title) {
CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {
@Override

View file

@ -41,6 +41,8 @@ public class EditCategoryDialogFragment extends DialogFragment {
FavouritesDbHelper helper;
private SelectCategoryDialogFragment.CategorySelectionListener selectionListener;
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
@ -87,6 +89,10 @@ public class EditCategoryDialogFragment extends DialogFragment {
return builder.create();
}
public void setSelectionListener(SelectCategoryDialogFragment.CategorySelectionListener selectionListener) {
this.selectionListener = selectionListener;
}
@Override
public void onStart()
{
@ -103,10 +109,17 @@ public class EditCategoryDialogFragment extends DialogFragment {
name = nameEdit.getText().toString().trim();
if (!helper.groupExists(name)) {
helper.addEmptyCategory(name, color);
PointEditor editor = ((MapActivity) getActivity()).getContextMenu().getPointEditor(editorTag);
if (editor != null) {
editor.setCategory(name);
}
if (selectionListener != null){
selectionListener.onCategorySelected(name, color);
}
d.dismiss();
} else {
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());

View file

@ -2,6 +2,7 @@ package net.osmand.plus.mapcontextmenu.editors;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.activities.MapActivity;
import net.osmand.util.Algorithms;
@ -39,6 +40,28 @@ public class FavoritePointEditor extends PointEditor {
FavoritePointEditorFragment.showInstance(mapActivity);
}
public void add(LatLon latLon, String title, String originObjectName, String categoryName, int categoryColor, boolean autoFill) {
if (latLon == null) return;
isNew = true;
if (categoryName != null && !categoryName.isEmpty()) {
FavouritesDbHelper.FavoriteGroup category = mapActivity.getMyApplication().getFavorites().getGroup(categoryName);
if (category == null)
mapActivity.getMyApplication().getFavorites().addEmptyCategory(categoryName, categoryColor);
} else categoryName = "";
favorite = new FavouritePoint(latLon.getLatitude(), latLon.getLongitude(), title, categoryName);
favorite.setDescription("");
favorite.setOriginObjectName(originObjectName);
FavoritePointEditorFragment.showAutoFillInstance(mapActivity);
}
public void edit(FavouritePoint favorite) {
if (favorite == null) {
return;

View file

@ -4,11 +4,13 @@ import android.app.Activity;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
@ -28,6 +30,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
private FavoriteGroup group;
FavouritesDbHelper helper;
private boolean autoFill;
private boolean saved;
private int defaultColor;
@ -67,6 +70,23 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
return view;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (autoFill){
// String name = favorite.getName() != null && !favorite.getName().isEmpty() ?
// favorite.getName() : getString(R.string.favorite_empty_place_name);
//
// String tostText = name + getString(R.string.favorite_autofill_toast_text) + group.name;
//
// Toast.makeText(getContext(), tostText, Toast.LENGTH_SHORT).show();
save(true);
}
}
@Override
public PointEditor getEditor() {
return editor;
@ -92,6 +112,8 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
return getString(R.string.shared_string_favorites);
}
public static void showInstance(final MapActivity mapActivity) {
FavoritePointEditor editor = mapActivity.getContextMenu().getFavoritePointEditor();
//int slideInAnim = editor.getSlideInAnimation();
@ -104,6 +126,21 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
.addToBackStack(null).commit();
}
public static void showAutoFillInstance(final MapActivity mapActivity) {
FavoritePointEditor editor = mapActivity.getContextMenu().getFavoritePointEditor();
//int slideInAnim = editor.getSlideInAnimation();
//int slideOutAnim = editor.getSlideOutAnimation();
FavoritePointEditorFragment fragment = new FavoritePointEditorFragment();
fragment.autoFill = true;
mapActivity.getSupportFragmentManager().beginTransaction()
//.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
.add(R.id.fragmentContainer, fragment, editor.getFragmentTag())
.addToBackStack(null).commit();
}
@Override
protected boolean wasSaved() {
return saved;
@ -126,7 +163,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
return;
}
if (builder != null) {
if (builder != null && !autoFill) {
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -153,7 +190,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
MapContextMenu menu = getMapActivity().getContextMenu();
LatLon latLon = new LatLon(favorite.getLatitude(), favorite.getLongitude());
if (menu.getLatLon().equals(latLon)) {
if (menu.getLatLon() != null && menu.getLatLon().equals(latLon)) {
menu.update(latLon, favorite.getPointDescription(), favorite);
}
}

View file

@ -19,6 +19,9 @@ import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionFactory;
import net.osmand.plus.quickaction.QuickActionRegistry;
import java.util.List;
@ -28,9 +31,15 @@ public class SelectCategoryDialogFragment extends DialogFragment {
public static final String TAG = "SelectCategoryDialogFragment";
public interface CategorySelectionListener{
void onCategorySelected(String category, int color);
}
private static final String KEY_CTX_SEL_CAT_EDITOR_TAG = "key_ctx_sel_cat_editor_tag";
private String editorTag;
private CategorySelectionListener selectionListener;
@NonNull
@Override
@ -64,10 +73,17 @@ public class SelectCategoryDialogFragment extends DialogFragment {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PointEditor editor = ((MapActivity) getActivity()).getContextMenu().getPointEditor(editorTag);
if (editor != null) {
editor.setCategory(category.name);
}
if (selectionListener != null) {
selectionListener.onCategorySelected(category.name, category.color);
}
dismiss();
}
});
@ -82,8 +98,9 @@ public class SelectCategoryDialogFragment extends DialogFragment {
@Override
public void onClick(View v) {
dismiss();
DialogFragment dialogFragment = EditCategoryDialogFragment.createInstance(editorTag);
EditCategoryDialogFragment dialogFragment = EditCategoryDialogFragment.createInstance(editorTag);
dialogFragment.show(getActivity().getSupportFragmentManager(), EditCategoryDialogFragment.TAG);
dialogFragment.setSelectionListener(selectionListener);
}
});
ll.addView(itemView);
@ -102,6 +119,10 @@ public class SelectCategoryDialogFragment extends DialogFragment {
return fragment;
}
public void setSelectionListener(CategorySelectionListener selectionListener) {
this.selectionListener = selectionListener;
}
public void saveState(Bundle bundle) {
bundle.putString(KEY_CTX_SEL_CAT_EDITOR_TAG, editorTag);
}

View file

@ -1,6 +1,7 @@
package net.osmand.plus.mapcontextmenu.editors;
import net.osmand.data.LatLon;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
@ -52,6 +53,42 @@ public class WptPtEditor extends PointEditor {
WptPtEditorFragment.showInstance(mapActivity);
}
public void add(GPXFile gpxFile, LatLon latLon, String title, String categoryName, int categoryColor, boolean skipDialog) {
if (latLon == null) {
return;
}
isNew = true;
this.gpxFile = gpxFile;
SelectedGpxFile selectedGpxFile =
mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path);
gpxSelected = selectedGpxFile != null;
wpt = new WptPt(latLon.getLatitude(), latLon.getLongitude(),
System.currentTimeMillis(), Double.NaN, 0, Double.NaN);
wpt.name = title;
if (categoryName != null && !categoryName.isEmpty()) {
FavouritesDbHelper.FavoriteGroup category = mapActivity.getMyApplication()
.getFavorites()
.getGroup(categoryName);
if (category == null) {
mapActivity.getMyApplication()
.getFavorites()
.addEmptyCategory(categoryName, categoryColor);
}
} else categoryName = "";
wpt.category = categoryName;
WptPtEditorFragment.showInstance(mapActivity, skipDialog);
}
public void edit(WptPt wpt) {
if (wpt == null) {
return;

View file

@ -6,6 +6,8 @@ import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import net.osmand.data.LatLon;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
@ -31,6 +33,7 @@ public class WptPtEditorFragment extends PointEditorFragment {
private boolean saved;
private int color;
private boolean skipDialog;
@Override
public void onAttach(Activity activity) {
@ -45,8 +48,22 @@ public class WptPtEditorFragment extends PointEditorFragment {
super.onCreate(savedInstanceState);
wpt = editor.getWptPt();
int defaultColor = getResources().getColor(R.color.gpx_color_point);
color = wpt.getColor(defaultColor);
FavoriteGroup group = getMyApplication().getFavorites().getGroup(wpt.category);
if (group == null) {
int defaultColor = getResources().getColor(R.color.gpx_color_point);
color = wpt.getColor(defaultColor);
} else color = group.color;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (skipDialog) save(true);
}
@Override
@ -75,6 +92,20 @@ public class WptPtEditorFragment extends PointEditorFragment {
.addToBackStack(null).commit();
}
public static void showInstance(final MapActivity mapActivity, boolean skipDialog) {
WptPtEditor editor = mapActivity.getContextMenu().getWptPtPointEditor();
//int slideInAnim = editor.getSlideInAnimation();
//int slideOutAnim = editor.getSlideOutAnimation();
WptPtEditorFragment fragment = new WptPtEditorFragment();
fragment.skipDialog = skipDialog;
mapActivity.getSupportFragmentManager().beginTransaction()
//.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
.add(R.id.fragmentContainer, fragment, editor.getFragmentTag())
.addToBackStack(null).commit();
}
@Override
protected boolean wasSaved() {
return saved;
@ -96,9 +127,14 @@ public class WptPtEditorFragment extends PointEditorFragment {
}
MapContextMenu menu = getMapActivity().getContextMenu();
LatLon latLon = new LatLon(wpt.getLatitude(), wpt.getLongitude());
if (menu.getLatLon().equals(latLon)) {
menu.update(latLon, wpt.getPointDescription(getMapActivity()), wpt);
if (menu.getLatLon() != null) {
LatLon latLon = new LatLon(wpt.getLatitude(), wpt.getLongitude());
if (menu.getLatLon().equals(latLon)) {
menu.update(latLon, wpt.getPointDescription(getMapActivity()), wpt);
}
}
saved = true;

View file

@ -170,13 +170,17 @@ public class MapMultiSelectionMenu extends BaseMenuController {
}
public boolean isVisible() {
Fragment fragment = getMapActivity().getSupportFragmentManager().findFragmentByTag(MapMultiSelectionMenuFragment.TAG);
Fragment fragment = getFragmentByTag();
return fragment != null;
}
public Fragment getFragmentByTag() {
return getMapActivity().getSupportFragmentManager().findFragmentByTag(MapMultiSelectionMenuFragment.TAG);
}
public void hide() {
clearMenu();
Fragment fragment = getMapActivity().getSupportFragmentManager().findFragmentByTag(MapMultiSelectionMenuFragment.TAG);
Fragment fragment = getFragmentByTag();
if (fragment != null) {
MapMultiSelectionMenuFragment menuFragment = (MapMultiSelectionMenuFragment) fragment;
menuFragment.dismissMenu();

View file

@ -267,7 +267,7 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
});
}
private static void addPoiToStringSet(AbstractPoiType abstractPoiType, Set<String> stringSet,
public static void addPoiToStringSet(AbstractPoiType abstractPoiType, Set<String> stringSet,
Set<String> values) {
if (abstractPoiType instanceof PoiType) {
PoiType poiType = (PoiType) abstractPoiType;

View file

@ -1,33 +1,5 @@
package net.osmand.plus.osmedit;
import java.io.Serializable;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.osmand.CallbackWithObject;
import net.osmand.PlatformUtil;
import net.osmand.data.Amenity;
import net.osmand.data.LatLon;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType;
import net.osmand.osm.edit.EntityInfo;
import net.osmand.osm.edit.Node;
import net.osmand.osm.edit.OSMSettings;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndDialogFragment;
import net.osmand.plus.osmedit.dialogs.PoiSubTypeDialogFragment;
import net.osmand.plus.osmedit.dialogs.PoiTypeDialogFragment;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
@ -74,6 +46,35 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.CallbackWithObject;
import net.osmand.PlatformUtil;
import net.osmand.data.Amenity;
import net.osmand.data.LatLon;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType;
import net.osmand.osm.edit.EntityInfo;
import net.osmand.osm.edit.Node;
import net.osmand.osm.edit.OSMSettings;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndDialogFragment;
import net.osmand.plus.osmedit.dialogs.PoiSubTypeDialogFragment;
import net.osmand.plus.osmedit.dialogs.PoiTypeDialogFragment;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.io.Serializable;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
public static final String TAG = "EditPoiDialogFragment";
private static final Log LOG = PlatformUtil.getLog(EditPoiDialogFragment.class);
@ -82,7 +83,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
private static final String TAGS_LIST = "tags_list";
private static final String IS_ADDING_POI = "is_adding_poi";
private static final HashSet<String> BASIC_TAGS = new HashSet<String>() {
public static final HashSet<String> BASIC_TAGS = new HashSet<String>() {
{
add(OSMSettings.OSMTagKey.NAME.getValue());
add(OSMSettings.OSMTagKey.ADDR_STREET.getValue());
@ -219,7 +220,13 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
poiTypeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DialogFragment fragment = PoiTypeDialogFragment.createInstance();
PoiTypeDialogFragment fragment = PoiTypeDialogFragment.createInstance();
fragment.setOnItemSelectListener(new PoiTypeDialogFragment.OnItemSelectListener() {
@Override
public void select(PoiCategory poiCategory) {
setPoiCategory(poiCategory);
}
});
fragment.show(getChildFragmentManager(), "PoiTypeDialogFragment");
}
});
@ -279,8 +286,14 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
- editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width()
- editText.getPaddingRight())) {
if (editPoiData.getPoiCategory() != null) {
DialogFragment dialogFragment =
PoiSubTypeDialogFragment dialogFragment =
PoiSubTypeDialogFragment.createInstance(editPoiData.getPoiCategory());
dialogFragment.setOnItemSelectListener(new PoiSubTypeDialogFragment.OnItemSelectListener() {
@Override
public void select(String category) {
setSubCategory(category);
}
});
dialogFragment.show(getChildFragmentManager(), "PoiSubTypeDialogFragment");
}
@ -574,6 +587,16 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
return editPoiDialogFragment;
}
public static EditPoiDialogFragment createInstance(Node node, boolean isAddingPoi, Map<String, String> tagList) {
EditPoiDialogFragment editPoiDialogFragment = new EditPoiDialogFragment();
Bundle args = new Bundle();
args.putSerializable(KEY_AMENITY_NODE, node);
args.putBoolean(IS_ADDING_POI, isAddingPoi);
args.putSerializable(TAGS_LIST, (Serializable) Collections.unmodifiableMap(tagList));
editPoiDialogFragment.setArguments(args);
return editPoiDialogFragment;
}
public static void showEditInstance(final Amenity amenity,
final AppCompatActivity activity) {
final OsmandSettings settings = ((OsmandApplication) activity.getApplication())

View file

@ -369,6 +369,16 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
showBugDialog(bug, Action.CREATE, message);
}
public void openBug(final double latitude, final double longitude, String message, boolean autofill) {
OpenStreetNote bug = new OpenStreetNote();
bug.setLatitude(latitude);
bug.setLongitude(longitude);
if (autofill) asyncActionTask(bug, message, Action.CREATE);
else showBugDialog(bug, Action.CREATE, message);
}
public void closeBug(final OpenStreetNote bug, String txt) {
showBugDialog(bug, Action.DELETE, txt);
}

View file

@ -180,10 +180,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
editPoiDialogFragment.show(mapActivity.getSupportFragmentManager(),
EditPoiDialogFragment.TAG);
} else if (resId == R.string.context_menu_item_open_note) {
if (osmBugsLayer == null) {
registerLayers(mapActivity);
}
osmBugsLayer.openBug(latitude, longitude, "");
openOsmNote(mapActivity, latitude, longitude);
} else if (resId == R.string.poi_context_menu_delete) {
new EditPoiDialogFragment.ShowDeleteDialogAsyncTask(mapActivity)
.execute((Amenity) selectedObj);
@ -228,6 +225,20 @@ public class OsmEditingPlugin extends OsmandPlugin {
.setListener(listener).createItem());
}
public void openOsmNote(MapActivity mapActivity, double latitude, double longitude) {
if (osmBugsLayer == null) {
registerLayers(mapActivity);
}
osmBugsLayer.openBug(latitude, longitude, "");
}
public void openOsmNote(MapActivity mapActivity, double latitude, double longitude, String message, boolean autofill) {
if (osmBugsLayer == null) {
registerLayers(mapActivity);
}
osmBugsLayer.openBug(latitude, longitude, message, autofill);
}
@Override
public void addMyPlacesTab(FavoritesActivity favoritesActivity, List<TabActivity.TabItem> mTabs, Intent intent) {
if (getDBPOI().getOpenstreetmapPoints().size() > 0 || getDBBug().getOsmbugsPoints().size() > 0) {

View file

@ -1,13 +1,5 @@
package net.osmand.plus.osmedit.dialogs;
import java.util.Set;
import java.util.TreeSet;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.osmedit.EditPoiDialogFragment;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@ -15,8 +7,17 @@ import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication;
import java.util.Set;
import java.util.TreeSet;
public class PoiSubTypeDialogFragment extends DialogFragment {
private static final String KEY_POI_CATEGORY = "amenity";
private OnItemSelectListener onItemSelectListener;
@NonNull
@Override
@ -38,7 +39,7 @@ public class PoiSubTypeDialogFragment extends DialogFragment {
builder.setItems(subCats, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
((EditPoiDialogFragment) getParentFragment()).setSubCategory(subCats[which]);
onItemSelectListener.select(subCats[which]);
dismiss();
}
});
@ -60,4 +61,12 @@ public class PoiSubTypeDialogFragment extends DialogFragment {
fragment.setArguments(args);
return fragment;
}
public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
this.onItemSelectListener = onItemSelectListener;
}
public interface OnItemSelectListener {
void select(String category);
}
}

View file

@ -1,12 +1,5 @@
package net.osmand.plus.osmedit.dialogs;
import java.util.ArrayList;
import java.util.List;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.osmedit.EditPoiDialogFragment;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
@ -14,7 +7,15 @@ import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.plus.OsmandApplication;
import java.util.ArrayList;
import java.util.List;
public class PoiTypeDialogFragment extends DialogFragment {
private OnItemSelectListener onItemSelectListener;
@NonNull
@Override
@ -33,7 +34,7 @@ public class PoiTypeDialogFragment extends DialogFragment {
@Override
public void onClick(DialogInterface dialog, int which) {
PoiCategory aType = categories.get(which);
((EditPoiDialogFragment) getParentFragment()).setPoiCategory(aType);
onItemSelectListener.select(aType);
dismiss();
}
});
@ -46,4 +47,12 @@ public class PoiTypeDialogFragment extends DialogFragment {
poiTypeDialogFragment.setArguments(args);
return poiTypeDialogFragment;
}
public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
this.onItemSelectListener = onItemSelectListener;
}
public interface OnItemSelectListener {
void select(PoiCategory poiCategory);
}
}

View file

@ -238,7 +238,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
* Method dialog for adding of a parking location.
* It allows user to choose a type of parking (time-limited or time-unlimited).
*/
private void showAddParkingDialog(final MapActivity mapActivity, final double latitude, final double longitude) {
public void showAddParkingDialog(final MapActivity mapActivity, final double latitude, final double longitude) {
final boolean wasEventPreviouslyAdded = isParkingEventAdded();
final View addParking = mapActivity.getLayoutInflater().inflate(R.layout.parking_set_type, null);
final Dialog choose = new Dialog(mapActivity);

View file

@ -308,6 +308,10 @@ public class PoiFiltersHelper {
saveSelectedPoiFilters();
}
public void hidePoiFilters() {
selectedPoiFilters.clear();
}
public String getFiltersName(Set<PoiUIFilter> filters) {
if (filters.isEmpty()) {
return application.getResources().getString(R.string.shared_string_none);

View file

@ -0,0 +1,180 @@
package net.osmand.plus.quickaction;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v7.view.ContextThemeWrapper;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import java.util.List;
/**
* Created by rosty on 12/22/16.
*/
public class AddQuickActionDialog extends DialogFragment {
public static final String TAG = AddQuickActionDialog.class.getSimpleName();
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
OsmandApplication application = (OsmandApplication) getActivity().getApplication();
boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
return new Dialog(new ContextThemeWrapper(getActivity(), light
? R.style.Dialog90Light
: R.style.Dialog90Dark), getTheme());
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
List<QuickAction> active = ((MapActivity) getActivity())
.getMapLayers()
.getQuickActionRegistry()
.getQuickActions();
View root = inflater.inflate(R.layout.quick_action_add_dialog, container, false);
Adapter adapter = new Adapter(QuickActionFactory.produceTypeActionsListWithHeaders(active));
RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.recycler_view);
Button btnDismiss = (Button) root.findViewById(R.id.btnDismiss);
btnDismiss.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
recyclerView.setAdapter(adapter);
return root;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
public class Adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int HEADER = 1;
private static final int ITEM = 2;
private List<QuickAction> data;
public class ItemViewHolder extends RecyclerView.ViewHolder {
private TextView title;
private ImageView icon;
public ItemViewHolder(View v) {
super(v);
title = (TextView) v.findViewById(R.id.title);
icon = (ImageView) v.findViewById(R.id.image);
}
}
public class HeaderViewHolder extends RecyclerView.ViewHolder {
private TextView header;
private View divider;
public HeaderViewHolder(View v) {
super(v);
header = (TextView) v.findViewById(R.id.header);
divider = v.findViewById(R.id.divider);
}
}
public Adapter(List<QuickAction> data) {
this.data = data;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == HEADER) {
return new HeaderViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_add_dialog_header, parent, false));
} else {
return new ItemViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_add_dialog_item, parent, false));
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
final QuickAction action = data.get(position);
if (getItemViewType(position) == HEADER) {
HeaderViewHolder headerHolder = (HeaderViewHolder) holder;
headerHolder.header.setText(action.getNameRes());
if (position == 0) headerHolder.divider.setVisibility(View.GONE);
else headerHolder.divider.setVisibility(View.VISIBLE);
} else {
ItemViewHolder itemHolder = (ItemViewHolder) holder;
itemHolder.title.setText(action.getNameRes());
itemHolder.icon.setImageResource(action.getIconRes());
itemHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CreateEditActionDialog dialog = CreateEditActionDialog.newInstance(action.type);
dialog.show(getFragmentManager(), CreateEditActionDialog.TAG);
dismiss();
}
});
}
}
@Override
public int getItemCount() {
return data.size();
}
@Override
public int getItemViewType(int position) {
if (data.get(position).type == 0)
return HEADER;
return ITEM;
}
}
}

View file

@ -0,0 +1,251 @@
package net.osmand.plus.quickaction;
import android.app.Dialog;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
/**
* Created by rosty on 12/27/16.
*/
public class CreateEditActionDialog extends DialogFragment {
public static final String TAG = CreateEditActionDialog.class.getSimpleName();
public static final String KEY_ACTION_ID = "action_id";
public static final String KEY_ACTION_TYPE = "action_type";
public static final String KEY_ACTION_IS_NEW = "action_is_new";
public static CreateEditActionDialog newInstance(long id) {
Bundle args = new Bundle();
args.putLong(KEY_ACTION_ID, id);
CreateEditActionDialog dialog = new CreateEditActionDialog();
dialog.setArguments(args);
return dialog;
}
public static CreateEditActionDialog newInstance(int type) {
Bundle args = new Bundle();
args.putInt(KEY_ACTION_TYPE, type);
CreateEditActionDialog dialog = new CreateEditActionDialog();
dialog.setArguments(args);
return dialog;
}
private QuickActionRegistry quickActionRegistry;
private QuickAction action;
private boolean isNew;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
OsmandApplication application = (OsmandApplication) getActivity().getApplication();
boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
Dialog dialog = new Dialog(new ContextThemeWrapper(getActivity(), light
? R.style.Dialog90Light
: R.style.Dialog90Dark), getTheme());
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
return dialog;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
OsmandApplication application = (OsmandApplication) getActivity().getApplication();
boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
setStyle(DialogFragment.STYLE_NORMAL, light
? R.style.OsmandLightTheme
: R.style.OsmandDarkTheme);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
return inflater.inflate(R.layout.quick_action_create_edit_dialog, parent, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
quickActionRegistry = ((MapActivity) getActivity()).getMapLayers().getQuickActionRegistry();
long actionId = savedInstanceState == null
? getArguments().getLong(KEY_ACTION_ID)
: savedInstanceState.getLong(KEY_ACTION_ID);
int type = savedInstanceState == null
? getArguments().getInt(KEY_ACTION_TYPE)
: savedInstanceState.getInt(KEY_ACTION_TYPE);
isNew = savedInstanceState == null
? isNew = actionId == 0
: savedInstanceState.getBoolean(KEY_ACTION_IS_NEW);
action = QuickActionFactory.produceAction(isNew
? QuickActionFactory.newActionByType(type)
: quickActionRegistry.getQuickAction(actionId));
setupToolbar(view);
setupHeader(view, savedInstanceState);
setupFooter(view);
action.drawUI((ViewGroup) getView().findViewById(R.id.container), (MapActivity) getActivity());
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putLong(KEY_ACTION_ID, action.getId());
outState.putInt(KEY_ACTION_TYPE, action.type);
outState.putBoolean(KEY_ACTION_IS_NEW, isNew);
}
private void setupToolbar(View root) {
Toolbar toolbar = (Toolbar) root.findViewById(R.id.toolbar);
toolbar.setTitle(isNew
? R.string.quick_action_new_action
: R.string.quick_action_edit_action);
toolbar.setTitleTextColor(Color.WHITE);
toolbar.setNavigationIcon(getIconsCache().getIcon(
R.drawable.abc_ic_ab_back_mtrl_am_alpha,
R.color.color_white));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
}
private void setupHeader(View root, Bundle savedInstanceState){
ImageView image = (ImageView) root.findViewById(R.id.image);
EditText name = (EditText) root.findViewById(R.id.name);
name.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
action.setName(charSequence.toString());
}
@Override
public void afterTextChanged(Editable editable) {
}
});
name.setEnabled(action.isActionEditable());
action.setAutoGeneratedTitle(name);
if (savedInstanceState == null) name.setText(action.getName(getContext()));
else action.setName(name.getText().toString());
image.setImageResource(action.getIconRes(getApplication()));
}
private void setupFooter(final View root){
root.findViewById(R.id.btnApply).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (action.fillParams(((ViewGroup) root.findViewById(R.id.container)).getChildAt(0), (MapActivity) getActivity())) {
if (quickActionRegistry.isNameUnique(action, getContext())) {
if (isNew) quickActionRegistry.addQuickAction(action);
else quickActionRegistry.updateQuickAction(action);
quickActionRegistry.notifyUpdates();
dismiss();
} else {
action = quickActionRegistry.generateUniqueName(action, getContext());
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(R.string.quick_action_duplicate);
builder.setMessage(getString(R.string.quick_action_duplicates, action.getName(getContext())));
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (isNew) quickActionRegistry.addQuickAction(action);
else quickActionRegistry.updateQuickAction(action);
quickActionRegistry.notifyUpdates();
CreateEditActionDialog.this.dismiss();
dismiss();
}
});
builder.create().show();
((EditText) root.findViewById(R.id.name)).setText(action.getName(getContext()));
}
} else {
Toast.makeText(getContext(), R.string.quick_action_empty_param_error, Toast.LENGTH_SHORT).show();
}
}
});
}
private OsmandApplication getApplication(){
return (OsmandApplication)(getContext().getApplicationContext());
}
private IconsCache getIconsCache(){
return getApplication().getIconsCache();
}
}

View file

@ -0,0 +1,153 @@
package net.osmand.plus.quickaction;
import android.content.Context;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.activities.MapActivity;
import java.util.HashMap;
import java.util.List;
public class QuickAction {
public interface QuickActionSelectionListener {
void onActionSelected(QuickAction action);
}
protected int type;
protected long id;
private @StringRes int nameRes;
private @DrawableRes int iconRes;
private boolean isActionEditable;
private String name;
private HashMap<String, String> params;
protected QuickAction() {
this.id = System.currentTimeMillis();
}
protected QuickAction(int type, int nameRes) {
this.id = System.currentTimeMillis();
this.nameRes = nameRes;
this.type = type;
}
protected QuickAction(int type) {
this.id = System.currentTimeMillis();
this.type = type;
this.nameRes = QuickActionFactory.getActionName(type);
this.iconRes = QuickActionFactory.getActionIcon(type);
this.isActionEditable = QuickActionFactory.isActionEditable(type);
}
public QuickAction(QuickAction quickAction) {
this.type = quickAction.type;
this.id = quickAction.id;
this.name = quickAction.name;
this.params = quickAction.params;
this.nameRes = QuickActionFactory.getActionName(type);
this.iconRes = QuickActionFactory.getActionIcon(type);
this.isActionEditable = QuickActionFactory.isActionEditable(type);
}
public int getNameRes() {
return nameRes;
}
public int getIconRes() {
return iconRes;
}
public int getIconRes(Context context) {
return iconRes;
}
public long getId() {
return id;
}
public boolean isActionEditable() {
return isActionEditable;
}
public String getName(Context context) {
return name == null || name.isEmpty() ? nameRes > 0 ? context.getString(nameRes) : "" : name;
}
public HashMap<String, String> getParams() {
if (params == null) params = new HashMap<>();
return params;
}
public void setName(String name) {
this.name = name;
}
public void setParams(HashMap<String, String> params) {
this.params = params;
}
public boolean isActionWithSlash(OsmandApplication application){
return false;
}
public String getActionText(OsmandApplication application){
return getName(application);
}
public void setAutoGeneratedTitle(EditText title){
}
public void execute(MapActivity activity){};
public void drawUI(ViewGroup parent, MapActivity activity){};
public boolean fillParams(View root, MapActivity activity){ return true; };
public boolean hasInstanceInList(List<QuickAction> active){
for (QuickAction action: active){
if (action.type == type) return true;
}
return false;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
if (o instanceof QuickAction) {
QuickAction action = (QuickAction) o;
if (type != action.type) return false;
if (id != action.id) return false;
return true;
} else return false;
}
@Override
public int hashCode() {
int result = type;
result = 31 * result + (int) (id ^ (id >>> 32));
result = 31 * result + nameRes;
result = 31 * result + iconRes;
result = 31 * result + (name != null ? name.hashCode() : 0);
return result;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,67 @@
package net.osmand.plus.quickaction;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
/**
* Created by okorsun on 21.12.16.
*/
public class QuickActionItemTouchHelperCallback extends ItemTouchHelper.Callback {
private OnItemMoveCallback itemMoveCallback;
public QuickActionItemTouchHelperCallback() {
}
public QuickActionItemTouchHelperCallback(OnItemMoveCallback itemMoveCallback) {
this.itemMoveCallback = itemMoveCallback;
}
public void setItemMoveCallback(OnItemMoveCallback itemMoveCallback) {
this.itemMoveCallback = itemMoveCallback;
}
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
int swipeFlags = 0;
return !isaHeaderType(viewHolder) ? makeMovementFlags(dragFlags, swipeFlags) : 0;
}
@Override
public boolean isItemViewSwipeEnabled() {
return false;
}
@Override
public boolean isLongPressDragEnabled() {
return false;
}
@Override
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
super.clearView(recyclerView, viewHolder);
itemMoveCallback.onViewDropped(recyclerView, viewHolder);
}
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return itemMoveCallback.onMove(recyclerView, viewHolder, target);
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
}
private boolean isaHeaderType(RecyclerView.ViewHolder viewHolder) {
return viewHolder.getItemViewType() == QuickActionListFragment.QuickActionAdapter.SCREEN_HEADER_TYPE;
}
interface OnItemMoveCallback {
boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target);
void onViewDropped(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder);
}
}

View file

@ -0,0 +1,420 @@
package net.osmand.plus.quickaction;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MotionEventCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
/**
* Created by okorsun on 20.12.16.
*/
public class QuickActionListFragment extends BaseOsmAndFragment implements QuickActionRegistry.QuickActionUpdatesListener{
public static final String TAG = QuickActionListFragment.class.getSimpleName();
RecyclerView quickActionRV;
FloatingActionButton fab;
QuickActionAdapter adapter;
ItemTouchHelper touchHelper;
QuickActionRegistry quickActionRegistry;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.quick_action_list, container, false);
quickActionRV = (RecyclerView) view.findViewById(R.id.recycler_view);
fab = (FloatingActionButton) view.findViewById(R.id.fabButton);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AddQuickActionDialog dialog = new AddQuickActionDialog();
dialog.show(getFragmentManager(), AddQuickActionDialog.TAG);
}
});
return view;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
quickActionRegistry = getMapActivity().getMapLayers().getQuickActionRegistry();
setUpToolbar(view);
setUpQuickActionRV();
}
private void setUpQuickActionRV() {
adapter = new QuickActionAdapter(new OnStartDragListener() {
@Override
public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
touchHelper.startDrag(viewHolder);
}
});
quickActionRV.setAdapter(adapter);
quickActionRV.setLayoutManager(new LinearLayoutManager(getContext()));
ItemTouchHelper.Callback touchHelperCallback = new QuickActionItemTouchHelperCallback(adapter);
touchHelper = new ItemTouchHelper(touchHelperCallback);
touchHelper.attachToRecyclerView(quickActionRV);
adapter.addItems(quickActionRegistry.getFilteredQuickActions());
quickActionRV.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (dy > 0 && fab.getVisibility() == View.VISIBLE)
fab.hide();
else if (dy < 0 && fab.getVisibility() != View.VISIBLE)
fab.show();
}
});
}
private void setUpToolbar(View view) {
Toolbar toolbar = (Toolbar) view.findViewById(R.id.custom_toolbar);
Drawable back = getMyApplication().getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
back.setColorFilter(ContextCompat.getColor(getContext(), R.color.color_white), PorterDuff.Mode.MULTIPLY);
toolbar.setNavigationIcon(back);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
toolbar.setTitle(R.string.configure_screen_quick_action);
toolbar.setTitleTextColor(ContextCompat.getColor(getContext(), R.color.color_white));
}
@Override
public void onResume() {
super.onResume();
getMapActivity().disableDrawer();
quickActionRegistry.setUpdatesListener(this);
}
@Override
public void onPause() {
super.onPause();
getMapActivity().enableDrawer();
quickActionRegistry.setUpdatesListener(null);
}
private MapActivity getMapActivity() {
return (MapActivity) getActivity();
}
private void saveQuickActions(){
quickActionRegistry.updateQuickActions(adapter.getQuickActions());
}
void createAndShowDeleteDialog(final int itemPosition, final String itemName) {
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getContext(), R.style.OsmandLightTheme));
builder.setTitle(R.string.quick_actions_delete);
builder.setMessage(getResources().getString(R.string.quick_actions_delete_text, itemName));
builder.setIcon(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_delete_dark));
builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
adapter.deleteItem(itemPosition);
dialog.dismiss();
}
});
builder.setNegativeButton(R.string.shared_string_no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.show();
dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(ContextCompat.getColor(getContext(), R.color.dashboard_blue));
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(getContext(), R.color.dashboard_blue));
}
@Override
public void onActionsUpdated() {
adapter.addItems(quickActionRegistry.getFilteredQuickActions());
}
public class QuickActionAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements QuickActionItemTouchHelperCallback.OnItemMoveCallback {
public static final int SCREEN_ITEM_TYPE = 1;
public static final int SCREEN_HEADER_TYPE = 2;
private static final int ITEMS_IN_GROUP = 6;
private List<QuickAction> itemsList = new ArrayList<>();
private final OnStartDragListener onStartDragListener;
public QuickActionAdapter(OnStartDragListener onStartDragListener) {
this.onStartDragListener = onStartDragListener;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
if (viewType == SCREEN_ITEM_TYPE)
return new QuickActionItemVH(inflater.inflate(R.layout.quick_action_list_item, parent, false));
else
return new QuickActionHeaderVH(inflater.inflate(R.layout.quick_action_list_header, parent, false));
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
int viewType = getItemViewType(position);
final QuickAction item = QuickActionFactory.produceAction(itemsList.get(position));
if (viewType == SCREEN_ITEM_TYPE) {
final QuickActionItemVH itemVH = (QuickActionItemVH) holder;
itemVH.title.setText(item.getName(getContext()));
itemVH.subTitle.setText(getResources().getString(R.string.quick_action_item_action, getActionPosition(position)));
itemVH.icon.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(item.getIconRes(getContext())));
itemVH.handleView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) ==
MotionEvent.ACTION_DOWN) {
onStartDragListener.onStartDrag(itemVH);
}
return false;
}
});
itemVH.closeBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
createAndShowDeleteDialog(holder.getAdapterPosition(), getResources().getString(item.getNameRes()));
}
});
itemVH.container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CreateEditActionDialog dialog = CreateEditActionDialog.newInstance(item.id);
dialog.show(getFragmentManager(), AddQuickActionDialog.TAG);
}
});
LinearLayout.LayoutParams dividerParams = (LinearLayout.LayoutParams) itemVH.divider.getLayoutParams();
//noinspection ResourceType
dividerParams.setMargins(!isLongDivider(position) ? dpToPx(56f) : 0, 0, 0, 0);
itemVH.divider.setLayoutParams(dividerParams);
} else {
QuickActionHeaderVH headerVH = (QuickActionHeaderVH) holder;
headerVH.headerName.setText(getResources().getString(R.string.quick_action_item_screen, position / (ITEMS_IN_GROUP + 1) + 1));
}
}
@Override
public int getItemCount() {
return itemsList.size();
}
@Override
public int getItemViewType(int position) {
return itemsList.get(position).type == 0 ? SCREEN_HEADER_TYPE : SCREEN_ITEM_TYPE;
}
public void deleteItem(int position) {
if (position == -1)
return;
itemsList.remove(position);
notifyItemRemoved(position);
moveHeaders(position);
showFABIfNotScrollable();
saveQuickActions();
}
private void moveHeaders(int position) {
for (int i = position; i < itemsList.size(); i++) {
if (getItemViewType(i) == SCREEN_HEADER_TYPE) {
if (i != itemsList.size() - 2) {
Collections.swap(itemsList, i, i + 1);
notifyItemMoved(i, i + 1);
i++;
} else {
itemsList.remove(i);
notifyItemRemoved(i);
}
}
}
notifyItemRangeChanged(position, itemsList.size() - position);
int lastPosition = itemsList.size() - 1;
if (getItemViewType(lastPosition) == SCREEN_HEADER_TYPE){
itemsList.remove(lastPosition);
notifyItemRemoved(lastPosition);
}
}
private void showFABIfNotScrollable() {
LinearLayoutManager layoutManager = (LinearLayoutManager) quickActionRV.getLayoutManager();
int lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition();
if ((lastVisibleItemPosition == itemsList.size() - 1 || lastVisibleItemPosition == itemsList.size()) &&
layoutManager.findFirstVisibleItemPosition() == 0 &&
fab.getVisibility() != View.VISIBLE ||
itemsList.size() == 0)
fab.show();
}
public List<QuickAction> getQuickActions() {
List<QuickAction> result = new ArrayList<>();
for (int i = 0; i < itemsList.size(); i++) {
if (getItemViewType(i) == SCREEN_ITEM_TYPE)
result.add(itemsList.get(i));
}
return result;
}
public void addItems(List<QuickAction> data) {
List<QuickAction> resultList = new ArrayList<>();
for (int i = 0; i < data.size(); i++) {
if (i % ITEMS_IN_GROUP == 0)
resultList.add(createHeader());
resultList.add(data.get(i));
}
itemsList = resultList;
notifyDataSetChanged();
}
public void addItem(QuickAction item) {
int oldSize = itemsList.size();
if (oldSize % (ITEMS_IN_GROUP + 1) == 0)
itemsList.add(createHeader());
itemsList.add(item);
notifyItemRangeInserted(oldSize, itemsList.size() - oldSize);
}
private QuickAction createHeader() {
return new QuickAction();
}
private int getActionPosition(int globalPosition) {
return globalPosition % (ITEMS_IN_GROUP + 1);
}
private boolean isLongDivider(int globalPosition) {
return getActionPosition(globalPosition) == ITEMS_IN_GROUP || globalPosition == getItemCount() - 1;
}
private int dpToPx(float dp) {
Resources r = getActivity().getResources();
return (int) TypedValue.applyDimension(
COMPLEX_UNIT_DIP,
dp,
r.getDisplayMetrics()
);
}
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
if (viewHolder.getItemViewType() == SCREEN_HEADER_TYPE || target.getItemViewType() == SCREEN_HEADER_TYPE)
return false;
else {
int selectedPosition = viewHolder.getAdapterPosition();
int targetPosition = target.getAdapterPosition();
Log.v(TAG, "selected: " + selectedPosition + ", target: " + targetPosition);
if (selectedPosition < 0 || targetPosition < 0)
return false;
Collections.swap(itemsList, selectedPosition, targetPosition);
if (selectedPosition - targetPosition < -1) {
notifyItemMoved(selectedPosition, targetPosition);
notifyItemMoved(targetPosition - 1, selectedPosition);
} else if (selectedPosition - targetPosition > 1) {
notifyItemMoved(selectedPosition, targetPosition);
notifyItemMoved(targetPosition + 1, selectedPosition);
} else {
notifyItemMoved(selectedPosition, targetPosition);
}
notifyItemChanged(selectedPosition);
notifyItemChanged(targetPosition);
return true;
}
}
@Override
public void onViewDropped(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
saveQuickActions();
}
public class QuickActionItemVH extends RecyclerView.ViewHolder {
public TextView title;
public TextView subTitle;
public ImageView icon;
public View divider;
public ImageView handleView;
public ImageView closeBtn;
public View container;
public QuickActionItemVH(View itemView) {
super(itemView);
// AndroidUtils.setListItemBackground(itemView.getContext(), itemView, getMyApplication().getDaynightHelper().isNightMode());
title = (TextView) itemView.findViewById(R.id.title);
subTitle = (TextView) itemView.findViewById(R.id.subtitle);
icon = (ImageView) itemView.findViewById(R.id.imageView);
divider = itemView.findViewById(R.id.divider);
handleView = (ImageView) itemView.findViewById(R.id.handle_view);
closeBtn = (ImageView) itemView.findViewById(R.id.closeImageButton);
container = itemView.findViewById(R.id.searchListItemLayout);
handleView.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_reorder));
closeBtn.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_remove_dark));
}
}
public class QuickActionHeaderVH extends RecyclerView.ViewHolder {
public TextView headerName;
public QuickActionHeaderVH(View itemView) {
super(itemView);
headerName = (TextView) itemView.findViewById(R.id.header);
}
}
}
public interface OnStartDragListener {
void onStartDrag(RecyclerView.ViewHolder viewHolder);
}
}

View file

@ -0,0 +1,233 @@
package net.osmand.plus.quickaction;
import android.content.Context;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
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 java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by rosty on 12/27/16.
*/
public class QuickActionRegistry {
public interface QuickActionUpdatesListener{
void onActionsUpdated();
}
private final QuickActionFactory factory;
private final OsmandSettings settings;
private final List<QuickAction> quickActions;
private final Map<String, Boolean> fabStateMap;
private QuickActionUpdatesListener updatesListener;
public QuickActionRegistry(OsmandSettings settings) {
this.factory = new QuickActionFactory();
this.settings = settings;
quickActions = factory.parseActiveActionsList(settings.QUICK_ACTION_LIST.get());
fabStateMap = getQuickActionFabStateMapFromJson(settings.QUICK_ACTION.get());
}
public void setUpdatesListener(QuickActionUpdatesListener updatesListener) {
this.updatesListener = updatesListener;
}
public void notifyUpdates() {
if (updatesListener != null) updatesListener.onActionsUpdated();
}
public List<QuickAction> getQuickActions() {
List<QuickAction> actions = new ArrayList<>();
actions.addAll(quickActions);
return actions;
}
public List<QuickAction> getFilteredQuickActions() {
List<QuickAction> actions = getQuickActions();
List<QuickAction> filteredActions = new ArrayList<>();
for (QuickAction action: actions){
boolean skip = false;
if (OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class) == null) {
if (action.type == QuickActionFactory.TakeAudioNoteAction.TYPE ||
action.type == QuickActionFactory.TakePhotoNoteAction.TYPE ||
action.type == QuickActionFactory.TakeVideoNoteAction.TYPE) {
skip = true;
}
}
if (OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class) == null) {
if (action.type == QuickActionFactory.ParkingAction.TYPE) {
skip = true;
}
}
if (OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) == null) {
if (action.type == QuickActionFactory.MapStyleAction.TYPE) {
if (((QuickActionFactory.MapStyleAction) QuickActionFactory.produceAction(action))
.getFilteredStyles().isEmpty()){
skip = true;
}
}
}
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
if (action.type == QuickActionFactory.MapSourceAction.TYPE) {
skip = true;
}
}
if (OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class) == null) {
if (action.type == QuickActionFactory.AddPOIAction.TYPE) {
skip = true;
}
if (action.type == QuickActionFactory.AddOSMBugAction.TYPE) {
skip = true;
}
}
if (!skip) filteredActions.add(action);
}
return filteredActions;
}
public void addQuickAction(QuickAction action){
quickActions.add(action);
settings.QUICK_ACTION_LIST.set(factory.quickActionListToString(quickActions));
}
public void deleteQuickAction(QuickAction action){
int index = quickActions.indexOf(action);
if (index >= 0) quickActions.remove(index);
settings.QUICK_ACTION_LIST.set(factory.quickActionListToString(quickActions));
}
public void deleteQuickAction(int id){
int index = -1;
for (QuickAction action: quickActions){
if (action.id == id)
index = quickActions.indexOf(action);
}
if (index >= 0) quickActions.remove(index);
settings.QUICK_ACTION_LIST.set(factory.quickActionListToString(quickActions));
}
public void updateQuickAction(QuickAction action){
int index = quickActions.indexOf(action);
if (index >= 0) quickActions.set(index, action);
settings.QUICK_ACTION_LIST.set(factory.quickActionListToString(quickActions));
}
public void updateQuickActions(List<QuickAction> quickActions){
this.quickActions.clear();
this.quickActions.addAll(quickActions);
settings.QUICK_ACTION_LIST.set(factory.quickActionListToString(this.quickActions));
}
public QuickAction getQuickAction(long id){
for (QuickAction action: quickActions){
if (action.id == id) return action;
}
return null;
}
public boolean isNameUnique(QuickAction action, Context context){
for (QuickAction a: quickActions){
if (action.id != a.id) {
if (action.getName(context).equals(a.getName(context)))
return false;
}
}
return true;
}
public QuickAction generateUniqueName(QuickAction action, Context context) {
int number = 0;
String name = action.getName(context);
while (true) {
number++;
action.setName(name + " (" + number + ")");
if (isNameUnique(action, context)) return action;
}
}
public boolean isQuickActionOn() {
Boolean result = fabStateMap.get(settings.APPLICATION_MODE.get().getStringKey());
return result != null && result;
}
public void setQuickActionFabState(boolean isOn) {
fabStateMap.put(settings.APPLICATION_MODE.get().getStringKey(), isOn);
settings.QUICK_ACTION.set(new Gson().toJson(fabStateMap));
}
private Map<String, Boolean> getQuickActionFabStateMapFromJson(String json) {
Type type = new TypeToken<HashMap<String, Boolean>>() {
}.getType();
HashMap<String, Boolean> quickActions = new Gson().fromJson(json, type);
return quickActions != null ? quickActions : new HashMap<String, Boolean>();
}
}

View file

@ -0,0 +1,294 @@
package net.osmand.plus.quickaction;
import android.app.Activity;
import android.content.Context;
import android.support.annotation.StyleRes;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.view.ContextThemeWrapper;
import android.support.v7.widget.GridLayout;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import java.util.List;
public class QuickActionsWidget extends LinearLayout {
private static final int ELEMENT_PER_PAGE = 6;
private QuickAction.QuickActionSelectionListener selectionListener;
private List<QuickAction> actions;
private ImageButton next;
private ImageButton prev;
private ViewPager viewPager;
private LinearLayout dots;
private LinearLayout controls;
private View container;
public QuickActionsWidget(Context context) {
super(context);
}
public QuickActionsWidget(Context context, AttributeSet attrs) {
super(context, attrs);
}
public QuickActionsWidget(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void setActions(List<QuickAction> actions){
this.actions = actions;
this.actions.add(new QuickActionFactory.NewAction());
removeAllViews();
setupLayout(getContext(), countPage());
}
public void setSelectionListener(QuickAction.QuickActionSelectionListener selectionListener) {
this.selectionListener = selectionListener;
}
private void setupLayout(Context context, int pageCount){
OsmandApplication application = ((OsmandApplication) getContext().getApplicationContext());
boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
inflate(new ContextThemeWrapper(context, light
? R.style.OsmandLightTheme
: R.style.OsmandDarkTheme), R.layout.quick_action_widget, this);
container = findViewById(R.id.container);
viewPager = (ViewPager) findViewById(R.id.viewPager);
viewPager.setAdapter(new ViewsPagerAdapter());
container.setBackgroundResource(light
? R.drawable.bg_card_light
: R.drawable.bg_card_dark);
viewPager.getLayoutParams().height = actions.size() > ELEMENT_PER_PAGE / 2
? (int) getResources().getDimension(R.dimen.quick_action_widget_height_big)
: (int) getResources().getDimension(R.dimen.quick_action_widget_height_small);
viewPager.requestLayout();
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
updateControls(position);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
next = (ImageButton) findViewById(R.id.btnNext);
prev = (ImageButton) findViewById(R.id.btnPrev);
next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (viewPager.getAdapter().getCount() > viewPager.getCurrentItem() + 1) {
viewPager.setCurrentItem(viewPager.getCurrentItem() + 1);
}
}
});
prev.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (viewPager.getCurrentItem() - 1 >= 0) {
viewPager.setCurrentItem(viewPager.getCurrentItem() - 1);
}
}
});
dots = (LinearLayout) findViewById(R.id.dots);
dots.removeAllViews();
if (pageCount > 1) {
int color = light ? R.color.icon_color_light : R.color.white_50_transparent;
for (int i = 0; i < pageCount; i++) {
ImageView dot = (ImageView) getLayoutInflater()
.inflate(R.layout.quick_action_widget_dot, dots, false);
dot.setImageDrawable(i == 0
? getIconsCache().getIcon(R.drawable.ic_dot_position, R.color.dashboard_blue)
: getIconsCache().getIcon(R.drawable.ic_dot_position, color));
dots.addView(dot);
}
}
controls = (LinearLayout) findViewById(R.id.controls);
controls.setVisibility(pageCount > 1 ? VISIBLE : GONE);
updateControls(viewPager.getCurrentItem());
}
private void updateControls(int position) {
OsmandApplication application = ((OsmandApplication) getContext().getApplicationContext());
boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
int colorEnabled = light ? R.color.icon_color : R.color.color_white;
int colorDisabled = light ? R.color.icon_color_light : R.color.white_50_transparent;
next.setEnabled(viewPager.getAdapter().getCount() > position + 1);
next.setImageDrawable(next.isEnabled()
? getIconsCache().getIcon(R.drawable.ic_arrow_forward, colorEnabled)
: getIconsCache().getIcon(R.drawable.ic_arrow_forward, colorDisabled));
prev.setEnabled(position > 0);
prev.setImageDrawable(prev.isEnabled()
? getIconsCache().getIcon(R.drawable.ic_arrow_back, colorEnabled)
: getIconsCache().getIcon(R.drawable.ic_arrow_back, colorDisabled));
for (int i = 0; i < dots.getChildCount(); i++){
((ImageView) dots.getChildAt(i)).setImageDrawable(i == position
? getIconsCache().getIcon(R.drawable.ic_dot_position, R.color.dashboard_blue)
: getIconsCache().getIcon(R.drawable.ic_dot_position, colorDisabled));
}
}
private View createPageView(ViewGroup container, int position){
OsmandApplication application = ((OsmandApplication) getContext().getApplicationContext());
boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
LayoutInflater li = getLayoutInflater(light
? R.style.OsmandLightTheme
: R.style.OsmandDarkTheme);
View page = li.inflate(R.layout.quick_action_widget_page, container, false);
GridLayout gridLayout = (GridLayout) page.findViewById(R.id.grid);
final boolean land = !AndroidUiHelper.isOrientationPortrait((Activity) getContext());
final int maxItems = actions.size() == 1 ? 1 : ELEMENT_PER_PAGE;
for (int i = 0; i < maxItems; i++){
View view = li.inflate(R.layout.quick_action_widget_item, gridLayout, false);
if (i + (position * ELEMENT_PER_PAGE) < actions.size()) {
final QuickAction action = QuickActionFactory.produceAction(
actions.get(i + (position * ELEMENT_PER_PAGE)));
((ImageView) view.findViewById(R.id.imageView))
.setImageResource(action.getIconRes(getContext()));
((TextView) view.findViewById(R.id.title))
.setText(action.getActionText(application));
if (action.isActionWithSlash(application)) {
((ImageView) view.findViewById(R.id.imageSlash))
.setImageResource(light
? R.drawable.ic_action_icon_hide_white
: R.drawable.ic_action_icon_hide_dark);
}
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (selectionListener != null) selectionListener.onActionSelected(action);
}
});
}
if (land) {
view.findViewById(R.id.dividerBot).setVisibility(GONE);
view.findViewById(R.id.dividerRight).setVisibility(VISIBLE);
} else {
view.findViewById(R.id.dividerBot).setVisibility(i < ELEMENT_PER_PAGE / 2 ? VISIBLE : GONE);
view.findViewById(R.id.dividerRight).setVisibility(((i + 1) % 3) == 0 ? GONE : VISIBLE);
}
gridLayout.addView(view);
}
return gridLayout;
}
private class ViewsPagerAdapter extends PagerAdapter {
@Override
public int getCount() {
return countPage();
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view = createPageView(container, position);
container.addView(view, 0);
return view;
}
@Override
public void destroyItem(ViewGroup collection, int position, Object view) {
collection.removeView((View) view);
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
}
private int countPage(){
return (int) Math.ceil((actions.size()) / (double) 6);
}
private LayoutInflater getLayoutInflater(){
return (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
private LayoutInflater getLayoutInflater(@StyleRes int style){
return (LayoutInflater) new ContextThemeWrapper(getContext(), style).getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
private OsmandApplication getApplication(){
return (OsmandApplication)(getContext().getApplicationContext());
}
private IconsCache getIconsCache(){
return getApplication().getIconsCache();
}
}

View file

@ -61,6 +61,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
private MapContextMenu menu;
private MapMultiSelectionMenu multiSelectionMenu;
private CallbackWithObject<LatLon> selectOnMap = null;
private MapQuickActionLayer mapQuickActionLayer;
private ImageView contextMarker;
private Paint paint;
@ -145,6 +146,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
canvas.drawBitmap(pressedBitmap, x - pressedBitmap.getWidth() / 2, y - pressedBitmap.getHeight() / 2, paint);
}
if (mapQuickActionLayer!= null && mapQuickActionLayer.isInChangeMarkerPositionMode())
return;
if (mInChangeMarkerPositionMode) {
if (menu.getObject() == null) {
canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
@ -651,6 +655,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
multiSelectionMenu.show(latLon, selectedObjects);
}
public void setMapQuickActionLayer(MapQuickActionLayer mapQuickActionLayer) {
this.mapQuickActionLayer = mapQuickActionLayer;
}
@Override
public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) {

View file

@ -2,7 +2,6 @@ package net.osmand.plus.views;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
@ -27,6 +26,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.core.android.MapRendererContext;
import net.osmand.data.LatLon;
@ -99,6 +99,7 @@ public class MapControlsLayer extends OsmandMapLayer {
private long lastZoom;
private boolean hasTargets;
private ContextMenuLayer contextMenuLayer;
private MapQuickActionLayer mapQuickActionLayer;
private boolean forceShowCompass;
public MapControlsLayer(MapActivity activity) {
@ -628,7 +629,7 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean showRouteCalculationControls = routePlanningMode ||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
updateMyLocation(rh, dialogOpened);
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode) && !contextMenuLayer.isInChangeMarkerPositionMode();
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode) && !isInChangeMarkerPositionMode();
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
if (rh.isFollowingMode()) {
routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
@ -1029,6 +1030,15 @@ public class MapControlsLayer extends OsmandMapLayer {
return zoomText;
}
public void setMapQuickActionLayer(MapQuickActionLayer mapQuickActionLayer) {
this.mapQuickActionLayer = mapQuickActionLayer;
}
private boolean isInChangeMarkerPositionMode(){
return mapQuickActionLayer == null ? contextMenuLayer.isInChangeMarkerPositionMode() :
mapQuickActionLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInChangeMarkerPositionMode();
}
public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) {
return new View.OnLongClickListener() {

View file

@ -0,0 +1,400 @@
package net.osmand.plus.views;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.os.Vibrator;
import android.support.annotation.DimenRes;
import android.support.v4.content.ContextCompat;
import android.support.v4.util.Pair;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import com.getkeepsafe.taptargetview.TapTarget;
import com.getkeepsafe.taptargetview.TapTargetView;
import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionFactory;
import net.osmand.plus.quickaction.QuickActionRegistry;
import net.osmand.plus.quickaction.QuickActionsWidget;
import static net.osmand.plus.views.ContextMenuLayer.VIBRATE_SHORT;
/**
* Created by okorsun on 23.12.16.
*/
public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRegistry.QuickActionUpdatesListener, QuickAction.QuickActionSelectionListener {
private final ContextMenuLayer contextMenuLayer;
private ImageView contextMarker;
private final MapActivity mapActivity;
private final OsmandApplication app;
private final OsmandSettings settings;
private final QuickActionRegistry quickActionRegistry;
private ImageButton quickActionButton;
private QuickActionsWidget quickActionsWidget;
private OsmandMapTileView view;
private boolean wasCollapseButtonVisible;
private int previousMapPosition;
private boolean inChangeMarkerPositionMode;
private boolean isLayerOn;
public MapQuickActionLayer(MapActivity activity, ContextMenuLayer contextMenuLayer) {
this.mapActivity = activity;
this.contextMenuLayer = contextMenuLayer;
app = activity.getMyApplication();
settings = activity.getMyApplication().getSettings();
quickActionRegistry = activity.getMapLayers().getQuickActionRegistry();
}
@Override
public void initLayer(OsmandMapTileView view) {
this.view = view;
quickActionsWidget = (QuickActionsWidget) mapActivity.findViewById(R.id.quick_action_widget);
quickActionButton = (ImageButton) mapActivity.findViewById(R.id.map_quick_actions_button);
setQuickActionButtonMargin();
isLayerOn = quickActionRegistry.isQuickActionOn();
quickActionButton.setImageResource(R.drawable.map_quick_action);
quickActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!showTutorialIfNeeded())
setLayerState(quickActionsWidget.getVisibility() == View.VISIBLE);
}
});
Context context = view.getContext();
contextMarker = new ImageView(context);
contextMarker.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT));
contextMarker.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.map_pin_context_menu));
contextMarker.setClickable(true);
int minw = contextMarker.getDrawable().getMinimumWidth();
int minh = contextMarker.getDrawable().getMinimumHeight();
contextMarker.layout(0, 0, minw, minh);
quickActionButton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Vibrator vibrator = (Vibrator) mapActivity.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_SHORT);
quickActionButton.setScaleX(1.5f);
quickActionButton.setScaleY(1.5f);
quickActionButton.setAlpha(0.95f);
quickActionButton.setOnTouchListener(onQuickActionTouchListener);
return true;
}
});
}
public void refreshLayer() {
setLayerState(true);
isLayerOn = quickActionRegistry.isQuickActionOn();
setUpQuickActionBtnVisibility();
}
private boolean showTutorialIfNeeded() {
if (isLayerOn && !settings.IS_QUICK_ACTION_TUTORIAL_SHOWN.get()) {
TapTargetView.showFor(mapActivity, // `this` is an Activity
TapTarget.forView(quickActionButton, mapActivity.getString(R.string.quck_action_btn_tutorial_title), mapActivity.getString(R.string.quick_action_btn_tutorial_description))
// All options below are optional
.outerCircleColor(R.color.osmand_orange) // Specify a color for the outer circle
.targetCircleColor(R.color.color_white) // Specify a color for the target circle
.titleTextSize(20) // Specify the size (in sp) of the title text
.descriptionTextSize(16) // Specify the size (in sp) of the description text
// .textColor(R.color.color_white) // Specify a color for both the title and description text
.descriptionTextColor(R.color.color_white) // Specify a color for both the title and description text
.titleTextColor(R.color.color_white) // Specify a color for both the title and description text
// .textTypeface(Typeface.SANS_SERIF) // Specify a typeface for the text
// .dimColor(R.color.black) // If set, will dim behind the view with 30% opacity of the given color
.drawShadow(true) // Whether to draw a drop shadow or not
.cancelable(false) // Whether tapping outside the outer circle dismisses the view
.tintTarget(false) // Whether to tint the target view's color
.transparentTarget(false) // Specify whether the target is transparent (displays the content underneath)
// .icon(Drawable) // Specify a custom drawable to draw as the target
.targetRadius(50), // Specify the target radius (in dp)
new TapTargetView.Listener() { // The listener can listen for regular clicks, long clicks or cancels
@Override
public void onTargetClick(TapTargetView view) {
super.onTargetClick(view); // This call is optional
settings.IS_QUICK_ACTION_TUTORIAL_SHOWN.set(true);
}
});
return true;
} else
return false;
}
private void setQuickActionButtonMargin() {
FrameLayout.LayoutParams param = (FrameLayout.LayoutParams) quickActionButton.getLayoutParams();
if (AndroidUiHelper.isOrientationPortrait(mapActivity)) {
Pair<Integer, Integer> fabMargin = settings.getPortraitFabMargin();
if (fabMargin != null) {
param.rightMargin = fabMargin.first;
param.bottomMargin = fabMargin.second;
} else {
param.bottomMargin = calculateTotalSizePx(R.dimen.map_button_size, R.dimen.map_button_spacing) * 2;
}
} else {
Pair<Integer, Integer> fabMargin = settings.getLandscapeFabMargin();
if (fabMargin != null) {
param.rightMargin = fabMargin.first;
param.bottomMargin = fabMargin.second;
} else {
param.rightMargin = calculateTotalSizePx(R.dimen.map_button_size, R.dimen.map_button_spacing_land) * 2;
}
}
quickActionButton.setLayoutParams(param);
}
private int calculateTotalSizePx(@DimenRes int... dimensId) {
int result = 0;
for (int id : dimensId) {
result += mapActivity.getResources().getDimensionPixelSize(id);
}
return result;
}
/**
* @param isClosed
* @return true, if state was changed
*/
public boolean setLayerState(boolean isClosed) {
if ((quickActionsWidget.getVisibility() == View.VISIBLE) != isClosed) // check if state change is needed
return false;
quickActionButton.setImageResource(isClosed ? R.drawable.map_quick_action : R.drawable.map_action_cancel);
quickActionsWidget.setVisibility(isClosed ? View.GONE : View.VISIBLE);
if (isClosed) {
quitMovingMarker();
quickActionRegistry.setUpdatesListener(null);
quickActionsWidget.setSelectionListener(null);
} else {
enterMovingMode(mapActivity.getMapView().getCurrentRotatedTileBox());
quickActionsWidget.setActions(quickActionRegistry.getFilteredQuickActions());
quickActionRegistry.setUpdatesListener(MapQuickActionLayer.this);
quickActionsWidget.setSelectionListener(MapQuickActionLayer.this);
}
return true;
}
private void enterMovingMode(RotatedTileBox tileBox) {
previousMapPosition = view.getMapPosition();
view.setMapPosition(OsmandSettings.BOTTOM_CONSTANT);
MapContextMenu menu = mapActivity.getContextMenu();
LatLon ll = menu.isActive() && tileBox.containsLatLon(menu.getLatLon()) ? menu.getLatLon() : tileBox.getCenterLatLon();
menu.updateMapCenter(null);
menu.close();
RotatedTileBox rb = new RotatedTileBox(tileBox);
// tileBox.setCenterLocation(0.5f, 0.75f);
rb.setLatLonCenter(ll.getLatitude(), ll.getLongitude());
double lat = rb.getLatFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
double lon = rb.getLonFromPixel(tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
view.setLatLon(lat, lon);
inChangeMarkerPositionMode = true;
mark(View.INVISIBLE, R.id.map_ruler_layout,
R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
View collapseButton = mapActivity.findViewById(R.id.map_collapse_button);
if (collapseButton != null && collapseButton.getVisibility() == View.VISIBLE) {
wasCollapseButtonVisible = true;
collapseButton.setVisibility(View.INVISIBLE);
} else {
wasCollapseButtonVisible = false;
}
view.refreshMap();
}
private void quitMovingMarker() {
view.setMapPosition(previousMapPosition);
inChangeMarkerPositionMode = false;
mark(View.VISIBLE, R.id.map_ruler_layout,
R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
View collapseButton = mapActivity.findViewById(R.id.map_collapse_button);
if (collapseButton != null && wasCollapseButtonVisible) {
collapseButton.setVisibility(View.VISIBLE);
}
view.refreshMap();
}
private void mark(int status, int... widgets) {
for (int widget : widgets) {
View v = mapActivity.findViewById(widget);
if (v != null) {
v.setVisibility(status);
}
}
}
@Override
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
if (isInChangeMarkerPositionMode() && !pressedQuickActionWidget(point.x, point.y)) {
setLayerState(true);
return true;
} else
return false;
}
private boolean pressedQuickActionWidget(float px, float py) {
return py <= quickActionsWidget.getHeight();
}
@Override
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings settings) {
if (isInChangeMarkerPositionMode()) {
canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight());
contextMarker.draw(canvas);
}
setUpQuickActionBtnVisibility();
}
private void setUpQuickActionBtnVisibility() {
boolean hideQuickButton = !isLayerOn ||
contextMenuLayer.isInChangeMarkerPositionMode() ||
mapActivity.getContextMenu().isVisible() && !mapActivity.getContextMenu().findMenuFragment().get().isRemoving() ||
mapActivity.getContextMenu().isVisible() && mapActivity.getContextMenu().findMenuFragment().get().isAdded() ||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isAdded() ||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && !mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isRemoving();
quickActionButton.setVisibility(hideQuickButton ? View.GONE : View.VISIBLE);
}
@Override
public void destroyLayer() {
}
@Override
public boolean drawInScreenPixels() {
return true;
}
@Override
public void onActionsUpdated() {
quickActionsWidget.setActions(quickActionRegistry.getFilteredQuickActions());
}
@Override
public void onActionSelected(QuickAction action) {
QuickActionFactory.produceAction(action).execute(mapActivity);
setLayerState(true);
}
public PointF getMovableCenterPoint(RotatedTileBox tb) {
return new PointF(tb.getPixWidth() / 2, tb.getPixHeight() / 2);
}
public boolean isInChangeMarkerPositionMode() {
return isLayerOn && inChangeMarkerPositionMode;
}
public boolean isLayerOn() {
return isLayerOn;
}
public boolean onBackPressed() {
return setLayerState(true);
}
View.OnTouchListener onQuickActionTouchListener = new View.OnTouchListener() {
private int initialMarginX;
private int initialMarginY;
private float initialTouchX;
private float initialTouchY;
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
setUpInitialValues(v, event);
return true;
case MotionEvent.ACTION_UP:
quickActionButton.setOnTouchListener(null);
quickActionButton.setPressed(false);
quickActionButton.setScaleX(1);
quickActionButton.setScaleY(1);
quickActionButton.setAlpha(1f);
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) v.getLayoutParams();
if (AndroidUiHelper.isOrientationPortrait(mapActivity))
settings.setPortraitFabMargin(params.rightMargin, params.bottomMargin);
else
settings.setLandscapeFabMargin(params.rightMargin, params.bottomMargin);
return true;
case MotionEvent.ACTION_MOVE:
if (initialMarginX == 0 && initialMarginY == 0 && initialTouchX == 0 && initialTouchY == 0)
setUpInitialValues(v, event);
int padding = calculateTotalSizePx(R.dimen.map_button_margin);
FrameLayout parent = (FrameLayout) v.getParent();
FrameLayout.LayoutParams param = (FrameLayout.LayoutParams) v.getLayoutParams();
int deltaX = (int) (initialTouchX - event.getRawX());
int deltaY = (int) (initialTouchY - event.getRawY());
int newMarginX = interpolate(initialMarginX + deltaX, v.getWidth(), parent.getWidth() - padding * 2);
int newMarginY = interpolate(initialMarginY + deltaY, v.getHeight(), parent.getHeight() - padding * 2);
if (v.getHeight() + newMarginY <= parent.getHeight() - padding * 2 && newMarginY > 0)
param.bottomMargin = newMarginY;
if (v.getWidth() + newMarginX <= parent.getWidth() - padding * 2 && newMarginX > 0) {
param.rightMargin = newMarginX;
}
v.setLayoutParams(param);
return true;
}
return false;
}
private int interpolate(int value, int divider, int boundsSize) {
int viewSize = divider;
if (value <= divider && value > 0)
return value * value / divider;
else {
int leftMargin = boundsSize - value - viewSize;
if (leftMargin <= divider && value < boundsSize - viewSize)
return leftMargin - (leftMargin * leftMargin / divider) + value;
else
return value;
}
}
private void setUpInitialValues(View v, MotionEvent event) {
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) v.getLayoutParams();
initialMarginX = params.rightMargin;
initialMarginY = params.bottomMargin;
initialTouchX = event.getRawX();
initialTouchY = event.getRawY();
}
};
}

View file

@ -24,7 +24,9 @@ import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.quickaction.QuickActionListFragment;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.MapQuickActionLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.widgets.IconPopupMenu;
@ -36,7 +38,6 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.zip.GZIPOutputStream;
public class MapWidgetRegistry {
@ -358,6 +359,7 @@ public class MapWidgetRegistry {
public void addControls(MapActivity map, ContextMenuAdapter cm, ApplicationMode mode) {
addQuickActionControl(map, cm, mode);
// Right panel
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_right, map)
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
@ -384,6 +386,58 @@ public class MapWidgetRegistry {
return leftWidgetSet;
}
private void addQuickActionControl(final MapActivity mapActivity, final ContextMenuAdapter contextMenuAdapter, ApplicationMode mode) {
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_right, mapActivity)
.setCategory(true).setLayout(R.layout.list_group_empty_title_with_switch).createItem());
boolean selected = mapActivity.getMapLayers().getQuickActionRegistry().isQuickActionOn();
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.configure_screen_quick_action, mapActivity)
.setIcon(R.drawable.map_quick_action)
.setSelected(selected)
.setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setSecondaryIcon( R.drawable.ic_action_additional_option)
.setListener(new ContextMenuAdapter.OnRowItemClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked) {
setVisibility(adapter, position, isChecked);
return false;
}
@Override
public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int position) {
int slideInAnim = R.anim.slide_in_bottom;
int slideOutAnim = R.anim.slide_out_bottom;
mapActivity.getSupportFragmentManager().beginTransaction()
.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
.add(R.id.fragmentContainer, new QuickActionListFragment(), QuickActionListFragment.TAG)
.addToBackStack(QuickActionListFragment.TAG).commitAllowingStateLoss();
return true;
}
private void setVisibility(ArrayAdapter<ContextMenuItem> adapter,
int position,
boolean visible) {
mapActivity.getMapLayers().getQuickActionRegistry().setQuickActionFabState(visible);
MapQuickActionLayer mil = mapActivity.getMapLayers().getMapQuickActionLayer();
if (mil != null) {
mil.refreshLayer();
}
ContextMenuItem item = adapter.getItem(position);
item.setSelected(visible);
item.setColorRes(visible ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
}
})
.createItem());
}
private void addControls(final MapActivity mapActivity, final ContextMenuAdapter contextMenuAdapter,
Set<MapWidgetRegInfo> groupTitle, final ApplicationMode mode) {
for (final MapWidgetRegInfo r : groupTitle) {