Merge pull request #1304 from nextcloud/improvePreviews

Improve Preview Screens
This commit is contained in:
Andy Scherzinger 2021-06-01 10:36:11 +02:00 committed by GitHub
commit 715eea917f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 88 additions and 36 deletions

View File

@ -4,7 +4,7 @@
* @author Marcel Hibbe
* @author Dariusz Olszewski
* @author Andy Scherzinger
* Copyright (C) 2021 Andy Scherzinger (infoi@andy-scherzinger.de)
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
* Copyright (C) 2021 Dariusz Olszewski
*
@ -54,7 +54,10 @@ class FullScreenImageActivity : AppCompatActivity() {
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return if (item.itemId == R.id.share) {
return if (item.itemId == android.R.id.home) {
onBackPressed()
true
} else if (item.itemId == R.id.share) {
val shareUri = FileProvider.getUriForFile(
this,
BuildConfig.APPLICATION_ID,
@ -82,7 +85,6 @@ class FullScreenImageActivity : AppCompatActivity() {
setContentView(binding.root)
setSupportActionBar(binding.imageviewToolbar)
supportActionBar?.setDisplayShowTitleEnabled(false)
binding.photoView.setOnPhotoTapListener { view, x, y ->
toggleFullscreen()
@ -102,6 +104,9 @@ class FullScreenImageActivity : AppCompatActivity() {
val fileName = intent.getStringExtra("FILE_NAME")
val isGif = intent.getBooleanExtra("IS_GIF", false)
supportActionBar?.title = fileName
supportActionBar?.setDisplayHomeAsUpEnabled(true)
path = applicationContext.cacheDir.absolutePath + "/" + fileName
if (isGif) {
binding.photoView.visibility = View.INVISIBLE

View File

@ -3,7 +3,7 @@
*
* @author Marcel Hibbe
* @author Andy Scherzinger
* Copyright (C) 2021 Andy Scherzinger (infoi@andy-scherzinger.de)
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
*
* This program is free software: you can redistribute it and/or modify
@ -53,7 +53,10 @@ class FullScreenMediaActivity : AppCompatActivity(), Player.EventListener {
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return if (item.itemId == R.id.share) {
return if (item.itemId == android.R.id.home) {
onBackPressed()
true
} else if (item.itemId == R.id.share) {
val shareUri = FileProvider.getUriForFile(
this,
BuildConfig.APPLICATION_ID,
@ -86,7 +89,8 @@ class FullScreenMediaActivity : AppCompatActivity(), Player.EventListener {
setContentView(binding.root)
setSupportActionBar(binding.mediaviewToolbar)
supportActionBar?.setDisplayShowTitleEnabled(false)
supportActionBar?.title = fileName
supportActionBar?.setDisplayHomeAsUpEnabled(true)
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)

View File

@ -3,7 +3,7 @@
*
* @author Marcel Hibbe
* @author Andy Scherzinger
* Copyright (C) 2021 Andy Scherzinger (infoi@andy-scherzinger.de)
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
*
* This program is free software: you can redistribute it and/or modify
@ -28,11 +28,13 @@ import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.FileProvider
import androidx.core.content.res.ResourcesCompat
import autodagger.AutoInjector
import com.nextcloud.talk.BuildConfig
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.databinding.ActivityFullScreenTextBinding
import com.nextcloud.talk.utils.DisplayUtils
import io.noties.markwon.Markwon
import java.io.File
@ -48,7 +50,10 @@ class FullScreenTextViewerActivity : AppCompatActivity() {
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return if (item.itemId == R.id.share) {
return if (item.itemId == android.R.id.home) {
onBackPressed()
true
} else if (item.itemId == R.id.share) {
val shareUri = FileProvider.getUriForFile(
this,
BuildConfig.APPLICATION_ID,
@ -76,7 +81,6 @@ class FullScreenTextViewerActivity : AppCompatActivity() {
setContentView(binding.root)
setSupportActionBar(binding.textviewToolbar)
supportActionBar?.setDisplayShowTitleEnabled(false)
val fileName = intent.getStringExtra("FILE_NAME")
val isMarkdown = intent.getBooleanExtra("IS_MARKDOWN", false)
@ -89,6 +93,21 @@ class FullScreenTextViewerActivity : AppCompatActivity() {
} else {
binding.textView.text = text
}
supportActionBar?.title = fileName
supportActionBar?.setDisplayHomeAsUpEnabled(true)
if (resources != null) {
DisplayUtils.applyColorToStatusBar(
this,
ResourcesCompat.getColor(resources, R.color.appbar, null)
)
DisplayUtils.applyColorToNavigationBar(
this.window,
ResourcesCompat.getColor(resources, R.color.bg_default, null)
)
}
}
private fun readFile(fileName: String) = File(fileName).inputStream().readBytes().toString(Charsets.UTF_8)

View File

@ -3,6 +3,8 @@
~
~ @author Marcel Hibbe
~ @author Dariusz Olszewski
~ @author Andy Scherzinger
~ Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
~ Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
~ Copyright (C) 2021 Dariusz Olszewski
~
@ -20,24 +22,22 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/image_wrapper_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:fitsSystemWindows="true"
tools:context=".activities.FullScreenImageActivity">
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/imageview_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/photo_view"
@ -49,7 +49,6 @@
android:id="@+id/gif_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"
/>
android:visibility="invisible" />
</FrameLayout>

View File

@ -2,6 +2,8 @@
~ Nextcloud Talk application
~
~ @author Marcel Hibbe
~ @author Andy Scherzinger
~ Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
~ Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
~
~ This program is free software: you can redistribute it and/or modify
@ -23,7 +25,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:fitsSystemWindows="true"
tools:context=".activities.FullScreenMediaActivity">
@ -33,7 +34,7 @@
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/player_view"

View File

@ -2,6 +2,8 @@
~ Nextcloud Talk application
~
~ @author Marcel Hibbe
~ @author Andy Scherzinger
~ Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
~ Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
~
~ This program is free software: you can redistribute it and/or modify
@ -18,27 +20,47 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:background="@color/bg_default"
tools:context=".activities.FullScreenTextViewerActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/textview_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Light"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<TextView
android:id="@+id/text_view"
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
tools:text="Lorem Ipsum"/>
android:clipChildren="true"
android:clipToPadding="false"
android:windowContentOverlay="@null">
</FrameLayout>
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/textview_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/appActionBarPopupMenu"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:navigationIconTint="@color/fontAppbar"
app:popupTheme="@style/appActionBarPopupMenu"
app:titleTextColor="@color/fontAppbar"
tools:title="Text File Preview" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/standard_padding"
tools:text="Lorem Ipsum" />
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -138,6 +138,7 @@
</style>
<style name="FullScreenImageTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@color/black</item>
<item name="android:navigationBarColor">@color/black</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">true</item>
@ -146,6 +147,7 @@
</style>
<style name="FullScreenMediaTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@color/black</item>
<item name="android:navigationBarColor">@color/black</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">true</item>
@ -153,8 +155,8 @@
<item name="android:windowContentOverlay">@null</item>
</style>
<style name="FullScreenTextTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:navigationBarColor">@color/black</item>
<style name="FullScreenTextTheme" parent="AppTheme">
<item name="android:navigationBarColor">@color/bg_default</item>
</style>
<!-- Launch screen -->

View File

@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 3 errors and 330 warnings</span>
<span class="mdl-layout-title">Lint Report: 3 errors and 329 warnings</span>