Groundwork for editing posts

This commit is contained in:
Balazs Toldi 2023-07-31 16:21:45 +02:00
parent 3e10186c7c
commit 92292be472
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
4 changed files with 61 additions and 6 deletions

View File

@ -13,7 +13,6 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
@ -81,7 +80,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
@BindView(R.id.toolbar_edit_post_activity)
Toolbar toolbar;
@BindView(R.id.post_title_text_view_edit_post_activity)
TextView titleTextView;
EditText titleEditText;
@BindView(R.id.divider_edit_post_activity)
View divider;
@BindView(R.id.post_text_content_edit_text_edit_post_activity)
@ -140,7 +139,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
mFullName = getIntent().getStringExtra(EXTRA_FULLNAME);
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
titleTextView.setText(getIntent().getStringExtra(EXTRA_TITLE));
titleEditText.setText(getIntent().getStringExtra(EXTRA_TITLE));
mPostContent = getIntent().getStringExtra(EXTRA_CONTENT);
contentEditText.setText(mPostContent);
@ -190,12 +189,12 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
protected void applyCustomTheme() {
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
titleTextView.setTextColor(mCustomThemeWrapper.getPostTitleColor());
titleEditText.setTextColor(mCustomThemeWrapper.getPostTitleColor());
divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor());
contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor());
if (titleTypeface != null) {
titleTextView.setTypeface(titleTypeface);
titleEditText.setTypeface(titleTypeface);
}
if (contentTypeface != null) {
contentEditText.setTypeface(contentTypeface);

View File

@ -6,6 +6,7 @@ import eu.toldi.infinityforlemmy.dto.AccountLoginDTO;
import eu.toldi.infinityforlemmy.dto.CommentDTO;
import eu.toldi.infinityforlemmy.dto.CommentVoteDTO;
import eu.toldi.infinityforlemmy.dto.EditCommentDTO;
import eu.toldi.infinityforlemmy.dto.EditPostDTO;
import eu.toldi.infinityforlemmy.dto.FollowCommunityDTO;
import eu.toldi.infinityforlemmy.dto.PostVoteDTO;
import eu.toldi.infinityforlemmy.dto.ReadPostDTO;
@ -43,6 +44,10 @@ public interface LemmyAPI {
@POST("api/v3/post")
Call<String> postCreate(@Body SubmitPostDTO params);
@Headers("Content-Type: application/json")
@PUT("api/v3/post")
Call<String> postUpdate(@Body EditPostDTO params);
@GET("api/v3/user")
ListenableFuture<Response<String>> getUserPosts(
@Query("username") String username,

View File

@ -0,0 +1,51 @@
package eu.toldi.infinityforlemmy.dto;
public class EditPostDTO {
private int post_id;
private String name;
private String url;
private String body;
private boolean nsfw;
private Integer language_id;
private String auth;
public EditPostDTO(int post_id, String name, String url, String body, boolean nsfw, Integer language_id, String auth) {
this.post_id = post_id;
this.name = name;
this.url = url;
this.body = body;
this.nsfw = nsfw;
this.language_id = language_id;
this.auth = auth;
}
public int getPost_id() {
return post_id;
}
public String getName() {
return name;
}
public String getUrl() {
return url;
}
public String getBody() {
return body;
}
public boolean isNsfw() {
return nsfw;
}
public Integer getLanguage_id() {
return language_id;
}
public String getAuth() {
return auth;
}
}

View File

@ -39,7 +39,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
<EditText
android:id="@+id/post_title_text_view_edit_post_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"