mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
undo community hack
This commit is contained in:
@@ -15,7 +15,6 @@ This app has some extended support for WebXDC apps:
|
||||
|
||||
- `window.webxdc.arcanechat` a string with the ArcaneChat version and can be used by app developers
|
||||
to detect when they can use the ArcaneChat-specific features.
|
||||
- `window.webxdc.isCommunity` true if the current account is a community account
|
||||
- `sendToChat()`: extra property `subject` can be set to a text string to set message/email's subject.
|
||||
- `sendToChat()`: extra property `html` can be set to a string of html markup to set the HTML part of the email/message.
|
||||
- `sendToChat()`: the file object parameter also accepts a `type` field that can be one of:
|
||||
|
||||
@@ -1373,11 +1373,6 @@ JNIEXPORT jint Java_com_b44t_messenger_DcMsg_getId(JNIEnv *env, jobject obj)
|
||||
return dc_msg_get_id(get_dc_msg(env, obj));
|
||||
}
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_DcMsg_getSenderColor(JNIEnv *env, jobject obj)
|
||||
{
|
||||
return dc_msg_get_sender_color(get_dc_msg(env, obj));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring Java_com_b44t_messenger_DcMsg_getText(JNIEnv *env, jobject obj)
|
||||
{
|
||||
char* temp = dc_msg_get_text(get_dc_msg(env, obj));
|
||||
|
||||
@@ -245,23 +245,6 @@ public class DcContext {
|
||||
return displayname;
|
||||
}
|
||||
|
||||
public boolean isCommunity() {
|
||||
return getConfigInt("is_community") == 1;
|
||||
}
|
||||
|
||||
public void setCommunityMode(boolean enable) {
|
||||
setConfig("is_community", enable? "1" : null);
|
||||
}
|
||||
|
||||
public String getCommunityUser() {
|
||||
String name = getConfig("ui.community.selfname");
|
||||
return name == null? "" : name;
|
||||
}
|
||||
|
||||
public void setCommunityUser(String name) {
|
||||
setConfig("ui.community.selfname", name);
|
||||
}
|
||||
|
||||
public boolean isChatmail() {
|
||||
return getConfigInt("is_chatmail") == 1;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,6 @@ public class DcMsg {
|
||||
public native String getQuotedText ();
|
||||
public native String getError ();
|
||||
public native String getOverrideSenderName();
|
||||
public native int getSenderColor();
|
||||
public native boolean isEdited ();
|
||||
|
||||
public String getSenderName(DcContact dcContact) {
|
||||
|
||||
@@ -336,7 +336,7 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
menu.findItem(R.id.menu_context_reply).setVisible(chat.canSend() && canReply);
|
||||
boolean canEdit = canEditMsg(messageRecord);
|
||||
menu.findItem(R.id.menu_context_edit).setVisible(chat.canSend() && canEdit);
|
||||
boolean showReplyPrivately = !dcContext.isCommunity() && chat.isMultiUser() && !messageRecord.isOutgoing() && canReply;
|
||||
boolean showReplyPrivately = chat.isMultiUser() && !messageRecord.isOutgoing() && canReply;
|
||||
menu.findItem(R.id.menu_context_reply_privately).setVisible(showReplyPrivately);
|
||||
menu.findItem(R.id.menu_add_to_home_screen).setVisible(messageRecord.getType() == DcMsg.DC_MSG_WEBXDC);
|
||||
|
||||
@@ -801,9 +801,6 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
list.getAdapter().notifyDataSetChanged();
|
||||
|
||||
actionMode = ((AppCompatActivity)getActivity()).startSupportActionMode(actionModeCallback);
|
||||
|
||||
if (dcContext.isCommunity()) return;
|
||||
|
||||
addReactionView.show(messageRecord, view, () -> {
|
||||
if (actionMode != null) {
|
||||
actionMode.finish();
|
||||
|
||||
@@ -178,7 +178,7 @@ public class ConversationItem extends BaseConversationItem
|
||||
{
|
||||
bind(messageRecord, dcChat, batchSelected, pulseHighlight, recipients);
|
||||
this.glideRequests = glideRequests;
|
||||
this.showSender = dcContext.isCommunity() || ((dcChat.isMultiUser() || dcChat.isSelfTalk()) && !messageRecord.isOutgoing()) || messageRecord.getOverrideSenderName() != null;
|
||||
this.showSender = ((dcChat.isMultiUser() || dcChat.isSelfTalk()) && !messageRecord.isOutgoing()) || messageRecord.getOverrideSenderName() != null;
|
||||
|
||||
if (showSender) {
|
||||
this.dcContact = dcContext.getContact(messageRecord.getFromId());
|
||||
@@ -437,10 +437,10 @@ public class ConversationItem extends BaseConversationItem
|
||||
showFullButton.setVisibility(View.GONE);
|
||||
msgActionButton.setVisibility(View.VISIBLE);
|
||||
msgActionButton.setEnabled(true);
|
||||
msgActionButton.setText(webxdcViewStub.get().isCommunity()? R.string.join: R.string.start_app);
|
||||
msgActionButton.setText(R.string.start_app);
|
||||
msgActionButton.setOnClickListener(view -> {
|
||||
if (batchSelected.isEmpty()) {
|
||||
DcHelper.openWebxdc(getContext(), messageRecord);
|
||||
WebxdcActivity.openWebxdcActivity(getContext(), messageRecord);
|
||||
} else {
|
||||
passthroughClickListener.onClick(view);
|
||||
}
|
||||
@@ -674,9 +674,7 @@ public class ConversationItem extends BaseConversationItem
|
||||
if (!showSender || dcContact ==null) {
|
||||
contactPhoto.setVisibility(View.GONE);
|
||||
} else {
|
||||
int color = messageRecord.getSenderColor();
|
||||
Recipient recipient = new Recipient(context, dcContact, messageRecord.getSenderName(dcContact), color);
|
||||
contactPhoto.setAvatar(glideRequests, recipient, true);
|
||||
contactPhoto.setAvatar(glideRequests, new Recipient(context, dcContact), true);
|
||||
contactPhoto.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
@@ -701,7 +699,7 @@ public class ConversationItem extends BaseConversationItem
|
||||
Recipient author = null;
|
||||
SlideDeck slideDeck = new SlideDeck();
|
||||
if (msg != null) {
|
||||
author = new Recipient(context, dcContext.getContact(msg.getFromId()), msg.getSenderColor());
|
||||
author = new Recipient(context, dcContext.getContact(msg.getFromId()));
|
||||
if (msg.getType() != DcMsg.DC_MSG_TEXT) {
|
||||
Slide slide = MediaUtil.getSlideForMsg(context, msg);
|
||||
if (slide != null) {
|
||||
@@ -809,8 +807,7 @@ public class ConversationItem extends BaseConversationItem
|
||||
}
|
||||
else if (showSender && dcContact !=null) {
|
||||
this.groupSender.setText(messageRecord.getSenderName(dcContact));
|
||||
int color = messageRecord.getSenderColor();
|
||||
this.groupSender.setTextColor(Util.rgbToArgbColor(color!=0? color : dcContact.getColor()));
|
||||
this.groupSender.setTextColor(Util.rgbToArgbColor(dcContact.getColor()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -893,7 +890,7 @@ public class ConversationItem extends BaseConversationItem
|
||||
if (shouldInterceptClicks(messageRecord) || !batchSelected.isEmpty()) {
|
||||
performClick();
|
||||
} else if (slide.isWebxdcDocument()) {
|
||||
msgActionButton.performClick();
|
||||
WebxdcActivity.openWebxdcActivity(context, messageRecord);
|
||||
} else if (slide.isVcard()) {
|
||||
try {
|
||||
String path = slide.asAttachment().getRealPath(context);
|
||||
|
||||
@@ -99,10 +99,7 @@ public class ConversationTitleView extends RelativeLayout {
|
||||
}
|
||||
} else if( dcChat.isMultiUser() ) {
|
||||
if (!profileView) {
|
||||
if (dcContext.isCommunity() && chatContacts.length == 1)
|
||||
subtitleStr = context.getString(R.string.super_group);
|
||||
else
|
||||
subtitleStr = context.getResources().getQuantityString(R.plurals.n_members, chatContacts.length, chatContacts.length);
|
||||
subtitleStr = context.getResources().getQuantityString(R.plurals.n_members, chatContacts.length, chatContacts.length);
|
||||
}
|
||||
} else if( chatContacts.length>=1 ) {
|
||||
if( dcChat.isSelfTalk() ) {
|
||||
|
||||
@@ -60,7 +60,6 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
private InputAwareLayout container;
|
||||
private ImageView avatar;
|
||||
private EditText name;
|
||||
private EditText overridenName;
|
||||
private EditText statusView;
|
||||
|
||||
private boolean fromWelcome;
|
||||
@@ -184,27 +183,14 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
TextView loginSuccessText = ViewUtil.findById(this, R.id.login_success_text);
|
||||
this.avatar = ViewUtil.findById(this, R.id.avatar);
|
||||
this.name = ViewUtil.findById(this, R.id.name_text);
|
||||
this.overridenName = ViewUtil.findById(this, R.id.overriden_name);
|
||||
this.container = ViewUtil.findById(this, R.id.container);
|
||||
this.statusView = ViewUtil.findById(this, R.id.status_text);
|
||||
|
||||
if (fromWelcome) {
|
||||
if (DcHelper.getContext(this).isCommunity()) {
|
||||
ViewUtil.findById(this, R.id.community_user_container).setVisibility(View.VISIBLE);
|
||||
loginSuccessText.setText(R.string.community_set_name_explain);
|
||||
ViewUtil.findById(this, R.id.avatar_and_name).setVisibility(View.GONE);
|
||||
} else {
|
||||
loginSuccessText.setText(R.string.set_name_and_avatar_explain);
|
||||
}
|
||||
loginSuccessText.setText(R.string.set_name_and_avatar_explain);
|
||||
ViewUtil.findById(this, R.id.status_text_layout).setVisibility(View.GONE);
|
||||
ViewUtil.findById(this, R.id.information_label).setVisibility(View.GONE);
|
||||
} else {
|
||||
if (DcHelper.getContext(this).isCommunity()) {
|
||||
ViewUtil.findById(this, R.id.community_user_container).setVisibility(View.VISIBLE);
|
||||
ViewUtil.findById(this, R.id.information_label).setVisibility(View.GONE);
|
||||
((TextInputLayout)ViewUtil.findById(this, R.id.name)).setHint(R.string.community);
|
||||
((TextInputLayout)ViewUtil.findById(this, R.id.status_text_layout)).setHint(R.string.description);
|
||||
}
|
||||
loginSuccessText.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
@@ -215,10 +201,6 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
name.setText(profileName);
|
||||
name.setSelection(profileName.length(), profileName.length());
|
||||
}
|
||||
DcContext dcContext = DcHelper.getContext(this);
|
||||
if (dcContext.isCommunity()) {
|
||||
overridenName.setText(dcContext.getCommunityUser());
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeProfileAvatar() {
|
||||
@@ -245,22 +227,16 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
}
|
||||
|
||||
private void updateProfile() {
|
||||
boolean isCommunity = DcHelper.getContext(this).isCommunity();
|
||||
if (TextUtils.isEmpty(this.name.getText()) && !(isCommunity && fromWelcome)) {
|
||||
if (TextUtils.isEmpty(this.name.getText())) {
|
||||
Toast.makeText(this, R.string.please_enter_name, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
final String name = this.name.getText().toString();
|
||||
final String ovName = this.overridenName.getText().toString().trim();
|
||||
|
||||
new AsyncTask<Void, Void, Boolean>() {
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
Context context = CreateProfileActivity.this;
|
||||
if (isCommunity) {
|
||||
DcHelper.getContext(context).setCommunityUser(ovName);
|
||||
}
|
||||
DcHelper.set(context, DcHelper.CONFIG_DISPLAY_NAME, name);
|
||||
setStatusText();
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ public class ProfileDocumentsFragment
|
||||
}
|
||||
|
||||
if (dcMsg.getType() == DcMsg.DC_MSG_WEBXDC) {
|
||||
DcHelper.openWebxdc(context, dcMsg);
|
||||
WebxdcActivity.openWebxdcActivity(context, dcMsg);
|
||||
} else {
|
||||
DcHelper.openForViewOrShare(getActivity(), dcMsg.getId(), Intent.ACTION_VIEW);
|
||||
}
|
||||
|
||||
@@ -519,11 +519,6 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
|
||||
return BuildConfig.VERSION_NAME;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public boolean isCommunity() {
|
||||
return dcContext.isCommunity();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public int sendUpdateMaxSize() {
|
||||
return WebxdcActivity.this.sendUpdateMaxSize;
|
||||
@@ -536,10 +531,6 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
|
||||
|
||||
@JavascriptInterface
|
||||
public String selfAddr() {
|
||||
if (dcContext.isCommunity() && !TextUtils.isEmpty(dcContext.getCommunityUser())) {
|
||||
int flags = Base64.NO_WRAP | Base64.NO_PADDING | Base64.URL_SAFE;
|
||||
return Base64.encodeToString(dcContext.getCommunityUser().getBytes(), flags);
|
||||
}
|
||||
return WebxdcActivity.this.selfAddr;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ import java.io.OutputStream;
|
||||
|
||||
public class WelcomeActivity extends BaseActionBarActivity implements DcEventCenter.DcEventDelegate {
|
||||
public static final String BACKUP_QR_EXTRA = "backup_qr_extra";
|
||||
public static final String COMMUNITY_EXTRA = "community_extra";
|
||||
public static final int PICK_BACKUP = 20574;
|
||||
private final static String TAG = WelcomeActivity.class.getSimpleName();
|
||||
public static final String TMP_BACKUP_FILE = "tmp-backup-file";
|
||||
@@ -59,7 +58,6 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||
private boolean imexUserAborted;
|
||||
DcContext dcContext;
|
||||
private NotificationController notificationController;
|
||||
private Uri communityUri;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
@@ -120,10 +118,6 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
communityUri = getIntent().getParcelableExtra(COMMUNITY_EXTRA);
|
||||
if (communityUri != null) {
|
||||
startImport(null, communityUri);
|
||||
}
|
||||
String backupQr = getIntent().getStringExtra(BACKUP_QR_EXTRA);
|
||||
if (backupQr != null) {
|
||||
getIntent().removeExtra(BACKUP_QR_EXTRA);
|
||||
@@ -263,15 +257,9 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||
private void progressSuccess() {
|
||||
DcHelper.getEventCenter(this).endCaptureNextError();
|
||||
progressDialog.dismiss();
|
||||
if (dcContext.isCommunity()) {
|
||||
Intent intent = new Intent(getApplicationContext(), CreateProfileActivity.class);
|
||||
intent.putExtra(CreateProfileActivity.FROM_WELCOME, true);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(getApplicationContext(), ConversationListActivity.class);
|
||||
intent.putExtra(ConversationListActivity.FROM_WELCOME, true);
|
||||
startActivity(intent);
|
||||
}
|
||||
Intent intent = new Intent(getApplicationContext(), ConversationListActivity.class);
|
||||
intent.putExtra(ConversationListActivity.FROM_WELCOME, true);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -318,10 +306,6 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||
notificationController.setProgress(1000, progress, String.format(" %d%%", (int) progress / 10));
|
||||
}
|
||||
else if (progress==1000/*done*/) {
|
||||
if (communityUri != null) dcContext.setCommunityMode(true);
|
||||
if (dcContext.isCommunity()) {
|
||||
dcContext.setCommunityUser(null);
|
||||
}
|
||||
DcHelper.getAccounts(this).startIo();
|
||||
progressSuccess();
|
||||
notificationController.close();
|
||||
|
||||
@@ -87,12 +87,8 @@ public class AccountSelectionListItem extends LinearLayout {
|
||||
}
|
||||
|
||||
addrOrTag = dcContext.getConfig(CONFIG_PRIVATE_TAG);
|
||||
if ("".equals(addrOrTag)) {
|
||||
if (dcContext.isCommunity()) {
|
||||
addrOrTag = getContext().getString(R.string.community);
|
||||
} else if (!dcContext.isChatmail()) {
|
||||
addrOrTag = self.getAddr();
|
||||
}
|
||||
if ("".equals(addrOrTag) && !dcContext.isChatmail()) {
|
||||
addrOrTag = self.getAddr();
|
||||
}
|
||||
|
||||
unreadCount = dcContext.getFreshMsgs().length;
|
||||
|
||||
@@ -180,9 +180,8 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver {
|
||||
authorView.setTextColor(getResources().getColor(R.color.core_dark_05));
|
||||
quoteBarView.setBackgroundColor(getResources().getColor(R.color.core_dark_05));
|
||||
} else {
|
||||
int color = author.getColor()==0? contact.getColor() : author.getColor();
|
||||
authorView.setTextColor(Util.rgbToArgbColor(color));
|
||||
quoteBarView.setBackgroundColor(Util.rgbToArgbColor(color));
|
||||
authorView.setTextColor(Util.rgbToArgbColor(contact.getColor()));
|
||||
quoteBarView.setBackgroundColor(Util.rgbToArgbColor(contact.getColor()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ public class WebxdcView extends FrameLayout {
|
||||
private final @NonNull TextView appSubtitle;
|
||||
|
||||
private @Nullable SlideClickListener viewListener;
|
||||
private boolean isCommunity;
|
||||
|
||||
public WebxdcView(@NonNull Context context) {
|
||||
this(context, null);
|
||||
@@ -67,7 +66,6 @@ public class WebxdcView extends FrameLayout {
|
||||
public void setWebxdc(final @NonNull DcMsg dcMsg, String defaultSummary)
|
||||
{
|
||||
JSONObject info = dcMsg.getWebxdcInfo();
|
||||
isCommunity = JsonUtils.optBoolean(info, "community");
|
||||
setOnClickListener(new OpenClickedListener(getContext(), dcMsg));
|
||||
|
||||
// icon
|
||||
@@ -86,17 +84,13 @@ public class WebxdcView extends FrameLayout {
|
||||
// subtitle
|
||||
String summary = info.optString("summary");
|
||||
if (summary.isEmpty()) {
|
||||
summary = isCommunity? getContext().getString(R.string.community) : defaultSummary;
|
||||
summary = defaultSummary;
|
||||
}
|
||||
appSubtitle.setText(summary);
|
||||
}
|
||||
|
||||
public boolean isCommunity() {
|
||||
return isCommunity;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
String type = getContext().getString(isCommunity? R.string.community : R.string.webxdc_app);
|
||||
String type = getContext().getString( R.string.webxdc_app);
|
||||
String desc = type;
|
||||
desc += "\n" + appName.getText();
|
||||
if (appSubtitle.getText() != null && !appSubtitle.getText().toString().isEmpty() && !appSubtitle.getText().toString().equals(type)) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_VERIFIED_ONE_ON
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -22,7 +21,6 @@ import org.thoughtcrime.securesms.ConversationListActivity;
|
||||
import org.thoughtcrime.securesms.InstantOnboardingActivity;
|
||||
import org.thoughtcrime.securesms.WelcomeActivity;
|
||||
import org.thoughtcrime.securesms.accounts.AccountSelectionListFragment;
|
||||
import org.thoughtcrime.securesms.providers.PersistentBlobProvider;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -127,10 +125,10 @@ public class AccountManager {
|
||||
}
|
||||
|
||||
public void switchAccountAndStartActivity(Activity activity, int destAccountId) {
|
||||
switchAccountAndStartActivity(activity, destAccountId, null, null);
|
||||
switchAccountAndStartActivity(activity, destAccountId, null);
|
||||
}
|
||||
|
||||
private void switchAccountAndStartActivity(Activity activity, int destAccountId, @Nullable String backupQr, @Nullable byte[] communityBlob) {
|
||||
private void switchAccountAndStartActivity(Activity activity, int destAccountId, @Nullable String backupQr) {
|
||||
if (destAccountId==0) {
|
||||
beginAccountCreation(activity);
|
||||
} else {
|
||||
@@ -143,12 +141,6 @@ public class AccountManager {
|
||||
if (backupQr != null) {
|
||||
intent.putExtra(WelcomeActivity.BACKUP_QR_EXTRA, backupQr);
|
||||
}
|
||||
if (communityBlob != null) {
|
||||
String mimeType = "application/octet-stream";
|
||||
Uri uri = PersistentBlobProvider.getInstance().create(activity, communityBlob, mimeType, "backup.tar");
|
||||
intent.setType(mimeType);
|
||||
intent.putExtra(WelcomeActivity.COMMUNITY_EXTRA, uri);
|
||||
}
|
||||
activity.startActivity(intent);
|
||||
} else {
|
||||
activity.startActivity(new Intent(activity.getApplicationContext(), ConversationListActivity.class));
|
||||
@@ -170,11 +162,7 @@ public class AccountManager {
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
|
||||
public void addAccountFromCommunity(Activity activity, byte[] communityBlob) {
|
||||
switchAccountAndStartActivity(activity, 0, null, communityBlob);
|
||||
}
|
||||
|
||||
public void addAccountFromSecondDevice(Activity activity, String backupQr) {
|
||||
switchAccountAndStartActivity(activity, 0, backupQr, null);
|
||||
switchAccountAndStartActivity(activity, 0, backupQr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,21 +24,17 @@ import com.b44t.messenger.DcLot;
|
||||
import com.b44t.messenger.DcMsg;
|
||||
import com.b44t.messenger.rpc.Rpc;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.BuildConfig;
|
||||
import org.thoughtcrime.securesms.LocalHelpActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.ShareActivity;
|
||||
import org.thoughtcrime.securesms.WebxdcActivity;
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationCenter;
|
||||
import org.thoughtcrime.securesms.providers.PersistentBlobProvider;
|
||||
import org.thoughtcrime.securesms.qr.QrActivity;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.IntentUtils;
|
||||
import org.thoughtcrime.securesms.util.FileUtils;
|
||||
import org.thoughtcrime.securesms.util.JsonUtils;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
|
||||
import java.io.File;
|
||||
@@ -506,28 +502,6 @@ public class DcHelper {
|
||||
.show();
|
||||
}
|
||||
|
||||
public static void openWebxdc(Context context, DcMsg dcMsg) {
|
||||
JSONObject info = dcMsg.getWebxdcInfo();
|
||||
if (JsonUtils.optBoolean(info, "community")) {
|
||||
String name = JsonUtils.optString(info, "name");
|
||||
new AlertDialog.Builder(context)
|
||||
.setMessage(context.getString(R.string.ask_join_community, name))
|
||||
.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
String filename = "backup.tar";
|
||||
byte[] blob = dcMsg.getWebxdcBlob(filename);
|
||||
if (blob == null) {
|
||||
Toast.makeText(context, "invalid community file", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
AccountManager.getInstance().addAccountFromCommunity((Activity) context, blob);
|
||||
})
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.show();
|
||||
} else {
|
||||
WebxdcActivity.openWebxdcActivity(context, dcMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void openHelp(Context context, String section) {
|
||||
Intent intent = new Intent(context, LocalHelpActivity.class);
|
||||
if (section != null) { intent.putExtra(LocalHelpActivity.SECTION_EXTRA, section); }
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.MediaPreviewActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.ShareLocationDialog;
|
||||
import org.thoughtcrime.securesms.WebxdcActivity;
|
||||
import org.thoughtcrime.securesms.WebxdcStoreActivity;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
||||
@@ -313,7 +314,7 @@ public class AttachmentManager {
|
||||
DcMsg instance = msg != null ? msg : DcHelper.getContext(context).getMsg(slide.dcMsgId);
|
||||
webxdcView.setWebxdc(instance, context.getString(R.string.videochat_tap_to_open));
|
||||
webxdcView.setWebxdcClickListener((v, s) -> {
|
||||
DcHelper.openWebxdc(context, instance);
|
||||
WebxdcActivity.openWebxdcActivity(context, instance);
|
||||
});
|
||||
removableMediaView.display(webxdcView, false);
|
||||
} else {
|
||||
|
||||
@@ -154,10 +154,8 @@ public class PrivacyPreferenceFragment extends ListSummaryPreferenceFragment {
|
||||
.setView(gl)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, whichButton) -> {
|
||||
if (confirmCheckbox.isChecked()) {
|
||||
if (!dcContext.isCommunity() || timeout >= 86400) {
|
||||
dcContext.setConfigInt(coreKey, timeout);
|
||||
initAutodelFromCore();
|
||||
}
|
||||
dcContext.setConfigInt(coreKey, timeout);
|
||||
initAutodelFromCore();
|
||||
} else {
|
||||
onPreferenceChange(preference, newValue);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import androidx.appcompat.app.AlertDialog;
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||
import org.thoughtcrime.securesms.BaseActionBarActivity;
|
||||
import org.thoughtcrime.securesms.ConversationListActivity;
|
||||
import org.thoughtcrime.securesms.CreateProfileActivity;
|
||||
import org.thoughtcrime.securesms.LogViewActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
@@ -183,14 +182,7 @@ public class BackupTransferActivity extends BaseActionBarActivity {
|
||||
notificationControllerClosed = true;
|
||||
|
||||
if (transferMode == TransferMode.RECEIVER_SCAN_QR && transferState == TransferState.TRANSFER_SUCCESS) {
|
||||
if (DcHelper.getContext(this).isCommunity()) {
|
||||
DcHelper.getContext(this).setCommunityUser(null);
|
||||
Intent intent = new Intent(getApplicationContext(), CreateProfileActivity.class);
|
||||
intent.putExtra(CreateProfileActivity.FROM_WELCOME, true);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
startActivity(new Intent(getApplicationContext(), ConversationListActivity.class));
|
||||
}
|
||||
startActivity(new Intent(getApplicationContext(), ConversationListActivity.class));
|
||||
} else if (transferMode == TransferMode.SENDER_SHOW_QR) {
|
||||
// restart the activities that were removed when BackupTransferActivity was started at (**2)
|
||||
// (we removed the activity backstack as otherwise a tap on the ArcaneChat icon on the home screen would
|
||||
|
||||
@@ -66,7 +66,6 @@ public class Recipient {
|
||||
|
||||
private final @Nullable DcChat dcChat;
|
||||
private @Nullable DcContact dcContact;
|
||||
private int color = 0;
|
||||
private final @Nullable VcardContact vContact;
|
||||
|
||||
public static @NonNull Recipient fromChat(@NonNull Context context, int dcMsgId) {
|
||||
@@ -104,19 +103,10 @@ public class Recipient {
|
||||
this(context, null, dcContact, null, null);
|
||||
}
|
||||
|
||||
public Recipient(@NonNull Context context, @NonNull DcContact dcContact, int color) {
|
||||
this(context, dcContact, null, color);
|
||||
}
|
||||
|
||||
public Recipient(@NonNull Context context, @NonNull DcContact dcContact, @NonNull String profileName) {
|
||||
this(context, null, dcContact, profileName, null);
|
||||
}
|
||||
|
||||
public Recipient(@NonNull Context context, @NonNull DcContact dcContact, @NonNull String profileName, int color) {
|
||||
this(context, null, dcContact, profileName, null);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
private Recipient(@NonNull Context context, @Nullable DcChat dcChat, @Nullable DcContact dcContact, @Nullable String profileName, @Nullable VcardContact vContact) {
|
||||
this.dcChat = dcChat;
|
||||
this.dcContact = dcContact;
|
||||
@@ -205,9 +195,6 @@ public class Recipient {
|
||||
if(dcChat!=null) {
|
||||
rgb = dcChat.getColor();
|
||||
}
|
||||
else if(color!=0) {
|
||||
rgb = color;
|
||||
}
|
||||
else if(dcContact!=null) {
|
||||
rgb = dcContact.getColor();
|
||||
}
|
||||
@@ -233,10 +220,6 @@ public class Recipient {
|
||||
}
|
||||
|
||||
public synchronized @Nullable ContactPhoto getContactPhoto(Context context) {
|
||||
if (color != 0) { // community nick
|
||||
return null;
|
||||
}
|
||||
|
||||
LocalFileContactPhoto contactPhoto = null;
|
||||
if (dcChat!=null) {
|
||||
contactPhoto = new GroupRecordContactPhoto(context, address, dcChat);
|
||||
@@ -315,11 +298,6 @@ public class Recipient {
|
||||
return dcChat!=null? dcChat : new DcChat(0, 0);
|
||||
}
|
||||
|
||||
public int getColor()
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public abstract class BreakIteratorCompat implements Iterable<CharSequence> {
|
||||
public static final int DONE = -1;
|
||||
private CharSequence charSequence;
|
||||
|
||||
public abstract int first();
|
||||
|
||||
public abstract int next();
|
||||
|
||||
public void setText(CharSequence charSequence) {
|
||||
this.charSequence = charSequence;
|
||||
}
|
||||
|
||||
public static BreakIteratorCompat getInstance() {
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
return new AndroidIcuBreakIterator();
|
||||
} else {
|
||||
return new FallbackBreakIterator();
|
||||
}
|
||||
}
|
||||
|
||||
public int countBreaks() {
|
||||
int breakCount = 0;
|
||||
|
||||
first();
|
||||
|
||||
while (next() != DONE) {
|
||||
breakCount++;
|
||||
}
|
||||
|
||||
return breakCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterator<CharSequence> iterator() {
|
||||
return new Iterator<CharSequence>() {
|
||||
|
||||
int index1 = BreakIteratorCompat.this.first();
|
||||
int index2 = BreakIteratorCompat.this.next();
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return index2 != DONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence next() {
|
||||
CharSequence c = index2 != DONE ? charSequence.subSequence(index1, index2) : "";
|
||||
|
||||
index1 = index2;
|
||||
index2 = BreakIteratorCompat.this.next();
|
||||
|
||||
return c;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Take {@param atMost} graphemes from the start of string.
|
||||
*/
|
||||
public final CharSequence take(int atMost) {
|
||||
if (atMost <= 0) return "";
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder(charSequence.length());
|
||||
int count = 0;
|
||||
|
||||
for (CharSequence grapheme : this) {
|
||||
stringBuilder.append(grapheme);
|
||||
|
||||
count++;
|
||||
|
||||
if (count >= atMost) break;
|
||||
}
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* An BreakIteratorCompat implementation that delegates calls to `android.icu.text.BreakIterator`.
|
||||
* This class handles grapheme clusters fine but requires Android API >= 24.
|
||||
*/
|
||||
@RequiresApi(24)
|
||||
private static class AndroidIcuBreakIterator extends BreakIteratorCompat {
|
||||
private final android.icu.text.BreakIterator breakIterator = android.icu.text.BreakIterator.getCharacterInstance();
|
||||
|
||||
@Override
|
||||
public int first() {
|
||||
return breakIterator.first();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int next() {
|
||||
return breakIterator.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(CharSequence charSequence) {
|
||||
super.setText(charSequence);
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
breakIterator.setText(charSequence);
|
||||
} else {
|
||||
breakIterator.setText(charSequence.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An BreakIteratorCompat implementation that delegates calls to `java.text.BreakIterator`.
|
||||
* This class may or may not handle grapheme clusters well depending on the underlying implementation.
|
||||
* In the emulator, API 23 implements ICU version of the BreakIterator so that it handles grapheme
|
||||
* clusters fine. But API 21 implements RuleBasedIterator which does not handle grapheme clusters.
|
||||
* <p>
|
||||
* If it doesn't handle grapheme clusters correctly, in most cases the combined characters are
|
||||
* broken up into pieces when the code tries to trim a string. For example, an emoji that is
|
||||
* a combination of a person, gender and skin tone, trimming the character using this class may result
|
||||
* in trimming the parts of the character, e.g. a dark skin frowning woman emoji may result in
|
||||
* a neutral skin frowning woman emoji.
|
||||
*/
|
||||
private static class FallbackBreakIterator extends BreakIteratorCompat {
|
||||
private final java.text.BreakIterator breakIterator = java.text.BreakIterator.getCharacterInstance();
|
||||
|
||||
@Override
|
||||
public int first() {
|
||||
return breakIterator.first();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int next() {
|
||||
return breakIterator.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(CharSequence charSequence) {
|
||||
super.setText(charSequence);
|
||||
breakIterator.setText(charSequence.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public final class StringUtil {
|
||||
|
||||
/**
|
||||
* @return The number of graphemes in the provided string.
|
||||
*/
|
||||
public static int getGraphemeCount(@NonNull CharSequence text) {
|
||||
BreakIteratorCompat iterator = BreakIteratorCompat.getInstance();
|
||||
iterator.setText(text);
|
||||
return iterator.countBreaks();
|
||||
}
|
||||
}
|
||||
@@ -24,33 +24,7 @@
|
||||
android:textSize="16sp"
|
||||
android:textColor="?android:attr/textColorPrimary" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/community_user_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="40dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
android:id="@+id/overriden_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/pref_your_name"
|
||||
android:inputType="textCapWords" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/avatar_and_name"
|
||||
android:layout_width="match_parent"
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
|
||||
@@ -45,7 +45,7 @@ window.webxdc = (() => {
|
||||
arcanechat: InternalJSApi.arcanechat(),
|
||||
deltalab: InternalJSApi.arcanechat(),
|
||||
|
||||
isCommunity: InternalJSApi.isCommunity(),
|
||||
isCommunity: false,
|
||||
sendUpdateMaxSize: InternalJSApi.sendUpdateMaxSize(),
|
||||
|
||||
sendUpdateInterval: InternalJSApi.sendUpdateInterval(),
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||
<!-- custom strings -->
|
||||
<string name="community">Comunidad</string>
|
||||
<string name="description">Descripción</string>
|
||||
<string name="ask_join_community">¿Quieres unirte a la comunidad \"%1$s\"?</string>
|
||||
<string name="community_set_name_explain">Establece un nombre que otros puedan reconocer.</string>
|
||||
<string name="or_separator">o</string>
|
||||
<string name="online">en línea</string>
|
||||
<string name="pink">Rosa</string>
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||
<!-- custom strings -->
|
||||
<string name="community">Community</string>
|
||||
<string name="description">Description</string>
|
||||
<string name="ask_join_community">Do you want to join the Community \"%1$s\"?</string>
|
||||
<string name="community_set_name_explain">Set a name that other will recognize.</string>
|
||||
<string name="could_not_open_file">Could not open file</string>
|
||||
<string name="menu_export_image">Export Image</string>
|
||||
<!-- the word "or" to separate blocks in the user interface that are mutually exclusive -->
|
||||
|
||||
Reference in New Issue
Block a user