mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-26 06:47:03 +03:00
Colorize license button when branding is enabled
This commit is contained in:
parent
bbb4e50bff
commit
46359ae84f
3 changed files with 21 additions and 4 deletions
|
@ -1,20 +1,27 @@
|
|||
package it.niedermann.owncloud.notes.android.fragment.about;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
|
||||
import it.niedermann.owncloud.notes.R;
|
||||
import it.niedermann.owncloud.notes.branding.BrandedFragment;
|
||||
import it.niedermann.owncloud.notes.branding.BrandingUtil;
|
||||
import it.niedermann.owncloud.notes.databinding.FragmentAboutLicenseTabBinding;
|
||||
import it.niedermann.owncloud.notes.util.ColorUtil;
|
||||
import it.niedermann.owncloud.notes.util.SupportUtil;
|
||||
|
||||
public class AboutFragmentLicenseTab extends Fragment {
|
||||
public class AboutFragmentLicenseTab extends BrandedFragment {
|
||||
|
||||
private FragmentAboutLicenseTabBinding binding;
|
||||
|
||||
private void openLicense() {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_license))));
|
||||
|
@ -22,9 +29,16 @@ public class AboutFragmentLicenseTab extends Fragment {
|
|||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
FragmentAboutLicenseTabBinding binding = FragmentAboutLicenseTabBinding.inflate(inflater, container, false);
|
||||
binding = FragmentAboutLicenseTabBinding.inflate(inflater, container, false);
|
||||
binding.aboutAppLicenseButton.setOnClickListener((v) -> openLicense());
|
||||
SupportUtil.setHtml(binding.aboutIconsDisclaimer, R.string.about_icons_disclaimer, getString(R.string.about_app_icon_author));
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyBrand(int mainColor, int textColor) {
|
||||
@ColorInt final int finalMainColor = BrandingUtil.getSecondaryForegroundColorDependingOnTheme(requireContext(), mainColor);
|
||||
DrawableCompat.setTintList(binding.aboutAppLicenseButton.getBackground(), ColorStateList.valueOf(finalMainColor));
|
||||
binding.aboutAppLicenseButton.setTextColor(ColorUtil.getForegroundColorForBackgroundColor(finalMainColor));
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@
|
|||
android:id="@+id/tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabIndicatorColor="@color/defaultBrand"
|
||||
android:background="?attr/colorPrimary" />
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
@ -27,7 +28,8 @@
|
|||
style="@style/Widget.MaterialComponents.Button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/about_app_license_button" />
|
||||
android:text="@string/about_app_license_button"
|
||||
app:backgroundTint="@color/defaultBrand" />
|
||||
|
||||
<TextView
|
||||
style="?android:attr/listSeparatorTextViewStyle"
|
||||
|
|
Loading…
Reference in a new issue