Commit 7e90cc95 authored by Jonas L.'s avatar Jonas L.

Add new download content dialog

parent 74d80c75
......@@ -16,8 +16,8 @@ import com.mikepenz.materialdrawer.DrawerBuilder
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem
import com.mikepenz.materialdrawer.model.ProfileDrawerItem
import de.determapp.android.R
import de.determapp.android.ui.viewer.info.DownloadContentDialogFragment
import de.determapp.android.ui.viewer.info.ProjectInfoDialogFragment
import de.determapp.android.ui.viewer.info.ViewerContentInfoDialogFragment
import de.determapp.android.ui.viewer.loading.ViewerModel
import kotlinx.android.synthetic.main.app_bar_viewer.*
import kotlinx.android.synthetic.main.content_viewer.*
......@@ -65,11 +65,6 @@ class ViewerActivity : AppCompatActivity(), StackAdapterHandler, ViewPager.OnPag
.withTextColorRes(R.color.md_white_1000)
.withSelectionListEnabled(false)
.withProfileImagesVisible(false)
.withOnAccountHeaderSelectionViewClickListener { _, _ ->
ViewerContentInfoDialogFragment().show(supportFragmentManager)
false
}
.build()
drawer = DrawerBuilder()
......@@ -78,6 +73,16 @@ class ViewerActivity : AppCompatActivity(), StackAdapterHandler, ViewPager.OnPag
.withSavedInstance(savedInstanceState)
.withAccountHeader(accountHeader)
.addStickyDrawerItems(
PrimaryDrawerItem()
.withName(R.string.viewer_menu_download_project)
.withIcon(R.drawable.ic_file_download_black_24dp)
.withIconTintingEnabled(true)
.withSelectable(false)
.withOnDrawerItemClickListener { _, _, _ ->
DownloadContentDialogFragment().show(supportFragmentManager)
false
},
PrimaryDrawerItem()
.withName(R.string.viewer_menu_about_project)
.withIcon(R.drawable.ic_info_outline_black_24dp)
......@@ -124,11 +129,7 @@ class ViewerActivity : AppCompatActivity(), StackAdapterHandler, ViewPager.OnPag
// this is required because the headerView is not attached during until the first
// layout pass because it uses an RecyclerView
accountHeader.clear()
accountHeader.addProfiles(
ProfileDrawerItem()
.withName(it.project.title)
.withEmail(R.string.drawer_header_tap_for_info)
)
accountHeader.addProfiles(ProfileDrawerItem().withName(it.project.title))
setDrawerEnabled(true)
......
package de.determapp.android.ui.viewer.info
import android.app.Dialog
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
......@@ -10,16 +7,14 @@ import android.view.View
import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Toast
import androidx.appcompat.app.AppCompatDialog
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import de.determapp.android.R
import de.determapp.android.content.database.AppDatabaseInstance
import de.determapp.android.content.projectdata.Image
import de.determapp.android.databinding.ViewerInfoDialogBinding
import de.determapp.android.databinding.DownloadContentDialogBinding
import de.determapp.android.service.work.PackageSourceContentDownloading
import de.determapp.android.ui.viewer.PackageSource
import de.determapp.android.ui.viewer.ViewerActivity
......@@ -28,12 +23,12 @@ import de.determapp.android.ui.viewer.loading.ViewerModel
import de.determapp.android.util.Async
import de.determapp.android.util.formatSize
class ViewerContentInfoDialogFragment: DialogFragment(), ViewerInfoHandlers {
class DownloadContentDialogFragment: BottomSheetDialogFragment(), ViewerInfoHandlers {
companion object {
const val TAG = "ViewerContentInfoDialogFragment"
const val TAG = "DownloadContentDialogFragment"
}
lateinit var binding: ViewerInfoDialogBinding
lateinit var binding: DownloadContentDialogBinding
lateinit var viewerMode: LiveData<ViewerInfoMode>
lateinit var resolutionSpinnerAdapter: ArrayAdapter<String>
......@@ -41,12 +36,8 @@ class ViewerContentInfoDialogFragment: DialogFragment(), ViewerInfoHandlers {
show(fragmentManager, TAG)
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return AppCompatDialog(context, theme)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = ViewerInfoDialogBinding.inflate(inflater, container, false)
binding = DownloadContentDialogBinding.inflate(inflater, container, false)
binding.handlers = this
......@@ -75,12 +66,12 @@ class ViewerContentInfoDialogFragment: DialogFragment(), ViewerInfoHandlers {
if (resolution.width != status.loadedProjectSpec.selectedResolution) {
val db = AppDatabaseInstance.with(context!!)
Async.disk.submit({
Async.disk.submit {
db.packageSourceProjectDao().updateSelectedResolution(
status.loadedProjectSpec.projectSpec.projectId,
resolution.width
)
})
}
}
}
}
......@@ -157,21 +148,6 @@ class ViewerContentInfoDialogFragment: DialogFragment(), ViewerInfoHandlers {
return getViewerActivity().model
}
override fun openImprint() {
val status = getModel().getStatus().value
if (status is ViewerStatusRunning) {
try {
startActivity(
Intent(Intent.ACTION_VIEW, Uri.parse(status.project.imprint))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
)
} catch (ex: Throwable) {
Toast.makeText(context, R.string.toast_open_external_failed, Toast.LENGTH_SHORT).show()
}
}
}
override fun scheduleDownload() {
if (viewerMode.value != ViewerInfoMode.Streaming) {
return
......@@ -236,7 +212,6 @@ class ViewerContentInfoDialogFragment: DialogFragment(), ViewerInfoHandlers {
data class ViewerContentInfo (val title: String, val description: String, val hasImprint: Boolean)
interface ViewerInfoHandlers {
fun openImprint()
fun scheduleDownload()
fun downloadNow()
fun cancelDownload()
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19,9h-4V3H9v6H5l7,7 7,-7zM5,18v2h14v-2H5z"/>
</vector>
......@@ -18,7 +18,6 @@
<import type="android.text.TextUtils" />
</data>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:minWidth="400dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
......@@ -28,33 +27,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="@{status.title}"
android:textAppearance="?android:textAppearanceLarge"
tools:text="Schmetterlinge"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:visibility="@{TextUtils.isEmpty(status.description) ? View.GONE : View.VISIBLE}"
android:text="@{status.description}"
android:textAppearance="?android:textAppearanceSmall"
tools:text="Dieser Bestimmungsschlüssel enthält die 50 häufigsten Tagfalter Deutschlands laut dem Tagfalter Monitoring Deutschland. Die Bildquellen sind jeweils auf den Ergebnissseiten angegeben."
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:visibility="@{TextUtils.isEmpty(status.description) ? View.GONE : View.VISIBLE}"
android:onClick="@{() -> handlers.openImprint()}"
style="?android:buttonStyleSmall"
android:background="?selectableItemBackground"
android:text="@string/viewer_info_dialog_btn_imprint"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:visibility="@{mode == ViewerInfoMode.LocalNetworkPackage ? View.GONE : View.VISIBLE}"
android:textAppearance="?android:textAppearance"
android:textAppearance="?android:textAppearanceLarge"
android:text="@string/viewer_info_dialog_section_resolution"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
......@@ -66,7 +41,7 @@
android:layout_height="wrap_content" />
<TextView
android:textAppearance="?android:textAppearance"
android:textAppearance="?android:textAppearanceLarge"
android:text="@string/viewer_info_dialog_section_download"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
app:srcCompat="@mipmap/ic_launcher" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:text="@string/app_name"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:clickable="true"
android:focusable="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
app:srcCompat="@mipmap/ic_launcher" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:id="@+id/drawerHeaderText"
tools:text="Wirbellose im Wasser"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/drawer_header_tap_for_info" />
</LinearLayout>
......@@ -24,7 +24,6 @@
<string name="notification_channel_download_description">Benachrichtigung über den Fortschritt des laufenden Downloads</string>
<string name="drawer_placeholder">(Kein Text)</string>
<string name="drawer_header_tap_for_info">Für weitere Informationen und die Option zum Herunterladen hier tippen</string>
<string name="package_source_add_dialog_title">Paketquelle hinzufügen</string>
<string name="package_source_add_dialog_hint">URL der Paketquelle</string>
......@@ -61,6 +60,7 @@
<string name="viewer_subtitle_last_question">Das ist die letzte Frage</string>
<string name="viewer_menu_about_project">Über den Bestimmungsschlüssel</string>
<string name="viewer_menu_download_project">Bestimmungsschlüssel herunterladen</string>
<string name="viewer_info_dialog_btn_imprint">Impressum des Bestimmungsschlüssels öffnen</string>
<string name="viewer_info_dialog_section_resolution">Auflösung der Bilder</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment