Update UI of Description in Overview Tab in GPX context menu
This commit is contained in:
parent
92217cba9f
commit
b249fdbab6
6 changed files with 262 additions and 118 deletions
|
@ -42,25 +42,31 @@
|
||||||
android:textSize="@dimen/dialog_header_text_size"
|
android:textSize="@dimen/dialog_header_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium" />
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<FrameLayout
|
||||||
android:id="@+id/btn_save"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="@dimen/content_padding_half"
|
android:layout_marginRight="@dimen/content_padding_half"
|
||||||
android:layout_marginEnd="@dimen/content_padding_half"
|
android:layout_marginEnd="@dimen/content_padding_half"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:background="@drawable/btn_border_active"
|
android:background="@drawable/btn_border_active">
|
||||||
android:paddingStart="@dimen/content_padding"
|
|
||||||
android:paddingLeft="@dimen/content_padding"
|
|
||||||
android:paddingTop="@dimen/content_padding_half"
|
|
||||||
android:paddingRight="@dimen/content_padding"
|
|
||||||
android:paddingEnd="@dimen/content_padding"
|
|
||||||
android:paddingBottom="@dimen/content_padding_half"
|
|
||||||
android:text="@string/shared_string_save"
|
|
||||||
android:textColor="?attr/active_color_basic"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium" />
|
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/btn_save"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:paddingStart="@dimen/content_padding"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingTop="@dimen/content_padding_half"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:paddingEnd="@dimen/content_padding"
|
||||||
|
android:paddingBottom="@dimen/content_padding_half"
|
||||||
|
android:text="@string/shared_string_save"
|
||||||
|
android:textColor="?attr/active_color_basic"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -69,17 +75,26 @@
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="?attr/divider_color" />
|
android:background="?attr/divider_color" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.EditTextEx
|
<ScrollView
|
||||||
android:id="@+id/description"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent">
|
||||||
android:layout_margin="@dimen/content_padding"
|
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
<net.osmand.plus.widgets.EditTextEx
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:id="@+id/description"
|
||||||
android:background="?attr/card_and_list_background_basic"
|
android:layout_width="match_parent"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:layout_marginStart="@dimen/content_padding"
|
||||||
osmand:typeface="@string/font_roboto_regular"
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
tools:text="Amsterdam is the Netherlands' capital and financial, cultural and creative centre with more than 850,000 inhabitants. Amsterdam is known for the canals that criss-cross the city, its impressive architecture and more than 1,500 bridges. The city has a heritage dating back to the Dutch Golden Age in the 17th century as well as a diverse art scene and a bustling nightlife." />
|
android:layout_marginTop="@dimen/content_padding_half"
|
||||||
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
|
android:layout_marginBottom="@dimen/content_padding_half"
|
||||||
|
android:background="?attr/card_and_list_background_basic"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_regular"
|
||||||
|
tools:text="Amsterdam is the Netherlands' capital and financial, cultural and creative centre with more than 850,000 inhabitants. Amsterdam is known for the canals that criss-cross the city, its impressive architecture and more than 1,500 bridges. The city has a heritage dating back to the Dutch Golden Age in the 17th century as well as a diverse art scene and a bustling nightlife." />
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -56,32 +56,40 @@
|
||||||
android:id="@+id/divider"
|
android:id="@+id/divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="?attr/divider_color"
|
android:background="?attr/ctx_menu_info_divider"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible"/>
|
tools:visibility="visible"/>
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<FrameLayout
|
||||||
android:id="@+id/btn_edit"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
android:layout_marginStart="@dimen/content_padding"
|
android:layout_marginStart="@dimen/content_padding"
|
||||||
android:layout_marginTop="@dimen/context_menu_padding_margin_small"
|
android:layout_marginTop="@dimen/context_menu_padding_margin_small"
|
||||||
android:layout_marginBottom="@dimen/context_menu_padding_margin_small"
|
android:layout_marginBottom="@dimen/context_menu_padding_margin_small"
|
||||||
android:gravity="center_vertical"
|
android:background="@drawable/rounded_background_3dp">
|
||||||
android:padding="@dimen/context_menu_padding_margin_small"
|
|
||||||
android:paddingStart="@dimen/context_menu_padding_margin_small"
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:paddingEnd="@dimen/context_menu_padding_margin_small"
|
android:id="@+id/btn_edit"
|
||||||
android:drawablePadding="@dimen/list_content_padding_large"
|
android:layout_width="wrap_content"
|
||||||
osmand:drawableLeftCompat="@drawable/ic_action_edit_dark"
|
android:layout_height="wrap_content"
|
||||||
osmand:drawableStartCompat="@drawable/ic_action_edit_dark"
|
android:gravity="center_vertical"
|
||||||
osmand:drawableTint="?attr/active_color_basic"
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
android:visibility="gone"
|
android:padding="@dimen/context_menu_padding_margin_small"
|
||||||
android:text="@string/shared_string_edit"
|
android:paddingStart="@dimen/context_menu_padding_margin_small"
|
||||||
android:textColor="?attr/active_color_basic"
|
android:paddingEnd="@dimen/context_menu_padding_margin_small"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:drawablePadding="@dimen/list_content_padding_large"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
osmand:drawableLeftCompat="@drawable/ic_action_edit_dark"
|
||||||
tools:visibility="visible" />
|
osmand:drawableStartCompat="@drawable/ic_action_edit_dark"
|
||||||
|
osmand:drawableTint="?attr/active_color_basic"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:text="@string/shared_string_edit"
|
||||||
|
android:textColor="?attr/active_color_basic"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/bottom_empty_space"
|
android:id="@+id/bottom_empty_space"
|
||||||
|
|
|
@ -40,69 +40,119 @@
|
||||||
tools:visibility="visible"
|
tools:visibility="visible"
|
||||||
tools:src="@drawable/img_help_announcement_time_day"/>
|
tools:src="@drawable/img_help_announcement_time_day"/>
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<LinearLayout
|
||||||
android:id="@+id/description"
|
android:id="@id/description_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/content_padding"
|
android:orientation="vertical">
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
|
||||||
android:layout_marginTop="@dimen/context_menu_padding_margin_small"
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:id="@+id/description"
|
||||||
android:layout_marginEnd="@dimen/content_padding"
|
android:layout_width="match_parent"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:layout_marginStart="@dimen/content_padding"
|
||||||
android:lineSpacingMultiplier="1.1"
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
osmand:typeface="@string/font_roboto_regular"
|
android:layout_marginTop="@dimen/context_menu_padding_margin_small"
|
||||||
tools:text="Amsterdam is the Netherlands' capital and financial, cultural and creative centre with more than 850,000 inhabitants. Amsterdam is known for the canals that criss-cross the city, its impressive architecture and more than 1,500 bridges. The city has a heritage dating back to the Dutch Golden Age in the 17th century as well as a diverse art scene and a bustling nightlife."/>
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
android:lineSpacingMultiplier="1.1"
|
||||||
|
osmand:typeface="@string/font_roboto_regular"
|
||||||
|
tools:text="Amsterdam is the Netherlands' capital and financial, cultural and creative centre with more than 850,000 inhabitants. Amsterdam is known for the canals that criss-cross the city, its impressive architecture and more than 1,500 bridges. The city has a heritage dating back to the Dutch Golden Age in the 17th century as well as a diverse art scene and a bustling nightlife."/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/context_menu_padding_margin_small"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/context_menu_padding_margin_small"
|
||||||
|
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
|
||||||
|
android:background="@drawable/rounded_background_3dp">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/btn_read_full"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:padding="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:paddingStart="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:paddingEnd="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
osmand:drawableStartCompat="@drawable/ic_action_read_article"
|
||||||
|
osmand:drawableLeftCompat="@drawable/ic_action_read_article"
|
||||||
|
osmand:drawableTint="?attr/wikivoyage_active_color"
|
||||||
|
android:text="@string/context_menu_read_full"
|
||||||
|
android:textColor="?attr/wikivoyage_active_color"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||||
|
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:background="@drawable/rounded_background_3dp">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/btn_edit"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:padding="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:paddingStart="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:paddingEnd="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
osmand:drawableRightCompat="@drawable/ic_action_edit_dark"
|
||||||
|
osmand:drawableEndCompat="@drawable/ic_action_edit_dark"
|
||||||
|
osmand:drawableTint="?attr/wikivoyage_active_color"
|
||||||
|
android:text="@string/shared_string_edit"
|
||||||
|
android:textColor="?attr/wikivoyage_active_color"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/btn_add"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/context_menu_padding_margin_small"
|
android:layout_marginStart="@dimen/card_padding"
|
||||||
android:layout_marginBottom="@dimen/context_menu_padding_margin_small"
|
android:layout_marginLeft="@dimen/card_padding"
|
||||||
android:orientation="horizontal">
|
android:layout_marginTop="@dimen/content_padding"
|
||||||
|
android:background="@drawable/rounded_background_3dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/btn_read_full"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/context_menu_padding_margin_small"
|
|
||||||
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
|
|
||||||
android:layout_gravity="start"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:paddingStart="@dimen/bottom_sheet_content_padding_small"
|
|
||||||
android:paddingLeft="@dimen/bottom_sheet_content_padding_small"
|
|
||||||
android:paddingTop="@dimen/bottom_sheet_content_padding_small"
|
|
||||||
android:paddingRight="@dimen/bottom_sheet_content_padding_small"
|
|
||||||
android:paddingEnd="@dimen/bottom_sheet_content_padding_small"
|
|
||||||
android:paddingBottom="@dimen/bottom_sheet_content_padding_small"
|
|
||||||
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
|
||||||
osmand:drawableStartCompat="@drawable/ic_action_read_article"
|
|
||||||
osmand:drawableLeftCompat="@drawable/ic_action_read_article"
|
|
||||||
osmand:drawableTint="?attr/wikivoyage_active_color"
|
|
||||||
android:text="@string/context_menu_read_full"
|
|
||||||
android:textColor="?attr/wikivoyage_active_color"
|
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium" />
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/btn_edit"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
|
||||||
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
android:padding="@dimen/bottom_sheet_content_padding_small"
|
android:padding="@dimen/bottom_sheet_content_padding_small"
|
||||||
android:paddingStart="@dimen/bottom_sheet_content_padding_small"
|
android:paddingStart="@dimen/bottom_sheet_content_padding_small"
|
||||||
android:paddingEnd="@dimen/bottom_sheet_content_padding_small"
|
android:paddingEnd="@dimen/bottom_sheet_content_padding_small"
|
||||||
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
android:drawablePadding="@dimen/dialog_button_height"
|
||||||
osmand:drawableRightCompat="@drawable/ic_action_edit_dark"
|
osmand:drawableStartCompat="@drawable/ic_action_add"
|
||||||
osmand:drawableEndCompat="@drawable/ic_action_edit_dark"
|
osmand:drawableLeftCompat="@drawable/ic_action_add"
|
||||||
osmand:drawableTint="?attr/wikivoyage_active_color"
|
osmand:drawableTint="?attr/wikivoyage_active_color"
|
||||||
android:text="@string/shared_string_edit"
|
android:text="@string/add_description"
|
||||||
android:textColor="?attr/wikivoyage_active_color"
|
android:textColor="?attr/wikivoyage_active_color"
|
||||||
android:textSize="@dimen/default_desc_text_size"
|
android:textSize="@dimen/default_list_text_size"
|
||||||
osmand:typeface="@string/font_roboto_medium" />
|
osmand:typeface="@string/font_roboto_medium" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
@ -110,6 +160,7 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/context_menu_padding_margin_small"
|
||||||
android:background="?attr/activity_background_basic">
|
android:background="?attr/activity_background_basic">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package net.osmand.plus.track;
|
package net.osmand.plus.track;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import androidx.annotation.NonNull;
|
import android.widget.LinearLayout;
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
|
||||||
|
|
||||||
import com.squareup.picasso.Callback;
|
import com.squareup.picasso.Callback;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
import com.squareup.picasso.RequestCreator;
|
import com.squareup.picasso.RequestCreator;
|
||||||
|
|
||||||
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.PicassoUtils;
|
import net.osmand.PicassoUtils;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -19,6 +19,9 @@ import net.osmand.plus.widgets.TextViewEx;
|
||||||
import net.osmand.plus.wikipedia.WikiArticleHelper;
|
import net.osmand.plus.wikipedia.WikiArticleHelper;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
|
|
||||||
import static net.osmand.plus.myplaces.TrackActivityFragmentAdapter.getMetadataImageLink;
|
import static net.osmand.plus.myplaces.TrackActivityFragmentAdapter.getMetadataImageLink;
|
||||||
|
|
||||||
public class DescriptionCard extends BaseCard {
|
public class DescriptionCard extends BaseCard {
|
||||||
|
@ -37,11 +40,8 @@ public class DescriptionCard extends BaseCard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateContent() {
|
protected void updateContent() {
|
||||||
if (gpxFile.metadata == null || gpxFile.metadata.getDescription() == null) {
|
if (gpxFile.metadata == null) {
|
||||||
AndroidUiHelper.updateVisibility(view, false);
|
gpxFile.metadata = new GPXUtilities.Metadata();
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
AndroidUiHelper.updateVisibility(view, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final String title = gpxFile.metadata.getArticleTitle();
|
final String title = gpxFile.metadata.getArticleTitle();
|
||||||
|
@ -50,6 +50,31 @@ public class DescriptionCard extends BaseCard {
|
||||||
|
|
||||||
setupImage(imageUrl);
|
setupImage(imageUrl);
|
||||||
|
|
||||||
|
if (descriptionHtml == null || Algorithms.isEmpty(descriptionHtml.trim())) {
|
||||||
|
showAddBtn();
|
||||||
|
} else {
|
||||||
|
showDescription(title, imageUrl, descriptionHtml);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAddBtn() {
|
||||||
|
LinearLayout descriptionContainer = view.findViewById(R.id.description_container);
|
||||||
|
FrameLayout addBtn = view.findViewById(R.id.btn_add);
|
||||||
|
|
||||||
|
addBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
GpxEditDescriptionDialogFragment.showInstance(getMapActivity(), "", null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AndroidUiHelper.updateVisibility(descriptionContainer, false);
|
||||||
|
AndroidUiHelper.updateVisibility(addBtn, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showDescription(final String title, final String imageUrl, final String descriptionHtml) {
|
||||||
|
LinearLayout descriptionContainer = view.findViewById(R.id.description_container);
|
||||||
|
AndroidUiHelper.updateVisibility(descriptionContainer, true);
|
||||||
|
|
||||||
TextViewEx tvDescription = view.findViewById(R.id.description);
|
TextViewEx tvDescription = view.findViewById(R.id.description);
|
||||||
tvDescription.setText(getFirstParagraph(descriptionHtml));
|
tvDescription.setText(getFirstParagraph(descriptionHtml));
|
||||||
|
|
||||||
|
@ -60,6 +85,7 @@ public class DescriptionCard extends BaseCard {
|
||||||
GpxReadDescriptionDialogFragment.showInstance(mapActivity, title, imageUrl, descriptionHtml);
|
GpxReadDescriptionDialogFragment.showInstance(mapActivity, title, imageUrl, descriptionHtml);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
TextViewEx editBtn = view.findViewById(R.id.btn_edit);
|
TextViewEx editBtn = view.findViewById(R.id.btn_edit);
|
||||||
editBtn.setOnClickListener(new View.OnClickListener() {
|
editBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package net.osmand.plus.track;
|
package net.osmand.plus.track;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -7,12 +9,6 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
|
|
||||||
import net.osmand.GPXUtilities.GPXFile;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -22,12 +18,18 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
import net.osmand.plus.base.BaseOsmAndDialogFragment;
|
||||||
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
|
import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener;
|
||||||
import net.osmand.plus.widgets.EditTextEx;
|
import net.osmand.plus.widgets.EditTextEx;
|
||||||
import net.osmand.util.Algorithms;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
|
|
||||||
public static final String TAG = GpxEditDescriptionDialogFragment.class.getSimpleName();
|
public static final String TAG = GpxEditDescriptionDialogFragment.class.getSimpleName();
|
||||||
|
@ -37,6 +39,8 @@ public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
|
|
||||||
private EditTextEx editableHtml;
|
private EditTextEx editableHtml;
|
||||||
|
|
||||||
|
private String htmlCode;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
@ -46,11 +50,16 @@ public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
View view = themedInflater.inflate(R.layout.dialog_edit_gpx_description, container, false);
|
View view = themedInflater.inflate(R.layout.dialog_edit_gpx_description, container, false);
|
||||||
|
|
||||||
editableHtml = view.findViewById(R.id.description);
|
editableHtml = view.findViewById(R.id.description);
|
||||||
|
editableHtml.requestFocus();
|
||||||
|
|
||||||
view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
dismiss();
|
if (shouldClose()) {
|
||||||
|
dismiss();
|
||||||
|
} else {
|
||||||
|
showDismissDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -58,7 +67,7 @@ public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Editable editable = editableHtml.getText();
|
Editable editable = editableHtml.getText();
|
||||||
if (!Algorithms.isEmpty(editable) && !saveGpx(editable.toString())) {
|
if (editable != null && !saveGpx(editable.toString())) {
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,15 +75,43 @@ public class GpxEditDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
|
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
String html = args.getString(CONTENT_KEY);
|
htmlCode = args.getString(CONTENT_KEY);
|
||||||
if (html != null) {
|
if (htmlCode != null) {
|
||||||
editableHtml.setText(html);
|
editableHtml.setText(htmlCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private boolean shouldClose() {
|
||||||
|
Editable editable = editableHtml.getText();
|
||||||
|
if (htmlCode == null || editable == null || editable.toString() == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (htmlCode.equals(editable.toString())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showDismissDialog() {
|
||||||
|
Context themedContext = UiUtilities.getThemedContext(getMapActivity(), isNightMode(false));
|
||||||
|
AlertDialog.Builder dismissDialog = new AlertDialog.Builder(themedContext);
|
||||||
|
dismissDialog.setTitle(getString(R.string.shared_string_dismiss));
|
||||||
|
dismissDialog.setMessage(getString(R.string.exit_without_saving));
|
||||||
|
dismissDialog.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
dismissDialog.setPositiveButton(R.string.shared_string_exit, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dismissDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean saveGpx(final String html) {
|
private boolean saveGpx(final String html) {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity == null || mapActivity.getTrackMenuFragment() == null) {
|
if (mapActivity == null || mapActivity.getTrackMenuFragment() == null) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.track;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -15,14 +16,6 @@ import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
|
|
||||||
import com.squareup.picasso.Callback;
|
import com.squareup.picasso.Callback;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
import com.squareup.picasso.RequestCreator;
|
import com.squareup.picasso.RequestCreator;
|
||||||
|
@ -39,6 +32,14 @@ import net.osmand.plus.widgets.WebViewEx;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
|
|
||||||
public static final String TAG = GpxReadDescriptionDialogFragment.class.getSimpleName();
|
public static final String TAG = GpxReadDescriptionDialogFragment.class.getSimpleName();
|
||||||
|
@ -181,10 +182,16 @@ public class GpxReadDescriptionDialogFragment extends BaseOsmAndDialogFragment {
|
||||||
|
|
||||||
private void setupWebView(final View view) {
|
private void setupWebView(final View view) {
|
||||||
webView = view.findViewById(R.id.content);
|
webView = view.findViewById(R.id.content);
|
||||||
|
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||||
|
if (Build.VERSION.SDK_INT >= 19) {
|
||||||
|
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||||
|
}
|
||||||
webView.setScrollbarFadingEnabled(true);
|
webView.setScrollbarFadingEnabled(true);
|
||||||
webView.setVerticalScrollBarEnabled(false);
|
webView.setVerticalScrollBarEnabled(false);
|
||||||
webView.setBackgroundColor(Color.TRANSPARENT);
|
webView.setBackgroundColor(Color.TRANSPARENT);
|
||||||
webView.setLayerType(WebView.LAYER_TYPE_HARDWARE, null);
|
|
||||||
webView.getSettings().setTextZoom((int) (getResources().getConfiguration().fontScale * 100f));
|
webView.getSettings().setTextZoom((int) (getResources().getConfiguration().fontScale * 100f));
|
||||||
webView.getSettings().setDomStorageEnabled(true);
|
webView.getSettings().setDomStorageEnabled(true);
|
||||||
webView.getSettings().setLoadWithOverviewMode(true);
|
webView.getSettings().setLoadWithOverviewMode(true);
|
||||||
|
|
Loading…
Reference in a new issue