manage privacy
This commit is contained in:
parent
b69db8aa71
commit
fad83de6c1
|
@ -37,6 +37,8 @@ import android.os.AsyncTask;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.MediaStore;
|
||||
import android.speech.RecognizerIntent;
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -53,7 +55,6 @@ import android.text.Html;
|
|||
import android.text.InputFilter;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
@ -255,7 +256,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
private TextWatcher textWatcher;
|
||||
private int pollCountItem;
|
||||
private UploadServiceSingleBroadcastReceiver uploadReceiver;
|
||||
private String quickmessagecontent;
|
||||
private String quickmessagecontent, quickmessagevisibility;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -436,6 +437,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
visibility = b.getString("visibility", null);
|
||||
restoredScheduled = b.getBoolean("restoredScheduled", false);
|
||||
quickmessagecontent = b.getString("quickmessagecontent", null);
|
||||
quickmessagevisibility = b.getString("quickmessagevisibility", null);
|
||||
// ACTION_SEND route
|
||||
if (b.getInt("uriNumberMast", 0) == 1) {
|
||||
Uri fileUri = b.getParcelable("sharedUri");
|
||||
|
@ -589,12 +591,12 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
uploadSharedImage(sharedUri);
|
||||
}
|
||||
|
||||
|
||||
if (tootReply == null) {
|
||||
if (visibility == null) {
|
||||
String defaultVisibility = account.isLocked() ? "private" : "public";
|
||||
visibility = sharedpreferences.getString(Helper.SET_TOOT_VISIBILITY + "@" + account.getAcct() + "@" + account.getInstance(), defaultVisibility);
|
||||
}
|
||||
assert visibility != null;
|
||||
switch (visibility) {
|
||||
case "public":
|
||||
toot_visibility.setImageResource(R.drawable.ic_public_toot);
|
||||
|
@ -610,6 +612,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
toot_sensitive.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
|
@ -791,7 +794,6 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
Log.v(Helper.TAG,"s: " + s.toString());
|
||||
if (autocomplete) {
|
||||
toot_content.removeTextChangedListener(finalTextw);
|
||||
Thread thread = new Thread() {
|
||||
|
@ -799,25 +801,37 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
public void run() {
|
||||
String fedilabHugsTrigger = ":fedilab_hugs:";
|
||||
|
||||
|
||||
newContent[0] = s.toString().replaceAll(fedilabHugsTrigger, "");
|
||||
|
||||
int currentLength = countLength(toot_content, toot_cw_content);
|
||||
int toFill = 500 + fedilabHugsTrigger.length() - currentLength;
|
||||
int toFill = 500 - currentLength;
|
||||
if(toFill <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
newContent[0] = s.toString().replaceAll(fedilabHugsTrigger, "");
|
||||
|
||||
|
||||
StringBuilder hugs = new StringBuilder();
|
||||
for(int i = 0; i < toFill; i++) {
|
||||
hugs.append(new String(Character.toChars(0x1F917)));
|
||||
}
|
||||
|
||||
newContent[0] = newContent[0] + hugs.toString();
|
||||
toot_content.setText(newContent[0]);
|
||||
toot_content.setSelection(toot_content.getText().length());
|
||||
toot_content.addTextChangedListener(finalTextw);
|
||||
autocomplete = false;
|
||||
toot_space_left.setText(String.valueOf(countLength(toot_content, toot_cw_content)));
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
Runnable myRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
newContent[0] = newContent[0] + hugs.toString();
|
||||
toot_content.setText(newContent[0]);
|
||||
toot_content.setSelection(toot_content.getText().length());
|
||||
// toot_content.addTextChangedListener(finalTextw);
|
||||
autocomplete = false;
|
||||
toot_space_left.setText(String.valueOf(countLength(toot_content, toot_cw_content)));
|
||||
}
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
|
@ -2881,7 +2895,11 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
String settingsVisibility = sharedpreferences.getString(Helper.SET_TOOT_VISIBILITY + "@" + account.getAcct() + "@" + account.getInstance(), defaultVisibility);
|
||||
int initialTootVisibility = 0;
|
||||
int ownerTootVisibility = 0;
|
||||
switch (tootReply.getVisibility()){
|
||||
String temp_visibility = tootReply.getVisibility();
|
||||
if( quickmessagevisibility != null){
|
||||
temp_visibility = quickmessagevisibility;
|
||||
}
|
||||
switch (temp_visibility){
|
||||
case "public":
|
||||
initialTootVisibility = 4;
|
||||
break;
|
||||
|
@ -2985,7 +3003,6 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
|
|||
else
|
||||
contentView.setText(String.format("%s", (contentView.getText().toString() + " ")));
|
||||
for(Mention mention : tootReply.getMentions()){
|
||||
Log.v(Helper.TAG, mention.getAcct());
|
||||
if( mention.getAcct() != null && !mention.getId().equals(userIdReply) && !mentionedAccountsAdded.contains(mention.getAcct())) {
|
||||
mentionedAccountsAdded.add(mention.getAcct());
|
||||
String tootTemp = String.format("@%s ", mention.getAcct());
|
||||
|
|
|
@ -51,7 +51,6 @@ import android.text.method.LinkMovementMethod;
|
|||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
|
@ -63,6 +62,7 @@ import android.webkit.URLUtil;
|
|||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.DatePicker;
|
||||
|
@ -196,7 +196,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
private static MastalabAutoCompleteTextView toot_content;
|
||||
private static EditText toot_cw_content;
|
||||
private static TextView toot_space_left;
|
||||
|
||||
private static String visibility;
|
||||
|
||||
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, List<Status> statuses){
|
||||
super();
|
||||
this.context = context;
|
||||
|
@ -287,14 +288,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
|
||||
@Override
|
||||
public void onRetrieveSearchAccounts(APIResponse apiResponse) {
|
||||
Log.v(Helper.TAG,"onRetrieveSearch");
|
||||
if( apiResponse.getError() != null)
|
||||
return;
|
||||
int searchLength = 15;
|
||||
final List<Account> accounts = apiResponse.getAccounts();
|
||||
Log.v(Helper.TAG,"accounts: " +accounts);
|
||||
if( accounts != null)
|
||||
Log.v(Helper.TAG,"size: " +accounts.size());
|
||||
if( accounts != null && accounts.size() > 0){
|
||||
int currentCursorPosition = toot_content.getSelectionStart();
|
||||
AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(context, accounts);
|
||||
|
@ -560,6 +557,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
TextView toot_space_left;
|
||||
ImageView quick_reply_emoji;
|
||||
Button quick_reply_button;
|
||||
ImageView quick_reply_privacy;
|
||||
|
||||
public View getView(){
|
||||
return itemView;
|
||||
|
@ -678,6 +676,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
toot_space_left = itemView.findViewById(R.id.toot_space_left);
|
||||
quick_reply_emoji = itemView.findViewById(R.id.quick_reply_emoji);
|
||||
quick_reply_button = itemView.findViewById(R.id.quick_reply_button);
|
||||
quick_reply_privacy = itemView.findViewById(R.id.quick_reply_privacy);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -996,6 +995,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
|
||||
}
|
||||
|
||||
|
||||
holder.quick_reply_emoji.setOnClickListener(view ->{
|
||||
int style;
|
||||
if (theme == Helper.THEME_DARK) {
|
||||
|
@ -2276,6 +2276,55 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
|
||||
|
||||
holder.quick_reply_privacy.setOnClickListener(view -> {
|
||||
|
||||
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;
|
||||
}
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(context, style);
|
||||
dialog.setTitle(R.string.toot_visibility_tilte);
|
||||
final String[] stringArray = context.getResources().getStringArray(R.array.toot_visibility);
|
||||
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, stringArray);
|
||||
dialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int position) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int position) {
|
||||
switch (position){
|
||||
case 0:
|
||||
visibility = "public";
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_public_toot);
|
||||
break;
|
||||
case 1:
|
||||
visibility = "unlisted";
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_open_toot);
|
||||
break;
|
||||
case 2:
|
||||
visibility = "private";
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_outline_toot);
|
||||
break;
|
||||
case 3:
|
||||
visibility = "direct";
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_mail_outline_toot);
|
||||
break;
|
||||
}
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
});
|
||||
|
||||
|
||||
|
||||
if ((type == RetrieveFeedsAsyncTask.Type.CONTEXT && viewHolder.getAdapterPosition() == conversationPosition) || display_card || display_video_preview) {
|
||||
|
||||
|
@ -2388,6 +2437,86 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
toot_cw_content = content_cw;
|
||||
toot_space_left = holder.toot_space_left;
|
||||
|
||||
if( theme == Helper.THEME_DARK || theme == Helper.THEME_BLACK) {
|
||||
changeDrawableColor(context, R.drawable.ic_public_toot, R.color.dark_text);
|
||||
changeDrawableColor(context, R.drawable.ic_lock_open_toot, R.color.dark_text);
|
||||
changeDrawableColor(context, R.drawable.ic_lock_outline_toot, R.color.dark_text);
|
||||
changeDrawableColor(context, R.drawable.ic_mail_outline_toot, R.color.dark_text);
|
||||
}else {
|
||||
changeDrawableColor(context, R.drawable.ic_public_toot, R.color.white);
|
||||
changeDrawableColor(context, R.drawable.ic_lock_open_toot, R.color.white);
|
||||
changeDrawableColor(context, R.drawable.ic_lock_outline_toot, R.color.white);
|
||||
changeDrawableColor(context, R.drawable.ic_mail_outline_toot, R.color.white);
|
||||
|
||||
}
|
||||
|
||||
final SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, null);
|
||||
Account account = new AccountDAO(context, db).getUniqAccount(userId, instance);
|
||||
|
||||
String defaultVisibility = account.isLocked()?"private":"public";
|
||||
String settingsVisibility = sharedpreferences.getString(Helper.SET_TOOT_VISIBILITY + "@" + account.getAcct() + "@" + account.getInstance(), defaultVisibility);
|
||||
int initialTootVisibility = 0;
|
||||
int ownerTootVisibility = 0;
|
||||
switch (status.getReblog() != null ?status.getReblog().getVisibility():status.getVisibility()){
|
||||
case "public":
|
||||
initialTootVisibility = 4;
|
||||
break;
|
||||
case "unlisted":
|
||||
initialTootVisibility = 3;
|
||||
break;
|
||||
case "private":
|
||||
visibility = "private";
|
||||
initialTootVisibility = 2;
|
||||
break;
|
||||
case "direct":
|
||||
visibility = "direct";
|
||||
initialTootVisibility = 1;
|
||||
break;
|
||||
}
|
||||
if (settingsVisibility != null) {
|
||||
switch (settingsVisibility){
|
||||
case "public":
|
||||
ownerTootVisibility = 4;
|
||||
break;
|
||||
case "unlisted":
|
||||
ownerTootVisibility = 3;
|
||||
break;
|
||||
case "private":
|
||||
visibility = "private";
|
||||
ownerTootVisibility = 2;
|
||||
break;
|
||||
case "direct":
|
||||
visibility = "direct";
|
||||
ownerTootVisibility = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int tootVisibility;
|
||||
if( ownerTootVisibility >= initialTootVisibility){
|
||||
tootVisibility = initialTootVisibility;
|
||||
}else {
|
||||
tootVisibility = ownerTootVisibility;
|
||||
}
|
||||
switch (tootVisibility){
|
||||
case 4:
|
||||
visibility = "public";
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_public_toot);
|
||||
break;
|
||||
case 3:
|
||||
visibility = "unlisted";
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_open_toot);
|
||||
break;
|
||||
case 2:
|
||||
visibility = "private";
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_lock_outline_toot);
|
||||
break;
|
||||
case 1:
|
||||
visibility = "direct";
|
||||
holder.quick_reply_privacy.setImageResource(R.drawable.ic_mail_outline_toot);
|
||||
break;
|
||||
}
|
||||
|
||||
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)
|
||||
holder.quick_reply_text.addTextChangedListener(textWatcher);
|
||||
|
||||
|
@ -2409,6 +2538,8 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}else {
|
||||
b.putParcelable("tootReply", status);
|
||||
}
|
||||
|
||||
b.putString("quickmessagevisibility", visibility);
|
||||
b.putString("quickmessagecontent", holder.quick_reply_text.getText().toString());
|
||||
intent.putExtras(b); //Put your id to your next Intent
|
||||
context.startActivity(intent);
|
||||
|
|
|
@ -29,7 +29,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
Loading…
Reference in New Issue