Skip to content

Commit d8e0c06

Browse files
committed
feat: overhaul source archiving
1 parent 7025f80 commit d8e0c06

40 files changed

+3495
-1664
lines changed

packages/android/app/build.gradle

+11-6
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@ android {
3232
applicationId "io.literal"
3333
minSdkVersion 26
3434
targetSdkVersion 30
35-
versionCode 28
35+
versionCode 29
3636
versionName "1.1.21"
3737

3838
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3939
}
4040

4141
buildTypes {
4242
release {
43-
minifyEnabled false
4443
debuggable false
4544
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
4645
signingConfig signingConfigs.release
@@ -58,6 +57,9 @@ android {
5857
}
5958
}
6059

60+
packagingOptions {
61+
exclude 'META-INF/DEPENDENCIES'
62+
}
6163
}
6264

6365
task buildSourceWebViewScripts(type: Exec) {
@@ -74,11 +76,11 @@ tasks.whenTaskAdded { task ->
7476
dependencies {
7577
implementation fileTree(dir: 'libs', include: ['*.jar'])
7678

77-
implementation "androidx.activity:activity:1.2.0-rc01"
78-
implementation "androidx.fragment:fragment:1.3.0-rc02"
79+
implementation "androidx.activity:activity:1.3.0-beta01"
80+
implementation "androidx.fragment:fragment:1.4.0-alpha02"
7981
implementation 'androidx.webkit:webkit:1.4.0'
8082
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
81-
implementation 'com.google.android.material:material:1.3.0-rc01'
83+
implementation 'com.google.android.material:material:1.4.0-rc01'
8284

8385
testImplementation 'junit:junit:4.12'
8486
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
@@ -90,9 +92,12 @@ dependencies {
9092
implementation 'io.sentry:sentry-android:4.3.0'
9193
implementation 'net.jodah:failsafe:2.4.0'
9294

95+
implementation 'org.apache.james:apache-mime4j-core:0.8.4'
96+
implementation 'org.apache.james:apache-mime4j-dom:0.8.4'
97+
9398
// Amplitude
9499
implementation 'com.amplitude:android-sdk:2.25.2'
95-
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
100+
implementation 'com.squareup.okhttp3:okhttp:4.3.1'
96101

97102
//
98103
// AWS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.literal.lib;
2+
3+
import android.content.Context;
4+
5+
import com.amazonaws.services.s3.AmazonS3URI;
6+
7+
import java.net.URI;
8+
import java.net.URISyntaxException;
9+
10+
import io.literal.repository.StorageRepository;
11+
12+
public class AmazonS3URILib {
13+
14+
/**
15+
* AmazonS3URI.getURI formats with s3:// scheme, we persist https:// equivalent for consistency
16+
*/
17+
public static URI toHTTPs(Context context, AmazonS3URI uri) {
18+
try {
19+
return new URI(
20+
"https",
21+
uri.getURI().getHost() + ".s3." + StorageRepository.getBucketRegion(context) +".amazonaws.com",
22+
uri.getURI().getPath(),
23+
null
24+
);
25+
} catch (URISyntaxException e) {
26+
return null;
27+
}
28+
}
29+
}

packages/android/app/src/main/java/io/literal/lib/AnnotationTargetLib.java

+15
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,23 @@
22

33
import java.util.UUID;
44

5+
import io.literal.model.ExternalTarget;
6+
import io.literal.model.SpecificTarget;
7+
import io.literal.model.Target;
8+
import io.literal.model.TextualTarget;
9+
510
public class AnnotationTargetLib {
611
public static String makeId(String annotationId) {
712
return annotationId + "/targets/" + UUID.randomUUID().toString();
813
}
14+
15+
public static String getID(Target target) {
16+
if (target instanceof ExternalTarget) {
17+
return ((ExternalTarget) target).getId().toString();
18+
} else if (target instanceof SpecificTarget) {
19+
return ((SpecificTarget) target).getId();
20+
} else {
21+
return ((TextualTarget) target).getId();
22+
}
23+
};
924
}

packages/android/app/src/main/java/io/literal/lib/Constants.java

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.literal.lib;
22

33
public class Constants {
4+
public static final String NAMESPACE = "io.literal";
45
public static final String LOG_TAG = "Literal";
56

67
public static final String RECENT_ANNOTATION_COLLECTION_ID_COMPONENT = "034a7e52c5c9534b709dc1dba403868399b0949f7c1933a67325c22077ffc221";

packages/android/app/src/main/java/io/literal/model/Annotation.java

+78
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.literal.model;
22

3+
import android.util.Log;
4+
35
import org.jetbrains.annotations.NotNull;
46
import org.json.JSONArray;
57
import org.json.JSONException;
@@ -19,6 +21,7 @@
1921
import io.literal.lib.JsonArrayUtil;
2022
import io.literal.lib.WebRoutes;
2123
import io.literal.repository.ErrorRepository;
24+
import kotlin.jvm.functions.Function1;
2225
import type.AnnotationType;
2326
import type.CreateAnnotationInput;
2427

@@ -144,4 +147,79 @@ public static Annotation fromScreenshot(StorageObject screenshot, String creator
144147
annotationId
145148
);
146149
}
150+
151+
public Annotation updateTarget(Target updatedTarget, String idToUpdate) {
152+
Target[] newTarget = getTarget().clone();
153+
for (int i = 0; i < getTarget().length; i++) {
154+
if (AnnotationTargetLib.getID(newTarget[i]).equals(idToUpdate)) {
155+
newTarget[i] = updatedTarget;
156+
break;
157+
}
158+
}
159+
160+
return new Annotation.Builder(this).setTarget(newTarget).build();
161+
}
162+
163+
public Annotation updateTarget(Target updatedTarget) {
164+
return this.updateTarget(updatedTarget, AnnotationTargetLib.getID(updatedTarget));
165+
}
166+
167+
public static class Builder {
168+
private Body[] body;
169+
private Target[] target;
170+
private Motivation[] motivation;
171+
private String created;
172+
private String modified;
173+
private String id;
174+
175+
public Builder(Annotation base) {
176+
this.body = base.getBody().clone();
177+
this.target = base.getTarget().clone();
178+
this.motivation = base.getMotivation();
179+
this.created = base.getCreated();
180+
this.id = base.getId();
181+
this.modified = base.getModified();
182+
}
183+
184+
public Builder setBody(Body[] body) {
185+
this.body = body;
186+
return this;
187+
}
188+
189+
public Builder setTarget(Target[] target) {
190+
this.target = target;
191+
return this;
192+
}
193+
194+
public Builder setMotivation(Motivation[] motivation) {
195+
this.motivation = motivation;
196+
return this;
197+
}
198+
199+
public Builder setCreated(String created) {
200+
this.created = created;
201+
return this;
202+
}
203+
204+
public Builder setModified(String modified) {
205+
this.modified = modified;
206+
return this;
207+
}
208+
209+
public Builder setId(String id) {
210+
this.id = id;
211+
return this;
212+
}
213+
214+
public Annotation build() {
215+
return new Annotation(
216+
body,
217+
target,
218+
motivation,
219+
created,
220+
modified,
221+
id
222+
);
223+
}
224+
}
147225
}

packages/android/app/src/main/java/io/literal/model/ExternalTarget.java

+80-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.net.URISyntaxException;
1010
import java.security.NoSuchAlgorithmException;
1111
import java.util.Arrays;
12+
import java.util.Objects;
1213

1314
import io.literal.lib.Crypto;
1415
import io.literal.lib.JsonArrayUtil;
@@ -66,8 +67,9 @@ public static Id fromString(String json) {
6667
}
6768
}
6869

70+
@NotNull
6971
public String toString() {
70-
if (type.equals(Type.IRI)) {
72+
if (type.equals(Type.IRI) && iri != null) {
7173
return iri;
7274
}
7375
return storageObject.getCanonicalURI().toString();
@@ -215,4 +217,81 @@ public PatchAnnotationOperationInput toPatchAnnotationOperationInputSet() {
215217
)
216218
.build();
217219
}
220+
221+
public static class Builder {
222+
private Id id;
223+
private Format format;
224+
private Language language;
225+
private Language processingLanguage;
226+
private TextDirection textDirection;
227+
private ResourceType resourceType;
228+
private String[] accessibility;
229+
private String[] rights;
230+
231+
public Builder(ExternalTarget base) {
232+
this.id = base.getId();
233+
this.format = base.getFormat();
234+
this.language = base.getLanguage();
235+
this.processingLanguage = base.getProcessingLanguage();
236+
this.textDirection = base.getTextDirection();
237+
this.resourceType = base.getResourceType();
238+
this.accessibility = base.getAccessibility();
239+
this.rights = base.getRights();
240+
}
241+
242+
public Builder setId(Id id) {
243+
this.id = id;
244+
return this;
245+
}
246+
247+
public Builder setFormat(Format format) {
248+
this.format = format;
249+
return this;
250+
}
251+
252+
public Builder setLanguage(Language language) {
253+
this.language = language;
254+
return this;
255+
}
256+
257+
public Builder setProcessingLanguage(Language processingLanguage) {
258+
this.processingLanguage = processingLanguage;
259+
return this;
260+
}
261+
262+
public Builder setTextDirection(TextDirection textDirection) {
263+
this.textDirection = textDirection;
264+
return this;
265+
}
266+
267+
public Builder setResourceType(ResourceType resourceType) {
268+
this.resourceType = resourceType;
269+
return this;
270+
}
271+
272+
public Builder setAccessibility(String[] accessibility) {
273+
this.accessibility = accessibility;
274+
return this;
275+
}
276+
277+
public Builder setRights(String[] rights) {
278+
this.rights = rights;
279+
return this;
280+
}
281+
282+
public ExternalTarget build() {
283+
Objects.requireNonNull(id);
284+
285+
return new ExternalTarget(
286+
id,
287+
format,
288+
language,
289+
processingLanguage,
290+
textDirection,
291+
accessibility,
292+
rights,
293+
resourceType
294+
);
295+
}
296+
}
218297
}

0 commit comments

Comments
 (0)