Skip to content

Commit

Permalink
Color navigation bar on Oreo
Browse files Browse the repository at this point in the history
  • Loading branch information
DSteve595 committed May 14, 2018
1 parent abe0150 commit 9f196a9
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 52 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/com/stevenschoen/putionew/PutioActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.os.Build
import android.os.Bundle
import android.preference.PreferenceManager
import android.support.v4.app.Fragment
import android.support.v4.content.ContextCompat
import android.support.v4.view.animation.FastOutSlowInInterpolator
import android.support.v7.widget.Toolbar
import android.view.Menu
Expand Down Expand Up @@ -298,7 +299,7 @@ class PutioActivity : BaseCastActivity() {
setSupportActionBar(toolbar)

bottomNavView = findViewById(R.id.main_bottom_nav)
bottomNavView.defaultBackgroundColor = Color.parseColor("#F8F8F8")
bottomNavView.defaultBackgroundColor = ContextCompat.getColor(this, R.color.putio_light_canvas)
bottomNavView.accentColor = Color.BLACK
bottomNavView.inactiveColor = Color.parseColor("#80000000")
bottomNavView.addItem(AHBottomNavigationItem(getString(R.string.account), R.drawable.ic_nav_account))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,17 @@ import io.reactivex.schedulers.Schedulers

class FileDetailsFragment : RxFragment() {

companion object {
const val EXTRA_FILE = "file"

const val REQUEST_DOWNLOAD = 1
const val REQUEST_DOWNLOAD_MP4 = 2

fun newInstance(context: Context, file: PutioFile): FileDetailsFragment {
if (file.isFolder) {
throw IllegalStateException("FileDetailsFragment created for the wrong kind of file: " +
"${file.name} (ID ${file.id}), type ${file.contentType}")
}
val args = Bundle()
args.putParcelable(EXTRA_FILE, file)
return Fragment.instantiate(context, FileDetailsFragment::class.java.name, args) as FileDetailsFragment
}
}

val fileDownloads by lazy { putioApp.fileDownloadDatabase.fileDownloadsDao() }
val fileDownloadHelper by lazy { FileDownloadHelper(context!!) }
private val fileDownloads by lazy { putioApp.fileDownloadDatabase.fileDownloadsDao() }
private val fileDownloadHelper by lazy { FileDownloadHelper(context!!) }

var onBackPressed: (() -> Any)? = null
var castCallbacks: PutioApplication.CastCallbacks? = null

val file by lazy { arguments!!.getParcelable<PutioFile>(EXTRA_FILE)!! }
val showMp4Options by lazy { file.isVideo && !file.isMp4 }
private val file by lazy { arguments!!.getParcelable<PutioFile>(EXTRA_FILE)!! }
private val showMp4Options by lazy { file.isVideo && !file.isMp4 }

lateinit var loader: FileDetailsLoader
var mp4Loader: Mp4StatusLoader? = null
private lateinit var loader: FileDetailsLoader
private var mp4Loader: Mp4StatusLoader? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -282,20 +265,24 @@ class FileDetailsFragment : RxFragment() {
data class DownloadAndMp4Status(
val download: FileDownload, val mp4Status: PutioMp4Status)

val mp4Status = if (showMp4Options) {
mp4Loader!!.mp4Status()
.startWith(PutioMp4Status().apply {
// Assume it's completed, most common case
status = PutioMp4Status.Status.Completed
})
.bindToLifecycle(this@FileDetailsFragment)
} else if (useVideoTitleBackground) {
Observable.just(PutioMp4Status().apply { status = PutioMp4Status.Status.AlreadyMp4 })
} else {
playActionView.visibility = View.GONE
playProgressBarView.visibility = View.GONE
playMoreView.visibility = View.GONE
Observable.just(PutioMp4Status().apply { status = PutioMp4Status.Status.NotVideo })
val mp4Status = when {
showMp4Options -> {
mp4Loader!!.mp4Status()
.startWith(PutioMp4Status().apply {
// Assume it's completed, most common case
status = PutioMp4Status.Status.Completed
})
.bindToLifecycle(this@FileDetailsFragment)
}
useVideoTitleBackground -> {
Observable.just(PutioMp4Status().apply { status = PutioMp4Status.Status.AlreadyMp4 })
}
else -> {
playActionView.visibility = View.GONE
playProgressBarView.visibility = View.GONE
playMoreView.visibility = View.GONE
Observable.just(PutioMp4Status().apply { status = PutioMp4Status.Status.NotVideo })
}
}
val downloadAndMp4Status: Observable<DownloadAndMp4Status> = Observable.combineLatest(
fileDownloadWithDefault, mp4Status, BiFunction { newDownload, newMp4Status ->
Expand Down Expand Up @@ -516,4 +503,22 @@ class FileDetailsFragment : RxFragment() {
}
}
}

companion object {
const val EXTRA_FILE = "file"

const val REQUEST_DOWNLOAD = 1
const val REQUEST_DOWNLOAD_MP4 = 2

fun newInstance(context: Context, file: PutioFile): FileDetailsFragment {
if (file.isFolder) {
throw IllegalStateException("FileDetailsFragment created for the wrong kind of file: " +
"${file.name} (ID ${file.id}), type ${file.contentType}")
}
val args = Bundle()
args.putParcelable(EXTRA_FILE, file)
return Fragment.instantiate(context, FileDetailsFragment::class.java.name, args) as FileDetailsFragment
}
}

}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
android:layout_alignParentBottom="true"
android:background="#F8F8F8"
android:elevation="@dimen/appBarElevation"
></FrameLayout>
/>

<android.support.design.widget.AppBarLayout
android:id="@+id/main_appbarlayout"
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values-large-port/integers.xml

This file was deleted.

4 changes: 0 additions & 4 deletions app/src/main/res/values-large/integers.xml

This file was deleted.

12 changes: 12 additions & 0 deletions app/src/main/res/values-v27/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Base.V27.Theme.Putio" parent="Base.V21.Theme.Putio">
<item name="android:navigationBarColor">@color/putio_light_canvas</item>
<item name="android:navigationBarDividerColor">@color/putio_divider</item>
<item name="android:windowLightNavigationBar">true</item>
</style>

<style name="Theme.Putio" parent="Base.V27.Theme.Putio" />

</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values/colors_putio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@
<color name="putio_filedetails_downloaded">#E5FFE5</color>
<color name="putio_filedetails_inprogress">#fbfbdf</color>
<color name="putio_filedetails_notdownloaded">#F8F8F8</color>

<color name="putio_light_canvas">#F8F8F8</color>
<color name="putio_divider">#1e000000</color>

</resources>
4 changes: 0 additions & 4 deletions app/src/main/res/values/integers.xml

This file was deleted.

4 changes: 3 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">

<style name="Theme.Putio" parent="Theme.AppCompat.Light.NoActionBar">
<style name="Base.V21.Theme.Putio" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/putio_accent</item>
<item name="colorPrimaryDark">@color/putio_accent_dark</item>
<item name="colorAccent">@color/putio_accent</item>
Expand All @@ -19,6 +19,8 @@
<item name="listChoiceBackgroundIndicator">@drawable/putio_clickable_list</item>
</style>

<style name="Theme.Putio" parent="Base.V21.Theme.Putio" />

<style name="Theme.Putio.Dark" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/putio_accent</item>
<item name="colorPrimaryDark">@color/putio_accent_dark</item>
Expand Down

0 comments on commit 9f196a9

Please sign in to comment.