Organize button styles more neatly

This commit is contained in:
Grishka 2022-02-16 01:46:13 +03:00
parent 1e911c2245
commit f7ddac6ae6
22 changed files with 115 additions and 54 deletions

View File

@ -1,7 +1,5 @@
package org.joinmastodon.android.api.requests.oauth; package org.joinmastodon.android.api.requests.oauth;
import android.net.Uri;
import org.joinmastodon.android.api.MastodonAPIRequest; import org.joinmastodon.android.api.MastodonAPIRequest;
import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.model.Application; import org.joinmastodon.android.model.Application;

View File

@ -6,6 +6,7 @@ import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
@ -55,7 +56,8 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
@Override @Override
public void onCreate(Bundle savedInstanceState){ public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setRetainInstance(true); if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N)
setRetainInstance(true);
} }
@Override @Override

View File

@ -49,7 +49,8 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
accountID=getArguments().getString("account"); accountID=getArguments().getString("account");
setRetainInstance(true); if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N)
setRetainInstance(true);
Bundle args=new Bundle(); Bundle args=new Bundle();
args.putString("account", accountID); args.putString("account", accountID);

View File

@ -12,6 +12,7 @@ import android.content.res.Configuration;
import android.graphics.Outline; import android.graphics.Outline;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.view.Gravity; import android.view.Gravity;
@ -123,7 +124,8 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
@Override @Override
public void onCreate(Bundle savedInstanceState){ public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setRetainInstance(true); if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N)
setRetainInstance(true);
accountID=getArguments().getString("account"); accountID=getArguments().getString("account");
if(getArguments().containsKey("profileAccount")){ if(getArguments().containsKey("profileAccount")){
@ -435,7 +437,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
if(isOwnProfile && isInEditMode){ if(isOwnProfile && isInEditMode){
Button cancelButton=new Button(getActivity(), null, 0, R.style.Widget_Mastodon_Button_Secondary); Button cancelButton=new Button(getActivity(), null, 0, R.style.Widget_Mastodon_Button_Secondary_LightOnDark);
cancelButton.setText(R.string.cancel); cancelButton.setText(R.string.cancel);
cancelButton.setOnClickListener(v->exitEditMode()); cancelButton.setOnClickListener(v->exitEditMode());
FrameLayout wrap=new FrameLayout(getActivity()); FrameLayout wrap=new FrameLayout(getActivity());

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?colorButtonPrimary" android:state_enabled="true"/>
<item android:color="?colorButtonPrimary" android:alpha="0.5"/>
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/gray_800" android:state_enabled="true"/>
<item android:color="@color/gray_300"/>
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/gray_100" android:state_enabled="true"/>
<item android:color="@color/gray_500"/>
</selector>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?colorButtonSecondary" android:state_enabled="true"/>
<item android:color="?colorButtonSecondary" android:alpha="0.5"/>
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/gray_25" android:state_enabled="true"/>
<item android:color="@color/gray_100"/>
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/gray_600" android:state_enabled="true"/>
<item android:color="@color/gray_300"/>
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/gray_50" android:state_enabled="true"/>
<item android:color="@color/gray_400"/>
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/gray_800" android:state_enabled="true"/>
<item android:color="@color/gray_400"/>
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/gray_800" android:state_enabled="true"/>
<item android:color="@color/gray_400"/>
</selector>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/gray_50"/>
</selector>

View File

@ -4,9 +4,8 @@
<ripple android:color="@color/highlight_over_dark"> <ripple android:color="@color/highlight_over_dark">
<item> <item>
<shape> <shape>
<solid android:color="@color/button_bg"/> <solid android:color="@color/button_bg_primary_dark_on_light"/>
<corners android:radius="10dp"/> <corners android:radius="10dp"/>
<padding android:left="16dp" android:right="16dp" android:top="8dp" android:bottom="8dp"/>
</shape> </shape>
</item> </item>
</ripple> </ripple>

View File

@ -4,9 +4,8 @@
<ripple android:color="@color/highlight_over_dark"> <ripple android:color="@color/highlight_over_dark">
<item> <item>
<shape> <shape>
<solid android:color="@color/button_bg_secondary"/> <solid android:color="@color/button_bg_primary_dark_on_light"/>
<corners android:radius="10dp"/> <corners android:radius="10dp"/>
<padding android:left="16dp" android:right="16dp" android:top="8dp" android:bottom="8dp"/>
</shape> </shape>
</item> </item>
</ripple> </ripple>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<ripple android:color="@color/highlight_over_dark">
<item>
<shape>
<solid android:color="@color/button_bg_secondary_dark_on_light"/>
<corners android:radius="10dp"/>
</shape>
</item>
</ripple>
</item>
</selector>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<ripple android:color="@color/highlight_over_dark">
<item>
<shape>
<solid android:color="@color/button_bg_secondary_light_on_dark"/>
<corners android:radius="10dp"/>
</shape>
</item>
</ripple>
</item>
</selector>

View File

@ -28,7 +28,7 @@
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_marginBottom="24dp" android:layout_marginBottom="24dp"
android:background="@drawable/bg_fab" android:background="@drawable/bg_fab"
android:tint="@color/base" android:tint="@color/fab_icon"
android:scaleType="center" android:scaleType="center"
android:stateListAnimator="@animator/fab_shadow" android:stateListAnimator="@animator/fab_shadow"
android:src="@drawable/ic_edit_34"/> android:src="@drawable/ic_edit_34"/>

View File

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<attr name="colorButtonPrimary" format="color"/>
<attr name="colorButtonSecondary" format="color"/>
<attr name="colorButtonText" format="color"/> <attr name="colorButtonText" format="color"/>
<attr name="colorSecondary" format="color"/> <attr name="colorSecondary" format="color"/>
<attr name="colorBackgroundLight" format="color"/> <attr name="colorBackgroundLight" format="color"/>
<attr name="colorBackgroundLightest" format="color"/> <attr name="colorBackgroundLightest" format="color"/>
<attr name="colorDarkIcon" format="color"/> <attr name="colorDarkIcon" format="color"/>
<attr name="secondaryButtonStyle" format="reference"/>
</resources> </resources>

View File

@ -15,24 +15,21 @@
<color name="gray_50">#F9FAFB</color> <color name="gray_50">#F9FAFB</color>
<color name="gray_100">#F2F4F7</color> <color name="gray_100">#F2F4F7</color>
<color name="gray_200">#E4E7EC</color> <color name="gray_200">#E4E7EC</color>
<color name="gray_300">#D0D5DD</color>
<color name="gray_400">#98A2B3</color> <color name="gray_400">#98A2B3</color>
<color name="gray_500">#667085</color> <color name="gray_500">#667085</color>
<color name="gray_600">#475467</color> <color name="gray_600">#475467</color>
<color name="gray_700">#344054</color>
<color name="gray_800">#282C37</color> <color name="gray_800">#282C37</color>
<color name="gray_800t">#CC282C37</color>
<color name="gray_900">#101828</color> <color name="gray_900">#101828</color>
<color name="primary_700">#2B90D9</color> <color name="primary_700">#2B90D9</color>
<color name="gray_800_alpha50">#80282C37</color> <color name="fab_icon">#282C37</color>
<color name="light_ui_action_button">#606984</color>
<color name="secondary">#E9EDF2</color>
<color name="base">#282C37</color>
<color name="text_secondary_alpha50">#80667085</color>
<color name="actionbar_bg">#FAFBFC</color> <color name="actionbar_bg">#FAFBFC</color>
<color name="navigation_bar_bg">#000</color> <color name="navigation_bar_bg">#282C37</color>
<color name="highlight_over_dark">#80FFFFFF</color> <color name="highlight_over_dark">#80FFFFFF</color>
<color name="text_button">@color/gray_50</color>
<color name="favorite_selected">#FF9F0A</color> <color name="favorite_selected">#FF9F0A</color>
<color name="boost_selected">#79BD9A</color> <color name="boost_selected">#79BD9A</color>

View File

@ -4,30 +4,30 @@
<!-- needed to disable scrim on API 29+ --> <!-- needed to disable scrim on API 29+ -->
<item name="android:enforceNavigationBarContrast" tools:ignore="NewApi">false</item> <item name="android:enforceNavigationBarContrast" tools:ignore="NewApi">false</item>
<item name="android:enforceStatusBarContrast" tools:ignore="NewApi">false</item> <item name="android:enforceStatusBarContrast" tools:ignore="NewApi">false</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightNavigationBar" tools:ignore="NewApi">true</item>
<item name="android:windowBackground">@color/white</item>
<item name="android:statusBarColor">@color/actionbar_bg</item>
<item name="android:navigationBarColor">@color/navigation_bar_bg</item>
<item name="android:actionBarTheme">@style/Theme.Mastodon.Toolbar</item>
<item name="android:buttonStyle">@style/Widget.Mastodon.Button</item>
<item name="android:alertDialogTheme">@style/Theme.Mastodon.Dialog.Alert</item>
<item name="appkitBackDrawable">@drawable/ic_fluent_arrow_left_24_regular</item> <item name="appkitBackDrawable">@drawable/ic_fluent_arrow_left_24_regular</item>
<item name="android:splitMotionEvents">false</item> <item name="android:splitMotionEvents">false</item>
<!-- colors --> <!-- below depends on light/dark theme -->
<item name="android:buttonStyle">@style/Widget.Mastodon.Button.Primary_DarkOnLight</item>
<item name="secondaryButtonStyle">@style/Widget.Mastodon.Button.Secondary_DarkOnLight</item>
<item name="android:colorAccent">@color/primary_700</item> <item name="android:colorAccent">@color/primary_700</item>
<item name="android:colorPrimary">@color/gray_800</item> <item name="android:colorPrimary">@color/gray_800</item>
<item name="android:colorBackground">@color/gray_100</item> <item name="android:colorBackground">@color/gray_100</item>
<item name="android:textColorPrimary">@color/gray_800</item> <item name="android:textColorPrimary">@color/gray_800</item>
<item name="android:textColorSecondary">@color/gray_500</item> <item name="android:textColorSecondary">@color/gray_500</item>
<item name="colorButtonPrimary">@color/gray_800</item>
<item name="colorButtonSecondary">@color/gray_600</item>
<item name="colorButtonText">@color/gray_50</item> <item name="colorButtonText">@color/gray_50</item>
<item name="colorSecondary">#E9EDF2</item> <item name="colorSecondary">#E9EDF2</item>
<item name="colorBackgroundLight">@color/gray_50</item> <item name="colorBackgroundLight">@color/gray_50</item>
<item name="colorBackgroundLightest">@color/gray_25</item> <item name="colorBackgroundLightest">@color/gray_25</item>
<item name="colorDarkIcon">@color/gray_900</item> <item name="colorDarkIcon">@color/gray_900</item>
<item name="android:windowBackground">@color/white</item>
<item name="android:statusBarColor">@color/actionbar_bg</item>
<item name="android:navigationBarColor">@color/navigation_bar_bg</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightNavigationBar" tools:ignore="NewApi">true</item>
<item name="android:actionBarTheme">@style/Theme.Mastodon.Toolbar</item>
<item name="android:alertDialogTheme">@style/Theme.Mastodon.Dialog.Alert</item>
</style> </style>
<style name="Theme.Mastodon.Toolbar" parent="android:ThemeOverlay.Material.ActionBar"> <style name="Theme.Mastodon.Toolbar" parent="android:ThemeOverlay.Material.ActionBar">
@ -49,15 +49,31 @@
<style name="Widget.Mastodon.Button" parent="android:Widget.Material.Button"> <style name="Widget.Mastodon.Button" parent="android:Widget.Material.Button">
<item name="android:textAllCaps">false</item> <item name="android:textAllCaps">false</item>
<item name="android:background">@drawable/bg_button</item>
<item name="android:textAppearance">@style/m3_label_large</item> <item name="android:textAppearance">@style/m3_label_large</item>
<item name="android:textColor">?colorButtonText</item>
<item name="android:minHeight">36dp</item> <item name="android:minHeight">36dp</item>
<item name="android:minWidth">0px</item> <item name="android:minWidth">0px</item>
<item name="android:paddingLeft">16dp</item>
<item name="android:paddingRight">16dp</item>
</style> </style>
<style name="Widget.Mastodon.Button.Secondary"> <style name="Widget.Mastodon.Button.Primary_DarkOnLight">
<item name="android:background">@drawable/bg_button_secondary</item> <item name="android:background">@drawable/bg_button_primary_dark_on_light</item>
<item name="android:textColor">@color/button_text_primary_dark_on_light</item>
</style>
<style name="Widget.Mastodon.Button.Secondary_DarkOnLight">
<item name="android:background">@drawable/bg_button_secondary_dark_on_light</item>
<item name="android:textColor">@color/button_text_secondary_dark_on_light</item>
</style>
<style name="Widget.Mastodon.Button.Primary_LightOnDark">
<item name="android:background">@drawable/bg_button_primary_light_on_dark</item>
<item name="android:textColor">@color/button_text_primary_light_on_dark</item>
</style>
<style name="Widget.Mastodon.Button.Secondary_LightOnDark">
<item name="android:background">@drawable/bg_button_secondary_light_on_dark</item>
<item name="android:textColor">@color/button_text_secondary_light_on_dark</item>
</style> </style>
<style name="Theme.Mastodon.Dialog.Alert" parent="android:Theme.Material.Light.Dialog.Alert"> <style name="Theme.Mastodon.Dialog.Alert" parent="android:Theme.Material.Light.Dialog.Alert">
@ -72,13 +88,6 @@
<item name="android:colorBackground">@color/gray_100</item> <item name="android:colorBackground">@color/gray_100</item>
<item name="android:textColorPrimary">@color/gray_800</item> <item name="android:textColorPrimary">@color/gray_800</item>
<item name="android:textColorSecondary">@color/gray_500</item> <item name="android:textColorSecondary">@color/gray_500</item>
<item name="colorButtonPrimary">@color/gray_800</item>
<item name="colorButtonSecondary">@color/gray_600</item>
<item name="colorButtonText">@color/gray_50</item>
<item name="colorSecondary">#E9EDF2</item>
<item name="colorBackgroundLight">@color/gray_50</item>
<item name="colorBackgroundLightest">@color/gray_25</item>
<item name="colorDarkIcon">@color/gray_900</item>
</style> </style>
<style name="Widget.Mastodon.ButtonBarButton" parent="android:Widget.Material.Button.Borderless"> <style name="Widget.Mastodon.ButtonBarButton" parent="android:Widget.Material.Button.Borderless">
@ -141,6 +150,6 @@
<style name="m3_headline_small"> <style name="m3_headline_small">
<item name="android:textSize">24dp</item> <item name="android:textSize">24dp</item>
<item name="android:textColor">@color/gray_800</item> <item name="android:textColor">?android:textColorPrimary</item>
</style> </style>
</resources> </resources>