Merge pull request #9073 from osmandapp/QuickActionRedesign

Quick Action redesign
This commit is contained in:
max-klaus 2020-06-02 17:17:49 +03:00 committed by GitHub
commit 72bf71a2c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 1137 additions and 612 deletions

View file

@ -0,0 +1,25 @@
<?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:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingBottom="@dimen/content_padding_small"
android:minHeight="@dimen/card_row_min_height"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:minHeight="@dimen/bottom_sheet_descr_height"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
android:linksClickable="true"
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
tools:text="Some long description" />
</LinearLayout>

View file

@ -36,18 +36,42 @@
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:maxLines="2"
android:textColor="?attr/app_bar_primary_item_color"
android:textSize="@dimen/dialog_header_text_size"
app:typeface="@string/font_roboto_medium"
tools:text="@string/routing_settings_2" />
<FrameLayout
android:id="@+id/action_button"
android:layout_gravity="center"
android:layout_width="@dimen/acceptable_touch_radius"
android:layout_height="@dimen/acceptable_touch_radius">
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/action_button_icon"
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:contentDescription="@string/access_shared_string_navigate_up"
android:duplicateParentState="true"
android:clickable="false"
android:focusable="false"
android:layout_gravity="center"
android:scaleType="fitCenter"
app:srcCompat="@drawable/ic_action_info_dark" />
</FrameLayout>
</LinearLayout>
<include layout="@layout/preference_toolbar_switch" />

View file

@ -28,25 +28,37 @@
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginStart="@dimen/content_padding"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
<net.osmand.plus.widgets.TextViewEx
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:ellipsize="marquee"
android:singleLine="true"
android:textColor="?colorAccent"
android:paddingStart="0dp"
android:paddingLeft="0dp"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Button text" />
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:textColor="?colorAccent"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Button text" />
android:layout_height="1dp"
android:visibility="gone"
android:background="?attr/dashboard_divider" />
</LinearLayout>

View file

@ -1,45 +0,0 @@
<?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:id="@+id/tvTitle"
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:layout_marginEnd="24dp"
android:layout_marginStart="24dp" />
<androidx.recyclerview.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/shared_string_dismiss"
android:layout_gravity="end"
android:background="?attr/selectableItemBackground"
android:textColor="?attr/color_dialog_buttons"
android:textAllCaps="true"
android:layout_marginEnd="8dp" />
</LinearLayout>

View file

@ -3,25 +3,26 @@
<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:layout_height="wrap_content"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:background="?attr/bg_color">
<TextView
<net.osmand.plus.widgets.TextViewEx
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"
android:layout_height="@dimen/list_header_height"
android:gravity="center_vertical"
android:textColor="@color/preference_category_title"
android:textSize="@dimen/default_desc_text_size"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
tools:text="Screen 1"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp" />
osmand:typeface="@string/font_roboto_medium" />
<View android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="top"
android:background="?attr/dashboard_divider"/>
</FrameLayout>

View file

@ -6,33 +6,32 @@
android:id="@+id/searchListItemLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:paddingRight="24dp"
android:paddingLeft="24dp"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:background="?attr/selectableItemBackground"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/image"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:layout_marginRight="@dimen/content_padding"
android:scaleType="centerInside"
android:tint="?attr/default_icon_color"
osmand:srcCompat="@drawable/ic_action_flag"
android:layout_marginEnd="16dp" />
android:layout_marginEnd="@dimen/content_padding" />
<TextView
<net.osmand.plus.widgets.TextViewEx
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"
osmand:typeface="@string/font_roboto_regular"
tools:text="Add marker" />
</LinearLayout>

View file

