Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
1 change: 0 additions & 1 deletion app/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@
<ID>FinalNewline:VideoRequestHandler.kt$net.opendasharchive.openarchive.fragments.VideoRequestHandler.kt</ID>
<ID>FinalNewline:ViewExtension.kt$net.opendasharchive.openarchive.extensions.ViewExtension.kt</ID>
<ID>FinalNewline:WebDAVModel.kt$net.opendasharchive.openarchive.db.WebDAVModel.kt</ID>
<ID>FinalNewline:WebDavActivity.kt$net.opendasharchive.openarchive.services.webdav.WebDavActivity.kt</ID>
<ID>FinalNewline:WebDavConduit.kt$net.opendasharchive.openarchive.services.webdav.WebDavConduit.kt</ID>
<ID>FinalNewline:WebDavFragment.kt$net.opendasharchive.openarchive.services.webdav.WebDavFragment.kt</ID>
<ID>FinalNewline:WebDavSetupLicenseFragment.kt$net.opendasharchive.openarchive.services.webdav.WebDavSetupLicenseFragment.kt</ID>
Expand Down
48 changes: 2 additions & 46 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
android:name=".features.main.HomeActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@style/SaveAppTheme.NoActionBar">
android:theme="@style/SaveAppTheme.NoActionBar"
tools:ignore="DiscouragedApi">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->

Expand Down Expand Up @@ -142,44 +143,10 @@
</intent-filter>
</activity>

<activity
android:name=".upload.UploadManagerActivity"
android:exported="false"
android:label="@string/title_activity_upload_manager"
android:taskAffinity=""
android:theme="@style/SaveAppTheme.NoActionBar" />


<activity
android:name=".services.webdav.WebDavActivity"
android:label="@string/title_activity_login"
android:taskAffinity=""
android:theme="@style/SaveAppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan" />

<activity
android:name=".features.internetarchive.presentation.InternetArchiveActivity"
android:label="@string/title_activity_login"
android:taskAffinity=""
android:theme="@style/SaveAppTheme.NoActionBar" />

<activity
android:name=".services.gdrive.GDriveActivity"
android:theme="@style/SaveAppTheme.NoActionBar" />

<activity
android:name=".features.settings.FoldersActivity"
android:exported="false"
android:label="@string/folders"
android:theme="@style/SaveAppTheme.NoActionBar" />

<activity
android:name=".features.settings.GeneralSettingsActivity"
android:exported="false"
android:label="@string/general"
android:taskAffinity=""
android:theme="@style/SaveAppTheme.NoActionBar" />

<activity
android:name=".features.settings.ProofModeSettingsActivity"
android:exported="false"
Expand Down Expand Up @@ -229,17 +196,6 @@
android:taskAffinity=""
android:theme="@style/SaveAppTheme.NoActionBar" />

<!-- <activity-->
<!-- android:name=".features.folders.CreateNewFolderActivity"-->
<!-- android:label="@string/new_folder"-->
<!-- android:taskAffinity=""-->
<!-- android:theme="@style/SaveAppTheme.NoActionBar" />-->

<activity
android:name=".features.folders.AddFolderActivity"
android:taskAffinity=""
android:theme="@style/SaveAppTheme.NoActionBar" />

<activity
android:name=".features.settings.EditFolderActivity"
android:taskAffinity=""
Expand Down
59 changes: 19 additions & 40 deletions app/src/main/java/net/opendasharchive/openarchive/db/Space.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@

import android.content.Context
import android.content.Intent
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentActivity
import com.github.abdularis.civ.AvatarImageView
import com.orm.SugarRecord
import net.opendasharchive.openarchive.R
import net.opendasharchive.openarchive.core.logger.AppLogger
import net.opendasharchive.openarchive.features.onboarding.SpaceSetupActivity
import net.opendasharchive.openarchive.services.gdrive.GDriveConduit
import net.opendasharchive.openarchive.services.internetarchive.IaConduit
import net.opendasharchive.openarchive.util.DrawableUtil
import net.opendasharchive.openarchive.util.Prefs
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
Expand Down Expand Up @@ -76,10 +72,6 @@
RAVEN(5, "DWeb Service"),
}

