Merge pull request #9963 from AlexSyt/fix_selected_profile_color_9537

#9537 Use a profile color to highlight the selected profile
This commit is contained in:
Vitaliy 2020-10-06 18:16:08 +03:00 committed by GitHub
commit beaeafa9b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,6 +6,7 @@ import android.os.Bundle;
import android.view.View;
import androidx.annotation.ColorRes;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
@ -86,7 +87,8 @@ public class MainSettingsFragment extends BaseSettingsFragment {
if (CONFIGURE_PROFILE.equals(key)) {
View selectedProfile = holder.itemView.findViewById(R.id.selectable_list_item);
if (selectedProfile != null) {
int activeProfileColor = getActiveProfileColor();
int activeProfileColorId = getSelectedAppMode().getIconColorInfo().getColor(isNightMode());
int activeProfileColor = ContextCompat.getColor(app, activeProfileColorId);
Drawable backgroundDrawable = new ColorDrawable(UiUtilities.getColorWithAlpha(activeProfileColor, 0.15f));
AndroidUtils.setBackground(selectedProfile, backgroundDrawable);
}
@ -153,9 +155,8 @@ public class MainSettingsFragment extends BaseSettingsFragment {
ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get();
String title = selectedMode.toHumanString();
String profileType = getAppModeDescription(getContext(), selectedMode);
int iconRes = selectedMode.getIconRes();
Preference configureProfile = findPreference(CONFIGURE_PROFILE);
configureProfile.setIcon(getPaintedIcon(iconRes, getActiveProfileColor()));
configureProfile.setIcon(getAppProfilesIcon(selectedMode, true));
configureProfile.setTitle(title);
configureProfile.setSummary(profileType);
}