Compare commits

..

13 Commits

Author SHA1 Message Date
LucasGGamerM
770fde7aac Fixing the background of the disabled button on light themes and dark themes 2022-12-23 12:03:17 -03:00
LucasGGamerM
29b8cedc7c Merge remote-tracking branch 'origin/development_of_the_nord_theme' into development_of_the_nord_theme
# Conflicts:
#	mastodon/src/main/res/values/colors.xml
2022-12-23 11:55:22 -03:00
LucasGGamerM
33b65c3bf3 Merge pull request #9 from FineFindus/development_of_the_nord_theme
feat(theme/nord): change popup color
2022-12-23 11:54:49 -03:00
LucasGGamerM
34ab1bcd9c Change the accent color back to default 2022-12-23 11:54:47 -03:00
LucasGGamerM
20086d76ce Fixing the accent color for the nord theme 2022-12-23 11:46:11 -03:00
FineFindus
1ca4fb5c37 feat(theme/nord): change popup color 2022-12-23 15:41:28 +01:00
LucasGGamerM
1604c067fd Fixing up the nord theme 2022-12-23 10:59:12 -03:00
LucasGGamerM
0c7419e2b3 Its less broken, but I still found some bugs 2022-12-23 10:37:14 -03:00
LucasGGamerM
7cf30ccb98 Maybe fixing the nord theme. Still a lot of work that needs to be done 2022-12-23 08:29:01 -03:00
LucasGGamerM
875695c239 Fixing up the nord theme 2022-12-22 20:17:05 -03:00
LucasGGamerM
61049a1302 Adding the nord theme 2022-12-22 19:27:02 -03:00
LucasGGamerM
28db90aa82 Its going there 2022-12-22 18:59:28 -03:00
LucasGGamerM
f0e7fc5e3b Its almost working 2022-12-22 18:58:20 -03:00
5 changed files with 100 additions and 91 deletions

View File