enum class IconStyle {
SOLID, OUTLINE
}

companion object {
fun getAll(): Iterator<Space> {
return findAll(Space::class.java)
Expand Down Expand Up @@ -131,6 +123,15 @@
activity.startActivity(Intent(activity, SpaceSetupActivity::class.java))
}
}

fun navigate(activity: FragmentActivity) {
if (getAll().hasNext()) {
activity.finish()
} else {
activity.finishAffinity()
activity.startActivity(Intent(activity, SpaceSetupActivity::class.java))
}
}
}

val friendlyName: String
Expand All @@ -151,7 +152,7 @@
var tType: Type
get() = Type.entries.first { it.id == type }
set(value) {
type = (value ?: Type.WEBDAV).id
type = value.id
}

var license: String?
Expand Down Expand Up @@ -199,61 +200,39 @@
"space_id = ? AND description = ?",
id.toString(),
description
).size > 0
).isNotEmpty()
}

fun getAvatar(context: Context, style: IconStyle = IconStyle.SOLID): Drawable? {


return when (tType) {
fun getAvatar(context: Context): Drawable? = when (tType) {
Type.WEBDAV -> ContextCompat.getDrawable(
context,
R.drawable.ic_private_server
) // ?.tint(color)
)

Check warning

Code scanning / detekt

Reports mis-indented code Warning

Unexpected indentation (12) (should be 8)

Type.INTERNET_ARCHIVE -> ContextCompat.getDrawable(
context,
R.drawable.ic_internet_archive
) // ?.tint(color)
)

Check warning

Code scanning / detekt

Reports mis-indented code Warning

Unexpected indentation (12) (should be 8)

Type.GDRIVE -> ContextCompat.getDrawable(
context,
R.drawable.logo_gdrive_outline
) // ?.tint(color)

Type.RAVEN -> ContextCompat.getDrawable(context, R.drawable.snowbird) // ?.tint(color)

else -> {
val color = ContextCompat.getColor(context, R.color.colorOnBackground)
BitmapDrawable(
context.resources,
DrawableUtil.createCircularTextDrawable(initial, color)
)
}
)

Check warning

Code scanning / detekt

Reports mis-indented code Warning

Unexpected indentation (12) (should be 8)

}
Type.RAVEN -> ContextCompat.getDrawable(context, R.drawable.snowbird)

Check warning

Code scanning / detekt

Reports mis-indented code Warning

Unexpected indentation (12) (should be 8)
}