@ -37,7 +37,8 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="72dp"
android:layout_height="wrap_content"
android:minHeight="72dp"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:background="?attr/actionModeBackground">
@ -64,7 +65,7 @@
android:textColorHint="@color/white_80_transparent"
android:textSize="@dimen/default_list_text_size_large"
android:hint="@string/shared_string_action_name"
android:maxLines="1"
android:maxLines="5"
android:layout_marginLeft="-4dp"
android:layout_marginRight="16dp"
android:layout_alignLeft="@+id/title"

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<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"
@ -12,66 +11,99 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/custom_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar"/>
<include layout="@layout/global_preferences_toolbar_with_switch" />
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:id="@+id/top_divider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/appbar"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="4dp"/>
<include layout="@layout/card_top_divider"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/top_divider"
android:clipToPadding="false"/>
<LinearLayout
android:id="@+id/bottomShadowView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/recycler_view"
android:background="?attr/activity_background_color"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
app:srcCompat="@drawable/bg_shadow_list_bottom"/>
<View
android:id="@+id/bottomMarginView"
android:layout_width="match_parent"
android:layout_height="16dp"/>
</LinearLayout>
android:layout_height="match_parent"
android:layout_below="@id/appbar"
android:clipToPadding="false" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
app:srcCompat="@drawable/ic_action_plus"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/content_padding"
android:contentDescription="@string/quick_action_new_action"
app:backgroundTint="?attr/color_dialog_buttons"
android:layout_alignParentEnd="true" />
app:srcCompat="@drawable/ic_action_plus" />
<LinearLayout
android:id="@+id/bottom_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<include layout="@layout/card_top_divider" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:orientation="horizontal">
<FrameLayout
android:id="@+id/select_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
android:layout_margin="@dimen/content_padding_half"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/content_padding_half">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_select_all"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_desc_text_size"
app:typeface="@string/font_roboto_medium" />
</FrameLayout>
<FrameLayout
android:id="@+id/delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/content_padding_half"
android:layout_gravity="center_vertical|end">
<FrameLayout
android:id="@+id/button_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/content_padding_half"
android:background="?attr/selectableItemBackground">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawablePadding="@dimen/content_padding_half"
android:gravity="center_vertical"
android:text="@string/shared_string_delete"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_desc_text_size"
app:drawableLeftCompat="@drawable/ic_action_delete_dark"
app:drawableTint="?attr/active_color_basic"
app:typeface="@string/font_roboto_medium" />
</FrameLayout>
</FrameLayout>
</FrameLayout>
</LinearLayout>
</RelativeLayout>

View file

@ -1,21 +1,23 @@
<?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="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:background="?attr/bg_color"
android:paddingStart="16dp"
android:paddingEnd="16dp">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/bg_color"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<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"/>
<net.osmand.plus.widgets.TextViewEx
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_list_text_size"
app:typeface="@string/font_roboto_medium"
tools:text="Screen 1" />
</FrameLayout>

View file

@ -1,92 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
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">
xmlns:osmand="http://schemas.android.com/apk/res-auto"
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="?attr/selectableItemBackground"
android:minHeight="60dp"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView
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"
osmand:srcCompat="@drawable/ic_action_item_move"
android:layout_marginEnd="4dp" />
<FrameLayout
android:layout_width="@dimen/acceptable_touch_radius"
android:layout_height="@dimen/acceptable_touch_radius"
android:layout_gravity="center">
<androidx.appcompat.widget.AppCompatImageView
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/default_icon_color"
osmand:srcCompat="@drawable/ic_action_flag"
android:layout_marginEnd="8dp" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/action_icon"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:src="@drawable/ic_action_remove"
tools:tint="@color/icon_color_default_light" />
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
tools:tint="@color/icon_color_default_light" />
</FrameLayout>
<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"
android:layout_marginStart="8dp">
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginStart="@dimen/content_padding"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/title"
<LinearLayout
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"
android:paddingEnd="16dp" />
android:minHeight="@dimen/setting_profile_item_height"
android:orientation="horizontal">
<TextView
android:id="@+id/subtitle"
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imageView"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/content_padding_half"
android:layout_marginRight="@dimen/content_padding_half"
android:scaleType="centerInside"
android:tint="?attr/default_icon_color"
osmand:srcCompat="@drawable/ic_action_flag" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_weight="1"
android:orientation="vertical"
android:paddingTop="@dimen/content_padding_half"
android:paddingBottom="@dimen/content_padding_half">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:paddingStart="0dp"
android:paddingLeft="0dp"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular"
tools:text="Add marker" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"
tools:text="Action 1" />
</LinearLayout>
<FrameLayout
android:id="@+id/move_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/content_padding_half"
android:layout_marginRight="@dimen/content_padding_half"
android:padding="@dimen/content_padding_small">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/move_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:tint="?attr/secondary_icon_color"
osmand:srcCompat="@drawable/ic_action_item_move" />
</FrameLayout>
</LinearLayout>
<View
android:id="@+id/item_divider"
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"/>
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
</LinearLayout>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/closeImageButton"
android:layout_width="56dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:background="?attr/selectableItemBackground"
android:scaleType="centerInside"
android:tint="?attr/secondary_icon_color"
android:contentDescription="@string/action_delete"
osmand:srcCompat="@drawable/ic_action_remove_dark"/>
</LinearLayout>
<View
android:id="@+id/divider"
android:id="@+id/long_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
android:background="?attr/dashboard_divider" />
</LinearLayout>

