Skip to content

Commit

Permalink
Status bar color fix for pre-lollipop versions oppia#1042
Browse files Browse the repository at this point in the history
  • Loading branch information
prathameshbhalekar committed May 18, 2020
1 parent 5b5c6f9 commit 344d228
Show file tree
Hide file tree
Showing 26 changed files with 131 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ class NavigationDrawerFragmentPresenter @Inject constructor(
override fun onDrawerOpened(drawerView: View) {
super.onDrawerOpened(drawerView)
fragment.activity!!.invalidateOptionsMenu()
StatusBarColor.statusBarColorUpdate(R.color.slideDrawerOpenStatusBar, activity, false)
StatusBarColor.statusBarColorUpdate(R.color.slideDrawerOpenStatusBar, activity,binding.statusBarBackground, false)
}

override fun onDrawerClosed(drawerView: View) {
super.onDrawerClosed(drawerView)
fragment.activity!!.invalidateOptionsMenu()
StatusBarColor.statusBarColorUpdate(R.color.colorPrimaryDark, activity, false)
StatusBarColor.statusBarColorUpdate(R.color.colorPrimaryDark, activity,binding.statusBarBackground, false)
}
}
drawerLayout.setDrawerListener(drawerToggle)
Expand All @@ -279,13 +279,13 @@ class NavigationDrawerFragmentPresenter @Inject constructor(
override fun onDrawerOpened(drawerView: View) {
super.onDrawerOpened(drawerView)
fragment.activity!!.invalidateOptionsMenu()
StatusBarColor.statusBarColorUpdate(R.color.slideDrawerOpenStatusBar, activity, false)
StatusBarColor.statusBarColorUpdate(R.color.slideDrawerOpenStatusBar, activity,binding.statusBarBackground, false)
}

override fun onDrawerClosed(drawerView: View) {
super.onDrawerClosed(drawerView)
fragment.activity!!.invalidateOptionsMenu()
StatusBarColor.statusBarColorUpdate(R.color.colorPrimaryDark, activity, false)
StatusBarColor.statusBarColorUpdate(R.color.colorPrimaryDark, activity,binding.statusBarBackground, false)
}
}
drawerLayout.setDrawerListener(drawerToggle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class TopicListAdapter(
*/
val snapHelper = StartSnapHelper()
binding.promotedStoryListRecyclerView.layoutManager = horizontalLayoutManager
binding.promotedStoryListRecyclerView.setOnFlingListener(null)
binding.promotedStoryListRecyclerView.onFlingListener = null
snapHelper.attachToRecyclerView(binding.promotedStoryListRecyclerView)

val paddingEnd = if (orientation == Configuration.ORIENTATION_PORTRAIT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ class OnboardingFragmentPresenter @Inject constructor(

private fun onboardingStatusBarColorUpdate(position: Int) {
when (position) {
0 -> StatusBarColor.statusBarColorUpdate(R.color.onboarding1StatusBar, activity, false)
1 -> StatusBarColor.statusBarColorUpdate(R.color.onboarding2StatusBar, activity, false)
2 -> StatusBarColor.statusBarColorUpdate(R.color.onboarding3StatusBar, activity, false)
3 -> StatusBarColor.statusBarColorUpdate(R.color.onboarding4StatusBar, activity, false)
else -> StatusBarColor.statusBarColorUpdate(R.color.colorPrimaryDark, activity, false)
0 -> StatusBarColor.statusBarColorUpdate(R.color.onboarding1StatusBar, activity,binding.statusBarBackground, false)
1 -> StatusBarColor.statusBarColorUpdate(R.color.onboarding2StatusBar, activity,binding.statusBarBackground, false)
2 -> StatusBarColor.statusBarColorUpdate(R.color.onboarding3StatusBar, activity,binding.statusBarBackground, false)
3 -> StatusBarColor.statusBarColorUpdate(R.color.onboarding4StatusBar, activity,binding.statusBarBackground, false)
else -> StatusBarColor.statusBarColorUpdate(R.color.colorPrimaryDark, activity,binding.statusBarBackground, false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class StateFragmentPresenter @Inject constructor(
if (bottom < oldBottom) {
binding.stateRecyclerView.postDelayed({
binding.stateRecyclerView.scrollToPosition(
stateRecyclerViewAdapter.getItemCount() - 1
stateRecyclerViewAdapter.itemCount - 1
)
}, 100)
}
Expand Down Expand Up @@ -545,7 +545,7 @@ class StateFragmentPresenter @Inject constructor(
}

private fun showCongratulationMessageOnCorrectAnswer() {
binding.congratulationTextview.setVisibility(View.VISIBLE)
binding.congratulationTextview.visibility = View.VISIBLE

val fadeIn = AlphaAnimation(0f, 1f)
fadeIn.interpolator = DecelerateInterpolator() //add this
Expand All @@ -559,7 +559,7 @@ class StateFragmentPresenter @Inject constructor(
val animation = AnimationSet(false) //change to false
animation.addAnimation(fadeIn)
animation.addAnimation(fadeOut)
binding.congratulationTextview.setAnimation(animation)
binding.congratulationTextview.animation = animation

Handler().postDelayed({
binding.congratulationTextview.clearAnimation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class PinPasswordActivityPresenter @Inject constructor(

@ExperimentalCoroutinesApi
fun handleOnCreate() {
StatusBarColor.statusBarColorUpdate(R.color.pinInputStatusBar, activity, true)
val adminPin = activity.intent.getStringExtra(KEY_PIN_PASSWORD_ADMIN_PIN)
profileId = activity.intent.getIntExtra(KEY_PIN_PASSWORD_PROFILE_ID, -1)
val binding = DataBindingUtil.setContentView<PinPasswordActivityBinding>(activity, R.layout.pin_password_activity)
Expand All @@ -49,7 +48,7 @@ class PinPasswordActivityPresenter @Inject constructor(
lifecycleOwner = activity
viewModel = pinViewModel
}

StatusBarColor.statusBarColorUpdate(R.color.pinInputStatusBar, activity,binding.statusBarBackground, true)
binding.showPin.setOnClickListener {
pinViewModel.showPassword.set(!pinViewModel.showPassword.get()!!)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ package org.oppia.app.profile
import android.content.Context
import android.content.res.Configuration
import android.content.res.Resources
import android.os.Build
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.Window
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.databinding.ObservableField
Expand Down Expand Up @@ -78,12 +82,12 @@ class ProfileChooserFragmentPresenter @Inject constructor(

/** Binds ViewModel and sets up RecyclerView Adapter. */
fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? {
StatusBarColor.statusBarColorUpdate(R.color.profileStatusBar, activity, false)
binding = ProfileChooserFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false)
binding.apply {
viewModel = chooserViewModel
lifecycleOwner = fragment
}
StatusBarColor.statusBarColorUpdate(R.color.profileStatusBar, activity, binding.statusBarBackground, false)
binding.profileRecyclerView.isNestedScrollingEnabled = false
subscribeToWasProfileEverBeenAdded()
binding.profileRecyclerView.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class ProfilePictureActivityPresenter @Inject constructor(
private lateinit var profileId: ProfileId

fun handleOnCreate(internalProfileId: Int) {
StatusBarColor.statusBarColorUpdate(R.color.profileStatusBar, activity, false)
val binding = DataBindingUtil.setContentView<ProfilePictureActivityBinding>(activity, R.layout.profile_picture_activity)
profilePictureActivityViewModel = ProfilePictureActivityViewModel()

binding.apply {
viewModel = profilePictureActivityViewModel
lifecycleOwner = activity
}
StatusBarColor.statusBarColorUpdate(R.color.profileStatusBar, activity,binding.statusBarBackground, false)
profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build()

subscribeToProfileLiveData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class ProfileProgressViewModel @Inject constructor(
ongoingStoryList.recentStoryList
}
itemViewModelList.addAll(itemList.map { story ->
RecentlyPlayedStorySummaryViewModel(story) as ProfileProgressItemViewModel
RecentlyPlayedStorySummaryViewModel(story)
})
return itemViewModelList
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class BindableAdapter<T : Any> internal constructor(
private val dataList: MutableList<T> = ArrayList()

// TODO(#170): Introduce support for stable IDs.

/** Sets the data of this adapter. This is expected to be called by Android via data-binding. */
private fun setData(newDataList: List<T>) {
dataList.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ class InputInteractionViewTestActivity : AppCompatActivity(), StateKeyboardButto
override fun onPendingAnswerError(
pendingAnswerError: String?
) {
if (pendingAnswerError != null)
binding.submitButton.isEnabled = false
else
binding.submitButton.isEnabled = true
binding.submitButton.isEnabled = pendingAnswerError == null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class TopicPracticeViewModel @Inject constructor(
itemViewModelList.add(TopicPracticeHeaderViewModel() as TopicPracticeItemViewModel)

itemViewModelList.addAll(topic.subtopicList.map { subtopic ->
TopicPracticeSubtopicViewModel(subtopic) as TopicPracticeItemViewModel
TopicPracticeSubtopicViewModel(subtopic)
})

itemViewModelList.add(TopicPracticeFooterViewModel() as TopicPracticeItemViewModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class WalkthroughActivityPresenter @Inject constructor(
presenter = this@WalkthroughActivityPresenter
lifecycleOwner = activity
}
StatusBarColor.statusBarColorUpdate(R.color.walkthroughStatusBar, activity, true)
StatusBarColor.statusBarColorUpdate(R.color.walkthroughStatusBar, activity,binding.statusBarBackground, true)
val currentFragmentIndex = getWalkthroughViewModel().currentProgress.get()?.minus(1)

if (currentFragmentIndex == -1 && getWalkthroughWelcomeFragment() == null) {
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/res/layout-land/onboarding_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>

Expand All @@ -19,6 +20,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/oppiaBackgroundYellowIvory">
<View
android:id="@+id/statusBarBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" />

<androidx.viewpager.widget.ViewPager
android:id="@+id/onboarding_slide_view_pager"
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/res/layout-land/pin_password_activity.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>

Expand All @@ -20,6 +21,12 @@
android:paddingTop="48dp"
android:paddingBottom="76dp">

<View
android:id="@+id/statusBarBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/hello_text_view"
android:layout_width="wrap_content"
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/res/layout-land/profile_chooser_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>

Expand All @@ -24,7 +25,12 @@
android:id="@+id/profile_chooser_container"
android:layout_width="match_parent"
android:layout_height="match_parent">

<View
android:id="@+id/statusBarBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="-16dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout-land/profile_picture_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<View
android:id="@+id/statusBarBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
/>

<ImageView
android:id="@+id/profile_picture_image_view"
android:layout_width="0dp"
Expand Down
12 changes: 9 additions & 3 deletions app/src/main/res/layout/drawer_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>

Expand All @@ -14,7 +15,6 @@
<com.google.android.material.navigation.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.core.widget.NestedScrollView
android:id="@+id/drawer_nested_scroll_view"
android:layout_width="match_parent"
Expand All @@ -26,7 +26,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<View
android:id="@+id/statusBarBackground"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="invisible"
app:layout_constraintTop_toTopOf="parent"
/>
<com.google.android.material.navigation.NavigationView
android:id="@+id/fragment_drawer_nav_view"
android:layout_width="match_parent"
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/res/layout/onboarding_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>

Expand All @@ -19,7 +20,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/oppiaBackgroundYellowIvory">

<View
android:id="@+id/statusBarBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/onboarding_slide_view_pager"
android:layout_width="match_parent"
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/res/layout/pin_password_activity.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>

Expand All @@ -19,6 +20,12 @@
android:background="@color/oppiaLightGreen"
android:paddingTop="96dp">

<View
android:id="@+id/statusBarBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"/>

<TextView
android:id="@+id/hello_text_view"
android:layout_width="wrap_content"
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/res/layout/profile_chooser_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>
Expand All @@ -13,6 +14,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">


<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -25,6 +27,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<View
android:id="@+id/statusBarBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="-16dp" />

<ImageView
android:id="@+id/profile_chooser_language_icon"
android:layout_width="48dp"
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/profile_picture_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<View
android:id="@+id/statusBarBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
/>

<ImageView
android:id="@+id/profile_picture_image_view"
android:layout_width="0dp"
Expand Down
Loading

0 comments on commit 344d228

Please sign in to comment.