Skip to content

Commit

Permalink
Visual cleanup in file details
Browse files Browse the repository at this point in the history
  • Loading branch information
DSteve595 committed Dec 8, 2018
1 parent a6dc22a commit ffe3972
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.stevenschoen.putionew.files

import android.Manifest
import android.animation.Animator
import android.animation.ObjectAnimator
import android.app.Activity
import android.app.DownloadManager
import android.content.ActivityNotFoundException
Expand All @@ -16,7 +14,6 @@ import android.graphics.drawable.Animatable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.AsyncTask
import android.os.Build
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
Expand All @@ -27,7 +24,6 @@ import android.widget.ImageView
import android.widget.PopupMenu
import android.widget.TextView
import android.widget.Toast
import androidx.core.content.ContextCompat
import androidx.core.content.res.use
import androidx.core.view.updatePaddingRelative
import androidx.core.widget.ImageViewCompat
Expand Down Expand Up @@ -79,32 +75,12 @@ class FileDetailsFragment : RxFragment() {

val titleView: TextView = findViewById(R.id.filedetails_title)
titleView.text = file.name
var titleBackgroundColorAnimator: Animator? = null
var lastTitleBackgroundColor: Int? = null
fun setTitleBackgroundColor(color: Int, animate: Boolean) {
if (color == lastTitleBackgroundColor) return
if (animate && Build.VERSION.SDK_INT >= 21) {
val startingColor = lastTitleBackgroundColor ?: color
titleBackgroundColorAnimator = ObjectAnimator.ofArgb(
titleView, "backgroundColor", startingColor, color
).apply {
start()
}
} else {
titleBackgroundColorAnimator?.cancel()
titleBackgroundColorAnimator = null
titleView.setBackgroundColor(color)
}
lastTitleBackgroundColor = color
}

val screenshotView: ImageView = findViewById(R.id.filedetails_screenshot)
val screenshotBlurryView: ImageView = findViewById(R.id.filedetails_screenshot_blurry)
val screenshotTopScrimView: View = findViewById(R.id.filedetails_screenshot_scrim_top)
val screenshotTitleScrimView: View = findViewById(R.id.filedetails_screenshot_scrim_title)

val fileGraphicView: View = findViewById(R.id.filedetails_graphic_file)

val backView: ImageButton = findViewById(R.id.filedetails_back)
backView.setOnClickListener {
onBackPressed?.invoke()
Expand Down Expand Up @@ -166,9 +142,7 @@ class FileDetailsFragment : RxFragment() {
.subscribe {
Picasso.get().cancelRequest(screenshotTarget)
}
fileGraphicView.visibility = View.GONE
} else {
titleView.setBackgroundColor(ContextCompat.getColor(context, R.color.putio_filedetails_notdownloaded))
screenshotView.visibility = View.GONE
screenshotBlurryView.visibility = View.GONE
screenshotTopScrimView.visibility = View.GONE
Expand Down Expand Up @@ -427,24 +401,6 @@ class FileDetailsFragment : RxFragment() {
}, { error ->
PutioUtils.getRxJavaThrowable(error).printStackTrace()
})

if (!useVideoTitleBackground) {
downloadStatus.subscribe({
val animate = (lastDownloadStatus != null)
val backgroundColorRes = when (it!!) {
FileDownload.Status.Downloaded -> R.color.putio_filedetails_downloaded
FileDownload.Status.InProgress -> R.color.putio_filedetails_inprogress
FileDownload.Status.NotDownloaded -> R.color.putio_filedetails_notdownloaded
}
setTitleBackgroundColor(
ContextCompat.getColor(
context, backgroundColorRes
), animate
)
}, { error ->
PutioUtils.getRxJavaThrowable(error).printStackTrace()
})
}
}
}

Expand Down
15 changes: 0 additions & 15 deletions app/src/main/res/drawable/filedetails_file.xml

This file was deleted.

60 changes: 25 additions & 35 deletions app/src/main/res/layout/filedetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
android:id="@+id/filedetails_screenshot_blurry"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#383838"
android:elevation="2dp"
android:scaleType="centerCrop"
app:layout_constraintDimensionRatio="16:9"
app:layout_constraintEnd_toEndOf="@+id/filedetails_title"
Expand All @@ -31,7 +29,6 @@
android:id="@+id/filedetails_screenshot"
android:layout_width="0dp"
android:layout_height="0dp"
android:elevation="2dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="@+id/filedetails_screenshot_blurry"
app:layout_constraintEnd_toEndOf="@+id/filedetails_screenshot_blurry"
Expand All @@ -43,7 +40,6 @@
android:id="@+id/filedetails_screenshot_scrim_top"
android:layout_width="0dp"
android:layout_height="0dp"
android:elevation="2dp"
app:layout_constraintBottom_toBottomOf="@+id/filedetails_screenshot"
app:layout_constraintEnd_toEndOf="@+id/filedetails_screenshot"
app:layout_constraintHeight_max="96dp"
Expand All @@ -56,7 +52,6 @@
android:id="@+id/filedetails_screenshot_scrim_title"
android:layout_width="0dp"
android:layout_height="0dp"
android:elevation="2dp"
app:layout_constraintBottom_toBottomOf="@+id/filedetails_screenshot"
app:layout_constraintEnd_toEndOf="@+id/filedetails_screenshot"
app:layout_constraintHeight_max="120dp"
Expand All @@ -69,7 +64,6 @@
android:id="@+id/filedetails_title"
android:layout_width="0dp"
android:layout_height="0dp"
android:elevation="2dp"
android:ellipsize="end"
android:gravity="bottom"
android:maxLines="2"
Expand All @@ -85,32 +79,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1"
tools:background="@color/putio_filedetails_notdownloaded"
tools:paddingTop="@dimen/filedetails_title_top_padding_video"
tools:text="File name.rar"
/>

<ImageView
android:id="@+id/filedetails_graphic_file"
android:layout_width="160dp"
android:layout_height="160dp"
android:scaleType="fitCenter"
android:src="@drawable/filedetails_file"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/filedetails_title"
app:layout_constraintHorizontal_bias="0.85"
app:layout_constraintStart_toStartOf="@+id/filedetails_title"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.9"
/>

<ImageButton
android:id="@+id/filedetails_back"
android:layout_width="48dp"
android:layout_height="64dp"
android:layout_marginStart="4dp"
android:background="?selectableItemBackgroundBorderless"
android:elevation="2dp"
android:scaleType="centerInside"
android:src="@drawable/ic_back"
app:layout_constraintStart_toStartOf="parent"
Expand Down Expand Up @@ -179,18 +157,31 @@
app:layout_constraintTop_toTopOf="@+id/filedetails_download"
/>

<View
android:id="@+id/filedetails_info_divider"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="24dp"
android:background="?android:listDivider"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/filedetails_download"
/>

<TextView
android:id="@+id/filedetails_crc32"
android:id="@+id/filedetails_accessed"
style="@style/Widget.Putio.TextView.FileInfo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_fileinfo_crc32"
android:layout_marginTop="16dp"
android:drawableStart="@drawable/ic_fileinfo_accessed"
android:paddingStart="20dp"
android:paddingEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/filedetails_filesize"
tools:text="66a1512f"
app:layout_constraintTop_toTopOf="@+id/filedetails_info_divider"
tools:text="@string/accessed_on_x_at_x"
/>

<TextView
Expand All @@ -208,32 +199,31 @@
/>

<TextView
android:id="@+id/filedetails_accessed"
android:id="@+id/filedetails_filesize"
style="@style/Widget.Putio.TextView.FileInfo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:drawableStart="@drawable/ic_fileinfo_accessed"
android:drawableStart="@drawable/ic_fileinfo_size"
android:paddingStart="20dp"
android:paddingEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/filedetails_download"
tools:text="@string/accessed_on_x_at_x"
app:layout_constraintTop_toBottomOf="@+id/filedetails_created"
tools:text="100 MB"
/>

<TextView
android:id="@+id/filedetails_filesize"
android:id="@+id/filedetails_crc32"
style="@style/Widget.Putio.TextView.FileInfo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_fileinfo_size"
android:drawableStart="@drawable/ic_fileinfo_crc32"
android:paddingStart="20dp"
android:paddingEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/filedetails_created"
tools:text="100 MB"
app:layout_constraintTop_toBottomOf="@+id/filedetails_filesize"
tools:text="66a1512f"
/>

</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/res/values/colors_putio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

<color name="putio_tv_background">#202020</color>

<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>

Expand Down

0 comments on commit ffe3972

Please sign in to comment.