diff options
Diffstat (limited to 'app/src/main')
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); |