Skip to content

Commit a80d3ed

Browse files
committed
WIP
1 parent 752b7ef commit a80d3ed

File tree

8 files changed

+1224
-19
lines changed

8 files changed

+1224
-19
lines changed

android/Gutenberg/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ dependencies {
6767
testImplementation(libs.mockito.core)
6868
testImplementation(libs.mockito.kotlin)
6969
testImplementation(libs.robolectric)
70+
testImplementation(libs.okhttp.mockwebserver)
7071
androidTestImplementation(libs.androidx.junit)
7172
androidTestImplementation(libs.androidx.espresso.core)
7273
}

android/Gutenberg/src/main/java/org/wordpress/gutenberg/GutenbergRequestInterceptor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package org.wordpress.gutenberg
33
import android.webkit.WebResourceRequest
44
import android.webkit.WebResourceResponse
55

6-
public interface GutenbergRequestInterceptor {
6+
interface GutenbergRequestInterceptor {
77
fun canIntercept(request: WebResourceRequest): Boolean
88
fun handleRequest(request: WebResourceRequest): WebResourceResponse?
99
}
@@ -16,4 +16,4 @@ class DefaultGutenbergRequestInterceptor: GutenbergRequestInterceptor {
1616
override fun handleRequest(request: WebResourceRequest): WebResourceResponse? {
1717
return null
1818
}
19-
}
19+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package org.wordpress.gutenberg
2+
3+
import android.content.Context
4+
import org.wordpress.gutenberg.model.EditorConfiguration
5+
import java.io.File
6+
7+
/**
8+
* Utility object for constructing storage and cache directory paths.
9+
*/
10+
object Paths {
11+
/**
12+
* Returns the default storage root directory for GutenbergKit.
13+
*
14+
* This is typically in the app's files directory.
15+
*
16+
* @param context The Android context.
17+
* @return The default storage root directory.
18+
*/
19+
fun defaultStorageRoot(context: Context): File {
20+
return File(context.filesDir, "GutenbergKit")
21+
}
22+
23+
/**
24+
* Returns the storage root directory for a specific site configuration.
25+
*
26+
* @param context The Android context.
27+
* @param configuration The editor configuration.
28+
* @return The site-specific storage directory.
29+
*/
30+
fun storageRoot(context: Context, configuration: EditorConfiguration): File {
31+
return File(defaultStorageRoot(context), configuration.siteId)
32+
}
33+
34+
/**
35+
* Returns the storage root directory for a specific site configuration.
36+
*
37+
* @param baseDir The base directory to use instead of context.filesDir.
38+
* @param configuration The editor configuration.
39+
* @return The site-specific storage directory.
40+
*/
41+
fun storageRoot(baseDir: File, configuration: EditorConfiguration): File {
42+
return File(File(baseDir, "GutenbergKit"), configuration.siteId)
43+
}
44+
45+
/**
46+
* Returns the default cache root directory for GutenbergKit.
47+
*
48+
* This is typically in the app's cache directory.
49+
*
50+
* @param context The Android context.
51+
* @return The default cache root directory.
52+
*/
53+
fun defaultCacheRoot(context: Context): File {
54+
return File(context.cacheDir, "GutenbergKit")
55+
}
56+
57+
/**
58+
* Returns the cache root directory for a specific site configuration.
59+
*
60+
* @param context The Android context.
61+
* @param configuration The editor configuration.
62+
* @return The site-specific cache directory.
63+
*/
64+
fun cacheRoot(context: Context, configuration: EditorConfiguration): File {
65+
return File(defaultCacheRoot(context), configuration.siteId)
66+
}
67+
68+
/**
69+
* Returns the cache root directory for a specific site configuration.
70+
*
71+
* @param baseDir The base directory to use instead of context.cacheDir.
72+
* @param configuration The editor configuration.
73+
* @return The site-specific cache directory.
74+
*/
75+
fun cacheRoot(baseDir: File, configuration: EditorConfiguration): File {
76+
return File(File(baseDir, "GutenbergKit"), configuration.siteId)
77+
}
78+
}

0 commit comments

Comments
 (0)