Merge pull request #679 from AnotherDaniel/fixSettingsBreadcrumbColor
Fix settings breadcrumb color
This commit is contained in:
commit
499cbf1c69
1 changed files with 23 additions and 0 deletions
|
@ -46,6 +46,7 @@ import android.preference.TwoStatePreference;
|
|||
import android.provider.Settings;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.AppCompatCheckBox;
|
||||
import android.support.v7.widget.AppCompatCheckedTextView;
|
||||
import android.support.v7.widget.AppCompatEditText;
|
||||
|
@ -61,6 +62,7 @@ import android.view.View;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm;
|
||||
|
@ -279,9 +281,30 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void onBuildHeaders(List<Header> target) {
|
||||
super.onBuildHeaders(target);
|
||||
if (!isSimplePreferences(this)) {
|
||||
loadHeadersFromResource(R.xml.pref_headers, target);
|
||||
}
|
||||
|
||||
// below workaround is only necessary in tablet mode
|
||||
if (isXLargeTablet(this)) {
|
||||
|
||||
/* Fix settings page header ("breadcrumb") text color for dark mode
|
||||
* Thank you Stackoverflow: https://stackoverflow.com/a/27078485
|
||||
*/
|
||||
final View breadcrumb = findViewById(android.R.id.title);
|
||||
if (breadcrumb == null) {
|
||||
// Single pane layout
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Field titleColor = breadcrumb.getClass().getDeclaredField("mTextColor");
|
||||
titleColor.setAccessible(true);
|
||||
titleColor.setInt(breadcrumb, ContextCompat.getColor(this, R.color.primaryTextColor));
|
||||
} catch (final Exception ignored) {
|
||||
// Nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue