SettingsActivity: Fix toolbar color in night mode

pull/183/head
Alinson S. Xavier 9 years ago
parent df1751b21a
commit 65071797c9

@ -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);
} }
} }

Loading…
Cancel
Save