Refactoring

This commit is contained in:
Dima-1 2020-11-23 22:57:55 +02:00
parent 671db0c84a
commit ef9b018011
4 changed files with 56 additions and 23 deletions

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="@dimen/dialog_button_height"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginBottom="@dimen/content_padding_small"
tools:ignore="UselessParent">
<FrameLayout
android:id="@+id/button_container"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:duplicateParentState="true"
tools:ignore="UselessParent">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/button_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding"
android:gravity="center"
android:layout_gravity="center"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
android:duplicateParentState="true"
android:drawablePadding="@dimen/content_padding_small_half"
tools:text="Button"
android:paddingStart="@dimen/content_padding_half"
android:paddingEnd="@dimen/content_padding" />
</FrameLayout>
</FrameLayout>
</FrameLayout>

View file

@ -249,6 +249,7 @@
<dimen name="content_padding">16dp</dimen>
<dimen name="content_padding_small">12dp</dimen>
<dimen name="content_padding_half">8dp</dimen>
<dimen name="content_padding_small_half">6dp</dimen>
<dimen name="bottom_sheet_content_padding_small">8dp</dimen>
<dimen name="measurement_tool_menu_title_padding_top">13dp</dimen>
<dimen name="measurement_tool_menu_title_padding_bottom">5dp</dimen>

View file

@ -22,6 +22,7 @@ import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -313,34 +314,22 @@ public class MenuBuilder {
private View createAddPhotoButton(Context ctx) {
boolean nightMode = getApplication().getDaynightHelper().isNightModeForMapControls();
View view = UiUtilities.getInflater(app, nightMode).inflate(R.layout.bottom_sheet_dialog_button, null);
LinearLayout buttonLayout = new LinearLayout(ctx);
view.setOnClickListener(new OnClickListener() {
View view = UiUtilities.getInflater(ctx, nightMode).inflate(R.layout.dialog_button_with_icon, null);
int dp6 = ctx.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_title_padding_bottom);
View button = view.findViewById(R.id.button);
UiUtilities.setupDialogButton(nightMode, button, UiUtilities.DialogButtonType.STROKED,
ctx.getString(R.string.shared_string_add_photo), R.drawable.ic_sample);
TextView textView = view.findViewById(R.id.button_text);
textView.setCompoundDrawablePadding(dp6);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
AddPhotosBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
}
});
int dp6 = ctx.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_title_padding_bottom);
int dp8 = ctx.getResources().getDimensionPixelSize(R.dimen.content_padding_half);
int dp12 = ctx.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
int dp16 = ctx.getResources().getDimensionPixelSize(R.dimen.content_padding);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(dp16, 0, dp16, dp12);
buttonLayout.setLayoutParams(params);
LinearLayout.LayoutParams buttonParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
ctx.getResources().getDimensionPixelSize(R.dimen.dialog_button_height));
view.setLayoutParams(buttonParams);
buttonLayout.addView(view);
UiUtilities.setupDialogButton(nightMode, buttonLayout, UiUtilities.DialogButtonType.STROKED,
ctx.getString(R.string.shared_string_add_photo), R.drawable.ic_sample);
TextView textView = view.findViewById(R.id.button_text);
textView.setPadding(dp8, 0, dp16, 0);
textView.setCompoundDrawablePadding(dp6);
//TODO This feature is under development
buttonLayout.setVisibility(View.VISIBLE);
return buttonLayout;
view.setVisibility(View.VISIBLE);
return view;
}
private void buildCoordinatesRow(View view) {

View file

@ -58,7 +58,7 @@ public class OPRWebviewActivity extends OsmandActionBarActivity {
String title = bundle.getString(KEY_TITLE, "");
titleView.setText(title);
}
ColorDrawable colorDrawable = new ColorDrawable(AndroidUtils.getColorFromAttr(app, R.attr.bg_color));
ColorDrawable colorDrawable = new ColorDrawable(AndroidUtils.getColorFromAttr(this, R.attr.bg_color));
toolbar.setBackgroundDrawable(colorDrawable);
final Drawable upArrow = app.getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(this));
upArrow.setColorFilter(ContextCompat.getColor(this, R.color.color_favorite_gray), PorterDuff.Mode.SRC_ATOP);