Skip to content

Commit

Permalink
UI Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mickstar committed Jan 9, 2021
1 parent 254ec69 commit 77506ee
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ interface Contract {
fun showBasicSyncAnimation()
fun hideBasicSyncAnimation()
fun highlightMenuItem(state: LibraryModelState)
fun showLoadingAlertDialog(message: String)
fun hideLoadingAlertDialog()
}

interface Presenter {
Expand All @@ -63,6 +65,7 @@ interface Contract {
total: Int,
message: String
)

fun isLiveSearchEnabled(): Boolean
fun isShowingContent(): Boolean
fun cancelAttachmentDownload()
Expand All @@ -89,7 +92,9 @@ interface Contract {
fun backButtonPressed()
fun addFilterState(query: String)
fun openMyPublications()
fun onTagOpen(tagName: String)
fun onTagOpen(tagName: String)
fun showLoadingAlertDialog(message: String)
fun hideLoadingAlertDialog()
}

interface Model {
Expand All @@ -99,7 +104,7 @@ interface Contract {
fun refreshLibrary(useSmallLoadingAnimation: Boolean = false)
fun getCollections(): List<Collection>
fun getAttachments(itemKey: String): List<Item>
fun getMyPublications() : List<Item>
fun getMyPublications(): List<Item>
fun downloadAttachment(item: Item)
fun cancelAttachmentDownload()
fun getSubCollections(collectionName: String): List<Collection>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.mickstarify.zooforzotero.LibraryActivity.ItemView

import android.content.Context
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.*
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
Expand All @@ -28,8 +25,7 @@ import java.util.*
class ItemViewFragment : BottomSheetDialogFragment(),
NoteInteractionListener,
onShareItemListener,
ItemTagEntry.OnTagEntryInteractionListener
{
ItemTagEntry.OnTagEntryInteractionListener {
override fun deleteNote(note: Note) {
listener?.onNoteDelete(note)
}
Expand Down Expand Up @@ -140,14 +136,6 @@ class ItemViewFragment : BottomSheetDialogFragment(),
addTextEntry(key, value)
}
}
val attachmentsLayout =
view.findViewById<LinearLayout>(R.id.item_fragment_scrollview_ll_attachments)
attachmentsLayout.addView(TextView(context).apply {
this.text = "Attachments"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
this.setTextAppearance(android.R.style.TextAppearance_DeviceDefault_Large)
}
})
this.addAttachments(attachments)
this.populateNotes(notes)
this.populateTags(item.tags.map { it.tag })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.WindowManager
import android.widget.*
import android.widget.AbsListView
import android.widget.ListView
import android.widget.ProgressBar
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
Expand Down Expand Up @@ -87,7 +91,12 @@ class LibraryActivity : AppCompatActivity(), Contract.View,
.setIcon(R.drawable.baseline_description_24).isCheckable = true

// add our "My Publications" entry
navigationView.menu.add(R.id.group_other, MENU_ID_MY_PUBLICATIONS, Menu.NONE, "My Publications")
navigationView.menu.add(
R.id.group_other,
MENU_ID_MY_PUBLICATIONS,
Menu.NONE,
"My Publications"
)
.setIcon(R.drawable.baseline_book_24).isCheckable = true

// add our "Trash" entry
Expand Down Expand Up @@ -442,6 +451,21 @@ class LibraryActivity : AppCompatActivity(), Contract.View,
swipeRefresh.isRefreshing = false
}

override fun showLoadingAlertDialog(message: String) {
if (progressDialog == null) {
progressDialog = ProgressDialog(this)
}
progressDialog?.isIndeterminate = true
progressDialog?.setMessage(message)
progressDialog?.show()

}

override fun hideLoadingAlertDialog() {
progressDialog?.hide()
progressDialog = null
}

@Suppress("DEPRECATION")
var progressDialog: ProgressDialog? = null

Expand Down Expand Up @@ -645,6 +669,7 @@ class LibraryActivity : AppCompatActivity(), Contract.View,
override fun onNoteDelete(note: Note) {
presenter.deleteNote(note)
}

private var doubleBackToExitPressedOnce = false
override fun onBackPressed() {
if (!searchView.isIconified) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class LibraryActivityModel(private val presenter: Contract.Presenter, val contex
}
return
}

presenter.showLoadingAlertDialog("Opening your attachment")
// check to see if the attachment exists but is invalid
val attachmentExists: Boolean
try {
Expand All @@ -265,8 +265,8 @@ class LibraryActivityModel(private val presenter: Contract.Presenter, val contex
}
if (attachmentExists) {
// check the validity of the attachment before opening.
if (preferences.shouldCheckMd5SumBeforeOpening() &&
zoteroDB.hasMd5Key(
presenter.showLoadingAlertDialog("Verifying MD5 Checksum")
if (preferences.shouldCheckMd5SumBeforeOpening() && zoteroDB.hasMd5Key(
item,
onlyWebdav = preferences.isWebDAVEnabled()
) && !attachmentStorageManager.validateMd5ForItem(
Expand All @@ -282,15 +282,18 @@ class LibraryActivityModel(private val presenter: Contract.Presenter, val contex
attachmentStorageManager.deleteAttachment(item)
downloadAttachment(item)
}, {
presenter.hideLoadingAlertDialog()
openPDF(item)
}
)
return
} else {
presenter.hideLoadingAlertDialog()
openPDF(item)
}

} else {
presenter.hideLoadingAlertDialog()
presenter.updateAttachmentDownloadProgress(0, -1)
downloadAttachment(item)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import com.mickstarify.zooforzotero.ZoteroAPI.Model.Note
import com.mickstarify.zooforzotero.ZoteroStorage.Database.Collection
import com.mickstarify.zooforzotero.ZoteroStorage.Database.GroupInfo
import com.mickstarify.zooforzotero.ZoteroStorage.Database.Item
import java.util.*
import java.util.LinkedList
import java.util.Locale

class LibraryActivityPresenter(val view: Contract.View, context: Context) : Contract.Presenter {
val sortMethod = compareBy<Item> {
Expand Down Expand Up @@ -124,6 +125,14 @@ class LibraryActivityPresenter(val view: Contract.View, context: Context) : Cont
view.setTitle("Tag: $tagName")
}

override fun showLoadingAlertDialog(message: String) {
view.showLoadingAlertDialog(message)
}

override fun hideLoadingAlertDialog() {
view.hideLoadingAlertDialog()
}

override fun filterEntries(query: String) {
if (query == "" || !model.isLoaded()) {
//not going to waste my time lol.
Expand Down
54 changes: 35 additions & 19 deletions app/src/main/res/layout/fragment_item_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,56 @@
android:layout_height="match_parent">

<LinearLayout
android:theme="@style/AppTheme"
android:theme="@style/AppTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:id="@+id/item_fragment_scrollview_ll_attachments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="vertical">

<LinearLayout
android:id="@+id/item_fragment_scrollview_ll_layout"
<TextView
android:id="@+id/textView_attachments_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

android:text="Attachments"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
</LinearLayout>

<LinearLayout
android:id="@+id/item_fragment_scrollview_ll_attachments"
android:id="@+id/item_fragment_scrollview_ll_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/textView_information_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:orientation="vertical" />
android:text="Information"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />

</LinearLayout>

<LinearLayout
android:id="@+id/item_fragment_scrollview_ll_notes"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="vertical">
android:id="@+id/item_fragment_scrollview_ll_notes"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="vertical">


<TextView
android:id="@+id/textView_notes_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Notes"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
android:id="@+id/textView_notes_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Notes"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
</LinearLayout>

<LinearLayout
Expand Down

0 comments on commit 77506ee

Please sign in to comment.