@@ -98,7 +98,8 @@ public class GlobalUserPreferences{
BLUE, BLUE,
BROWN, BROWN,
RED, RED,
YELLOW YELLOW,
NORD
} }
public enum ThemePreference{ public enum ThemePreference{

View File

@@ -18,6 +18,8 @@ import android.view.WindowInsets;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.LinearInterpolator; import android.view.animation.LinearInterpolator;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.PopupMenu; import android.widget.PopupMenu;
@@ -102,7 +104,25 @@ public class SettingsFragment extends MastodonToolbarFragment{
GlobalUserPreferences.disableMarquee=i.checked; GlobalUserPreferences.disableMarquee=i.checked;
GlobalUserPreferences.save(); GlobalUserPreferences.save();
})); }));
items.add(new ColorPicker()); items.add(new ButtonItem(R.string.sk_settings_color_palette, R.drawable.ic_fluent_color_24_regular, b->{
PopupMenu popupMenu=new PopupMenu(getActivity(), b, Gravity.CENTER_HORIZONTAL);
popupMenu.inflate(R.menu.color_palettes);
popupMenu.getMenu().findItem(R.id.m3_color).setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S);
popupMenu.setOnMenuItemClickListener(SettingsFragment.this::onColorPreferenceClick);
b.setOnTouchListener(popupMenu.getDragToOpenListener());
b.setOnClickListener(v->popupMenu.show());
b.setText(switch(GlobalUserPreferences.color){
case MATERIAL3 -> R.string.sk_color_palette_material3;
case PINK -> R.string.sk_color_palette_pink;
case PURPLE -> R.string.sk_color_palette_purple;
case GREEN -> R.string.sk_color_palette_green;
case BLUE -> R.string.sk_color_palette_blue;
case BROWN -> R.string.sk_color_palette_brown;
case RED -> R.string.sk_color_palette_red;
case YELLOW -> R.string.sk_color_palette_yellow;
case NORD -> R.string.sk_color_palette_nord;
});
}));
items.add(new HeaderItem(R.string.settings_behavior)); items.add(new HeaderItem(R.string.settings_behavior));
items.add(new SwitchItem(R.string.settings_gif, R.drawable.ic_fluent_gif_24_regular, GlobalUserPreferences.playGifs, i->{ items.add(new SwitchItem(R.string.settings_gif, R.drawable.ic_fluent_gif_24_regular, GlobalUserPreferences.playGifs, i->{
@@ -248,13 +268,29 @@ public class SettingsFragment extends MastodonToolbarFragment{
restartActivityToApplyNewTheme(); restartActivityToApplyNewTheme();
} }
private void onColorPreferenceClick(GlobalUserPreferences.ColorPreference color){ private boolean onColorPreferenceClick(MenuItem item){
ColorPreference pref = null;
int id = item.getItemId();
GlobalUserPreferences.color=color; if (id == R.id.m3_color) pref = ColorPreference.MATERIAL3;
else if (id == R.id.pink_color) pref = ColorPreference.PINK;
else if (id == R.id.purple_color) pref = ColorPreference.PURPLE;
else if (id == R.id.green_color) pref = ColorPreference.GREEN;
else if (id == R.id.blue_color) pref = ColorPreference.BLUE;
else if (id == R.id.brown_color) pref = ColorPreference.BROWN;
else if (id == R.id.red_color) pref = ColorPreference.RED;
else if (id == R.id.yellow_color) pref = ColorPreference.YELLOW;
else if (id == R.id.nord_color) pref = ColorPreference.NORD;
if (pref == null) return false;
GlobalUserPreferences.color=pref;
GlobalUserPreferences.save(); GlobalUserPreferences.save();
restartActivityToApplyNewTheme(); restartActivityToApplyNewTheme();
return true;
} }
private void onTrueBlackThemeChanged(SwitchItem item){ private void onTrueBlackThemeChanged(SwitchItem item){
GlobalUserPreferences.trueBlackTheme=item.checked; GlobalUserPreferences.trueBlackTheme=item.checked;
GlobalUserPreferences.save(); GlobalUserPreferences.save();
@@ -458,6 +494,23 @@ public class SettingsFragment extends MastodonToolbarFragment{
} }
} }
public class ButtonItem extends Item{
private int text;
private int icon;
private Consumer<Button> buttonConsumer;
public ButtonItem(@StringRes int text, @DrawableRes int icon, Consumer<Button> buttonConsumer) {
this.text = text;
this.icon = icon;
this.buttonConsumer = buttonConsumer;
}
@Override
public int getViewType(){
return 8;
}
}
public class ColorPicker extends Item{ public class ColorPicker extends Item{
@Override @Override
public int getViewType(){ public int getViewType(){
@@ -549,7 +602,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
case 5 -> new HeaderViewHolder(true); case 5 -> new HeaderViewHolder(true);
case 6 -> new FooterViewHolder(); case 6 -> new FooterViewHolder();
case 7 -> new UpdateViewHolder(); case 7 -> new UpdateViewHolder();
case 8 -> new ColorPickerViewHolder(); case 8 -> new ButtonViewHolder();
default -> throw new IllegalStateException("Unexpected value: "+viewType); default -> throw new IllegalStateException("Unexpected value: "+viewType);
}; };
} }
@@ -678,78 +731,25 @@ public class SettingsFragment extends MastodonToolbarFragment{
} }
} }
} }
private class ColorPickerViewHolder extends BindableViewHolder<ColorPicker>{
private class ButtonViewHolder extends BindableViewHolder<ButtonItem>{
private final Button button; private final Button button;
private final PopupMenu popupMenu;
private final ImageView icon; private final ImageView icon;
private final TextView text;
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
public ColorPickerViewHolder(){ public ButtonViewHolder(){
super(getActivity(), R.layout.item_settings_color_picker, list); super(getActivity(), R.layout.item_settings_button, list);
text=findViewById(R.id.text);
icon=findViewById(R.id.icon); icon=findViewById(R.id.icon);
button=findViewById(R.id.color_picker_button); button=findViewById(R.id.button);
popupMenu=new PopupMenu(getActivity(), button, Gravity.CENTER_HORIZONTAL);
popupMenu.inflate(R.menu.color_picker);
popupMenu.setOnMenuItemClickListener(item->{
GlobalUserPreferences.ColorPreference pref;
int id=item.getItemId();
if(id==R.id.pink_color) {
pref = GlobalUserPreferences.ColorPreference.PINK;
onColorPreferenceClick(pref);
}
else if(id==R.id.purple_color) {
pref = GlobalUserPreferences.ColorPreference.PURPLE;
onColorPreferenceClick(pref);
}
else if(id==R.id.green_color) {
pref = GlobalUserPreferences.ColorPreference.GREEN;
onColorPreferenceClick(pref);
}
else if(id==R.id.blue_color) {
pref = GlobalUserPreferences.ColorPreference.BLUE;
onColorPreferenceClick(pref);
}
else if(id==R.id.orange_color) {
pref = ColorPreference.BROWN;
onColorPreferenceClick(pref);
}
else if(id==R.id.yellow_color) {
pref = GlobalUserPreferences.ColorPreference.YELLOW;
onColorPreferenceClick(pref);
}
else if(id==R.id.red_color) {
pref = GlobalUserPreferences.ColorPreference.RED;
onColorPreferenceClick(pref);
}
else if(id==R.id.m3_color) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
pref = GlobalUserPreferences.ColorPreference.MATERIAL3;
onColorPreferenceClick(pref);
}
}
else
return false;
return true;
});
// UiUtils.enablePopupMenuIcons(getActivity(), popupMenu);
popupMenu.getMenu().findItem(R.id.m3_color).setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S);
button.setOnTouchListener(popupMenu.getDragToOpenListener());
button.setOnClickListener(v->popupMenu.show());
} }
@Override @Override
public void onBind(ColorPicker item){ public void onBind(ButtonItem item){
icon.setImageResource(R.drawable.ic_fluent_color_24_regular); text.setText(item.text);
button.setText(switch(GlobalUserPreferences.color){ icon.setImageResource(item.icon);
case PINK -> R.string.sk_color_palette_pink; item.buttonConsumer.accept(button);
case PURPLE -> R.string.sk_color_palette_purple;
case GREEN -> R.string.sk_color_palette_green;
case BLUE -> R.string.sk_color_palette_blue;
case BROWN -> R.string.sk_color_palette_brown;
case YELLOW -> R.string.sk_color_palette_yellow;
case RED -> R.string.sk_color_palette_red;
case MATERIAL3 -> R.string.sk_color_palette_material3;
});
} }
} }

