Skip to content

Commit

Permalink
[DEV] Immersive ui
Browse files Browse the repository at this point in the history
  • Loading branch information
manneohlund committed Feb 28, 2018
1 parent 0f8f7fb commit 6ae3d38
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions jsonthemer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support:design:26.0.1'
implementation 'com.google.code.gson:gson:2.8.2'

testImplementation 'junit:junit:4.12'
Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ dependencies {

implementation project(path: ':jsonthemer')

implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support:design:26.0.1'
implementation 'com.google.code.gson:gson:2.8.2'

// Kotlin
Expand Down
4 changes: 2 additions & 2 deletions sample/src/main/assets/blue_theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"toolbarThemeOverlay": 1,
"popupThemeOverlay": 0,
"statusBarColor": "#303F9F",
"toolbarColor": "#3F51B5",
"toolbarColor": "#C83F51B5",
"accentColor": "#448AFF",
"navigationBarColor": "#303F9F",
"navigationBarColor": "#C8303F9F",
"backgroundColor": "#FFFFFFFF"
}
4 changes: 2 additions & 2 deletions sample/src/main/assets/green_theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"toolbarThemeOverlay": 0,
"popupThemeOverlay": 1,
"statusBarColor": "#388E3C",
"toolbarColor": "#4CAF50",
"toolbarColor": "#C84CAF50",
"accentColor": "#8BC34A",
"navigationBarColor": "#388E3C",
"navigationBarColor": "#C8388E3C",
"backgroundColor": "#FF000000"
}
4 changes: 2 additions & 2 deletions sample/src/main/assets/lime_theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"toolbarThemeOverlay": 0,
"popupThemeOverlay": 1,
"statusBarColor": "#00796B",
"toolbarColor": "#009688",
"toolbarColor": "#C8009688",
"accentColor": "#CDDC39",
"navigationBarColor": "#00796B",
"navigationBarColor": "#C800796B",
"backgroundColor": "#FF000000"
}
4 changes: 2 additions & 2 deletions sample/src/main/assets/red_theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"toolbarThemeOverlay": 1,
"popupThemeOverlay": 0,
"statusBarColor": "#D32F2F",
"toolbarColor": "#F44336",
"toolbarColor": "#C8F44336",
"accentColor": "#FF9800",
"navigationBarColor": "#D32F2F",
"navigationBarColor": "#C8D32F2F",
"backgroundColor": "#FFFFFFFF"
}
16 changes: 16 additions & 0 deletions sample/src/main/java/com/sample/jsonthemer/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import android.view.View
import com.sample.jsonthemer.databinding.ActivityMainBinding
import jsonthemer.JsonThemer
import jsonthemer.model.BaseThemeModel


class MainActivity : AppCompatActivity() {

companion object {
Expand Down Expand Up @@ -59,4 +61,18 @@ class MainActivity : AppCompatActivity() {
currentTheme = style
recreate()
}

override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus) {
window.decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
//or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
//or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
//or View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
or View.SYSTEM_UI_FLAG_IMMERSIVE);
}
}
}
10 changes: 6 additions & 4 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@{themeModel.toolbarColor}"
android:fitsSystemWindows="true"
app:contentScrim="@{themeModel.statusBarColorDrawable}"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
Expand All @@ -45,9 +46,10 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.sample.jsonthemer.MainActivity"
tools:showIn="@layout/activity_main">
android:fitsSystemWindows="true"
android:fillViewport="true"
android:overScrollMode="never"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<LinearLayout
android:layout_width="match_parent"
Expand Down

0 comments on commit 6ae3d38

Please sign in to comment.