aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-07-11 19:32:33 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-07-11 19:32:33 +0000
commit370b45e835ad0ca29f5cef52658f86f4326b836e (patch)
tree66e97f19053f61f824e38d108ed0646bd528e41b /app/src/main
parent44aaaeac58e143525b80cd173ac50fd8fa798193 (diff)
downloadinfinity-for-reddit-370b45e835ad0ca29f5cef52658f86f4326b836e.tar
infinity-for-reddit-370b45e835ad0ca29f5cef52658f86f4326b836e.tar.gz
infinity-for-reddit-370b45e835ad0ca29f5cef52658f86f4326b836e.tar.bz2
infinity-for-reddit-370b45e835ad0ca29f5cef52658f86f4326b836e.tar.lz
infinity-for-reddit-370b45e835ad0ca29f5cef52658f86f4326b836e.tar.xz
infinity-for-reddit-370b45e835ad0ca29f5cef52658f86f4326b836e.tar.zst
infinity-for-reddit-370b45e835ad0ca29f5cef52658f86f4326b836e.zip
Separate online theme modification and upload.
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/apis/OnlineCustomThemeAPI.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/OnlineCustomThemeMetadata.java5
3 files changed, 13 insertions, 3 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java
index 13f876c7..27328fdf 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CustomizeThemeActivity.java
@@ -248,8 +248,9 @@ public class CustomizeThemeActivity extends BaseActivity {
.setTitle(R.string.override_online_theme_question)
.setMessage(R.string.override_online_theme_message)
.setPositiveButton(R.string.yes, (dialogInterface, i) -> {
- onlineCustomThemesRetrofit.create(OnlineCustomThemeAPI.class).uploadTheme(
- customTheme.name, accountName, customTheme.getJSONModel(),
+ onlineCustomThemesRetrofit.create(OnlineCustomThemeAPI.class).modifyTheme(
+ onlineCustomThemeMetadata.id, customTheme.name,
+ customTheme.getJSONModel(),
('#' + Integer.toHexString(customTheme.colorPrimary)).toUpperCase()
).enqueue(new Callback<>() {
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/OnlineCustomThemeAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/OnlineCustomThemeAPI.java
index 71e5095e..dad0ea26 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/OnlineCustomThemeAPI.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/OnlineCustomThemeAPI.java
@@ -7,6 +7,7 @@ import retrofit2.Response;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
+import retrofit2.http.PATCH;
import retrofit2.http.POST;
import retrofit2.http.Query;
@@ -18,6 +19,11 @@ public interface OnlineCustomThemeAPI {
Call<String> getCustomTheme(@Query("name") String themeName, @Query("username") String username);
@FormUrlEncoded
+ @PATCH("/themes/modify")
+ Call<String> modifyTheme(@Field("id") int id, @Field("name") String themeName,
+ @Field("data") String customThemeJson, @Field("primary_color") String primaryColor);
+
+ @FormUrlEncoded
@POST("/themes/upload")
Call<String> uploadTheme(@Field("name") String themeName, @Field("username") String username,
@Field("data") String customThemeJson, @Field("primary_color") String primaryColor);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/OnlineCustomThemeMetadata.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/OnlineCustomThemeMetadata.java
index 1e629f92..2b07f9d5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/OnlineCustomThemeMetadata.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/OnlineCustomThemeMetadata.java
@@ -10,18 +10,20 @@ import com.google.gson.JsonParseException;
import com.google.gson.annotations.SerializedName;
public class OnlineCustomThemeMetadata implements Parcelable {
+ public int id;
public String name;
public String username;
@SerializedName("primary_color")
public String colorPrimary;
protected OnlineCustomThemeMetadata(Parcel in) {
+ id = in.readInt();
name = in.readString();
username = in.readString();
colorPrimary = in.readString();
}
- public static final Creator<OnlineCustomThemeMetadata> CREATOR = new Creator<OnlineCustomThemeMetadata>() {
+ public static final Creator<OnlineCustomThemeMetadata> CREATOR = new Creator<>() {
@Override
public OnlineCustomThemeMetadata createFromParcel(Parcel in) {
return new OnlineCustomThemeMetadata(in);
@@ -45,6 +47,7 @@ public class OnlineCustomThemeMetadata implements Parcelable {
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeInt(id);
dest.writeString(name);
dest.writeString(username);
dest.writeString(colorPrimary);