View file

@ -1054,12 +1054,10 @@
<string name="quick_action_poi_show">Sken %1$S</string>
<string name="quick_action_favorites_hide">Inurifen</string>
<string name="quick_action_favorites_show">Sken inurifen</string>
<string name="quick_actions_delete_text">Tebɣiḍ ad tekseḍ tigawt-agi\?</string>
<string name="quick_actions_delete">Kkes tigawt</string>
<string name="quick_action_edit_action">Tigawt</string>
<string name="quick_action_navigation_voice_on">Taɣect:</string>
<string name="quick_action_add_poi">Rnu</string>
<string name="quick_action_item_screen">Agdil</string>
<string name="upload_poi">Ali</string>
<string name="rendering_value_fine_name">Ṣeggem akken iwat anadi-ik</string>
<string name="gpx_add_track">Rnu ugar...</string>

View file

@ -11,6 +11,9 @@
Thx - Hardy
-->
<string name="delete_all_actions_message_q">Are you sure you want to irrevocably delete %d quick actions?</string>
<string name="shared_string_delete_all_q">Delete all?</string>
<string name="export_import_quick_actions_with_profiles_promo">You can Export or Import quick actions with application profiles.</string>
<string name="default_screen_timeout">System screen timeout</string>
<string name="tiles_storage_descr">Choose how downloaded tiles will be stored.</string>
<string name="expire_time_descr">Expiration time in minutes. Cached tiles will be reloaded after specified time.

View file