@Composable
fun getAvatar(): Painter {

return when (tType) {
fun getAvatar(): Painter = when (tType) {
Type.WEBDAV -> painterResource(R.drawable.ic_space_private_server)

Type.INTERNET_ARCHIVE -> painterResource(R.drawable.ic_space_interent_archive)

Type.GDRIVE -> painterResource(R.drawable.logo_gdrive_outline)

Type.RAVEN -> painterResource(R.drawable.ic_space_dweb)
null -> {
val context = LocalContext.current
val color = ContextCompat.getColor(context, R.color.colorOnBackground)
val bitmap = DrawableUtil.createCircularTextDrawable(initial, color)
val imageBitmap = bitmap.asImageBitmap()
BitmapPainter(imageBitmap)
}
}
}


fun setAvatar(view: ImageView) {
when (tType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.view.ViewGroup
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import com.google.android.material.appbar.MaterialToolbar
import net.opendasharchive.openarchive.R
import net.opendasharchive.openarchive.core.presentation.theme.SaveAppTheme
Expand Down Expand Up @@ -40,6 +41,7 @@ abstract class BaseActivity : AppCompatActivity() {
// Add ComposeView if not already present
if (rootView.findViewById<ComposeView>(R.id.compose_dialog_host) == null) {
ComposeView(this).apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
id = R.id.compose_dialog_host
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.opendasharchive.openarchive.features.core

Check warning

Code scanning / detekt

Detects missing final newlines Warning

File must end with a newline (\n)

object NavArgument {
const val START_DESTINATION = "start_destination"
const val SPACE_ID = "space_id"
const val FOLDER_ID = "folder_id"
const val FOLDER_NAME = "folder_name"
const val SHOW_ARCHIVED_FOLDERS = "show_archived_folders"
}

Check warning

Code scanning / detekt

Checks whether files end with a line separator. Warning

The file /home/runner/work/Save-app-android-old/Save-app-android-old/app/src/main/java/net/opendasharchive/openarchive/features/core/NavArgument.kt is not ending with a new line.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,25 @@
import net.opendasharchive.openarchive.core.presentation.theme.DefaultScaffoldPreview
import net.opendasharchive.openarchive.core.presentation.theme.SaveAppTheme

// This screen is used in space_setup_navigation.xml nav graph
@Suppress("unused")
@Composable
fun AddFolderScreen() {

val navController = LocalView.current.findNavController()

SaveAppTheme {
AddFolderScreenContent(
onCreateFolder = {
navController.navigate(R.id.fragment_add_folder_to_fragment_create_new_folder)
},
onBrowseFolders = {
navController.navigate(R.id.fragment_add_folder_to_fragment_browse_folders)
}
)
}

}

Check warning

Code scanning / detekt

Library classes should not be public. Warning

Top level function AddFolderScreen should not be public


@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import net.opendasharchive.openarchive.databinding.FragmentBrowseFoldersBinding
import net.opendasharchive.openarchive.db.Project
import net.opendasharchive.openarchive.db.Space
import net.opendasharchive.openarchive.features.core.BaseFragment
import net.opendasharchive.openarchive.features.core.NavArgument
import net.opendasharchive.openarchive.features.core.dialog.showSuccessDialog
import net.opendasharchive.openarchive.util.extensions.toggle
import org.koin.androidx.viewmodel.ext.android.viewModel
Expand Down Expand Up @@ -98,7 +99,7 @@ class BrowseFoldersFragment : BaseFragment(), MenuProvider {

private fun navigateBackWithResult(projectId: Long) {
requireActivity().setResult(RESULT_OK, Intent().apply {
putExtra(AddFolderActivity.EXTRA_FOLDER_ID, projectId)
putExtra(NavArgument.FOLDER_ID, projectId)
})
requireActivity().finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import net.opendasharchive.openarchive.databinding.FragmentCreateNewFolderBindin
import net.opendasharchive.openarchive.db.Project
import net.opendasharchive.openarchive.db.Space
import net.opendasharchive.openarchive.features.core.BaseFragment
import net.opendasharchive.openarchive.features.core.NavArgument
import net.opendasharchive.openarchive.features.core.dialog.showSuccessDialog
import net.opendasharchive.openarchive.features.settings.CreativeCommonsLicenseManager
import net.opendasharchive.openarchive.util.extensions.hide
Expand Down Expand Up @@ -45,7 +46,7 @@ class CreateNewFolderFragment : BaseFragment() {
super.onViewCreated(view, savedInstanceState)
val intent = requireActivity().intent

binding.newFolder.setText(intent.getStringExtra(AddFolderActivity.EXTRA_FOLDER_NAME))
binding.newFolder.setText(intent.getStringExtra(NavArgument.FOLDER_NAME))

binding.newFolder.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
Expand Down Expand Up @@ -142,7 +143,7 @@ class CreateNewFolderFragment : BaseFragment() {

private fun navigateBackWithResult(projectId: Long) {
val i = Intent()
i.putExtra(AddFolderActivity.EXTRA_FOLDER_ID, projectId)
i.putExtra(NavArgument.FOLDER_ID, projectId)

requireActivity().setResult(RESULT_OK, i)
requireActivity().finish()
Expand Down
Loading
Loading