[android] Fixed background color PopupMenu in PlacePage.

This commit is contained in:
velichkomarija 2021-01-26 13:53:51 +03:00 committed by Aleksandr Zatsepin
parent 69aec24e9e
commit e9ae976729
2 changed files with 15 additions and 14 deletions

View file

@ -130,6 +130,10 @@
<item name="android:fontFamily" tools:ignore="NewApi">@string/robotoRegular</item>
</style>
<style name="MwmWidget.PopupMenu" parent="Widget.AppCompat.PopupMenu.Overflow">
<item name="android:background">?cardBackground</item>
</style>
<style name="MwmWidget.ToolbarStyle" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:background">?colorPrimary</item>
<item name="android:elevation" tools:ignore="NewApi">@dimen/appbar_elevation</item>

View file

@ -34,6 +34,7 @@ import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.appcompat.widget.Toolbar;
import androidx.core.widget.NestedScrollViewClickFixed;
import androidx.fragment.app.Fragment;
@ -1976,7 +1977,8 @@ public class PlacePageView extends NestedScrollViewClickFixed
final String tagStr = tag == null ? "" : tag.toString();
AlohaHelper.logLongClick(tagStr);
final PopupMenu popup = new PopupMenu(getContext(), v);
Context wrapper = new ContextThemeWrapper(getContext(), R.style.MwmWidget_PopupMenu);
final PopupMenu popup = new PopupMenu(wrapper, v);
final Menu menu = popup.getMenu();
final List<String> items = new ArrayList<>();
switch (v.getId())
@ -2024,19 +2026,14 @@ public class PlacePageView extends NestedScrollViewClickFixed
for (int i = 0; i < items.size(); i++)
menu.add(Menu.NONE, i, i, String.format("%s %s", copyText, items.get(i)));
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener()
{
@Override
public boolean onMenuItemClick(MenuItem item)
{
final int id = item.getItemId();
final Context ctx = getContext();
Utils.copyTextToClipboard(ctx, items.get(id));
Utils.toastShortcut(ctx, ctx.getString(R.string.copied_to_clipboard, items.get(id)));
Statistics.INSTANCE.trackEvent(Statistics.EventName.PP_METADATA_COPY + ":" + tagStr);
AlohaHelper.logClick(AlohaHelper.PP_METADATA_COPY + ":" + tagStr);
return true;
}
popup.setOnMenuItemClickListener(item -> {
final int id = item.getItemId();
final Context ctx = getContext();
Utils.copyTextToClipboard(ctx, items.get(id));
Utils.toastShortcut(ctx, ctx.getString(R.string.copied_to_clipboard, items.get(id)));
Statistics.INSTANCE.trackEvent(Statistics.EventName.PP_METADATA_COPY + ":" + tagStr);
AlohaHelper.logClick(AlohaHelper.PP_METADATA_COPY + ":" + tagStr);
return true;
});
popup.show();