mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
clean up unused code
This commit is contained in:
parent
ff36fbb6a1
commit
fec13ba72e
@ -414,11 +414,6 @@
|
||||
android:authorities="network.loki.provider.securesms"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true" />
|
||||
<provider
|
||||
android:name="org.thoughtcrime.securesms.providers.MmsBodyProvider"
|
||||
android:authorities="network.loki.provider.securesms.mms"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true" />
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="network.loki.securesms.fileprovider"
|
||||
|
@ -163,7 +163,6 @@ import org.thoughtcrime.securesms.mms.TextSlide;
|
||||
import org.thoughtcrime.securesms.mms.VideoSlide;
|
||||
import org.thoughtcrime.securesms.notifications.MarkReadReceiver;
|
||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.profiles.GroupShareProfileView;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.messaging.threads.recipients.RecipientFormattingException;
|
||||
@ -262,7 +261,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
private Button unblockButton;
|
||||
private Button makeDefaultSmsButton;
|
||||
private InputAwareLayout container;
|
||||
private Stub<GroupShareProfileView> groupShareProfileView;
|
||||
private TypingStatusTextWatcher typingTextWatcher;
|
||||
private MentionTextWatcher mentionTextWatcher;
|
||||
private ConversationSearchBottomBar searchNav;
|
||||
@ -458,7 +456,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
updateProfilePicture();
|
||||
updateSubtitleTextView();
|
||||
updateInputUI(recipient);
|
||||
setGroupShareProfileReminder(recipient);
|
||||
|
||||
ApplicationContext.getInstance(this).messageNotifier.setVisibleThread(threadId);
|
||||
markThreadAsRead();
|
||||
@ -1294,7 +1291,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
unblockButton = ViewUtil.findById(this, R.id.unblock_button);
|
||||
makeDefaultSmsButton = ViewUtil.findById(this, R.id.make_default_sms_button);
|
||||
container = ViewUtil.findById(this, R.id.layout_container);
|
||||
groupShareProfileView = ViewUtil.findStubById(this, R.id.group_share_profile_view_stub);
|
||||
quickAttachmentToggle = ViewUtil.findById(this, R.id.quick_attachment_toggle);
|
||||
inlineAttachmentToggle = ViewUtil.findById(this, R.id.inline_attachment_container);
|
||||
inputPanel = ViewUtil.findById(this, R.id.bottom_panel);
|
||||
@ -1432,9 +1428,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
updateTitleTextView(recipient);
|
||||
updateProfilePicture();
|
||||
updateSubtitleTextView();
|
||||
// titleView.setVerified(identityRecords.isVerified());
|
||||
updateInputUI(recipient);
|
||||
setGroupShareProfileReminder(recipient);
|
||||
initializeSecurity(true, isDefaultSms);
|
||||
|
||||
if (searchViewItem == null || !searchViewItem.isActionViewExpanded()) {
|
||||
@ -1619,14 +1613,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
unblockButton.setVisibility(View.VISIBLE);
|
||||
inputPanel.setVisibility(View.GONE);
|
||||
makeDefaultSmsButton.setVisibility(View.GONE);
|
||||
// } else if (!isSecureText && isPushGroupConversation()) {
|
||||
// unblockButton.setVisibility(View.GONE);
|
||||
// inputPanel.setVisibility(View.GONE);
|
||||
// makeDefaultSmsButton.setVisibility(View.GONE);
|
||||
// } else if (!isSecureText && !isDefaultSms) {
|
||||
// unblockButton.setVisibility(View.GONE);
|
||||
// inputPanel.setVisibility(View.GONE);
|
||||
// makeDefaultSmsButton.setVisibility(View.GONE);
|
||||
} else {
|
||||
inputPanel.setVisibility(View.VISIBLE);
|
||||
unblockButton.setVisibility(View.GONE);
|
||||
@ -1634,15 +1620,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
}
|
||||
|
||||
private void setGroupShareProfileReminder(@NonNull Recipient recipient) {
|
||||
if (recipient.isPushGroupRecipient() && !recipient.isProfileSharing() && !recipient.getAddress().isOpenGroup()) {
|
||||
groupShareProfileView.get().setRecipient(recipient);
|
||||
groupShareProfileView.get().setVisibility(View.GONE); // Loki - Always hide for now
|
||||
} else if (groupShareProfileView.resolved()) {
|
||||
groupShareProfileView.get().setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeMediaKeyboardProviders(@NonNull MediaKeyboard mediaKeyboard) {
|
||||
boolean isSystemEmojiPreferred = TextSecurePreferences.isSystemEmojiPreferred(this);
|
||||
if (!isSystemEmojiPreferred) {
|
||||
|
@ -81,7 +81,6 @@ import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||
import org.thoughtcrime.securesms.mms.Slide;
|
||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.profiles.UnknownSenderView;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
|
||||
@ -144,7 +143,6 @@ public class ConversationFragment extends Fragment
|
||||
private ViewSwitcher topLoadMoreView;
|
||||
private ViewSwitcher bottomLoadMoreView;
|
||||
private ConversationTypingView typingView;
|
||||
private UnknownSenderView unknownSenderView;
|
||||
private View composeDivider;
|
||||
private View scrollToBottomButton;
|
||||
private TextView scrollDateHeader;
|
||||
@ -253,7 +251,6 @@ public class ConversationFragment extends Fragment
|
||||
this.lastSeen = this.getActivity().getIntent().getLongExtra(ConversationActivity.LAST_SEEN_EXTRA, -1);
|
||||
this.startingPosition = this.getActivity().getIntent().getIntExtra(ConversationActivity.STARTING_POSITION_EXTRA, -1);
|
||||
this.firstLoad = true;
|
||||
this.unknownSenderView = new UnknownSenderView(getActivity(), recipient, threadId);
|
||||
|
||||
OnScrollListener scrollListener = new ConversationScrollListener(getActivity());
|
||||
list.addOnScrollListener(scrollListener);
|
||||
|
@ -48,7 +48,6 @@ import org.session.libsignal.utilities.logging.Log;
|
||||
import org.thoughtcrime.securesms.mediasend.MediaSendActivity;
|
||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.providers.DeprecatedPersistentBlobProvider;
|
||||
import org.session.libsignal.utilities.externalstorage.ExternalStorageUtil;
|
||||
import org.thoughtcrime.securesms.util.FileProviderUtil;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
@ -158,16 +157,13 @@ public class AttachmentManager {
|
||||
}
|
||||
|
||||
private void cleanup(final @Nullable Uri uri) {
|
||||
if (uri != null && DeprecatedPersistentBlobProvider.isAuthority(context, uri)) {
|
||||
Log.d(TAG, "cleaning up " + uri);
|
||||
DeprecatedPersistentBlobProvider.getInstance(context).delete(context, uri);
|
||||
} else if (uri != null && BlobProvider.isAuthority(uri)) {
|
||||
if (uri != null && BlobProvider.isAuthority(uri)) {
|
||||
BlobProvider.getInstance().delete(context, uri);
|
||||
}
|
||||
}
|
||||
|
||||
private void markGarbage(@Nullable Uri uri) {
|
||||
if (uri != null && (DeprecatedPersistentBlobProvider.isAuthority(context, uri) || BlobProvider.isAuthority(uri))) {
|
||||
if (uri != null && BlobProvider.isAuthority(uri)) {
|
||||
Log.d(TAG, "Marking garbage that needs cleaning: " + uri);
|
||||
garbage.add(uri);
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import org.session.libsession.messaging.sending_receiving.attachments.Attachment
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.providers.DeprecatedPersistentBlobProvider;
|
||||
import org.thoughtcrime.securesms.providers.PartProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -39,8 +38,6 @@ public class PartAuthority {
|
||||
uriMatcher.addURI("network.loki.provider.securesms", "part/*/#", PART_ROW);
|
||||
uriMatcher.addURI("network.loki.provider.securesms", "thumb/*/#", THUMB_ROW);
|
||||
uriMatcher.addURI("network.loki.provider.securesms", "sticker/#", STICKER_ROW);
|
||||
uriMatcher.addURI(DeprecatedPersistentBlobProvider.AUTHORITY, DeprecatedPersistentBlobProvider.EXPECTED_PATH_OLD, PERSISTENT_ROW);
|
||||
uriMatcher.addURI(DeprecatedPersistentBlobProvider.AUTHORITY, DeprecatedPersistentBlobProvider.EXPECTED_PATH_NEW, PERSISTENT_ROW);
|
||||
uriMatcher.addURI(BlobProvider.AUTHORITY, BlobProvider.PATH, BLOB_ROW);
|
||||
}
|
||||
|
||||
@ -52,7 +49,6 @@ public class PartAuthority {
|
||||
switch (match) {
|
||||
case PART_ROW: return DatabaseFactory.getAttachmentDatabase(context).getAttachmentStream(new PartUriParser(uri).getPartId(), 0);
|
||||
case THUMB_ROW: return DatabaseFactory.getAttachmentDatabase(context).getThumbnailStream(new PartUriParser(uri).getPartId());
|
||||
case PERSISTENT_ROW: return DeprecatedPersistentBlobProvider.getInstance(context).getStream(context, ContentUris.parseId(uri));
|
||||
case BLOB_ROW: return BlobProvider.getInstance().getStream(context, uri);
|
||||
default: return context.getContentResolver().openInputStream(uri);
|
||||
}
|
||||
@ -71,8 +67,6 @@ public class PartAuthority {
|
||||
|
||||
if (attachment != null) return attachment.getFileName();
|
||||
else return null;
|
||||
case PERSISTENT_ROW:
|
||||
return DeprecatedPersistentBlobProvider.getFileName(context, uri);
|
||||
case BLOB_ROW:
|
||||
return BlobProvider.getFileName(uri);
|
||||
default:
|
||||
@ -90,8 +84,6 @@ public class PartAuthority {
|
||||
|
||||
if (attachment != null) return attachment.getSize();
|
||||
else return null;
|
||||
case PERSISTENT_ROW:
|
||||
return DeprecatedPersistentBlobProvider.getFileSize(context, uri);
|
||||
case BLOB_ROW:
|
||||
return BlobProvider.getFileSize(uri);
|
||||
default:
|
||||
@ -109,8 +101,6 @@ public class PartAuthority {
|
||||
|
||||
if (attachment != null) return attachment.getContentType();
|
||||
else return null;
|
||||
case PERSISTENT_ROW:
|
||||
return DeprecatedPersistentBlobProvider.getMimeType(context, uri);
|
||||
case BLOB_ROW:
|
||||
return BlobProvider.getMimeType(uri);
|
||||
default:
|
||||
@ -133,10 +123,6 @@ public class PartAuthority {
|
||||
return ContentUris.withAppendedId(uri, attachmentId.getRowId());
|
||||
}
|
||||
|
||||
public static Uri getStickerUri(long id) {
|
||||
return ContentUris.withAppendedId(STICKER_CONTENT_URI, id);
|
||||
}
|
||||
|
||||
public static boolean isLocalUri(final @NonNull Uri uri) {
|
||||
int match = uriMatcher.match(uri);
|
||||
switch (match) {
|
||||
|
@ -46,17 +46,6 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
|
||||
public void onCreate(Bundle paramBundle) {
|
||||
super.onCreate(paramBundle);
|
||||
|
||||
/*
|
||||
findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_MOBILE_PREF)
|
||||
.setOnPreferenceChangeListener(new MediaDownloadChangeListener());
|
||||
findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_WIFI_PREF)
|
||||
.setOnPreferenceChangeListener(new MediaDownloadChangeListener());
|
||||
findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_ROAMING_PREF)
|
||||
.setOnPreferenceChangeListener(new MediaDownloadChangeListener());
|
||||
findPreference(TextSecurePreferences.MESSAGE_BODY_TEXT_SIZE_PREF)
|
||||
.setOnPreferenceChangeListener(new ListSummaryListener());
|
||||
*/
|
||||
|
||||
findPreference(TextSecurePreferences.THREAD_TRIM_NOW)
|
||||
.setOnPreferenceClickListener(new TrimNowClickListener());
|
||||
findPreference(TextSecurePreferences.THREAD_TRIM_LENGTH)
|
||||
@ -67,8 +56,6 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
|
||||
findPreference(TextSecurePreferences.BACKUP_NOW)
|
||||
.setOnPreferenceClickListener(new BackupCreateListener());
|
||||
|
||||
// initializeListSummary((ListPreference) findPreference(TextSecurePreferences.MESSAGE_BODY_TEXT_SIZE_PREF));
|
||||
|
||||
backupDirSelector = new BackupDirSelector(this);
|
||||
|
||||
EventBus.getDefault().register(this);
|
||||
@ -82,7 +69,6 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setMediaDownloadSummaries();
|
||||
setBackupSummary();
|
||||
}
|
||||
|
||||
@ -132,17 +118,6 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
|
||||
BackupUtil.getLastBackupTimeString(getContext(), Locale.getDefault())));
|
||||
}
|
||||
|
||||
private void setMediaDownloadSummaries() {
|
||||
/*
|
||||
findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_MOBILE_PREF)
|
||||
.setSummary(getSummaryForMediaPreference(TextSecurePreferences.getMobileMediaDownloadAllowed(getActivity())));
|
||||
findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_WIFI_PREF)
|
||||
.setSummary(getSummaryForMediaPreference(TextSecurePreferences.getWifiMediaDownloadAllowed(getActivity())));
|
||||
findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_ROAMING_PREF)
|
||||
.setSummary(getSummaryForMediaPreference(TextSecurePreferences.getRoamingMediaDownloadAllowed(getActivity())));
|
||||
*/
|
||||
}
|
||||
|
||||
private CharSequence getSummaryForMediaPreference(Set<String> allowedNetworks) {
|
||||
String[] keys = getResources().getStringArray(R.array.pref_media_download_entries);
|
||||
String[] values = getResources().getStringArray(R.array.pref_media_download_values);
|
||||
|
@ -122,15 +122,11 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
||||
TextSecurePreferences.removeNotificationRingtone(getContext());
|
||||
} else {
|
||||
uri = uri == null ? Uri.EMPTY : uri;
|
||||
NotificationChannels.updateMessageRingtone(getContext(), uri );
|
||||
NotificationChannels.updateMessageRingtone(getContext(), uri);
|
||||
TextSecurePreferences.setNotificationRingtone(getContext(), uri.toString());
|
||||
}
|
||||
|
||||
initializeRingtoneSummary(findPreference(TextSecurePreferences.RINGTONE_PREF));
|
||||
} else if (requestCode == 2 && resultCode == RESULT_OK && data != null) {
|
||||
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||
|
||||
// initializeCallRingtoneSummary(findPreference(TextSecurePreferences.CALL_RINGTONE_PREF));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,69 +0,0 @@
|
||||
package org.thoughtcrime.securesms.profiles;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import androidx.annotation.AttrRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.utilities.ViewUtil;
|
||||
|
||||
public class GroupShareProfileView extends FrameLayout {
|
||||
|
||||
private View container;
|
||||
private @Nullable Recipient recipient;
|
||||
|
||||
public GroupShareProfileView(@NonNull Context context) {
|
||||
super(context);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public GroupShareProfileView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public GroupShareProfileView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initialize();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public GroupShareProfileView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
inflate(getContext(), R.layout.profile_group_share_view, this);
|
||||
|
||||
this.container = ViewUtil.findById(this, R.id.container);
|
||||
this.container.setOnClickListener(view -> {
|
||||
if (this.recipient != null) {
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setIconAttribute(R.attr.dialog_info_icon)
|
||||
.setTitle(R.string.GroupShareProfileView_share_your_profile_name_and_photo_with_this_group)
|
||||
.setMessage(R.string.GroupShareProfileView_do_you_want_to_make_your_profile_name_and_photo_visible_to_all_current_and_future_members_of_this_group)
|
||||
.setPositiveButton(R.string.GroupShareProfileView_make_visible, (dialog, which) -> {
|
||||
DatabaseFactory.getRecipientDatabase(getContext()).setProfileSharing(recipient, true);
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setRecipient(@NonNull Recipient recipient) {
|
||||
this.recipient = recipient;
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
package org.thoughtcrime.securesms.profiles;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.messaging.threads.recipients.RecipientExporter;
|
||||
import org.session.libsession.utilities.ViewUtil;
|
||||
|
||||
public class UnknownSenderView extends FrameLayout {
|
||||
|
||||
private final @NonNull Recipient recipient;
|
||||
private final long threadId;
|
||||
|
||||
public UnknownSenderView(@NonNull Context context, @NonNull Recipient recipient, long threadId) {
|
||||
super(context);
|
||||
this.recipient = recipient;
|
||||
this.threadId = threadId;
|
||||
|
||||
inflate(context, R.layout.unknown_sender_view, this);
|
||||
setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
|
||||
|
||||
View block = ViewUtil.findById(this, R.id.block);
|
||||
View add = ViewUtil.findById(this, R.id.add_to_contacts);
|
||||
View profileAccess = ViewUtil.findById(this, R.id.share_profile);
|
||||
|
||||
block.setOnClickListener(v -> handleBlock());
|
||||
add.setOnClickListener(v -> handleAdd());
|
||||
profileAccess.setOnClickListener(v -> handleProfileAccess());
|
||||
}
|
||||
|
||||
private void handleBlock() {
|
||||
final Context context = getContext();
|
||||
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setIconAttribute(R.attr.dialog_alert_icon)
|
||||
.setTitle(getContext().getString(R.string.UnknownSenderView_block_s, recipient.toShortString()))
|
||||
.setMessage(R.string.UnknownSenderView_blocked_contacts_will_no_longer_be_able_to_send_you_messages_or_call_you)
|
||||
.setPositiveButton(R.string.UnknownSenderView_block, (dialog, which) -> {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getRecipientDatabase(context).setBlocked(recipient, true);
|
||||
if (threadId != -1) DatabaseFactory.getThreadDatabase(context).setHasSent(threadId, true);
|
||||
return null;
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void handleAdd() {
|
||||
getContext().startActivity(RecipientExporter.export(recipient).asAddContactIntent());
|
||||
if (threadId != -1) DatabaseFactory.getThreadDatabase(getContext()).setHasSent(threadId, true);
|
||||
}
|
||||
|
||||
private void handleProfileAccess() {
|
||||
final Context context = getContext();
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setIconAttribute(R.attr.dialog_info_icon)
|
||||
.setTitle(context.getString(R.string.UnknownSenderView_share_profile_with_s, recipient.toShortString()))
|
||||
.setMessage(R.string.UnknownSenderView_the_easiest_way_to_share_your_profile_information_is_to_add_the_sender_to_your_contacts)
|
||||
.setPositiveButton(R.string.UnknownSenderView_share_profile, (dialog, which) -> {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient, true);
|
||||
if (threadId != -1) DatabaseFactory.getThreadDatabase(context).setHasSent(threadId, true);
|
||||
return null;
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
}
|
@ -1,193 +0,0 @@
|
||||
package org.thoughtcrime.securesms.providers;
|
||||
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.content.UriMatcher;
|
||||
import android.net.Uri;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.AttachmentSecret;
|
||||
import org.thoughtcrime.securesms.crypto.AttachmentSecretProvider;
|
||||
import org.thoughtcrime.securesms.crypto.ClassicDecryptingPartInputStream;
|
||||
import org.thoughtcrime.securesms.crypto.ModernDecryptingPartInputStream;
|
||||
import org.session.libsignal.utilities.logging.Log;
|
||||
import org.thoughtcrime.securesms.util.FileProviderUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link BlobProvider} instead. Keeping in read-only mode due to the number of
|
||||
* legacy URIs it handles. Given that this was largely used for drafts, and that files were stored
|
||||
* in the cache directory, it's possible that we could remove this class after a reasonable amount
|
||||
* of time has passed.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DeprecatedPersistentBlobProvider {
|
||||
|
||||
private static final String TAG = DeprecatedPersistentBlobProvider.class.getSimpleName();
|
||||
|
||||
private static final String URI_STRING = "content://network.loki.provider.securesms/capture-new";
|
||||
public static final Uri CONTENT_URI = Uri.parse(URI_STRING);
|
||||
public static final String AUTHORITY = "org.thoughtcrime.securesms";
|
||||
public static final String EXPECTED_PATH_OLD = "capture/*/*/#";
|
||||
public static final String EXPECTED_PATH_NEW = "capture-new/*/*/*/*/#";
|
||||
|
||||
private static final int MIMETYPE_PATH_SEGMENT = 1;
|
||||
private static final int FILENAME_PATH_SEGMENT = 2;
|
||||
private static final int FILESIZE_PATH_SEGMENT = 3;
|
||||
|
||||
private static final String BLOB_EXTENSION = "blob";
|
||||
private static final int MATCH_OLD = 1;
|
||||
private static final int MATCH_NEW = 2;
|
||||
|
||||
private static final UriMatcher MATCHER = new UriMatcher(UriMatcher.NO_MATCH) {{
|
||||
addURI(AUTHORITY, EXPECTED_PATH_OLD, MATCH_OLD);
|
||||
addURI(AUTHORITY, EXPECTED_PATH_NEW, MATCH_NEW);
|
||||
}};
|
||||
|
||||
private static volatile DeprecatedPersistentBlobProvider instance;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link BlobProvider} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static DeprecatedPersistentBlobProvider getInstance(Context context) {
|
||||
if (instance == null) {
|
||||
synchronized (DeprecatedPersistentBlobProvider.class) {
|
||||
if (instance == null) {
|
||||
instance = new DeprecatedPersistentBlobProvider(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final AttachmentSecret attachmentSecret;
|
||||
|
||||
private DeprecatedPersistentBlobProvider(@NonNull Context context) {
|
||||
this.attachmentSecret = AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret();
|
||||
}
|
||||
|
||||
public Uri createForExternal(@NonNull Context context, @NonNull String mimeType) throws IOException {
|
||||
File target = new File(getExternalDir(context), String.valueOf(System.currentTimeMillis()) + "." + getExtensionFromMimeType(mimeType));
|
||||
return FileProviderUtil.getUriFor(context, target);
|
||||
}
|
||||
|
||||
public boolean delete(@NonNull Context context, @NonNull Uri uri) {
|
||||
switch (MATCHER.match(uri)) {
|
||||
case MATCH_OLD:
|
||||
case MATCH_NEW:
|
||||
long id = ContentUris.parseId(uri);
|
||||
return getFile(context, ContentUris.parseId(uri)).file.delete();
|
||||
}
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (isExternalBlobUri(context, uri)) {
|
||||
return FileProviderUtil.delete(context, uri);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public @NonNull InputStream getStream(@NonNull Context context, long id) throws IOException {
|
||||
FileData fileData = getFile(context, id);
|
||||
|
||||
if (fileData.modern) return ModernDecryptingPartInputStream.createFor(attachmentSecret, fileData.file, 0);
|
||||
else return ClassicDecryptingPartInputStream.createFor(attachmentSecret, fileData.file);
|
||||
}
|
||||
|
||||
private FileData getFile(@NonNull Context context, long id) {
|
||||
File legacy = getLegacyFile(context, id);
|
||||
File cache = getCacheFile(context, id);
|
||||
File modernCache = getModernCacheFile(context, id);
|
||||
|
||||
if (legacy.exists()) return new FileData(legacy, false);
|
||||
else if (cache.exists()) return new FileData(cache, false);
|
||||
else return new FileData(modernCache, true);
|
||||
}
|
||||
|
||||
private File getLegacyFile(@NonNull Context context, long id) {
|
||||
return new File(context.getDir("captures", Context.MODE_PRIVATE), id + "." + BLOB_EXTENSION);
|
||||
}
|
||||
|
||||
private File getCacheFile(@NonNull Context context, long id) {
|
||||
return new File(context.getCacheDir(), "capture-" + id + "." + BLOB_EXTENSION);
|
||||
}
|
||||
|
||||
private File getModernCacheFile(@NonNull Context context, long id) {
|
||||
return new File(context.getCacheDir(), "capture-m-" + id + "." + BLOB_EXTENSION);
|
||||
}
|
||||
|
||||
public static @Nullable String getMimeType(@NonNull Context context, @NonNull Uri persistentBlobUri) {
|
||||
if (!isAuthority(context, persistentBlobUri)) return null;
|
||||
return isExternalBlobUri(context, persistentBlobUri)
|
||||
? getMimeTypeFromExtension(persistentBlobUri)
|
||||
: persistentBlobUri.getPathSegments().get(MIMETYPE_PATH_SEGMENT);
|
||||
}
|
||||
|
||||
public static @Nullable String getFileName(@NonNull Context context, @NonNull Uri persistentBlobUri) {
|
||||
if (!isAuthority(context, persistentBlobUri)) return null;
|
||||
if (isExternalBlobUri(context, persistentBlobUri)) return null;
|
||||
if (MATCHER.match(persistentBlobUri) == MATCH_OLD) return null;
|
||||
|
||||
return persistentBlobUri.getPathSegments().get(FILENAME_PATH_SEGMENT);
|
||||
}
|
||||
|
||||
public static @Nullable Long getFileSize(@NonNull Context context, Uri persistentBlobUri) {
|
||||
if (!isAuthority(context, persistentBlobUri)) return null;
|
||||
if (isExternalBlobUri(context, persistentBlobUri)) return null;
|
||||
if (MATCHER.match(persistentBlobUri) == MATCH_OLD) return null;
|
||||
|
||||
try {
|
||||
return Long.valueOf(persistentBlobUri.getPathSegments().get(FILESIZE_PATH_SEGMENT));
|
||||
} catch (NumberFormatException e) {
|
||||
Log.w(TAG, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static @NonNull String getExtensionFromMimeType(String mimeType) {
|
||||
final String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
|
||||
return extension != null ? extension : BLOB_EXTENSION;
|
||||
}
|
||||
|
||||
private static @NonNull String getMimeTypeFromExtension(@NonNull Uri uri) {
|
||||
final String mimeType = MimeTypeMap.getSingleton()
|
||||
.getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(uri.toString()));
|
||||
return mimeType != null ? mimeType : "application/octet-stream";
|
||||
}
|
||||
|
||||
private static @NonNull File getExternalDir(Context context) throws IOException {
|
||||
final File externalDir = context.getExternalCacheDir();
|
||||
if (externalDir == null) throw new IOException("no external files directory");
|
||||
return externalDir;
|
||||
}
|
||||
|
||||
public static boolean isAuthority(@NonNull Context context, @NonNull Uri uri) {
|
||||
int matchResult = MATCHER.match(uri);
|
||||
return matchResult == MATCH_NEW || matchResult == MATCH_OLD || isExternalBlobUri(context, uri);
|
||||
}
|
||||
|
||||
private static boolean isExternalBlobUri(@NonNull Context context, @NonNull Uri uri) {
|
||||
try {
|
||||
return uri.getPath().startsWith(getExternalDir(context).getAbsolutePath()) || FileProviderUtil.isAuthority(uri);
|
||||
} catch (IOException ioe) {
|
||||
Log.w(TAG, "Failed to determine if it's an external blob URI.", ioe);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FileData {
|
||||
private final File file;
|
||||
private final boolean modern;
|
||||
|
||||
private FileData(File file, boolean modern) {
|
||||
this.file = file;
|
||||
this.modern = modern;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2015 Open Whisper Systems
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.thoughtcrime.securesms.providers;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentUris;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.UriMatcher;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.session.libsignal.utilities.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class MmsBodyProvider extends ContentProvider {
|
||||
private static final String TAG = MmsBodyProvider.class.getSimpleName();
|
||||
private static final String CONTENT_URI_STRING = "content://network.loki.provider.securesms.mms/mms";
|
||||
public static final Uri CONTENT_URI = Uri.parse(CONTENT_URI_STRING);
|
||||
private static final int SINGLE_ROW = 1;
|
||||
|
||||
private static final UriMatcher uriMatcher;
|
||||
|
||||
static {
|
||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
uriMatcher.addURI("network.loki.provider.securesms.mms", "mms/#", SINGLE_ROW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private File getFile(Uri uri) {
|
||||
long id = Long.parseLong(uri.getPathSegments().get(1));
|
||||
return new File(getContext().getCacheDir(), id + ".mmsbody");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException {
|
||||
Log.i(TAG, "openFile(" + uri + ", " + mode + ")");
|
||||
|
||||
switch (uriMatcher.match(uri)) {
|
||||
case SINGLE_ROW:
|
||||
Log.i(TAG, "Fetching message body for a single row...");
|
||||
File tmpFile = getFile(uri);
|
||||
|
||||
final int fileMode;
|
||||
switch (mode) {
|
||||
case "w": fileMode = ParcelFileDescriptor.MODE_TRUNCATE |
|
||||
ParcelFileDescriptor.MODE_CREATE |
|
||||
ParcelFileDescriptor.MODE_WRITE_ONLY; break;
|
||||
case "r": fileMode = ParcelFileDescriptor.MODE_READ_ONLY; break;
|
||||
default: throw new IllegalArgumentException("requested file mode unsupported");
|
||||
}
|
||||
|
||||
Log.i(TAG, "returning file " + tmpFile.getAbsolutePath());
|
||||
return ParcelFileDescriptor.open(tmpFile, fileMode);
|
||||
}
|
||||
|
||||
throw new FileNotFoundException("Request for bad message.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(@NonNull Uri uri, String arg1, String[] arg2) {
|
||||
switch (uriMatcher.match(uri)) {
|
||||
case SINGLE_ROW:
|
||||
return getFile(uri).delete() ? 1 : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType(@NonNull Uri arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri insert(@NonNull Uri arg0, ContentValues arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor query(@NonNull Uri arg0, String[] arg1, String arg2, String[] arg3, String arg4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(@NonNull Uri arg0, ContentValues arg1, String arg2, String[] arg3) {
|
||||
return 0;
|
||||
}
|
||||
public static Pointer makeTemporaryPointer(Context context) {
|
||||
return new Pointer(context, ContentUris.withAppendedId(MmsBodyProvider.CONTENT_URI, System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
public static class Pointer {
|
||||
private final Context context;
|
||||
private final Uri uri;
|
||||
|
||||
public Pointer(Context context, Uri uri) {
|
||||
this.context = context;
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public Uri getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public OutputStream getOutputStream() throws FileNotFoundException {
|
||||
return context.getContentResolver().openOutputStream(uri, "w");
|
||||
}
|
||||
|
||||
public InputStream getInputStream() throws FileNotFoundException {
|
||||
return context.getContentResolver().openInputStream(uri);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
context.getContentResolver().delete(uri, null, null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package org.thoughtcrime.securesms.qr;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
|
||||
import org.session.libsignal.utilities.logging.Log;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class QrCode {
|
||||
|
||||
public static final String TAG = QrCode.class.getSimpleName();
|
||||
|
||||
public static @NonNull Bitmap create(String data) {
|
||||
return create(data, 1024);
|
||||
}
|
||||
public static @NonNull Bitmap create(String data, int size) { return create(data, size, 2); }
|
||||
public static @NonNull Bitmap create(String data, int size, int margin) {
|
||||
try {
|
||||
HashMap<EncodeHintType, Integer> hintMap = new HashMap<>();
|
||||
hintMap.put(EncodeHintType.MARGIN, margin);
|
||||
BitMatrix result = new QRCodeWriter().encode(data, BarcodeFormat.QR_CODE, size, size, hintMap);
|
||||
Bitmap bitmap = Bitmap.createBitmap(result.getWidth(), result.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
|
||||
for (int y = 0; y < result.getHeight(); y++) {
|
||||
for (int x = 0; x < result.getWidth(); x++) {
|
||||
if (result.get(x, y)) {
|
||||
bitmap.setPixel(x, y, Color.BLACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
} catch (WriterException e) {
|
||||
Log.w(TAG, e);
|
||||
return Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -134,13 +134,6 @@
|
||||
android:background="?android:dividerHorizontal"
|
||||
android:elevation="1dp" />
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/group_share_profile_view_stub"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inflatedId="@+id/group_share_profile_view"
|
||||
android:layout="@layout/conversation_activity_group_share_profile_stub" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_content"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<org.thoughtcrime.securesms.profiles.GroupShareProfileView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/group_share_profile_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
Loading…
Reference in New Issue
Block a user