mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
Introduce light/dark theme / black/white primary-color-aware primary-button theming
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
643454c1d7
commit
7005cdef2e
2 changed files with 17 additions and 2 deletions
|
@ -92,8 +92,7 @@ public class CommunityActivity extends FileActivity {
|
|||
getString(R.string.contributing_link)))));
|
||||
|
||||
MaterialButton reportButton = findViewById(R.id.community_testing_report);
|
||||
reportButton.setBackgroundColor(ThemeUtils.primaryColor(this,true));
|
||||
reportButton.setTextColor(ThemeUtils.fontColor(this, false));
|
||||
ThemeUtils.colorPrimaryButton(reportButton, this);
|
||||
reportButton.setOnClickListener(v -> DisplayUtils.startLinkIntent(this, R.string.report_issue_link));
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import android.text.style.ForegroundColorSpan;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
|
@ -435,6 +436,21 @@ public final class ThemeUtils {
|
|||
return hsl;
|
||||
}
|
||||
|
||||
public static void colorPrimaryButton(Button button, Context context) {
|
||||
int primaryColor = ThemeUtils.primaryColor(null, true, false, context);
|
||||
int fontColor = ThemeUtils.fontColor(context, false);
|
||||
|
||||
button.setBackgroundColor(primaryColor);
|
||||
|
||||
if (Color.BLACK == primaryColor) {
|
||||
button.setTextColor(Color.WHITE);
|
||||
} else if (Color.WHITE == primaryColor) {
|
||||
button.setTextColor(Color.BLACK);
|
||||
} else {
|
||||
button.setTextColor(fontColor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the tinting of the given ImageButton's icon to color_accent.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue