mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 09:38:52 -06:00
SettingsActivity: Fix toolbar color in night mode
This commit is contained in:
@@ -37,6 +37,9 @@ import org.isoron.uhabits.utils.*;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
import static android.os.Build.VERSION.*;
|
||||||
|
import static android.os.Build.VERSION_CODES.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for all screens in the application.
|
* Base class for all screens in the application.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -95,6 +98,22 @@ public class BaseScreen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static int getDefaultActionBarColor(Context context)
|
||||||
|
{
|
||||||
|
if (SDK_INT < LOLLIPOP)
|
||||||
|
{
|
||||||
|
return context
|
||||||
|
.getResources()
|
||||||
|
.getColor(R.color.grey_900, context.getTheme());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StyledResources res = new StyledResources(context);
|
||||||
|
return res.getColor(R.attr.colorPrimary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies the screen that its contents should be updated.
|
* Notifies the screen that its contents should be updated.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -35,9 +35,17 @@ public class SettingsActivity extends BaseActivity
|
|||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.settings_activity);
|
setContentView(R.layout.settings_activity);
|
||||||
|
setupActionBarColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupActionBarColor()
|
||||||
|
{
|
||||||
StyledResources res = new StyledResources(this);
|
StyledResources res = new StyledResources(this);
|
||||||
int color = res.getColor(R.attr.aboutScreenColor);
|
int color = BaseScreen.getDefaultActionBarColor(this);
|
||||||
|
|
||||||
|
if (res.getBoolean(R.attr.useHabitColorAsPrimary))
|
||||||
|
color = res.getColor(R.attr.aboutScreenColor);
|
||||||
|
|
||||||
BaseScreen.setupActionBarColor(this, color);
|
BaseScreen.setupActionBarColor(this, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user