Fix buttons above keyboard
This commit is contained in:
parent
6dc5f77ab3
commit
6e78494e37
3 changed files with 79 additions and 4 deletions
|
@ -4,6 +4,7 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
@ -18,8 +19,7 @@
|
||||||
android:paddingRight="@dimen/content_padding"
|
android:paddingRight="@dimen/content_padding"
|
||||||
android:paddingTop="@dimen/content_padding_small"
|
android:paddingTop="@dimen/content_padding_small"
|
||||||
android:paddingBottom="@dimen/content_padding_small"
|
android:paddingBottom="@dimen/content_padding_small"
|
||||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
android:textAppearance="@style/TextAppearance.ListItemCategoryTitle"
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:text="Some Title"
|
tools:text="Some Title"
|
||||||
android:paddingStart="@dimen/content_padding"
|
android:paddingStart="@dimen/content_padding"
|
||||||
android:paddingEnd="@dimen/content_padding" />
|
android:paddingEnd="@dimen/content_padding" />
|
||||||
|
@ -101,6 +101,7 @@
|
||||||
android:paddingRight="@dimen/content_padding_small"
|
android:paddingRight="@dimen/content_padding_small"
|
||||||
android:paddingEnd="@dimen/content_padding_small"
|
android:paddingEnd="@dimen/content_padding_small"
|
||||||
android:paddingLeft="@dimen/content_padding_small"
|
android:paddingLeft="@dimen/content_padding_small"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
android:text="@string/shared_string_meters" />
|
android:text="@string/shared_string_meters" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
@ -120,4 +121,33 @@
|
||||||
tools:itemCount="3"
|
tools:itemCount="3"
|
||||||
tools:listitem="@layout/point_editor_icon_category_item" />
|
tools:listitem="@layout/point_editor_icon_category_item" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/buttons_container_scroll"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/dialog_button_ex_height"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:paddingEnd="@dimen/content_padding"
|
||||||
|
android:paddingStart="@dimen/content_padding">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/dismiss_button"
|
||||||
|
layout="@layout/bottom_sheet_dialog_button" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/buttons_divider"
|
||||||
|
android:layout_width="@dimen/content_padding"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/right_bottom_button"
|
||||||
|
layout="@layout/bottom_sheet_dialog_button"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -106,12 +106,16 @@
|
||||||
<item name="colorPrimary">@color/active_color_primary_light</item>
|
<item name="colorPrimary">@color/active_color_primary_light</item>
|
||||||
<item name="dashboard_divider">@color/divider_color_light</item>
|
<item name="dashboard_divider">@color/divider_color_light</item>
|
||||||
<item name="divider_color">@color/divider_color</item>
|
<item name="divider_color">@color/divider_color</item>
|
||||||
|
<item name="android:textColorPrimary">@color/text_color_primary_light</item>
|
||||||
|
<item name="android:textColorSecondary">@color/text_color_secondary_light</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="OsmandMaterialDarkTheme" parent="Theme.MaterialComponents">
|
<style name="OsmandMaterialDarkTheme" parent="Theme.MaterialComponents">
|
||||||
<item name="colorPrimary">@color/active_color_primary_dark</item>
|
<item name="colorPrimary">@color/active_color_primary_dark</item>
|
||||||
<item name="dashboard_divider">@color/divider_color_dark</item>
|
<item name="dashboard_divider">@color/divider_color_dark</item>
|
||||||
<item name="divider_color">@color/divider_color_dark</item>
|
<item name="divider_color">@color/divider_color_dark</item>
|
||||||
|
<item name="android:textColorPrimary">@color/text_color_primary_dark</item>
|
||||||
|
<item name="android:textColorSecondary">@color/text_color_secondary_dark</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- MaterialComponents Widgets override -->
|
<!-- MaterialComponents Widgets override -->
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package net.osmand.plus.settings.bottomsheets;
|
package net.osmand.plus.settings.bottomsheets;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
@ -113,18 +116,56 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet {
|
||||||
currentValue = preference.getValueFromEntries(selectedItem);
|
currentValue = preference.getValueFromEntries(selectedItem);
|
||||||
String currentValueStr = currentValue == 0.0f ? "" : String.valueOf(currentValue + 0.01f);
|
String currentValueStr = currentValue == 0.0f ? "" : String.valueOf(currentValue + 0.01f);
|
||||||
text.setText(currentValueStr);
|
text.setText(currentValueStr);
|
||||||
text.requestFocus();
|
|
||||||
text.setSelection(text.getText().length());
|
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
adapter.setSelectedItem(selectedItem);
|
adapter.setSelectedItem(selectedItem);
|
||||||
|
|
||||||
|
rightButton = mainView.findViewById(R.id.right_bottom_button);
|
||||||
|
UiUtilities.setupDialogButton(nightMode, rightButton, getRightBottomButtonType(), getRightBottomButtonTextId());
|
||||||
|
rightButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
onRightBottomButtonClick();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return new BaseBottomSheetItem.Builder()
|
return new BaseBottomSheetItem.Builder()
|
||||||
.setCustomView(mainView)
|
.setCustomView(mainView)
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
final ScrollView scrollView = view.findViewById(R.id.scroll_view);
|
||||||
|
final EditText text = view.findViewById(R.id.text_edit);
|
||||||
|
text.clearFocus();
|
||||||
|
text.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
text.onTouchEvent(event);
|
||||||
|
text.setSelection(text.getText().length());
|
||||||
|
scrollView.postDelayed(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
View lastChild = scrollView.getChildAt(scrollView.getChildCount() - 1);
|
||||||
|
int bottom = lastChild.getBottom() + scrollView.getPaddingBottom();
|
||||||
|
int delta = bottom - (scrollView.getScrollY() + scrollView.getHeight());
|
||||||
|
scrollView.scrollBy(0, delta);
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean hideButtonsContainer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getRightBottomButtonTextId() {
|
protected int getRightBottomButtonTextId() {
|
||||||
return R.string.shared_string_apply;
|
return R.string.shared_string_apply;
|
||||||
|
|
Loading…
Reference in a new issue