mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-21 23:48:18 -05:00
Settings activity styled correctly
This commit is contained in:
parent
f26d6f5dc4
commit
f466f9b017
@ -16,6 +16,25 @@ import org.bspeice.minimalbible.R;
|
||||
*/
|
||||
public class BaseActivity extends ActionBarActivity {
|
||||
|
||||
// TODO: Refactor these methods to a utility class
|
||||
public static void setupStatusBar(Activity activity) {
|
||||
// Only set the tint if the device is running KitKat or above
|
||||
// TODO: Can this be set as part of styles.xml?
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
SystemBarTintManager tintManager = new SystemBarTintManager(activity);
|
||||
tintManager.setStatusBarTintEnabled(true);
|
||||
tintManager.setStatusBarTintColor(activity.getResources()
|
||||
.getColor(R.color.colorPrimary));
|
||||
}
|
||||
}
|
||||
|
||||
public static void setupInsets(Activity context, View view) {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
|
||||
SystemBarTintManager.SystemBarConfig config = getConfig(context);
|
||||
view.setPadding(0, config.getPixelInsetTop(false), config.getPixelInsetRight(), config.getPixelInsetBottom());
|
||||
}
|
||||
}
|
||||
|
||||
protected static SystemBarTintManager.SystemBarConfig getConfig(Activity context) {
|
||||
return new SystemBarTintManager(context).getConfig();
|
||||
}
|
||||
@ -28,9 +47,7 @@ public class BaseActivity extends ActionBarActivity {
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
protected static void setInsets(Activity context, View view) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
|
||||
SystemBarTintManager.SystemBarConfig config = getConfig(context);
|
||||
view.setPadding(0, config.getPixelInsetTop(false), config.getPixelInsetRight(), config.getPixelInsetBottom());
|
||||
setupInsets(context, view);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ -47,13 +64,6 @@ public class BaseActivity extends ActionBarActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Only set the tint if the device is running KitKat or above
|
||||
// TODO: Can this be set as part of styles.xml?
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
SystemBarTintManager tintManager = new SystemBarTintManager(this);
|
||||
tintManager.setStatusBarTintEnabled(true);
|
||||
tintManager.setStatusBarTintColor(getResources().getColor(
|
||||
R.color.colorPrimary));
|
||||
}
|
||||
setupStatusBar(this);
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,22 @@ package org.bspeice.minimalbible.activity.settings
|
||||
import android.preference.PreferenceActivity
|
||||
import android.os.Bundle
|
||||
import org.bspeice.minimalbible.R
|
||||
import android.support.v7.widget.Toolbar
|
||||
import org.bspeice.minimalbible.activity.BaseActivity
|
||||
|
||||
/**
|
||||
* Created by bspeice on 12/1/14.
|
||||
*/
|
||||
// TODO: Fix the status bar color/transparency, and lack of toolbar
|
||||
class MinimalBibleSettings() : PreferenceActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super<PreferenceActivity>.onCreate(savedInstanceState)
|
||||
|
||||
addPreferencesFromResource(R.xml.preferences)
|
||||
setContentView(R.layout.activity_settings)
|
||||
BaseActivity.setupStatusBar(this)
|
||||
|
||||
val toolbar = findViewById(R.id.toolbar) as Toolbar
|
||||
toolbar.setTitle(R.string.action_settings)
|
||||
}
|
||||
}
|
24
app/src/main/res/layout/activity_settings.xml
Normal file
24
app/src/main/res/layout/activity_settings.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- layout_marginTop is for the transparent status bar offset.
|
||||
Normally you'd use the SystemBarTintManager but I was having issues with it. -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="24dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Use style="MinimalBible" because we over-ride the settings in AndroidManifest.xml -->
|
||||
<!-- Also, text of the toolbar is set in the activity -->
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="MinimalBible"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorPrimary"
|
||||
android:minHeight="?attr/actionBarSize" />
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
@ -1,12 +0,0 @@
|
||||
<ExpandableListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/list_nav_drawer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#cccccc"
|
||||
android:choiceMode="singleChoice"
|
||||
android:divider="@android:color/transparent"
|
||||
android:dividerHeight="0dp"
|
||||
tools:context="org.bspeice.minimalbible.activity.viewer.BookChapterNavFragment">
|
||||
|
||||
</ExpandableListView>
|
@ -1,13 +0,0 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="org.bspeice.minimalbible.activity.viewer.BookFragment" >
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/book_content"
|
||||
android:scrollbars="none"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent" />
|
||||
|
||||
</RelativeLayout>
|
@ -7,7 +7,6 @@
|
||||
<string name="title_section3">Section 3</string>
|
||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||
<string name="action_example">Example action</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="activity_downloader">Downloads</string>
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
<item name="android:paddingLeft">8dp</item>
|
||||
</style>
|
||||
|
||||
<style name="MinimalBibleBase.Settings" parent="MinimalBibleBase">
|
||||
<item name="android:textColor">@color/settingsTextColor</item>
|
||||
<style name="MinimalBibleBase.Settings" parent="MinimalBible">
|
||||
<item name="android:textColor">@color/settingsTextColor</item>
|
||||
<item name="android:textColorSecondary">@color/settingsTextColorSecondary</item>
|
||||
</style>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user