@ -730,13 +730,15 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
prevActivityIntent = null;
return;
}
if (getMapView().getLayerByClass(MapQuickActionLayer.class).onBackPressed()) {
return;
}
QuickActionListFragment quickActionListFragment = getQuickActionListFragment();
if (quickActionListFragment != null && quickActionListFragment.isVisible()
&& quickActionListFragment.fromDashboard()) {
this.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, null);
if (quickActionListFragment != null && quickActionListFragment.isVisible()) {
if (quickActionListFragment.fromDashboard()) {
this.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, null);
} else {
getMapView().getLayerByClass(MapQuickActionLayer.class).onBackPressed();
}
} else if (getMapView().getLayerByClass(MapQuickActionLayer.class).onBackPressed()) {
return;
}
ImportSettingsFragment importSettingsFragment = getImportSettingsFragment();
if (importSettingsFragment != null) {

View file

@ -1,25 +1,20 @@
package net.osmand.plus.quickaction;
import android.app.Dialog;
import android.os.Bundle;
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 androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.DialogFragment;
import androidx.recyclerview.widget.RecyclerView;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import java.util.List;
@ -27,160 +22,59 @@ import java.util.List;
* Created by rosty on 12/22/16.
*/
public class AddQuickActionDialog extends DialogFragment {
public class AddQuickActionDialog extends MenuBottomSheetDialogFragment {
public static final String TAG = AddQuickActionDialog.class.getSimpleName();
private boolean isLightContent;
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
OsmandApplication application = (OsmandApplication) getActivity().getApplication();
isLightContent = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
return new Dialog(UiUtilities.getThemedContext(getActivity(), !isLightContent, 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);
QuickActionRegistry quickActionRegistry = ((MapActivity) getActivity())
.getMyApplication()
.getQuickActionRegistry();
View root = UiUtilities.getInflater(getActivity(), !isLightContent).inflate(R.layout.quick_action_add_dialog, container, false);
Adapter adapter = new Adapter(quickActionRegistry.produceTypeActionsListWithHeaders());
TextView tvTitle = root.findViewById(R.id.tvTitle);
RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.recycler_view);
Button btnDismiss = (Button) root.findViewById(R.id.btnDismiss);
tvTitle.setTextColor(ContextCompat.getColor(getContext(),
isLightContent ? R.color.text_color_primary_light : R.color.text_color_primary_dark));
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<QuickActionType> 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<QuickActionType> 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));
public void createMenuItems(Bundle savedInstanceState) {
OsmandApplication app = requiredMyApplication();
final FragmentActivity activity = getActivity();
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
QuickActionRegistry quickActionRegistry = app.getQuickActionRegistry();
items.add(new TitleItem(getString(R.string.dialog_add_action_title)));
List<QuickActionType> actions = quickActionRegistry.produceTypeActionsListWithHeaders();
boolean firstHeader = true;
for (final QuickActionType action : actions) {
if (action.getId() == 0) {
View itemView = inflater.inflate(R.layout.quick_action_add_dialog_header,
null, false);
TextView title = itemView.findViewById(R.id.header);
View divider = itemView.findViewById(R.id.divider);
title.setText(action.getNameRes());
divider.setVisibility(firstHeader ? View.GONE : View.VISIBLE);
items.add(new BaseBottomSheetItem.Builder()
.setCustomView(itemView)
.create());
firstHeader = false;
} else {
return new ItemViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_add_dialog_item, parent, false));
View itemView = inflater.inflate(R.layout.quick_action_add_dialog_item,
null, false);
TextView title = itemView.findViewById(R.id.title);
ImageView icon = itemView.findViewById(R.id.image);
title.setText(action.getNameRes());
icon.setImageResource(action.getIconRes());
items.add(new BaseBottomSheetItem.Builder()
.setCustomView(itemView)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CreateEditActionDialog dialog =
CreateEditActionDialog.newInstance(action.getId());
dialog.show(activity.getSupportFragmentManager(),
CreateEditActionDialog.TAG);
dismiss();
}
})
.create());
}
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
final QuickActionType 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.title.setTextColor(ContextCompat.getColor(getContext(),
isLightContent ? R.color.text_color_primary_light : R.color.text_color_primary_dark));
itemHolder.icon.setImageResource(action.getIconRes());
itemHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CreateEditActionDialog dialog = CreateEditActionDialog.newInstance(action.getId());
dialog.show(getFragmentManager(), CreateEditActionDialog.TAG);
dismiss();
}
});
}
}
@Override
public int getItemCount() {
return data.size();
}
@Override
public int getItemViewType(int position) {
if (data.get(position).getId() == 0)
return HEADER;
return ITEM;
}
public static void showInstance(FragmentManager fm, boolean usedOnMap) {
AddQuickActionDialog fragment = new AddQuickActionDialog();
fragment.setUsedOnMap(usedOnMap);
fragment.show(fm, AddQuickActionDialog.TAG);
}
}

View file

@ -0,0 +1,101 @@
package net.osmand.plus.quickaction;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
public class ConfirmationBottomSheet extends MenuBottomSheetDialogFragment {
private static final String TITLE_KEY = "title";
private static final String MESSAGE_KEY = "message";
private static final String RIGHT_BUTTON_TITLE_KEY = "right_button_title";
private String title;
private CharSequence message;
private int rightButtonTitle;
public static final String TAG = ConfirmationBottomSheet.class.getSimpleName();
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
OsmandApplication app = requiredMyApplication();
if (savedInstanceState != null) {
title = savedInstanceState.getString(TITLE_KEY);
message = savedInstanceState.getCharSequence(MESSAGE_KEY);
rightButtonTitle = savedInstanceState.getInt(RIGHT_BUTTON_TITLE_KEY);
}
View view = super.onCreateView(inflater, parent, savedInstanceState);
UiUtilities.setupDialogButton(nightMode, rightButton,
UiUtilities.DialogButtonType.SECONDARY, rightButtonTitle);
TextView tvRightButton = rightButton.findViewById(R.id.button_text);
int colorDelete = ContextCompat.getColor(app, R.color.color_osm_edit_delete);
tvRightButton.setTextColor(colorDelete);
return view;
}
@Override
public void createMenuItems(Bundle savedInstanceState) {
items.add(new TitleItem(title));
items.add(new BottomSheetItemWithDescription.Builder()
.setDescription(message)
.setLayoutId(R.layout.bottom_sheet_item_preference_descr)
.create());
}
@Override
protected void onRightBottomButtonClick() {
Fragment target = getTargetFragment();
if (target instanceof OnConfirmButtonClickListener) {
((OnConfirmButtonClickListener) target).onConfirmButtonClick();
}
dismiss();
}
@Override
protected int getRightBottomButtonTextId() {
return rightButtonTitle;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(TITLE_KEY, title);
outState.putCharSequence(MESSAGE_KEY, message);
outState.putInt(RIGHT_BUTTON_TITLE_KEY, rightButtonTitle);
}
public static void showInstance(@NonNull FragmentManager fm,
Fragment targetFragment,
@NonNull String title,
@NonNull CharSequence message,
int rightButtonTitle,
boolean usedOnMap) {
ConfirmationBottomSheet f = new ConfirmationBottomSheet();
f.title = title;
f.message = message;
f.rightButtonTitle = rightButtonTitle;
f.setTargetFragment(targetFragment, 0);
f.setUsedOnMap(usedOnMap);
f.show(fm, ConfirmationBottomSheet.TAG);
}
public interface OnConfirmButtonClickListener {
void onConfirmButtonClick();
}
}

View file

@ -1,7 +1,6 @@
package net.osmand.plus.quickaction;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
@ -24,6 +23,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentActivity;
import net.osmand.AndroidUtils;
import net.osmand.CallbackWithObject;
@ -34,13 +34,14 @@ import net.osmand.plus.activities.MapActivity;
import java.util.List;
import static net.osmand.plus.quickaction.QuickActionListFragment.showConfirmActionDeleteDialog;
import static net.osmand.plus.quickaction.QuickActionListFragment.showConfirmDeleteAnActionBottomSheet;
/**
* Created by rosty on 12/27/16.
*/
public class CreateEditActionDialog extends DialogFragment implements CallbackWithObject<Object> {
public class CreateEditActionDialog extends DialogFragment
implements CallbackWithObject<Object>, ConfirmationBottomSheet.OnConfirmButtonClickListener {
public static final String TAG = CreateEditActionDialog.class.getSimpleName();
@ -181,18 +182,11 @@ public class CreateEditActionDialog extends DialogFragment implements CallbackWi
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Context ctx = getContext();
if (ctx != null) {
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
quickActionRegistry.deleteQuickAction(action);
quickActionRegistry.notifyUpdates();
dialog.dismiss();
dismiss();
}
};
showConfirmActionDeleteDialog(ctx, action, !isLightContent, listener);
FragmentActivity activity = getActivity();
if (activity != null) {
showConfirmDeleteAnActionBottomSheet(
activity, CreateEditActionDialog.this,
action, false);
}
return true;
}
@ -296,4 +290,11 @@ public class CreateEditActionDialog extends DialogFragment implements CallbackWi
}
return false;
}
@Override
public void onConfirmButtonClick() {
quickActionRegistry.deleteQuickAction(action);
quickActionRegistry.notifyUpdates();
dismiss();
}
}

View file

@ -24,9 +24,7 @@ public class NewAction extends QuickAction {
@Override
public void execute(MapActivity activity) {
AddQuickActionDialog dialog = new AddQuickActionDialog();
dialog.show(activity.getSupportFragmentManager(), AddQuickActionDialog.TAG);
AddQuickActionDialog.showInstance(activity.getSupportFragmentManager(), true);
}
@Override

View file

@ -14,7 +14,7 @@ import androidx.appcompat.text.AllCapsTransformationMethod;
import net.osmand.plus.R;
import net.osmand.plus.helpers.FontCache;
public class TextViewEx extends TextView {
public class TextViewEx extends androidx.appcompat.widget.AppCompatTextView {
public TextViewEx(Context context) {
super(context);
}
@ -31,13 +31,6 @@ public class TextViewEx extends TextView {
parseAttributes(this, attrs, defStyleAttr, 0);
}
@TargetApi(21)
public TextViewEx(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
parseAttributes(this, attrs, defStyleAttr, defStyleRes);
}
/*internal*/ static void parseAttributes(TextView target, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
if (attrs == null) {

View file

@ -27,11 +27,6 @@ public class TextViewExProgress extends TextViewEx {
initPaint();
}
public TextViewExProgress(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
initPaint();
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);