Skip to content

Commit 3642aaa

Browse files
committed
兼容kitkat状态栏变色
1 parent 5fe3111 commit 3642aaa

File tree

15 files changed

+65
-45
lines changed

15 files changed

+65
-45
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<activity
6363
android:name=".ui.activity.AccountSettingActivity"
6464
android:label="@string/title_activity_account_setting"
65-
android:theme="@style/AppTheme" />
65+
android:theme="@style/AppTheme.NoActionBar" />
6666
<activity
6767
android:name=".ui.activity.BlocksActivity"
6868
android:label="@string/title_activity_blocks"
@@ -74,7 +74,7 @@
7474
<activity
7575
android:name=".ui.activity.ReplyActivity"
7676
android:label="@string/title_activity_reply"
77-
android:theme="@style/AppTheme" />
77+
android:theme="@style/AppTheme.NoActionBar" />
7878
</application>
7979

8080
</manifest>

app/src/main/kotlin/com/rayfantasy/icode/ui/activity/LoginActivity.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import org.jetbrains.anko.startActivity
1818
class LoginActivity : ActivityBase() {
1919
private var request: Request<*>? = null
2020

21+
override val bindingStatus: Boolean
22+
get() = true
23+
2124
override fun onCreate(savedInstanceState: Bundle?) {
2225
super.onCreate(savedInstanceState)
2326
DataBindingUtil.setContentView<ActivityLoginBinding>(this, R.layout.activity_login).theme = ICodeTheme

app/src/main/kotlin/com/rayfantasy/icode/ui/activity/MainActivity.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.content.Intent
99
import android.content.IntentFilter
1010
import android.databinding.DataBindingUtil
1111
import android.net.Uri
12+
import android.os.Build
1213
import android.os.Bundle
1314
import android.support.design.widget.NavigationView
1415
import android.support.v4.content.LocalBroadcastManager
@@ -44,6 +45,7 @@ import kotlinx.android.synthetic.main.activity_main.*
4445
import kotlinx.android.synthetic.main.app_bar_main.*
4546
import kotlinx.android.synthetic.main.nv_layout.view.*
4647
import org.jetbrains.anko.async
48+
import org.jetbrains.anko.configuration
4749
import org.jetbrains.anko.onClick
4850
import org.jetbrains.anko.startActivity
4951
import java.io.File
@@ -78,6 +80,7 @@ class MainActivity : ActivityBase(), NavigationView.OnNavigationItemSelectedList
7880
drawer_layout.setDrawerListener(toggle)
7981
toggle.syncState()
8082
nav_view.setNavigationItemSelectedListener(this)
83+
configuration(fromSdk = Build.VERSION_CODES.LOLLIPOP) { drawer_layout.fitsSystemWindows = true }
8184

8285
val headerView = nav_view.getHeaderView(0)
8386
NvLayoutBinding.bind(headerView).theme = ICodeTheme
@@ -227,8 +230,6 @@ class MainActivity : ActivityBase(), NavigationView.OnNavigationItemSelectedList
227230
}
228231

229232
private fun replaceFragment(fragment: Fragment) {
230-
if (fragment != mainFragment)
231-
app_bar.setExpanded(false)
232233
val transaction = fragmentManager.beginTransaction()
233234
transaction.replace(R.id.main_contain, fragment).commit()
234235
}

app/src/main/kotlin/com/rayfantasy/icode/ui/activity/RegisterActivity.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class RegisterActivity : ActivityBase() {
3030

3131
private var request: Request<*>? = null
3232
private lateinit var binding: ActivityRegisterBinding
33+
34+
override val bindingStatus: Boolean
35+
get() = true
36+
3337
override fun onCreate(savedInstanceState: Bundle?) {
3438
super.onCreate(savedInstanceState)
3539
binding = DataBindingUtil.setContentView(this, R.layout.activity_register)

app/src/main/res/layout/activity_account_setting.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<android.support.design.widget.CoordinatorLayout
1414
android:layout_width="match_parent"
1515
android:layout_height="match_parent"
16-
android:fitsSystemWindows="true"
1716
app:statusBarBackgroundColor="@{theme.colorPrimaryDark}"
1817
tools:context=".ui.activity.AccountSettingActivity">
1918

@@ -25,8 +24,10 @@
2524
<android.support.v7.widget.Toolbar
2625
android:id="@+id/toolbar"
2726
android:layout_width="match_parent"
28-
android:layout_height="?attr/actionBarSize"
27+
android:layout_height="wrap_content"
2928
android:background="@{theme.colorPrimary}"
29+
android:fitsSystemWindows="true"
30+
android:minHeight="?attr/actionBarSize"
3031
app:popupTheme="@style/AppTheme.PopupOverlay" />
3132

3233
</android.support.design.widget.AppBarLayout>

app/src/main/res/layout/activity_blocks.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<android.support.design.widget.CoordinatorLayout
1414
android:layout_width="match_parent"
1515
android:layout_height="match_parent"
16-
android:fitsSystemWindows="true"
1716
app:statusBarBackgroundColor="@{theme.colorPrimaryDark}"
1817
tools:context=".ui.activity.BlocksActivity">
1918

@@ -25,8 +24,10 @@
2524
<android.support.v7.widget.Toolbar
2625
android:id="@+id/toolbar"
2726
android:layout_width="match_parent"
28-
android:layout_height="?attr/actionBarSize"
27+
android:layout_height="wrap_content"
2928
android:background="@{theme.colorPrimary}"
29+
android:fitsSystemWindows="true"
30+
android:minHeight="?attr/actionBarSize"
3031
app:popupTheme="@style/AppTheme.PopupOverlay" />
3132

3233
</android.support.design.widget.AppBarLayout>

app/src/main/res/layout/activity_comment.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@
1313
<android.support.design.widget.CoordinatorLayout
1414
android:layout_width="match_parent"
1515
android:layout_height="match_parent"
16-
android:fitsSystemWindows="true"
1716
app:statusBarBackgroundColor="@{theme.colorPrimaryDark}"
1817
tools:context="com.rayfantasy.icode.ui.CommentActivity">
1918

2019
<android.support.design.widget.AppBarLayout
21-
android:layout_height="wrap_content"
2220
android:layout_width="match_parent"
21+
android:layout_height="wrap_content"
2322
android:theme="@style/AppTheme.AppBarOverlay">
2423

2524
<android.support.v7.widget.Toolbar
2625
android:id="@+id/toolbar"
2726
android:layout_width="match_parent"
28-
android:layout_height="?attr/actionBarSize"
27+
android:layout_height="wrap_content"
2928
android:background="@{theme.colorPrimary}"
29+
android:fitsSystemWindows="true"
30+
android:minHeight="?attr/actionBarSize"
3031
app:popupTheme="@style/AppTheme.PopupOverlay" />
3132

3233
</android.support.design.widget.AppBarLayout>

app/src/main/res/layout/activity_login.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<android.support.design.widget.CoordinatorLayout
1414
android:layout_width="match_parent"
1515
android:layout_height="match_parent"
16-
android:fitsSystemWindows="true"
1716
tools:context=".ui.activity.LoginActivity"
1817
tools:showIn="@layout/content_login">
1918

app/src/main/res/layout/activity_main.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
<variable
99
name="theme"
1010
type="com.rayfantasy.icode.model.ICodeTheme" />
11+
1112
</data>
1213

1314
<android.support.v4.widget.DrawerLayout
1415
android:id="@+id/drawer_layout"
1516
android:layout_width="match_parent"
1617
android:layout_height="match_parent"
17-
android:fitsSystemWindows="true"
18+
app:statusBarBackgroundColor="@{theme.colorPrimaryDark}"
1819
tools:openDrawer="start">
1920

2021
<include
@@ -30,8 +31,8 @@
3031
android:layout_gravity="start"
3132
android:fitsSystemWindows="true"
3233
app:headerLayout="@layout/nv_layout"
33-
app:menu="@menu/nv_menu"
34-
app:itemSelectColor="@{theme.colorPrimary}" />
34+
app:itemSelectColor="@{theme.colorPrimary}"
35+
app:menu="@menu/nv_menu" />
3536

3637
</android.support.v4.widget.DrawerLayout>
3738
</layout>

app/src/main/res/layout/activity_register.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<android.support.design.widget.CoordinatorLayout
1414
android:layout_width="match_parent"
1515
android:layout_height="match_parent"
16-
android:fitsSystemWindows="true"
1716
tools:context=".ui.activity.LoginActivity">
1817

1918
<android.support.design.widget.AppBarLayout
@@ -31,7 +30,6 @@
3130
android:fitsSystemWindows="true"
3231
app:contentScrimColor="@{theme.colorPrimary}"
3332
app:statusBarScrimColor="@{theme.colorPrimaryDark}"
34-
app:layout_scrollFlags="scroll|exitUntilCollapsed"
3533
app:contentScrim="?attr/colorPrimary">
3634

3735
<android.support.v7.widget.Toolbar

0 commit comments

Comments
 (0)