Warn when the account might not see the message.

This commit is contained in:
tom79 2019-06-28 14:40:33 +02:00
parent 34248772da
commit 9c9c7416d7
6 changed files with 62 additions and 4 deletions

View File

@ -136,6 +136,7 @@ import app.fedilab.android.asynctasks.PostActionAsyncTask;
import app.fedilab.android.asynctasks.PostStatusAsyncTask;
import app.fedilab.android.asynctasks.RetrieveAccountsForReplyAsyncTask;
import app.fedilab.android.asynctasks.RetrieveEmojiAsyncTask;
import app.fedilab.android.asynctasks.RetrieveRelationshipAsyncTask;
import app.fedilab.android.asynctasks.RetrieveSearchAccountsAsyncTask;
import app.fedilab.android.asynctasks.RetrieveSearchAsyncTask;
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
@ -150,6 +151,7 @@ import app.fedilab.android.client.Entities.Mention;
import app.fedilab.android.client.Entities.Notification;
import app.fedilab.android.client.Entities.Poll;
import app.fedilab.android.client.Entities.PollOptions;
import app.fedilab.android.client.Entities.Relationship;
import app.fedilab.android.client.Entities.Results;
import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.client.Entities.StoredStatus;
@ -172,6 +174,7 @@ import app.fedilab.android.interfaces.OnPostStatusActionInterface;
import app.fedilab.android.interfaces.OnRetrieveAccountsReplyInterface;
import app.fedilab.android.interfaces.OnRetrieveAttachmentInterface;
import app.fedilab.android.interfaces.OnRetrieveEmojiInterface;
import app.fedilab.android.interfaces.OnRetrieveRelationshipInterface;
import app.fedilab.android.interfaces.OnRetrieveSearcAccountshInterface;
import app.fedilab.android.interfaces.OnRetrieveSearchInterface;
import app.fedilab.android.jobs.ScheduledTootsSyncJob;
@ -196,7 +199,7 @@ import static app.fedilab.android.helper.Helper.orbotConnected;
* Toot activity class
*/
public class TootActivity extends BaseActivity implements UploadStatusDelegate, OnPostActionInterface, OnRetrieveSearcAccountshInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface, OnRetrieveAccountsReplyInterface, OnRetrieveEmojiInterface, OnDownloadInterface, OnRetrieveAttachmentInterface {
public class TootActivity extends BaseActivity implements UploadStatusDelegate, OnPostActionInterface, OnRetrieveSearcAccountshInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface, OnRetrieveAccountsReplyInterface, OnRetrieveEmojiInterface, OnDownloadInterface, OnRetrieveAttachmentInterface, OnRetrieveRelationshipInterface {
@ -264,6 +267,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
public static final int REQUEST_CAMERA_PERMISSION_RESULT = 1653;
public static final int SEND_VOICE_MESSAGE = 1423;
private TextView warning_message;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -385,6 +389,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
toot_sensitive = findViewById(R.id.toot_sensitive);
drawer_layout = findViewById(R.id.drawer_layout);
ImageButton toot_emoji = findViewById(R.id.toot_emoji);
warning_message = findViewById(R.id.warning_message);
poll_action = findViewById(R.id.poll_action);
isScheduled = false;
if (sharedpreferences.getBoolean(Helper.SET_DISPLAY_EMOJI, true)) {
@ -461,6 +466,12 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}
restored = b.getLong("restored", -1);
}
if( tootReply != null){
if( tootReply.getAccount().getMoved_to_account() != null){
warning_message.setVisibility(View.VISIBLE);
}
new RetrieveRelationshipAsyncTask(getApplicationContext(), tootReply.getAccount().getId(),TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
if (scheduledstatus != null)
toot_it.setText(R.string.modify);
if (restoredScheduled) {
@ -1244,6 +1255,17 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
// your code here
}
@Override
public void onRetrieveRelationship(Relationship relationship, Error error) {
if( error != null){
return;
}
if( relationship.isBlocked_by() ){
warning_message.setVisibility(View.VISIBLE);
}
}
class asyncPicture extends AsyncTask<Void, Void, Void> {

View File

@ -25,6 +25,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.apache.poi.hssf.usermodel.HSSFHeader;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -5479,6 +5480,11 @@ public class API {
}catch (Exception ignored){
relationship.setMuting_notifications(false);
}
try {
relationship.setBlocked_by(resobj.getBoolean("blocked_by"));
}catch (Exception ignored){
relationship.setBlocked_by(false);
}
relationship.setRequested(Boolean.valueOf(resobj.get("requested").toString()));
} catch (JSONException e) {
setDefaultError(e);

View File

@ -30,6 +30,7 @@ public class Relationship {
private boolean muting_notifications;
private boolean endorsed;
private boolean showing_reblogs;
private boolean blocked_by;
public String getId() {
@ -103,4 +104,12 @@ public class Relationship {
public void setShowing_reblogs(boolean showing_reblogs) {
this.showing_reblogs = showing_reblogs;
}
public boolean isBlocked_by() {
return blocked_by;
}
public void setBlocked_by(boolean blocked_by) {
this.blocked_by = blocked_by;
}
}

View File

@ -28,7 +28,17 @@
android:paddingTop="@dimen/fab_margin"
android:paddingRight="@dimen/fab_margin"
android:paddingBottom="@dimen/fab_margin">
<TextView
android:visibility="gone"
android:id="@+id/warning_message"
android:text="@string/reply_might_be_useless"
android:layout_margin="5dp"
android:layout_gravity="center"
android:gravity="center"
android:background="@drawable/red_border"
android:textColor="@color/red_1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/toot_cw_content"
android:layout_width="match_parent"

View File

@ -28,9 +28,20 @@
android:paddingTop="@dimen/toot_padding"
android:paddingRight="@dimen/toot_padding"
android:paddingBottom="@dimen/toot_padding">
<TextView
android:visibility="gone"
android:id="@+id/warning_message"
android:text="@string/reply_might_be_useless"
android:layout_margin="5dp"
android:layout_gravity="center"
android:gravity="center"
android:background="@drawable/red_border"
android:textColor="@color/red_1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/toot_cw_content"
android:layout_below="@+id/warning_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
@ -50,7 +61,6 @@
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
android:fillViewport="true">
<app.fedilab.android.helper.MastalabAutoCompleteTextView
android:id="@+id/toot_content"
android:layout_width="match_parent"

View File

@ -1085,6 +1085,7 @@
<string name="toot_message_record_error">An error occurred when recording the voice message!</string>
<string name="voice_message">Voice message</string>
<string name="set_quick_reply">Enable quick reply</string>
<string name="reply_might_be_useless">The account you are replying might not see your message!</string>
<plurals name="number_of_vote">
<item quantity="one">%d vote</item>
<item quantity="other">%d votes</item>