mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 04:37:25 +01:00
parent
0b74574fa6
commit
fd24f04254
@ -66,6 +66,7 @@ import eu.toldi.infinityforlemmy.activities.ViewVideoActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.WebViewActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.WikiActivity;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.CommentMoreBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.BlockedCommunitiesListingFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.BlockedUsersListingFragment;
|
||||
@ -316,6 +317,8 @@ public interface AppComponent {
|
||||
|
||||
void inject(BlockedUsersListingFragment blockedUsersListingFragment);
|
||||
|
||||
void inject(CommentMoreBottomSheetFragment commentMoreBottomSheetFragment);
|
||||
|
||||
|
||||
@Component.Factory
|
||||
interface Factory {
|
||||
|
@ -10,15 +10,13 @@ import javax.inject.Singleton;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
|
||||
import eu.toldi.infinityforlemmy.network.SortTypeConverterFactory;
|
||||
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
|
||||
import eu.toldi.infinityforlemmy.post.LemmyPostAPI;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import okhttp3.ConnectionPool;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.guava.GuavaCallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||
|
||||
@Module(includes = AppModule.class)
|
||||
abstract class NetworkModule {
|
||||
@ -216,4 +214,16 @@ abstract class NetworkModule {
|
||||
static StreamableAPI provideStreamableApi(@Named("streamable") Retrofit streamableRetrofit) {
|
||||
return streamableRetrofit.create(StreamableAPI.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static LemmyPostAPI providePostAPI(@Named("no_oauth") RetrofitHolder retrofitHolder) {
|
||||
return new LemmyPostAPI(retrofitHolder);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static LemmyCommentAPI provideCommentAPI(@Named("no_oauth") RetrofitHolder retrofitHolder) {
|
||||
return new LemmyCommentAPI(retrofitHolder);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ import eu.toldi.infinityforlemmy.dto.PostVoteDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadMessageDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadPostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReportCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReportPostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SaveCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SavePostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SubmitPostDTO;
|
||||
@ -82,6 +84,10 @@ public interface LemmyAPI {
|
||||
@POST("api/v3/post")
|
||||
Call<String> postCreate(@Body SubmitPostDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/post/report")
|
||||
Call<String> postReport(@Body ReportPostDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@PUT("api/v3/post")
|
||||
Call<String> postUpdate(@Body EditPostDTO params);
|
||||
@ -138,6 +144,10 @@ public interface LemmyAPI {
|
||||
@POST("api/v3/comment/like")
|
||||
Call<String> commentLike(@Body CommentVoteDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/comment/report")
|
||||
Call<String> commentReport(@Body ReportCommentDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/community/follow")
|
||||
Call<String> communityFollow(@Body FollowCommunityDTO params);
|
||||
|
@ -10,24 +10,32 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.CommentActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.EditCommentActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.GiveAwardActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ReportActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewPostDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
|
||||
@ -57,6 +65,13 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
||||
TextView copyTextView;
|
||||
@BindView(R.id.report_view_comment_more_bottom_sheet_fragment)
|
||||
TextView reportTextView;
|
||||
|
||||
@Inject
|
||||
LemmyCommentAPI lemmyCommentAPI;
|
||||
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
|
||||
private BaseActivity activity;
|
||||
|
||||
public CommentMoreBottomSheetFragment() {
|
||||
@ -66,6 +81,7 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
((Infinity) activity.getApplication()).getAppComponent().inject(this);
|
||||
View rootView = inflater.inflate(R.layout.fragment_comment_more_bottom_sheet, container, false);
|
||||
ButterKnife.bind(this, rootView);
|
||||
|
||||
@ -181,7 +197,44 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
||||
intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, comment.getCommunityName());
|
||||
intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, comment.getFullName());
|
||||
activity.startActivity(intent);*/
|
||||
Toast.makeText(activity, R.string.not_implemented, Toast.LENGTH_SHORT).show();
|
||||
if (accessToken == null) {
|
||||
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
LayoutInflater dialog_inflater = LayoutInflater.from(activity);
|
||||
View dialog_view = dialog_inflater.inflate(R.layout.dialog_report, null);
|
||||
EditText reasonEditText = dialog_view.findViewById(R.id.reasonEditText);
|
||||
|
||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(activity)
|
||||
.setTitle(R.string.report_post)
|
||||
.setView(dialog_view)
|
||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.dismiss())
|
||||
.setPositiveButton(R.string.send_report, (dialogInterface, i) -> {
|
||||
String reason = reasonEditText.getText().toString();
|
||||
if (reason.isEmpty()) {
|
||||
Toast.makeText(activity, "A report reason must be provided", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
lemmyCommentAPI.reportComment(comment.getId(), reason, accessToken, new LemmyCommentAPI.ReportCommentCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Toast.makeText(activity, R.string.report_successful, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
Toast.makeText(activity, R.string.report_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
|
||||
Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
Button negativeButton = dialog.getButton(AlertDialog.BUTTON_NEGATIVE);
|
||||
positiveButton.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||
negativeButton.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||
dismiss();
|
||||
});
|
||||
|
||||
|
@ -24,6 +24,8 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
@ -31,6 +33,7 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.appcompat.view.menu.MenuItemImpl;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
@ -106,6 +109,7 @@ import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import eu.toldi.infinityforlemmy.post.FetchPost;
|
||||
import eu.toldi.infinityforlemmy.post.FetchRemovedPost;
|
||||
import eu.toldi.infinityforlemmy.post.HidePost;
|
||||
import eu.toldi.infinityforlemmy.post.LemmyPostAPI;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
@ -194,6 +198,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
Executor mExecutor;
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
@Inject
|
||||
LemmyPostAPI mLemmyPostAPI;
|
||||
@State
|
||||
Post mPost;
|
||||
@State
|
||||
@ -1153,7 +1159,43 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
Toast.makeText(activity, R.string.not_implemented, Toast.LENGTH_SHORT).show();
|
||||
if (mAccessToken == null) {
|
||||
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
LayoutInflater inflater = LayoutInflater.from(activity);
|
||||
View view = inflater.inflate(R.layout.dialog_report, null);
|
||||
EditText reasonEditText = view.findViewById(R.id.reasonEditText);
|
||||
|
||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(activity)
|
||||
.setTitle(R.string.report_post)
|
||||
.setView(view)
|
||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.dismiss())
|
||||
.setPositiveButton(R.string.send_report, (dialogInterface, i) -> {
|
||||
String reason = reasonEditText.getText().toString();
|
||||
if (reason.isEmpty()) {
|
||||
Toast.makeText(activity, "A report reason must be provided", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
mLemmyPostAPI.reportPost(mPost.getId(), reason, mAccessToken, new LemmyPostAPI.ReportPostCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Toast.makeText(activity, R.string.report_successful, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
Toast.makeText(activity, R.string.report_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
|
||||
Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||
Button negativeButton = dialog.getButton(AlertDialog.BUTTON_NEGATIVE);
|
||||
positiveButton.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||
negativeButton.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_see_removed_view_post_detail_fragment) {
|
||||
showRemovedPost();
|
||||
|
@ -0,0 +1,35 @@
|
||||
package eu.toldi.infinityforlemmy.comment
|
||||
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI
|
||||
import eu.toldi.infinityforlemmy.dto.ReportCommentDTO
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
|
||||
class LemmyCommentAPI(val retrofitHolder: RetrofitHolder) {
|
||||
|
||||
fun reportComment(id: Int, reason: String, auth: String, callback: ReportCommentCallback) {
|
||||
val api = retrofitHolder.retrofit.create(LemmyAPI::class.java)
|
||||
api.commentReport(ReportCommentDTO(id, reason, auth)).enqueue(object : Callback<String> {
|
||||
override fun onResponse(
|
||||
call: retrofit2.Call<String>,
|
||||
response: retrofit2.Response<String>
|
||||
) {
|
||||
if (response.isSuccessful) {
|
||||
callback.onSuccess()
|
||||
} else {
|
||||
callback.onFailure()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||
callback.onFailure()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
public interface ReportCommentCallback {
|
||||
fun onSuccess()
|
||||
fun onFailure()
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package eu.toldi.infinityforlemmy.dto
|
||||
|
||||
data class ReportPostDTO(val post_id: Int, val reason: String, val auth: String)
|
||||
|
||||
data class ReportCommentDTO(val comment_id: Int, val reason: String, val auth: String)
|
15
app/src/main/res/layout/dialog_report.xml
Normal file
15
app/src/main/res/layout/dialog_report.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/reasonEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Reason"
|
||||
android:inputType="textMultiLine" />
|
||||
|
||||
</LinearLayout>
|
@ -1367,4 +1367,6 @@
|
||||
<string name="unblock_user_failed">Failed to unblock user</string>
|
||||
<string name="settings_hide_community_and_user_instance">Hide community and user instance</string>
|
||||
<string name="settings_show_display_name_instead_of_user_name">Show community and user display names</string>
|
||||
<string name="report_post">Report Post</string>
|
||||
<string name="send_report">Send Report</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user