Merge pull request #10256 from osmandapp/fix_add_photos_button

Fix add photos button
This commit is contained in:
Vitaliy 2020-11-24 14:00:57 +00:00 committed by GitHub
commit 6a085f5d0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 105 additions and 52 deletions

View file

@ -1,25 +1,23 @@
<?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:background="@color/color_white"
android:background="?attr/bg_color"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:background="@color/color_white"
android:background="?attr/bg_color"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="56dp">
android:layout_height="@dimen/toolbar_height">
<TextView
android:id="@+id/toolbar_text"
android:textSize="20sp"
tools:text="demdadao"
android:textColor="@color/color_black"
android:textSize="@dimen/dialog_header_text_size"
android:textColor="?android:textColorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

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

@ -10,7 +10,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
@ -368,34 +367,17 @@ public class MenuBuilder {
}
}
private View createAddPhotoButton(Context context) {
TextView b = new TextView(context);
b.setOnClickListener(new OnClickListener() {
private View createAddPhotoButton(Context ctx) {
View view = UiUtilities.getInflater(ctx, !light).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(!light, 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());
}
});
b.setTypeface(FontCache.getRobotoRegular(context));
Drawable d = ContextCompat.getDrawable(context, R.drawable.ic_sample);
b.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
LinearLayout.LayoutParams params = new
LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
int dp16 = AndroidUtils.dpToPx(context, 16f);
int dp8 = AndroidUtils.dpToPx(context, 8f);
params.setMargins(dp16, 0, dp16, dp16);
b.setPadding(dp8, dp8, dp16, dp8);
b.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
b.setLayoutParams(params);
b.setCompoundDrawablePadding(dp8);
b.setGravity(Gravity.CENTER_VERTICAL);
b.setTypeface(null, Typeface.BOLD);
b.setText(context.getResources().getString(R.string.shared_string_add_photo));
b.setBackgroundResource(R.drawable.btn_border_light);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View view) {
if (false) {
AddPhotosBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
} else {
@ -429,10 +411,9 @@ public class MenuBuilder {
}
}
});
//TODO feature under development
b.setVisibility(View.GONE);
b.setTextColor(ContextCompat.getColor(context, R.color.preference_category_title));
return b;
//TODO This feature is under development
view.setVisibility(View.VISIBLE);
return view;
}
private void buildCoordinatesRow(View view) {

View file

@ -3,8 +3,10 @@ package net.osmand.plus.openplacereviews;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
@ -14,8 +16,10 @@ import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import net.osmand.AndroidUtils;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.settings.backend.OsmandSettings;
public class OPRWebviewActivity extends OsmandActionBarActivity {
public static final String KEY_LOGIN = "LOGIN_KEY";
@ -30,7 +34,7 @@ public class OPRWebviewActivity extends OsmandActionBarActivity {
public static String getCookieUrl(Context ctx) {
return getBaseUrl(ctx) + "profile";
}
public static String getLoginUrl(Context ctx) {
return getBaseUrl(ctx) + "login";
}
@ -44,24 +48,39 @@ public class OPRWebviewActivity extends OsmandActionBarActivity {
}
public void onCreate(Bundle savedInstanceState) {
OsmandApplication app = getMyApplication();
OsmandSettings settings = app.getSettings();
boolean nightMode = !settings.isLightContent();
int themeId = nightMode ? R.style.OsmandDarkTheme_NoActionbar : R.style.OsmandLightTheme_NoActionbar_LightStatusBar;
setTheme(themeId);
getWindow().setStatusBarColor(ContextCompat.getColor(this, nightMode
? R.color.list_background_color_dark : R.color.list_background_color_light));
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_opr_webview);
Bundle b = getIntent().getExtras();
setSupportActionBar(this.<Toolbar>findViewById(R.id.toolbar));
if (b != null) {
String title = b.getString(KEY_TITLE, "");
this.<TextView>findViewById(R.id.toolbar_text).setText(title);
Bundle bundle = getIntent().getExtras();
Toolbar toolbar = findViewById(R.id.toolbar);
if (bundle != null) {
TextView titleView = findViewById(R.id.toolbar_text);
String title = bundle.getString(KEY_TITLE, "");
titleView.setText(title);
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
final Drawable upArrow = getMyApplication().getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(this));
toolbar.setBackgroundDrawable(new ColorDrawable(AndroidUtils.getColorFromAttr(this, R.attr.bg_color)));
final Drawable upArrow = app.getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(this));
upArrow.setColorFilter(ContextCompat.getColor(this, R.color.color_favorite_gray), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);
webView = (WebView) findViewById(R.id.printDialogWebview);
toolbar.setNavigationIcon(upArrow);
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
webView = findViewById(R.id.printDialogWebview);
webView.setWebViewClient(new CloseOnSuccessWebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
WebView.setWebContentsDebuggingEnabled(true);
if (b != null) {
isLogin = b.getBoolean(KEY_LOGIN);
if (bundle != null) {
isLogin = bundle.getBoolean(KEY_LOGIN);
if (isLogin) {
webView.loadUrl(getLoginUrl(this));
} else {

View file

@ -2,6 +2,7 @@ package net.osmand.plus.openplacereviews;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
@ -26,11 +27,13 @@ public class OprStartFragment extends BaseOsmAndFragment {
private static final String TAG = OprStartFragment.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(OprStartFragment.class);
private static final String openPlaceReviewsUrl = "OpenPlaceReviews.org";
private boolean nightMode;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
View v = inflater.inflate(R.layout.fragment_opr_login, container, false);
nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
View v = UiUtilities.getInflater(requireMyActivity(), nightMode).inflate(R.layout.fragment_opr_login, container,
false);
View createAccount = v.findViewById(R.id.register_opr_create_account);
v.findViewById(R.id.back_button).setOnClickListener(new View.OnClickListener() {
@Override
@ -77,6 +80,14 @@ public class OprStartFragment extends BaseOsmAndFragment {
v.<TextView>findViewById(R.id.start_opr_description).setMovementMethod(LinkMovementMethod.getInstance());
}
@Override
public int getStatusBarColorId() {
View view = getView();
if (view != null && Build.VERSION.SDK_INT >= 23 && !nightMode) {
view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
return nightMode ? R.color.list_background_color_dark : R.color.list_background_color_light;
}
private class URLSpanNoUnderline extends URLSpan {
public URLSpanNoUnderline(String url) {