View File

@@ -25,7 +25,8 @@ public class ColorPalette {
ColorPreference.BLUE, new ColorPalette(R.style.ColorPalette_Blue), ColorPreference.BLUE, new ColorPalette(R.style.ColorPalette_Blue),
ColorPreference.BROWN, new ColorPalette(R.style.ColorPalette_Brown), ColorPreference.BROWN, new ColorPalette(R.style.ColorPalette_Brown),
ColorPreference.RED, new ColorPalette(R.style.ColorPalette_Red), ColorPreference.RED, new ColorPalette(R.style.ColorPalette_Red),
ColorPreference.YELLOW, new ColorPalette(R.style.ColorPalette_Yellow) ColorPreference.YELLOW, new ColorPalette(R.style.ColorPalette_Yellow),
ColorPreference.NORD, new ColorPalette(R.style.ColorPalette_Nord)
); );
private @StyleRes int base; private @StyleRes int base;

View File

@@ -295,21 +295,28 @@
<color name="nord_primary_25">#fafaff</color> <color name="nord_primary_25">#fafaff</color>
<color name="nord_primary_50">#eff0ff</color> <color name="nord_primary_50">#eff0ff</color>
<color name="nord_primary_100">#dfe1f2</color> <color name="nord_primary_100">#eceff4</color>
<color name="nord_primary_200">#c3c6d6</color> <color name="nord_primary_200">#e5e9f0</color>
<color name="nord_primary_300">#a8aaba</color> <color name="nord_primary_300">#d8dee9</color>
<color name="nord_primary_400">#8f909f</color> <color name="nord_primary_400">#88c0d0</color>
<color name="nord_primary_500">#727584</color> <color name="nord_primary_500">#4c566a</color>
<color name="nord_primary_600">#5b5e6c</color> <color name="nord_primary_600">#4c566a</color>
<color name="nord_primary_700">#434654</color> <color name="nord_primary_700">#81a1c1</color>
<color name="nord_primary_800">#2d303d</color> <color name="nord_primary_800">#3b4252</color>
<color name="nord_primary_900">#181b27</color> <color name="nord_primary_900">#2e3440</color>
<color name="nord_gray_400">#aaaab4</color> <color name="nord_gray_900">#3B4252</color>
<color name="nord_gray_800t">#cc2D343F</color>
<color name="nord_gray_800">#2D343F</color>
<color name="nord_gray_700">#3A4250</color>
<color name="nord_gray_600">#404C5C</color>
<color name="nord_gray_500">#8C96B4</color>
<color name="nord_gray_400">#8C96B4</color>
<color name="nord_gray_300">#c5c6d0</color> <color name="nord_gray_300">#c5c6d0</color>
<color name="nord_gray_200">#e2e2ec</color> <color name="nord_gray_200">#D5DCE6</color>
<color name="nord_gray_100">#eff0ff</color> <color name="nord_gray_100">#E2E7EE</color>
<color name="nord_gray_50t">#f0f0faca</color> <color name="nord_gray_50t">#EAEDF2</color>
<color name="nord_gray_50">#f0f0fa</color> <color name="nord_gray_50">#EAEDF2</color>
<color name="nord_gray_25">#f7f8fa</color> <color name="nord_gray_25">#f7f8fa</color>
</resources> </resources>

