Skip to content
Closed
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
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,39 @@ git push --tags
- Create an action build file under `.github/workflows/` folder, following any existing build script.
- Create a release build file under `.github/workflows/` folder, following any existing release script.

## Making the Storage Demo work

This section guides you through setting up and running the Storage Demo subpage.

**1. Download the `fs-storage` JNI Libraries:**

The demo requires JNI libraries (libs). Download these from the following location:

* **[ark-core repository](https://github.com/ARK-Builders/ark-core)**

- If you can't find them in the "Releases" section, check the latest successful build actions for artifacts.

**2. Place the Libraries:**

After downloading, move the JNI library files into your project's `sample/src/main/jniLibs` directory. **If the path doesn't exist, create it**

Your project structure should resemble this:

```
...
sample/
...
src/
main/
...
jniLibs/
arm64-v8a/
armeabi-v7a/
x86/
x86_64/
...
...
...
```

With the `fs-storage` JNI libraries in place, you're ready to build, run the project and use the Storage Demo subpage.
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fastadapter = { group = "com.mikepenz", name = "fastadapter", version.ref = "fas
fastadapter-extensions-binding = { group = "com.mikepenz", name = "fastadapter-extensions-binding", version.ref = "fastadapter" }
fastadapter-extensions-diff = { group = "com.mikepenz", name = "fastadapter-extensions-diff", version.ref = "fastadapter" }
arklib = { group = "dev.arkbuilders", name = "arklib", version.ref = "arkLib" }
core = {group = "dev.arkbuilders.core", name = "lib", version = "1.0-SNAPSHOT"}
orbit-mvi-viewmodel = { group = "org.orbit-mvi", name = "orbit-viewmodel", version.ref = "orbitMvi" }
viewbinding-property-delegate = { group = "com.github.kirich1409", name = "viewbindingpropertydelegate-noreflection", version.ref = "viewbindingPropertyDelegate" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidXCore" }
Expand Down
9 changes: 8 additions & 1 deletion sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,19 @@ android {
dependencies {
implementation(project(":filepicker"))
implementation(project(":about"))

implementation(libraries.core)
implementation(libraries.arklib)
implementation("androidx.core:core-ktx:1.12.0")
implementation(libraries.androidx.appcompat)
implementation(libraries.android.material)
testImplementation(libraries.junit)
androidTestImplementation(libraries.androidx.test.junit)
androidTestImplementation(libraries.androidx.test.espresso)
runtimeOnly(
fileTree(
mapOf(
"dir" to "src/main/jniLibs",
)
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import androidx.activity.result.contract.ActivityResultContracts
import androidx.fragment.app.DialogFragment
import dev.arkbuilders.core.FileStorage
import dev.arkbuilders.sample.R
import dev.arkbuilders.sample.databinding.FragmentStorageDemoBinding
import dev.arkbuilders.sample.extension.getAbsolutePath
Expand All @@ -21,8 +22,8 @@ class StorageDemoFragment: DialogFragment() {
private val TAG = StorageDemoFragment::class.java.name

private lateinit var binding: FragmentStorageDemoBinding
private val map by lazy { mutableMapOf<String, String>() }
private var workingDir: String = "/"
private var storage: FileStorage? = null

private val selectDirRequest = registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri ->
uri?.let {
Expand Down Expand Up @@ -61,29 +62,38 @@ class StorageDemoFragment: DialogFragment() {

binding.edtStoragePath.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
refreshFilesTree()
val relativeStoragePath = v.text
storage = FileStorage(relativeStoragePath.toString(),
"$workingDir/$relativeStoragePath"
)
return@setOnEditorActionListener true
}
false
}

binding.btnNewMapEntry.setOnClickListener {
MapEntryDialog(isDelete = false, onDone = { key, value ->
map[key] = value ?: ""
refreshMap()
if (storage != null) {
storage!!.set(key, value)
}
refreshStorage()
}).show(parentFragmentManager, MapEntryDialog::class.java.name)
}

binding.btnDeleteEntry.setOnClickListener {
MapEntryDialog(isDelete = true, onDone = { key, value ->
map.remove(key)
refreshMap()
MapEntryDialog(isDelete = true, onDone = { key, _ ->
if (storage != null) {
storage!!.remove(key)
}
refreshStorage()
}).show(parentFragmentManager, MapEntryDialog::class.java.name)
}

binding.btnClearMap.setOnClickListener {
map.clear()
refreshMap()
if (storage != null) {
storage!!.erase()
}
refreshStorage()
}
}

Expand All @@ -105,13 +115,14 @@ class StorageDemoFragment: DialogFragment() {
}
}

private fun refreshMap() {
if (map.isEmpty()) {
private fun refreshStorage() {
if (storage == null) {
binding.tvMapValues.text = getString(R.string.empty_map)
return
}
storage!!.writeFS()
val mapEntries = StringBuilder()
for (entry in map) {
for (entry in storage!!) {
mapEntries.append(entry.key).append(" -> ").append(entry.value).append("\n")
}
binding.tvMapValues.text = mapEntries.toString()
Expand Down
10 changes: 9 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ dependencyResolutionManagement {
url = URI("https://jitpack.io")
}
maven {
name = "GitHubPackages"
name = "arklib-android GitHub Packages"
url = URI("https://maven.pkg.github.com/ARK-Builders/arklib-android")
credentials {
username = "token"
password = "\u0037\u0066\u0066\u0036\u0030\u0039\u0033\u0066\u0032\u0037\u0033\u0036\u0033\u0037\u0064\u0036\u0037\u0066\u0038\u0030\u0034\u0039\u0062\u0030\u0039\u0038\u0039\u0038\u0066\u0034\u0066\u0034\u0031\u0064\u0062\u0033\u0064\u0033\u0038\u0065"
}
}
maven {
name = "ark-core GitHub Packages"
url = URI("https://maven.pkg.github.com/ARK-Builders/ark-core")
credentials {
username = "token"
password = "\u0037\u0066\u0066\u0036\u0030\u0039\u0033\u0066\u0032\u0037\u0033\u0036\u0033\u0037\u0064\u0036\u0037\u0066\u0038\u0030\u0034\u0039\u0062\u0030\u0039\u0038\u0039\u0038\u0066\u0034\u0066\u0034\u0031\u0064\u0062\u0033\u0064\u0033\u0038\u0065"
}
}
}

versionCatalogs {
Expand Down