Merge pull request #5108 from nextcloud/whiteOptionMenu

Fix text in option menu within image preview
This commit is contained in:
Andy Scherzinger 2020-01-07 22:15:19 +01:00 committed by GitHub
commit de46f83ddd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,6 +24,7 @@ package com.owncloud.android.ui.preview;
import android.accounts.Account;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
@ -36,6 +37,8 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.Menu;
@ -70,6 +73,8 @@ import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.MimeType;
import com.owncloud.android.utils.MimeTypeUtil;
import org.jetbrains.annotations.NotNull;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@ -313,16 +318,28 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
* {@inheritDoc}
*/
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
public void onCreateOptionsMenu(@NotNull Menu menu, @NotNull MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.item_file, menu);
int nightModeFlag = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
if (Configuration.UI_MODE_NIGHT_NO == nightModeFlag) {
for (int i = 0; i < menu.size(); i++) {
MenuItem menuItem = menu.getItem(i);
SpannableString spanString = new SpannableString(menuItem.getTitle().toString());
spanString.setSpan(new ForegroundColorSpan(Color.BLACK), 0, spanString.length(), 0);
menuItem.setTitle(spanString);
}
}
}
/**
* {@inheritDoc}
*/
@Override
public void onPrepareOptionsMenu(Menu menu) {
public void onPrepareOptionsMenu(@NotNull Menu menu) {
super.onPrepareOptionsMenu(menu);
if (containerActivity.getStorageManager() != null && getFile() != null) {