Moderation feature in non compact mode
This commit is contained in:
parent
2c8d0fb6d0
commit
cebcfd3edc
|
@ -80,7 +80,7 @@ dependencies {
|
|||
implementation "com.github.stom79:SwipeBackLayout:$swipebackLibraryVersion"
|
||||
implementation 'com.github.stom79:country-picker-android:1.2.0'
|
||||
implementation 'com.github.stom79:mytransl:1.5'
|
||||
implementation 'com.github.stom79:SparkButton:1.0.10'
|
||||
implementation 'com.github.stom79:SparkButton:1.0.12'
|
||||
implementation "com.koushikdutta.async:androidasync:2.+"
|
||||
implementation 'com.vanniktech:emoji-one:0.6.0-SNAPSHOT'
|
||||
implementation 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
|
||||
|
|
|
@ -260,6 +260,9 @@ public class API {
|
|||
try {
|
||||
String response = new HttpsConnection(context).get(getAbsoluteUrl("/accounts/verify_credentials"), 60, null, prefKeyOauthTokenT);
|
||||
account = parseAccountResponse(context, new JSONObject(response));
|
||||
if( account.getSocial().equals("PLEROMA")){
|
||||
isPleromaAdmin(account.getAcct());
|
||||
}
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
e.printStackTrace();
|
||||
|
@ -286,6 +289,11 @@ public class API {
|
|||
try {
|
||||
String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/accounts/%s",accountId)), 60, null, prefKeyOauthTokenT);
|
||||
account = parseAccountResponse(context, new JSONObject(response));
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
if( account.getSocial().equals("PLEROMA") && accountId.equals(userId)){
|
||||
isPleromaAdmin(account.getAcct());
|
||||
}
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
|
@ -2281,18 +2289,22 @@ public class API {
|
|||
|
||||
//Pleroma admin calls
|
||||
/**
|
||||
* Retrieves Accounts when searching (ie: via @...) *synchronously*
|
||||
* @return boolean
|
||||
* Check if it's a Pleroma admin account and change in settings *synchronously*
|
||||
*/
|
||||
public boolean isPleromaAdmin(String nickname) {
|
||||
private void isPleromaAdmin(String nickname) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean isAdmin;
|
||||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||
String response = httpsConnection.get(String.format(Helper.getLiveInstanceWithProtocol(context)+"/api/pleroma/admin/permission_group/%s/admin",nickname), 60, null, prefKeyOauthTokenT);
|
||||
//Call didn't return a 404, so the account is admin
|
||||
return true;
|
||||
isAdmin = true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
isAdmin = false;
|
||||
}
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(Helper.PREF_IS_ADMINISTRATOR, isAdmin);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2879,52 +2891,49 @@ public class API {
|
|||
card.setTitle(resobj.get("title").toString());
|
||||
card.setDescription(resobj.get("description").toString());
|
||||
card.setImage(resobj.get("image").toString());
|
||||
card.setHtml(resobj.get("html").toString());
|
||||
|
||||
card.setType(resobj.get("type").toString());
|
||||
try {
|
||||
card.setAuthor_name(resobj.get("author_name").toString());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
card.setAuthor_name(null);
|
||||
}
|
||||
try {
|
||||
card.setAuthor_url(resobj.get("author_url").toString());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
card.setAuthor_url(null);
|
||||
}
|
||||
try {
|
||||
card.setHtml(resobj.get("html").toString());
|
||||
}catch (Exception e){
|
||||
card.setHtml(null);
|
||||
}
|
||||
try {
|
||||
card.setEmbed_url(resobj.get("embed_url").toString());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
card.setEmbed_url(null);
|
||||
}
|
||||
try {
|
||||
card.setProvider_name(resobj.get("provider_name").toString());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
card.setProvider_name(null);
|
||||
}
|
||||
try {
|
||||
card.setProvider_url(resobj.get("provider_url").toString());
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
card.setProvider_url(null);
|
||||
}
|
||||
try {
|
||||
card.setHeight(Integer.parseInt(resobj.get("height").toString()));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
card.setHeight(0);
|
||||
}
|
||||
try {
|
||||
card.setWidth(Integer.parseInt(resobj.get("width").toString()));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
card.setWidth(0);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
card = null;
|
||||
}
|
||||
return card;
|
||||
|
@ -3352,7 +3361,6 @@ public class API {
|
|||
}
|
||||
|
||||
try {
|
||||
|
||||
status.setCard(parseCardResponse(resobj.getJSONObject("card")));
|
||||
}catch (Exception e){status.setCard(null);}
|
||||
|
||||
|
|
|
@ -293,6 +293,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
RelativeLayout status_prev4_container;
|
||||
TextView status_reply;
|
||||
ImageView status_pin;
|
||||
ImageView status_remove;
|
||||
ImageView status_privacy;
|
||||
ImageButton status_translate, status_bookmark;
|
||||
LinearLayout status_container2;
|
||||
|
@ -344,6 +345,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
status_favorite_count = itemView.findViewById(R.id.status_favorite_count);
|
||||
status_reblog_count = itemView.findViewById(R.id.status_reblog_count);
|
||||
status_pin = itemView.findViewById(R.id.status_pin);
|
||||
status_remove = itemView.findViewById(R.id.status_remove);
|
||||
status_toot_date = itemView.findViewById(R.id.status_toot_date);
|
||||
status_show_more = itemView.findViewById(R.id.status_show_more);
|
||||
status_more = itemView.findViewById(R.id.status_more);
|
||||
|
@ -643,6 +645,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
|
||||
changeDrawableColor(context, R.drawable.video_preview, R.color.white);
|
||||
if (theme == Helper.THEME_BLACK) {
|
||||
changeDrawableColor(context, holder.status_remove, R.color.action_dark);
|
||||
changeDrawableColor(context, R.drawable.ic_reply, R.color.action_black);
|
||||
changeDrawableColor(context, holder.status_more, R.color.action_black);
|
||||
changeDrawableColor(context, holder.status_privacy, R.color.action_black);
|
||||
|
@ -669,7 +672,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
changeDrawableColor(context, R.drawable.ic_translate, R.color.black);
|
||||
holder.status_cardview.setBackgroundResource(R.drawable.card_border_black);
|
||||
} else if (theme == Helper.THEME_DARK) {
|
||||
|
||||
changeDrawableColor(context, holder.status_remove, R.color.action_dark);
|
||||
changeDrawableColor(context, R.drawable.ic_reply, R.color.action_dark);
|
||||
changeDrawableColor(context, holder.status_more, R.color.action_dark);
|
||||
changeDrawableColor(context, R.drawable.ic_repeat, R.color.action_dark);
|
||||
|
@ -696,6 +699,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
changeDrawableColor(context, R.drawable.ic_bookmark_border, R.color.mastodonC1);
|
||||
changeDrawableColor(context, R.drawable.ic_translate, R.color.mastodonC1);
|
||||
} else {
|
||||
changeDrawableColor(context, holder.status_remove, R.color.action_light);
|
||||
changeDrawableColor(context, R.drawable.ic_fetch_more, R.color.action_light);
|
||||
changeDrawableColor(context, R.drawable.ic_reply, R.color.action_light);
|
||||
changeDrawableColor(context, R.drawable.ic_conversation, R.color.action_light);
|
||||
|
@ -1410,6 +1414,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.status_pin.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if( (isAdmin || isModerator) && !isCompactMode && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS){
|
||||
holder.status_remove.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
holder.status_remove.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (status.getWebviewURL() != null) {
|
||||
holder.status_cardview_webview.loadUrl(status.getWebviewURL());
|
||||
|
@ -1536,7 +1545,86 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
CrossActions.doCrossAction(context, type, status, null, (status.isPinned() || (status.getReblog() != null && status.getReblog().isPinned())) ? API.StatusAction.UNPIN : API.StatusAction.PIN, statusListAdapter, StatusListAdapter.this, true);
|
||||
}
|
||||
});
|
||||
int style;
|
||||
if (theme == Helper.THEME_DARK) {
|
||||
style = R.style.DialogDark;
|
||||
} else if (theme == Helper.THEME_BLACK) {
|
||||
style = R.style.DialogBlack;
|
||||
} else {
|
||||
style = R.style.Dialog;
|
||||
}
|
||||
|
||||
holder.status_remove.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String[] stringArrayConf = context.getResources().getStringArray(R.array.more_action_owner_confirm);
|
||||
AlertDialog.Builder builderInner = new AlertDialog.Builder(context, style);
|
||||
builderInner.setTitle(stringArrayConf[0]);
|
||||
API.StatusAction doAction = API.StatusAction.UNSTATUS;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY));
|
||||
else
|
||||
//noinspection deprecation
|
||||
builderInner.setMessage(Html.fromHtml(status.getContent()));
|
||||
|
||||
|
||||
//Text for report
|
||||
EditText input = null;
|
||||
if (doAction == API.StatusAction.REPORT) {
|
||||
input = new EditText(context);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
input.setLayoutParams(lp);
|
||||
builderInner.setView(input);
|
||||
}
|
||||
builderInner.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
final EditText finalInput = input;
|
||||
builderInner.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String targetedId = status.getId();
|
||||
new PostActionAsyncTask(context, doAction, targetedId, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
if (redraft) {
|
||||
if (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().trim().equals("null")) {
|
||||
toot = new Status();
|
||||
toot.setIn_reply_to_id(status.getIn_reply_to_id());
|
||||
toot.setSensitive(status.isSensitive());
|
||||
toot.setMedia_attachments(status.getMedia_attachments());
|
||||
if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0)
|
||||
toot.setSpoiler_text(status.getSpoiler_text().trim());
|
||||
toot.setContent(status.getContent());
|
||||
toot.setVisibility(status.getVisibility());
|
||||
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ONESTATUS, status.getIn_reply_to_id(), null, false, false, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
toot = new Status();
|
||||
toot.setSensitive(status.isSensitive());
|
||||
toot.setMedia_attachments(status.getMedia_attachments());
|
||||
if (status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0)
|
||||
toot.setSpoiler_text(status.getSpoiler_text().trim());
|
||||
toot.setVisibility(status.getVisibility());
|
||||
toot.setContent(status.getContent());
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
long id = new StatusStoredDAO(context, db).insertStatus(toot, null);
|
||||
Intent intentToot = new Intent(context, TootActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putLong("restored", id);
|
||||
b.putBoolean("removed", true);
|
||||
intentToot.putExtras(b);
|
||||
context.startActivity(intentToot);
|
||||
}
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builderInner.show();
|
||||
}
|
||||
});
|
||||
if (!status.getVisibility().equals("direct"))
|
||||
holder.spark_button_fav.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
|
@ -1604,14 +1692,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
}
|
||||
});
|
||||
int style;
|
||||
if (theme == Helper.THEME_DARK) {
|
||||
style = R.style.DialogDark;
|
||||
} else if (theme == Helper.THEME_BLACK) {
|
||||
style = R.style.DialogBlack;
|
||||
} else {
|
||||
style = R.style.Dialog;
|
||||
}
|
||||
|
||||
if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE)
|
||||
holder.status_more.setVisibility(View.GONE);
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
|
||||
</vector>
|
|
@ -164,6 +164,17 @@
|
|||
android:src="@drawable/ic_bookmark_border"
|
||||
android:layout_marginTop="5dp"
|
||||
/>
|
||||
<ImageView
|
||||
android:id="@+id/status_remove"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:contentDescription="@string/delete"
|
||||
android:src="@drawable/ic_clear_toot"
|
||||
android:layout_marginTop="5dp"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -744,7 +744,19 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:id="@+id/status_remove"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:contentDescription="@string/delete"
|
||||
android:src="@drawable/ic_clear_toot"
|
||||
android:layout_marginTop="5dp"
|
||||
/>
|
||||
<ImageView
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginStart="15dp"
|
||||
|
|
|
@ -658,7 +658,19 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:id="@+id/status_remove"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:contentDescription="@string/delete"
|
||||
android:src="@drawable/ic_clear_toot"
|
||||
android:layout_marginTop="5dp"
|
||||
/>
|
||||
<ImageView
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
|
|
Loading…
Reference in New Issue