Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import java.io.FileInputStream
import java.text.SimpleDateFormat
import java.util.Properties

plugins {
Expand Down Expand Up @@ -45,8 +46,8 @@ android {
minSdk = 29
//noinspection OldTargetApi
targetSdk = 34
versionCode = 30007
versionName = "0.7.8"
versionCode = 30011
versionName = "4.0.0"
multiDexEnabled = true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,44 +176,41 @@ class UploadMediaAdapter(
if (pos < 0 || pos >= media.size) return

val item = media[pos]
var undone = false

val snackbar =
Snackbar.make(recyclerView, R.string.confirm_remove_media, Snackbar.LENGTH_LONG)
snackbar.setAction(R.string.undo) { _ ->
undone = true
media.add(pos, item)

notifyItemInserted(pos)
// var undone = false

// val snackbar = Snackbar.make(recyclerView, R.string.confirm_remove_media, Snackbar.LENGTH_LONG)
// snackbar.setAction(R.string.undo) { _ ->
// undone = true
// media.add(pos, item)
//
// notifyItemInserted(pos)
// }

// snackbar.addCallback(object : Snackbar.Callback() {
// override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
// if (!undone) {
val collection = item.collection

// Delete collection along with the item, if the collection
// would become empty.
if ((collection?.size ?: 0) < 2) {
collection?.delete()
} else {
item.delete()
}

snackbar.addCallback(object : Snackbar.Callback() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
if (!undone) {
val collection = item.collection

// Delete collection along with the item, if the collection
// would become empty.
if ((collection?.size ?: 0) < 2) {
collection?.delete()
} else {
item.delete()
}
// }
//
// super.onDismissed(transientBottomBar, event)
// }
// })

BroadcastManager.postDelete(recyclerView.context, item.id)
}

super.onDismissed(transientBottomBar, event)
}
})

snackbar.show()
// snackbar.show()

removeItem(item.id)

mActivity.get()?.let {
BroadcastManager.postDelete(it, item.id)
}
BroadcastManager.postDelete(recyclerView.context, item.id)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ fun DialogHost(dialogStateManager: DialogStateManager) {
BaseDialog(
onDismiss = {
dialogStateManager.dismissDialog()
config.onDismissAction?.invoke()
},
icon = config.icon,
iconColor = config.iconColor,
Expand Down Expand Up @@ -322,6 +323,7 @@ private fun TorWarningDialogPreview() {
BaseDialog(
onDismiss = {},
icon = Icons.Default.Info.asUiImage(),
iconColor = MaterialTheme.colorScheme.tertiary,
title = stringResource(R.string.tor_disabled_title),
message = stringResource(R.string.tor_disabled_message),
positiveButton = ButtonData(UiText.DynamicString(stringResource(R.string.lbl_ok))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ class DialogBuilder {
.build(defaultText = defaultDestructiveText())
}

fun onDismissAction(block: () -> Unit) {
_onDismissAction = block
}

// Default texts based on type.
private fun defaultPositiveTextFor(type: DialogType): UiText = when (type) {
DialogType.Success -> UiText.StringResource(R.string.lbl_ok)
Expand Down Expand Up @@ -211,6 +215,7 @@ class DialogBuilder {
positiveButton = _positiveButton, //?: ButtonData(defaultPositiveTextFor(type)),
neutralButton = _neutralButton,
destructiveButton = _destructiveButton,
onDismissAction = _onDismissAction,
showCheckbox = showCheckbox,
checkboxText = checkboxText,
onCheckboxChanged = onCheckboxChanged,
Expand Down Expand Up @@ -267,6 +272,7 @@ fun DialogStateManager.showSuccessDialog(
@StringRes positiveButtonText: Int? = null,
icon: UiImage? = null,
onDone: () -> Unit = {},
onDismissed: () -> Unit = {}
) {
val resourceProvider = this.requireResourceProvider()

Expand All @@ -280,6 +286,9 @@ fun DialogStateManager.showSuccessDialog(
text = UiText.StringResource(positiveButtonText ?: R.string.lbl_got_it)
action = onDone
}
onDismissAction {
onDismissed()
}
}
}

Expand Down Expand Up @@ -345,6 +354,7 @@ fun DialogStateManager.showWarningDialog(
type = DialogType.Warning
this.title = title
this.icon = icon
iconColor = resourceProvider.getColor(R.color.colorTertiary)
this.message = message
positiveButton {
text = positiveButtonText ?: UiText.StringResource(R.string.lbl_got_it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ class BrowseFoldersFragment : BaseFragment(), MenuProvider {
positiveButtonText = R.string.label_got_it,
onDone = {
navigateBackWithResult(projectId)
},
onDismissed = {
// If the dialog is dismissed, we still want to navigate back
navigateBackWithResult(projectId)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ class MainActivity : BaseActivity(), SpaceDrawerAdapterListener, FolderDrawerAda
UploadService.startUploadService(this)
}

supportFragmentManager.setFragmentResultListener(
ContentPickerFragment.KEY_DISMISS,
this
) { _, _ ->
// when the sheet goes away, show your arrow
getCurrentMediaFragment()?.setArrowVisible(true)
}

reviewManager = ReviewManagerFactory.create(this)
InAppReviewHelper.requestReviewInfo(this)
shouldPromptReview = InAppReviewHelper.onAppLaunched()
Expand Down Expand Up @@ -356,6 +364,7 @@ class MainActivity : BaseActivity(), SpaceDrawerAdapterListener, FolderDrawerAda
} else if (getSelectedProject() == null) {
navigateToAddFolder()
} else {
getCurrentMediaFragment()?.setArrowVisible(false)
val addMediaBottomSheet =
ContentPickerFragment { actionType -> addClicked(actionType) }
addMediaBottomSheet.show(supportFragmentManager, ContentPickerFragment.TAG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,11 @@
(activity as? MainActivity)?.showUploadManagerFragment()
}

fun setArrowVisible(visible: Boolean) {
binding.imgWelcomeArrowLayout.visibility =
if (visible) View.VISIBLE else View.INVISIBLE
}


override fun getToolbarTitle(): String = ""

Check warning

Code scanning / detekt

Reports consecutive blank lines Warning

Needless blank line(s)
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,20 @@
if (pos < 0 || pos >= media.size) return

val item = media[pos]
var undone = false

val snackbar =
Snackbar.make(recyclerView, R.string.confirm_remove_media, Snackbar.LENGTH_LONG)
snackbar.setAction(R.string.undo) { _ ->
undone = true
media.add(pos, item)

notifyItemInserted(pos)
}

snackbar.addCallback(object : Snackbar.Callback() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
if (!undone) {
// var undone = false

// val snackbar =
// Snackbar.make(recyclerView, R.string.confirm_remove_media, Snackbar.LENGTH_INDEFINITE)
// snackbar.setAction(R.string.undo) { _ ->
// undone = true
// media.add(pos, item)
//
// notifyItemInserted(pos)
// }
//
// snackbar.addCallback(object : Snackbar.Callback() {
// override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
// if (!undone) {
val collection = item.collection

// Delete collection along with the item, if the collection
Expand All @@ -255,20 +255,18 @@
item.delete()
}

BroadcastManager.postDelete(recyclerView.context, item.id)
}

super.onDismissed(transientBottomBar, event)
}
})
// }
//
// super.onDismissed(transientBottomBar, event)
// }
// })

snackbar.show()
//snackbar.show()

Check warning

Code scanning / detekt

Checks if comments have the right spacing Warning

Missing space after //

removeItem(item.id)

mActivity.get()?.let {
BroadcastManager.postDelete(it, item.id)
}
BroadcastManager.postDelete(recyclerView.context, item.id)
}

fun getSelectedCount(): Int = media.count { it.selected }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.opendasharchive.openarchive.features.media

import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -15,6 +16,7 @@ class ContentPickerFragment(private val onMediaPicked: (AddMediaType) -> Unit):

companion object {
const val TAG = "ModalBottomSheet-ContentPickerFragment"
const val KEY_DISMISS = "ContentPickerFragment.Dismiss"
}

override fun onCreateView(
Expand Down Expand Up @@ -43,4 +45,9 @@ class ContentPickerFragment(private val onMediaPicked: (AddMediaType) -> Unit):

return binding.root
}

override fun onDismiss(dialog: DialogInterface) {
parentFragmentManager.setFragmentResult(KEY_DISMISS, Bundle())
super.onDismiss(dialog)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.opendasharchive.openarchive.features.core.dialog.DialogStateManager
import net.opendasharchive.openarchive.features.core.dialog.DialogType
import net.opendasharchive.openarchive.features.core.dialog.showDialog
import net.opendasharchive.openarchive.features.core.dialog.showWarningDialog

Check warning

Code scanning / detekt

Detects unused imports Warning

Unused import
import net.opendasharchive.openarchive.features.onboarding.SpaceSetupActivity
import net.opendasharchive.openarchive.features.onboarding.StartDestination
import net.opendasharchive.openarchive.features.settings.passcode.PasscodeRepository
Expand Down Expand Up @@ -144,10 +145,19 @@
setOnPreferenceClickListener {
dialogManager.showDialog(dialogManager.requireResourceProvider()) {
type = DialogType.Info
iconColor = dialogManager.requireResourceProvider().getColor(R.color.colorTertiary)
title = UiText.StringResource(R.string.tor_disabled_title)
message = UiText.StringResource(R.string.tor_disabled_message)
positiveButton {
text = UiText.StringResource(android.R.string.ok)
text = UiText.StringResource(R.string.tor_download_btn_label)
action = {
// Launch the Tor download activity
val intent = Intent(Intent.ACTION_VIEW, Prefs.TOR_DOWNLOAD_URL)
startActivity(intent)
}
}
neutralButton {
text = UiText.StringResource(android.R.string.cancel)
}
}
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ open class UploadManagerFragment : SKBottomSheetDialogFragment() {
parentFragmentManager.setFragmentResult("uploadRetry", resultBundle)
}
}

destructiveButton {
text = UiText.StringResource(R.string.btn_lbl_remove_media)
action = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package net.opendasharchive.openarchive.util
import android.annotation.SuppressLint
import android.content.Context
import android.content.SharedPreferences
import android.net.Uri
import android.util.Base64
import androidx.preference.PreferenceManager
import org.witness.proofmode.ProofMode
Expand Down Expand Up @@ -30,6 +31,8 @@ object Prefs {
private const val LICENSE_URL = "archive_pref_share_license_url"
private const val PROOFMODE_ENCRYPTED_PASSPHRASE = "proof_mode_encrypted_passphrase"

val TOR_DOWNLOAD_URL = Uri.parse("https://play.google.com/store/apps/details?id=org.torproject.android")

private var prefs: SharedPreferences? = null

fun load(context: Context) {
Expand Down
Loading