Fix #2694
This commit is contained in:
parent
9899c8de5e
commit
97aac265ac
4 changed files with 175 additions and 266 deletions
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/point_edit_layout"
|
||||
android:layout_width="366dp"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -10,43 +9,19 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/ctx_menu_info_view_bg"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||
android:background="?attr/pstsTabBackground"
|
||||
android:background="@color/osmand_orange"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:theme="?attr/toolbar_theme"
|
||||
app:contentInsetLeft="72dp"
|
||||
app:contentInsetStart="72dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/delete_button"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:background="@android:color/transparent"
|
||||
android:src="@drawable/ic_action_delete_dark"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ok_button"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:background="@android:color/transparent"
|
||||
android:src="@drawable/ic_action_done"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/save_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:background="@android:color/transparent"
|
||||
android:text="@string/shared_string_save"/>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<ScrollView
|
||||
|
@ -66,36 +41,10 @@
|
|||
android:id="@+id/title_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_point_editor_view"
|
||||
android:paddingTop="16dp"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/header_caption"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
tools:text="Point info"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_replace"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:textColor="?attr/contextMenuButtonColor"
|
||||
android:text="@string/update_existing"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -209,7 +158,10 @@
|
|||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="48dp"
|
||||
android:foreground="@drawable/bg_contextmenu_shadow"
|
||||
android:foregroundGravity="top|fill_horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/description_info_view"
|
||||
|
@ -266,4 +218,73 @@
|
|||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="bottom">
|
||||
|
||||
<View
|
||||
android:id="@+id/buttons_top_border"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/delete_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/shared_string_delete"
|
||||
android:textColor="?attr/contextMenuButtonColor"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/replace_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/update_existing"
|
||||
android:textColor="?attr/contextMenuButtonColor"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/shared_string_cancel"
|
||||
android:textColor="?attr/contextMenuButtonColor"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/save_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/shared_string_save"
|
||||
android:textColor="?attr/contextMenuButtonColor"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -11,54 +11,25 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/ctx_menu_info_view_bg"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||
android:background="@drawable/gradient_toolbar"
|
||||
android:background="@color/osmand_orange"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:theme="?attr/toolbar_theme"
|
||||
app:contentInsetLeft="72dp"
|
||||
app:contentInsetStart="72dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/delete_button"
|
||||
android:contentDescription="@string/shared_string_delete"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:background="@android:color/transparent"
|
||||
android:src="@drawable/ic_action_delete_dark"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ok_button"
|
||||
android:contentDescription="@string/shared_string_save"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:background="@android:color/transparent"
|
||||
android:src="@drawable/ic_action_done"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/save_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="right"
|
||||
android:background="@android:color/transparent"
|
||||
android:drawableLeft="@drawable/ic_action_done"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/shared_string_save"/>
|
||||
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/editor_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
|
@ -66,14 +37,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/editor_scroll_view_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="550dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/main_view"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -85,39 +48,13 @@
|
|||
android:id="@+id/title_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_point_editor_view"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/header_caption"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_weight="1"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="Point info"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_replace"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:text="@string/update_existing"
|
||||
android:textColor="?attr/contextMenuButtonColor"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
@ -231,13 +168,15 @@
|
|||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="48dp"
|
||||
android:foreground="@drawable/bg_contextmenu_shadow"
|
||||
android:foregroundGravity="top|fill_horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/description_info_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/ctx_menu_info_view_bg"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
@ -292,4 +231,72 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="bottom">
|
||||
|
||||
<View
|
||||
android:id="@+id/buttons_top_border"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/delete_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/shared_string_delete"
|
||||
android:textColor="?attr/contextMenuButtonColor"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/replace_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/update_existing"
|
||||
android:textColor="?attr/contextMenuButtonColor"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/shared_string_cancel"
|
||||
android:textColor="?attr/contextMenuButtonColor"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/save_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/shared_string_save"
|
||||
android:textColor="?attr/contextMenuButtonColor"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -52,9 +52,9 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (view != null && editor.isNew()) {
|
||||
Button btnReplace = (Button) view.findViewById(R.id.button_replace);
|
||||
btnReplace.setVisibility(View.VISIBLE);
|
||||
btnReplace.setOnClickListener(new View.OnClickListener() {
|
||||
Button replaceButton = (Button) view.findViewById(R.id.replace_button);
|
||||
replaceButton.setVisibility(View.VISIBLE);
|
||||
replaceButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bundle args = new Bundle();
|
||||
|
|
|
@ -15,33 +15,24 @@ import android.view.LayoutInflater;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadPoint;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
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.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.widgets.AutoCompleteTextViewEx;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public abstract class PointEditorFragment extends Fragment {
|
||||
|
||||
private View view;
|
||||
private int mainViewHeight;
|
||||
private EditText nameEdit;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
|
@ -49,38 +40,11 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
getActivity().findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
|
||||
|
||||
view = inflater.inflate(R.layout.point_editor_fragment, container, false);
|
||||
|
||||
getEditor().updateLandscapePortrait();
|
||||
getEditor().updateNightMode();
|
||||
|
||||
if (getEditor().isLandscapeLayout()) {
|
||||
AndroidUtils.setBackground(view.getContext(), view, !getEditor().isLight(),
|
||||
R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(view.getContext(), view.findViewById(R.id.title_view), !getEditor().isLight(),
|
||||
R.drawable.bg_point_editor_view_light, R.drawable.bg_point_editor_view_dark);
|
||||
}
|
||||
|
||||
View editorScrollView = view.findViewById(R.id.editor_scroll_view);
|
||||
if (editorScrollView != null && getEditor().isLandscapeLayout()) {
|
||||
if (getEditor().isLight()) {
|
||||
editorScrollView.setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_light));
|
||||
} else {
|
||||
editorScrollView.setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
|
||||
}
|
||||
}
|
||||
View descriptionInfoView = view.findViewById(R.id.description_info_view);
|
||||
if (descriptionInfoView != null) {
|
||||
if (getEditor().isLight()) {
|
||||
descriptionInfoView.setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_light));
|
||||
} else {
|
||||
descriptionInfoView.setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
|
||||
}
|
||||
}
|
||||
|
||||
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(getToolbarTitle());
|
||||
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha));
|
||||
|
@ -93,17 +57,7 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
View scrollViewHeader = view.findViewById(R.id.editor_scroll_view_header);
|
||||
if (scrollViewHeader != null) {
|
||||
scrollViewHeader.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Button saveButton = (Button) toolbar.findViewById(R.id.save_button);
|
||||
Button saveButton = (Button) view.findViewById(R.id.save_button);
|
||||
saveButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -111,15 +65,15 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
ImageButton okButton = (ImageButton) toolbar.findViewById(R.id.ok_button);
|
||||
okButton.setOnClickListener(new View.OnClickListener() {
|
||||
Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
savePressed();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
ImageButton deleteButton = (ImageButton) toolbar.findViewById(R.id.delete_button);
|
||||
Button deleteButton = (Button) view.findViewById(R.id.delete_button);
|
||||
deleteButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -128,15 +82,11 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
});
|
||||
|
||||
if (getEditor().isNew()) {
|
||||
okButton.setVisibility(View.GONE);
|
||||
deleteButton.setVisibility(View.GONE);
|
||||
} else {
|
||||
saveButton.setVisibility(View.GONE);
|
||||
deleteButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
TextView headerCaption = (TextView) view.findViewById(R.id.header_caption);
|
||||
AndroidUtils.setTextPrimaryColor(view.getContext(), headerCaption, !getEditor().isLight());
|
||||
headerCaption.setText(getHeaderCaption());
|
||||
TextView nameCaption = (TextView) view.findViewById(R.id.name_caption);
|
||||
AndroidUtils.setTextSecondaryColor(view.getContext(), nameCaption, !getEditor().isLight());
|
||||
nameCaption.setText(getNameCaption());
|
||||
|
@ -165,13 +115,23 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
EditText descriptionEdit = (EditText) view.findViewById(R.id.description_edit);
|
||||
final EditText descriptionEdit = (EditText) view.findViewById(R.id.description_edit);
|
||||
AndroidUtils.setTextPrimaryColor(view.getContext(), descriptionEdit, !getEditor().isLight());
|
||||
AndroidUtils.setHintTextSecondaryColor(view.getContext(), descriptionEdit, !getEditor().isLight());
|
||||
if (getDescriptionInitValue() != null) {
|
||||
descriptionEdit.setText(getDescriptionInitValue());
|
||||
}
|
||||
|
||||
view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
if (descriptionEdit.isFocused()) {
|
||||
ScrollView scrollView = (ScrollView) view.findViewById(R.id.editor_scroll_view);
|
||||
scrollView.scrollTo(0, bottom);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ImageView nameImage = (ImageView) view.findViewById(R.id.name_image);
|
||||
nameImage.setImageDrawable(getNameIcon());
|
||||
ImageView categoryImage = (ImageView) view.findViewById(R.id.category_image);
|
||||
|
@ -181,7 +141,6 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
descriptionImage.setImageDrawable(getRowIcon(R.drawable.ic_action_note_dark));
|
||||
|
||||
if (getMyApplication().accessibilityEnabled()) {
|
||||
headerCaption.setFocusable(true);
|
||||
nameCaption.setFocusable(true);
|
||||
categoryCaption.setFocusable(true);
|
||||
nameEdit.setHint(R.string.access_hint_enter_name);
|
||||
|
@ -189,8 +148,6 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
descriptionEdit.setHint(R.string.access_hint_enter_description);
|
||||
}
|
||||
|
||||
runLayoutListener();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -229,82 +186,6 @@ public abstract class PointEditorFragment extends Fragment {
|
|||
save(false);
|
||||
}
|
||||
super.onDestroyView();
|
||||
getActivity().findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void adjustMapPosition(boolean animated) {
|
||||
OsmandMapTileView map = getMapActivity().getMapView();
|
||||
MapContextMenu menu = getMapActivity().getContextMenu();
|
||||
double markerLat = menu.getLatLon().getLatitude();
|
||||
double markerLon = menu.getLatLon().getLongitude();
|
||||
|
||||
RotatedTileBox box = map.getCurrentRotatedTileBox();
|
||||
int origMarkerY = (int)box.getPixYFromLatLon(markerLat, markerLon);
|
||||
|
||||
int markerPaddingPx = AndroidUtils.dpToPx(getMapActivity(), MapContextMenuFragment.MARKER_PADDING_DP);
|
||||
|
||||
int y = view.getHeight() - mainViewHeight;
|
||||
|
||||
if (!menu.isLandscapeLayout()) {
|
||||
int markerY = (int)box.getPixYFromLatLon(markerLat, markerLon);
|
||||
if (markerY + markerPaddingPx > y || markerY < origMarkerY) {
|
||||
int dy = markerY - (y - markerPaddingPx);
|
||||
if (markerY - dy <= origMarkerY) {
|
||||
QuadPoint cp = box.getCenterPixelPoint();
|
||||
LatLon latlon = box.getLatLonFromPixel(cp.x + 0, cp.y + dy);
|
||||
double destLat = latlon.getLatitude();
|
||||
double destLon = latlon.getLongitude();
|
||||
if (animated) {
|
||||
AnimateDraggingMapThread thread = map.getAnimatedDraggingThread();
|
||||
int fZoom = map.getZoom();
|
||||
double flat = destLat;
|
||||
double flon = destLon;
|
||||
|
||||
RotatedTileBox cbox = map.getCurrentRotatedTileBox().copy();
|
||||
cbox.setCenterLocation(0.5f, 0.5f);
|
||||
cbox.setLatLonCenter(flat, flon);
|
||||
flat = cbox.getLatFromPixel(cbox.getPixWidth() / 2, cbox.getPixHeight() / 2);
|
||||
flon = cbox.getLonFromPixel(cbox.getPixWidth() / 2, cbox.getPixHeight() / 2);
|
||||
|
||||
thread.startMoving(flat, flon, fZoom, true);
|
||||
} else {
|
||||
map.setLatLon(destLat, destLon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void runLayoutListener() {
|
||||
ViewTreeObserver vto = view.getViewTreeObserver();
|
||||
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
mainViewHeight = view.findViewById(R.id.main_view).getHeight();
|
||||
|
||||
ViewTreeObserver obs = view.getViewTreeObserver();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
obs.removeOnGlobalLayoutListener(this);
|
||||
} else {
|
||||
obs.removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
updateScrollHeaderHeight();
|
||||
adjustMapPosition(true);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void updateScrollHeaderHeight() {
|
||||
View scrollViewHeader = view.findViewById(R.id.editor_scroll_view_header);
|
||||
if (scrollViewHeader != null) {
|
||||
View scrollView = view.findViewById(R.id.editor_scroll_view);
|
||||
int headerHeight = scrollView.getHeight() - mainViewHeight;
|
||||
ViewGroup.LayoutParams p = scrollViewHeader.getLayoutParams();
|
||||
p.height = headerHeight;
|
||||
scrollViewHeader.setLayoutParams(p);
|
||||
}
|
||||
}
|
||||
|
||||
private void hideKeyboard() {
|
||||
|
|
Loading…
Reference in a new issue