View File

@@ -233,7 +233,7 @@
<item name="colorGray25">@color/red_gray_25</item> <item name="colorGray25">@color/red_gray_25</item>
</style> </style>
<style name="ColorPalette.Blueish"> <style name="ColorPalette.Nord">
<item name="colorPrimary25">@color/nord_primary_25</item> <item name="colorPrimary25">@color/nord_primary_25</item>
<item name="colorPrimary50">@color/nord_primary_50</item> <item name="colorPrimary50">@color/nord_primary_50</item>
<item name="colorPrimary100">@color/nord_primary_100</item> <item name="colorPrimary100">@color/nord_primary_100</item>
@@ -246,12 +246,12 @@
<item name="colorPrimary800">@color/nord_primary_800</item> <item name="colorPrimary800">@color/nord_primary_800</item>
<item name="colorPrimary900">@color/nord_primary_900</item> <item name="colorPrimary900">@color/nord_primary_900</item>
<item name="colorGray900">@color/brownish_gray_900</item> <item name="colorGray900">@color/nord_gray_900</item>
<item name="colorGray800t">@color/brownish_gray_800t</item> <item name="colorGray800t">@color/nord_gray_800t</item>
<item name="colorGray800">@color/brownish_gray_800</item> <item name="colorGray800">@color/nord_gray_800</item>
<item name="colorGray700">@color/brownish_gray_700</item> <item name="colorGray700">@color/nord_gray_700</item>
<item name="colorGray600">@color/brownish_gray_600</item> <item name="colorGray600">@color/nord_gray_600</item>
<item name="colorGray500">@color/brownish_gray_500</item> <item name="colorGray500">@color/nord_gray_500</item>
<item name="colorGray400">@color/nord_gray_400</item> <item name="colorGray400">@color/nord_gray_400</item>
<item name="colorGray300">@color/nord_gray_300</item> <item name="colorGray300">@color/nord_gray_300</item>