From 370b45e835ad0ca29f5cef52658f86f4326b836e Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Thu, 11 Jul 2024 15:32:33 -0400 Subject: Separate online theme modification and upload. --- .../infinityforreddit/activities/CustomizeThemeActivity.java | 5 +++-- .../infinityforreddit/apis/OnlineCustomThemeAPI.java | 6 ++++++ .../infinityforreddit/customtheme/OnlineCustomThemeMetadata.java | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'app/src/main/java/ml') 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; @@ -17,6 +18,11 @@ public interface OnlineCustomThemeAPI { @GET("/themes/theme") Call getCustomTheme(@Query("name") String themeName, @Query("username") String username); + @FormUrlEncoded + @PATCH("/themes/modify") + Call modifyTheme(@Field("id") int id, @Field("name") String themeName, + @Field("data") String customThemeJson, @Field("primary_color") String primaryColor); + @FormUrlEncoded @POST("/themes/upload") Call uploadTheme(@Field("name") String themeName, @Field("username") String username, 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 CREATOR = new Creator() { + public static final Creator 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); -- cgit v1.2.3