diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ff4e8d4f57..e615d85e6a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -327,15 +327,6 @@
-
-
-
-
-
-
-
-
.
- */
-package org.thoughtcrime.securesms;
-
-import android.annotation.TargetApi;
-import android.content.ClipData;
-import android.content.ClipboardManager;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.os.Build.VERSION;
-import android.os.Bundle;
-import org.thoughtcrime.securesms.logging.Log;
-import android.widget.Toast;
-
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AlertDialog;
-import androidx.core.content.ContextCompat;
-import androidx.core.graphics.drawable.DrawableCompat;
-import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentTransaction;
-import androidx.preference.Preference;
-
-import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
-import org.thoughtcrime.securesms.loki.activities.HomeActivity;
-import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment;
-import org.thoughtcrime.securesms.preferences.ChatsPreferenceFragment;
-import org.thoughtcrime.securesms.preferences.CorrectedPreferenceFragment;
-import org.thoughtcrime.securesms.preferences.NotificationsPreferenceFragment;
-import org.thoughtcrime.securesms.preferences.widgets.ProfilePreference;
-import org.thoughtcrime.securesms.service.KeyCachingService;
-import org.thoughtcrime.securesms.util.DynamicLanguage;
-import org.thoughtcrime.securesms.util.DynamicTheme;
-import org.thoughtcrime.securesms.util.TextSecurePreferences;
-import org.session.libsignal.service.loki.utilities.HexEncodingKt;
-
-import network.loki.messenger.R;
-
-/**
- * The Activity for application preference display and management.
- *
- * @author Moxie Marlinspike
- *
- */
-
-public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarActivity
- implements SharedPreferences.OnSharedPreferenceChangeListener
-{
- @SuppressWarnings("unused")
- private static final String TAG = ApplicationPreferencesActivity.class.getSimpleName();
-
- private static final String PREFERENCE_CATEGORY_PROFILE = "preference_category_profile";
- // private static final String PREFERENCE_CATEGORY_SMS_MMS = "preference_category_sms_mms";
- private static final String PREFERENCE_CATEGORY_NOTIFICATIONS = "preference_category_notifications";
- private static final String PREFERENCE_CATEGORY_APP_PROTECTION = "preference_category_app_protection";
- // private static final String PREFERENCE_CATEGORY_APPEARANCE = "preference_category_appearance";
- private static final String PREFERENCE_CATEGORY_CHATS = "preference_category_chats";
- // private static final String PREFERENCE_CATEGORY_DEVICES = "preference_category_devices";
- // private static final String PREFERENCE_CATEGORY_ADVANCED = "preference_category_advanced";
- private static final String PREFERENCE_CATEGORY_PUBLIC_KEY = "preference_category_public_key";
- private static final String PREFERENCE_CATEGORY_QR_CODE = "preference_category_qr_code";
- private static final String PREFERENCE_CATEGORY_LINKED_DEVICES = "preference_category_linked_devices";
- private static final String PREFERENCE_CATEGORY_SEED = "preference_category_seed";
-
- private final DynamicTheme dynamicTheme = new DynamicTheme();
- private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
-
- @Override
- protected void onPreCreate() {
- dynamicTheme.onCreate(this);
- dynamicLanguage.onCreate(this);
- }
-
- @Override
- protected void onCreate(Bundle icicle, boolean ready) {
- //noinspection ConstantConditions
- this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
-
- if (getIntent() != null && getIntent().getCategories() != null && getIntent().getCategories().contains("android.intent.category.NOTIFICATION_PREFERENCES")) {
- initFragment(android.R.id.content, new NotificationsPreferenceFragment());
- } else if (icicle == null) {
- initFragment(android.R.id.content, new ApplicationPreferenceFragment());
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
- dynamicTheme.onResume(this);
- dynamicLanguage.onResume(this);
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data)
- {
- super.onActivityResult(requestCode, resultCode, data);
- Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
- fragment.onActivityResult(requestCode, resultCode, data);
- }
-
- @Override
- public boolean onSupportNavigateUp() {
- FragmentManager fragmentManager = getSupportFragmentManager();
- if (fragmentManager.getBackStackEntryCount() > 0) {
- fragmentManager.popBackStack();
- } else {
- Intent intent = new Intent(this, HomeActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
- finish();
- }
- return true;
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- if (key.equals(TextSecurePreferences.THEME_PREF)) {
- recreate();
- } else if (key.equals(TextSecurePreferences.LANGUAGE_PREF)) {
- recreate();
-
- Intent intent = new Intent(this, KeyCachingService.class);
- intent.setAction(KeyCachingService.LOCALE_CHANGE_EVENT);
- startService(intent);
- }
- }
-
- public static class ApplicationPreferenceFragment extends CorrectedPreferenceFragment {
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- String masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(getContext());
- boolean isMasterDevice = (masterHexEncodedPublicKey == null);
-
- Preference profilePreference = this.findPreference(PREFERENCE_CATEGORY_PROFILE);
- if (isMasterDevice) { profilePreference.setOnPreferenceClickListener(new ProfileClickListener()); }
- /*
- this.findPreference(PREFERENCE_CATEGORY_SMS_MMS)
- .setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_SMS_MMS));
- */
- this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS)
- .setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_NOTIFICATIONS));
- this.findPreference(PREFERENCE_CATEGORY_APP_PROTECTION)
- .setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_APP_PROTECTION));
- /*
- this.findPreference(PREFERENCE_CATEGORY_APPEARANCE)
- .setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_APPEARANCE));
- */
- this.findPreference(PREFERENCE_CATEGORY_CHATS)
- .setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_CHATS));
- /*
- this.findPreference(PREFERENCE_CATEGORY_DEVICES)
- .setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_DEVICES));
- this.findPreference(PREFERENCE_CATEGORY_ADVANCED)
- .setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_ADVANCED));
- */
- this.findPreference(PREFERENCE_CATEGORY_PUBLIC_KEY)
- .setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_PUBLIC_KEY));
- this.findPreference(PREFERENCE_CATEGORY_QR_CODE)
- .setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_QR_CODE));
-
- Preference linkDevicesPreference = this.findPreference(PREFERENCE_CATEGORY_LINKED_DEVICES);
- linkDevicesPreference.setVisible(isMasterDevice);
- linkDevicesPreference.setOnPreferenceClickListener(new CategoryClickListener(PREFERENCE_CATEGORY_LINKED_DEVICES));
-
- Preference seedPreference = this.findPreference(PREFERENCE_CATEGORY_SEED);
- // Hide if this is a slave device
- seedPreference.setVisible(isMasterDevice);
- seedPreference.setOnPreferenceClickListener(new CategoryClickListener((PREFERENCE_CATEGORY_SEED)));
-
- if (VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
- tintIcons(getActivity());
- }
- }
-
- @Override
- public void onCreatePreferences(@Nullable Bundle savedInstanceState, String rootKey) {
- addPreferencesFromResource(R.xml.preferences);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- //noinspection ConstantConditions
- ((ApplicationPreferencesActivity) getActivity()).getSupportActionBar().setTitle(R.string.text_secure_normal__menu_settings);
- setCategorySummaries();
- setCategoryVisibility();
- }
-
- private void setCategorySummaries() {
- ((ProfilePreference)this.findPreference(PREFERENCE_CATEGORY_PROFILE)).refresh();
-
- /*
- this.findPreference(PREFERENCE_CATEGORY_SMS_MMS)
- .setSummary(SmsMmsPreferenceFragment.getSummary(getActivity()));
- */
- this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS)
- .setSummary(NotificationsPreferenceFragment.getSummary(getActivity()));
- this.findPreference(PREFERENCE_CATEGORY_APP_PROTECTION)
- .setSummary(AppProtectionPreferenceFragment.getSummary(getActivity()));
- /*
- this.findPreference(PREFERENCE_CATEGORY_APPEARANCE)
- .setSummary(AppearancePreferenceFragment.getSummary(getActivity()));
- */
- this.findPreference(PREFERENCE_CATEGORY_CHATS)
- .setSummary(ChatsPreferenceFragment.getSummary(getActivity()));
- }
-
- private void setCategoryVisibility() {
- /*
- Preference devicePreference = this.findPreference(PREFERENCE_CATEGORY_DEVICES);
- if (devicePreference != null && !TextSecurePreferences.isPushRegistered(getActivity())) {
- getPreferenceScreen().removePreference(devicePreference);
- }
- */
- }
-
- @TargetApi(11)
- private void tintIcons(Context context) {
- Drawable sms = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_textsms_white_24dp));
- Drawable notifications = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_notifications_white_24dp));
- Drawable privacy = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_security_white_24dp));
- Drawable appearance = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_brightness_6_white_24dp));
- Drawable chats = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_forum_white_24dp));
- Drawable devices = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_laptop_white_24dp));
- Drawable advanced = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_advanced_white_24dp));
- Drawable publicKey = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_textsms_24dp));
- Drawable qrCode = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_qr_code_24));
- Drawable linkDevice = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_link));
- Drawable seed = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.icon_seedling));
-
- int[] tintAttr = new int[]{R.attr.pref_icon_tint};
- TypedArray typedArray = context.obtainStyledAttributes(tintAttr);
- int color = typedArray.getColor(0, 0x0);
- typedArray.recycle();
-
- DrawableCompat.setTint(sms, color);
- DrawableCompat.setTint(notifications, color);
- DrawableCompat.setTint(privacy, color);
- DrawableCompat.setTint(appearance, color);
- DrawableCompat.setTint(chats, color);
- DrawableCompat.setTint(devices, color);
- DrawableCompat.setTint(advanced, color);
- DrawableCompat.setTint(publicKey, color);
- DrawableCompat.setTint(qrCode, color);
- DrawableCompat.setTint(linkDevice, color);
- DrawableCompat.setTint(seed, color);
-
- // this.findPreference(PREFERENCE_CATEGORY_SMS_MMS).setIcon(sms);
- this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS).setIcon(notifications);
- this.findPreference(PREFERENCE_CATEGORY_APP_PROTECTION).setIcon(privacy);
- // this.findPreference(PREFERENCE_CATEGORY_APPEARANCE).setIcon(appearance);
- this.findPreference(PREFERENCE_CATEGORY_CHATS).setIcon(chats);
- // this.findPreference(PREFERENCE_CATEGORY_DEVICES).setIcon(devices);
- // this.findPreference(PREFERENCE_CATEGORY_ADVANCED).setIcon(advanced);
- this.findPreference(PREFERENCE_CATEGORY_PUBLIC_KEY).setIcon(publicKey);
- this.findPreference(PREFERENCE_CATEGORY_QR_CODE).setIcon(qrCode);
- this.findPreference(PREFERENCE_CATEGORY_LINKED_DEVICES).setIcon(linkDevice);
- this.findPreference(PREFERENCE_CATEGORY_SEED).setIcon(seed);
- }
-
- private class CategoryClickListener implements Preference.OnPreferenceClickListener {
- private String category;
-
- CategoryClickListener(String category) {
- this.category = category;
- }
-
- @Override
- public boolean onPreferenceClick(Preference preference) {
- Fragment fragment = null;
-
- switch (category) {
- /*
- case PREFERENCE_CATEGORY_SMS_MMS:
- fragment = new SmsMmsPreferenceFragment();
- break;
- */
- case PREFERENCE_CATEGORY_NOTIFICATIONS:
- fragment = new NotificationsPreferenceFragment();
- break;
- case PREFERENCE_CATEGORY_APP_PROTECTION:
- fragment = new AppProtectionPreferenceFragment();
- break;
- /*
- case PREFERENCE_CATEGORY_APPEARANCE:
- fragment = new AppearancePreferenceFragment();
- break;
- */
- case PREFERENCE_CATEGORY_CHATS:
- fragment = new ChatsPreferenceFragment();
- break;
- /*
- case PREFERENCE_CATEGORY_DEVICES:
- Intent intent = new Intent(getActivity(), DeviceActivity.class);
- startActivity(intent);
- break;
- case PREFERENCE_CATEGORY_ADVANCED:
- fragment = new AdvancedPreferenceFragment();
- break;
- */
- case PREFERENCE_CATEGORY_PUBLIC_KEY:
- String hexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(getContext());
- if (hexEncodedPublicKey == null) {
- hexEncodedPublicKey = TextSecurePreferences.getLocalNumber(getContext());
- }
- Intent shareIntent = new Intent();
- shareIntent.setAction(Intent.ACTION_SEND);
- shareIntent.putExtra(Intent.EXTRA_TEXT, hexEncodedPublicKey);
- shareIntent.setType("text/plain");
- startActivity(shareIntent);
- break;
- case PREFERENCE_CATEGORY_QR_CODE: break;
- case PREFERENCE_CATEGORY_LINKED_DEVICES: break;
- case PREFERENCE_CATEGORY_SEED:
- try {
- String hexEncodedSeed = IdentityKeyUtil.retrieve(getContext(), IdentityKeyUtil.LOKI_SEED);
- if (hexEncodedSeed == null) {
- hexEncodedSeed = HexEncodingKt.getHexEncodedPrivateKey(IdentityKeyUtil.getIdentityKeyPair(getContext())); // Legacy account
- }
- String seed = "";
- new AlertDialog.Builder(getContext())
- .setTitle(R.string.activity_settings_seed_dialog_title)
- .setMessage(seed)
- .setPositiveButton(R.string.activity_settings_seed_dialog_copy_button_title, (DialogInterface.OnClickListener) (dialog, which) -> {
- ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
- ClipData clip = ClipData.newPlainText("seed", seed);
- clipboard.setPrimaryClip(clip);
- Toast.makeText(getContext(), R.string.activity_settings_seed_copied_message, Toast.LENGTH_SHORT).show();
- })
- .setNeutralButton(R.string.activity_settings_seed_dialog_ok_button_title, null)
- .show();
- } catch (Exception e) {
- Log.d("Loki", e.getMessage());
- }
- break;
- default:
- throw new AssertionError();
- }
-
- if (fragment != null) {
- Bundle args = new Bundle();
- fragment.setArguments(args);
-
- FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
- FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
- fragmentTransaction.replace(android.R.id.content, fragment);
- fragmentTransaction.addToBackStack(null);
- fragmentTransaction.commit();
- }
-
- return true;
- }
- }
-
- private class ProfileClickListener implements Preference.OnPreferenceClickListener {
- @Override
- public boolean onPreferenceClick(Preference preference) {
- Intent intent = new Intent(preference.getContext(), CreateProfileActivity.class);
- intent.putExtra(CreateProfileActivity.EXCLUDE_SYSTEM, true);
-
- getActivity().startActivity(intent);
-// ((BaseActionBarActivity)getActivity()).startActivitySceneTransition(intent, getActivity().findViewById(R.id.avatar), "avatar");
- return true;
- }
- }
- }
-
-}
diff --git a/app/src/main/java/org/thoughtcrime/securesms/CreateProfileActivity.java b/app/src/main/java/org/thoughtcrime/securesms/CreateProfileActivity.java
deleted file mode 100644
index 2f68ec2304..0000000000
--- a/app/src/main/java/org/thoughtcrime/securesms/CreateProfileActivity.java
+++ /dev/null
@@ -1,492 +0,0 @@
-package org.thoughtcrime.securesms;
-
-
-import android.Manifest;
-import android.animation.Animator;
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Build;
-import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.RequiresApi;
-import android.text.Editable;
-import android.text.TextUtils;
-import android.text.TextWatcher;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewAnimationUtils;
-import android.view.WindowManager;
-import android.widget.ImageView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.dd.CircularProgressButton;
-
-import org.session.libsignal.service.api.SignalServiceAccountManager;
-import org.thoughtcrime.securesms.avatar.AvatarSelection;
-import org.thoughtcrime.securesms.components.InputAwareLayout;
-import org.thoughtcrime.securesms.components.LabeledEditText;
-import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider;
-import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
-import org.thoughtcrime.securesms.components.emoji.MediaKeyboard;
-import org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto;
-import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
-import org.thoughtcrime.securesms.database.Address;
-import org.thoughtcrime.securesms.database.DatabaseFactory;
-import org.thoughtcrime.securesms.dependencies.InjectableType;
-import org.thoughtcrime.securesms.logging.Log;
-import org.thoughtcrime.securesms.mms.GlideApp;
-import org.thoughtcrime.securesms.permissions.Permissions;
-import org.thoughtcrime.securesms.profiles.AvatarHelper;
-import org.thoughtcrime.securesms.profiles.ProfileMediaConstraints;
-import org.thoughtcrime.securesms.profiles.SystemProfileUtil;
-import org.thoughtcrime.securesms.util.BitmapDecodingException;
-import org.thoughtcrime.securesms.util.BitmapUtil;
-import org.thoughtcrime.securesms.util.DynamicLanguage;
-import org.thoughtcrime.securesms.util.TextSecurePreferences;
-import org.thoughtcrime.securesms.util.Util;
-import org.thoughtcrime.securesms.util.ViewUtil;
-import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
-import org.session.libsignal.service.api.crypto.ProfileCipher;
-import org.session.libsignal.service.api.util.StreamDetails;
-import org.session.libsignal.service.loki.api.LokiDotNetAPI;
-import org.session.libsignal.service.loki.api.fileserver.FileServerAPI;
-import org.session.libsignal.service.loki.api.opengroups.PublicChatAPI;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.security.SecureRandom;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.inject.Inject;
-
-import kotlin.Unit;
-import network.loki.messenger.R;
-
-@SuppressLint("StaticFieldLeak")
-public class CreateProfileActivity extends BaseActionBarActivity implements InjectableType {
-
- private static final String TAG = CreateProfileActivity.class.getSimpleName();
-
- public static final String NEXT_INTENT = "next_intent";
- public static final String EXCLUDE_SYSTEM = "exclude_system";
-
- private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
-
- @Inject SignalServiceAccountManager accountManager;
-
- private InputAwareLayout container;
- private ImageView avatar;
- private CircularProgressButton finishButton;
- private LabeledEditText name;
- private EmojiToggle emojiToggle;
- private MediaKeyboard mediaKeyboard;
- private View reveal;
-
- private Intent nextIntent;
- private byte[] originalAvatarBytes;
- private byte[] avatarBytes;
- private File captureFile;
-
- @Override
- public void onCreate(Bundle bundle) {
- super.onCreate(bundle);
-
- dynamicLanguage.onCreate(this);
-
- setContentView(R.layout.profile_create_activity);
-
- getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
-
- initializeResources();
- initializeEmojiInput();
- initializeProfileName(getIntent().getBooleanExtra(EXCLUDE_SYSTEM, false));
- initializeProfileAvatar(getIntent().getBooleanExtra(EXCLUDE_SYSTEM, false));
-
- ApplicationContext.getInstance(this).injectDependencies(this);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- dynamicLanguage.onResume(this);
- }
-
- @Override
- public void onBackPressed() {
- if (container.isInputOpen()) container.hideCurrentInput(name.getInput());
- else super.onBackPressed();
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
-
- if (container.getCurrentInput() == mediaKeyboard) {
- container.hideAttachedInput(true);
- }
- }
-
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
- Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
-
- switch (requestCode) {
- case AvatarSelection.REQUEST_CODE_AVATAR:
- if (resultCode == Activity.RESULT_OK) {
- Uri outputFile = Uri.fromFile(new File(getCacheDir(), "cropped"));
- Uri inputFile = (data != null ? data.getData() : null);
-
- if (inputFile == null && captureFile != null) {
- inputFile = Uri.fromFile(captureFile);
- }
-
- if (data != null && data.getBooleanExtra("delete", false)) {
- avatarBytes = null;
- avatar.setImageDrawable(new ResourceContactPhoto(R.drawable.ic_camera_alt_white_24dp).asDrawable(this, getResources().getColor(R.color.grey_400)));
- } else {
- AvatarSelection.circularCropImage(this, inputFile, outputFile, R.string.CropImageActivity_profile_avatar);
- }
- }
-
- break;
- case AvatarSelection.REQUEST_CODE_CROP_IMAGE:
- if (resultCode == Activity.RESULT_OK) {
- new AsyncTask() {
- @Override
- protected byte[] doInBackground(Void... params) {
- try {
- BitmapUtil.ScaleResult result = BitmapUtil.createScaledBytes(CreateProfileActivity.this, AvatarSelection.getResultUri(data), new ProfileMediaConstraints());
- return result.getBitmap();
- } catch (BitmapDecodingException e) {
- Log.w(TAG, e);
- return null;
- }
- }
-
- @Override
- protected void onPostExecute(byte[] result) {
- if (result != null) {
- avatarBytes = result;
- GlideApp.with(CreateProfileActivity.this)
- .load(avatarBytes)
- .skipMemoryCache(true)
- .diskCacheStrategy(DiskCacheStrategy.NONE)
- .circleCrop()
- .into(avatar);
- } else {
- Toast.makeText(CreateProfileActivity.this, R.string.CreateProfileActivity_error_setting_profile_photo, Toast.LENGTH_LONG).show();
- }
- }
- }.execute();
- }
- break;
- }
- }
-
- private void initializeResources() {
- TextView skipButton = ViewUtil.findById(this, R.id.skip_button);
-
- this.avatar = ViewUtil.findById(this, R.id.avatar);
- this.name = ViewUtil.findById(this, R.id.name);
- this.emojiToggle = ViewUtil.findById(this, R.id.emoji_toggle);
- this.mediaKeyboard = ViewUtil.findById(this, R.id.emoji_drawer);
- this.container = ViewUtil.findById(this, R.id.container);
- this.finishButton = ViewUtil.findById(this, R.id.finish_button);
- this.reveal = ViewUtil.findById(this, R.id.reveal);
- this.nextIntent = getIntent().getParcelableExtra(NEXT_INTENT);
-
- this.avatar.setOnClickListener(view -> Permissions.with(this)
- .request(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE)
- .onAnyResult(this::startAvatarSelection)
- .execute());
-
- this.name.getInput().addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {}
- @Override
- public void afterTextChanged(Editable s) {
- Pattern pattern = Pattern.compile("[a-zA-Z0-9_]+");
- Matcher matcher = pattern.matcher(s.toString());
- if (s.toString().isEmpty()) {
- name.getInput().setError("Invalid");
- finishButton.setEnabled(false);
- } else if (!matcher.matches()) {
- name.getInput().setError("Invalid (a-z, A-Z, 0-9 and _ only)");
- finishButton.setEnabled(false);
- } else if (s.toString().getBytes().length > ProfileCipher.NAME_PADDED_LENGTH) {
- name.getInput().setError(getString(R.string.CreateProfileActivity_too_long));
- finishButton.setEnabled(false);
- } else if (name.getInput().getError() != null || !finishButton.isEnabled()) {
- name.getInput().setError(null);
- finishButton.setEnabled(true);
- }
- }
- });
-
- this.finishButton.setOnClickListener(view -> {
- this.finishButton.setIndeterminateProgressMode(true);
- this.finishButton.setProgress(50);
- handleUpload();
- });
-
- skipButton.setOnClickListener(view -> {
- if (nextIntent != null) startActivity(nextIntent);
- finish();
- });
- }
-
- private void initializeProfileName(boolean excludeSystem) {
- if (!TextUtils.isEmpty(TextSecurePreferences.getProfileName(this))) {
- String profileName = TextSecurePreferences.getProfileName(this);
-
- name.setText(profileName);
- name.getInput().setSelection(profileName.length(), profileName.length());
- } else if (!excludeSystem) {
- SystemProfileUtil.getSystemProfileName(this).addListener(new ListenableFuture.Listener() {
- @Override
- public void onSuccess(String result) {
- if (!TextUtils.isEmpty(result)) {
- name.setText(result);
- name.getInput().setSelection(result.length(), result.length());
- }
- }
-
- @Override
- public void onFailure(ExecutionException e) {
- Log.w(TAG, e);
- }
- });
- }
- }
-
- private void initializeProfileAvatar(boolean excludeSystem) {
- Address ourAddress = Address.fromSerialized(TextSecurePreferences.getLocalNumber(this));
-
- if (AvatarHelper.getAvatarFile(this, ourAddress).exists() && AvatarHelper.getAvatarFile(this, ourAddress).length() > 0) {
- new AsyncTask() {
- @Override
- protected byte[] doInBackground(Void... params) {
- try {
- return Util.readFully(AvatarHelper.getInputStreamFor(CreateProfileActivity.this, ourAddress));
- } catch (IOException e) {
- Log.w(TAG, e);
- return null;
- }
- }
-
- @Override
- protected void onPostExecute(byte[] result) {
- if (result != null) {
- originalAvatarBytes = result;
- avatarBytes = result;
- GlideApp.with(CreateProfileActivity.this)
- .load(result)
- .circleCrop()
- .into(avatar);
- }
- }
- }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- } else if (!excludeSystem) {
- SystemProfileUtil.getSystemProfileAvatar(this, new ProfileMediaConstraints()).addListener(new ListenableFuture.Listener() {
- @Override
- public void onSuccess(byte[] result) {
- if (result != null) {
- originalAvatarBytes = result;
- avatarBytes = result;
- GlideApp.with(CreateProfileActivity.this)
- .load(result)
- .circleCrop()
- .into(avatar);
- }
- }
-
- @Override
- public void onFailure(ExecutionException e) {
- Log.w(TAG, e);
- }
- });
- }
- }
-
- private void initializeEmojiInput() {
- this.emojiToggle.attach(mediaKeyboard);
-
- this.emojiToggle.setOnClickListener(v -> {
- if (container.getCurrentInput() == mediaKeyboard) {
- container.showSoftkey(name.getInput());
- } else {
- container.show(name.getInput(), mediaKeyboard);
- }
- });
-
- this.mediaKeyboard.setProviders(0, new EmojiKeyboardProvider(this, new EmojiKeyboardProvider.EmojiEventListener() {
- @Override
- public void onKeyEvent(KeyEvent keyEvent) {
- name.dispatchKeyEvent(keyEvent);
- }
-
- @Override
- public void onEmojiSelected(String emoji) {
- final int start = name.getInput().getSelectionStart();
- final int end = name.getInput().getSelectionEnd();
-
- name.getText().replace(Math.min(start, end), Math.max(start, end), emoji);
- name.getInput().setSelection(start + emoji.length());
- }
- }));
-
- this.container.addOnKeyboardShownListener(() -> emojiToggle.setToMedia());
- this.name.setOnClickListener(v -> container.showSoftkey(name.getInput()));
- }
-
- private void startAvatarSelection() {
- captureFile = AvatarSelection.startAvatarSelection(this, avatarBytes != null, true);
- }
-
- private void handleUpload() {
- final String name;
- final StreamDetails avatar;
-
- if (TextUtils.isEmpty(this.name.getText().toString())) name = null;
- else name = this.name.getText().toString();
-
- if (avatarBytes == null || avatarBytes.length == 0) avatar = null;
- else avatar = new StreamDetails(new ByteArrayInputStream(avatarBytes),
- "image/jpeg", avatarBytes.length);
-
- new AsyncTask() {
- @Override
- protected Boolean doInBackground(Void... params) {
- Context context = CreateProfileActivity.this;
-
- TextSecurePreferences.setProfileName(context, name);
- PublicChatAPI publicChatAPI = ApplicationContext.getInstance(context).getPublicChatAPI();
- if (publicChatAPI != null) {
- Set servers = DatabaseFactory.getLokiThreadDatabase(context).getAllPublicChatServers();
- for (String server : servers) {
- publicChatAPI.setDisplayName(name, server);
- }
- }
-
- // Loki - Only update avatar if there was a change
- if (!Arrays.equals(originalAvatarBytes, avatarBytes)) {
- try {
- // Loki - Original profile photo code
- // ========
- // accountManager.setProfileAvatar(profileKey, avatar);
- // ========
-
- // Try upload photo with a new profile key
- String newProfileKey = ProfileKeyUtil.generateEncodedProfileKey(context);
- byte[] profileKey = ProfileKeyUtil.getProfileKeyFromEncodedString(newProfileKey);
-
- // Loki - Upload the profile photo here
- if (avatar != null) {
- Log.d("Loki", "Start uploading profile photo");
- FileServerAPI storageAPI = FileServerAPI.shared;
- LokiDotNetAPI.UploadResult result = storageAPI.uploadProfilePicture(storageAPI.getServer(), profileKey, avatar, () -> {
- TextSecurePreferences.setLastProfilePictureUpload(CreateProfileActivity.this, new Date().getTime());
- return Unit.INSTANCE;
- });
- Log.d("Loki", "Profile photo uploaded, the url is " + result.getUrl());
- TextSecurePreferences.setProfilePictureURL(context, result.getUrl());
- } else {
- TextSecurePreferences.setProfilePictureURL(context, null);
- }
-
- AvatarHelper.setAvatar(context, Address.fromSerialized(TextSecurePreferences.getLocalNumber(context)), avatarBytes);
- TextSecurePreferences.setProfileAvatarId(context, new SecureRandom().nextInt());
-
- // Upload was successful with this new profile key, we should set it so the other users know to re-fetch profiles
- ProfileKeyUtil.setEncodedProfileKey(context, newProfileKey);
-
- // Update profile key on the public chat server
- ApplicationContext.getInstance(context).updateOpenGroupProfilePicturesIfNeeded();
- } catch (Exception e) {
- Log.d("Loki", "Failed to upload profile photo: " + e);
- return false;
- }
- }
-
- // ApplicationContext.getInstance(context).getJobManager().add(new MultiDeviceProfileKeyUpdateJob());
- return true;
- }
-
- @Override
- public void onPostExecute(Boolean result) {
- super.onPostExecute(result);
-
- if (result) {
- if (captureFile != null) captureFile.delete();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) handleFinishedLollipop();
- else handleFinishedLegacy();
- } else {
- Toast.makeText(CreateProfileActivity.this, R.string.CreateProfileActivity_problem_setting_profile, Toast.LENGTH_LONG).show();
- }
- }
- }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
-
- private void handleFinishedLegacy() {
- finishButton.setProgress(0);
- if (nextIntent != null) startActivity(nextIntent);
- finish();
- }
-
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
- private void handleFinishedLollipop() {
- int[] finishButtonLocation = new int[2];
- int[] revealLocation = new int[2];
-
- finishButton.getLocationInWindow(finishButtonLocation);
- reveal.getLocationInWindow(revealLocation);
-
- int finishX = finishButtonLocation[0] - revealLocation[0];
- int finishY = finishButtonLocation[1] - revealLocation[1];
-
- finishX += finishButton.getWidth() / 2;
- finishY += finishButton.getHeight() / 2;
-
- Animator animation = ViewAnimationUtils.createCircularReveal(reveal, finishX, finishY, 0f, (float) Math.max(reveal.getWidth(), reveal.getHeight()));
- animation.setDuration(500);
- animation.addListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animation) {}
-
- @Override
- public void onAnimationEnd(Animator animation) {
- finishButton.setProgress(0);
- if (nextIntent != null) startActivity(nextIntent);
- finish();
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {}
- @Override
- public void onAnimationRepeat(Animator animation) {}
- });
-
- reveal.setVisibility(View.VISIBLE);
- animation.start();
- }
-}
diff --git a/app/src/main/java/org/thoughtcrime/securesms/ExperienceUpgradeActivity.java b/app/src/main/java/org/thoughtcrime/securesms/ExperienceUpgradeActivity.java
index 88ed1153f9..efc2429ff1 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/ExperienceUpgradeActivity.java
+++ b/app/src/main/java/org/thoughtcrime/securesms/ExperienceUpgradeActivity.java
@@ -38,36 +38,6 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity implements
private static final int NOTIFICATION_ID = 1339;
private enum ExperienceUpgrade {
- SIGNAL_REBRANDING(157,
- new IntroPage(0xFF2090EA,
- BasicIntroFragment.newInstance(R.drawable.splash_logo,
- R.string.ExperienceUpgradeActivity_welcome_to_signal_dgaf,
- R.string.ExperienceUpgradeActivity_textsecure_is_now_called_signal)),
- R.string.ExperienceUpgradeActivity_welcome_to_signal_excited,
- R.string.ExperienceUpgradeActivity_textsecure_is_now_signal,
- R.string.ExperienceUpgradeActivity_textsecure_is_now_signal_long,
- null,
- false),
- VIDEO_CALLS(245,
- new IntroPage(0xFF2090EA,
- BasicIntroFragment.newInstance(R.drawable.video_splash,
- R.string.ExperienceUpgradeActivity_say_hello_to_video_calls,
- R.string.ExperienceUpgradeActivity_signal_now_supports_secure_video_calls)),
- R.string.ExperienceUpgradeActivity_say_hello_to_video_calls,
- R.string.ExperienceUpgradeActivity_signal_now_supports_secure_video_calling,
- R.string.ExperienceUpgradeActivity_signal_now_supports_secure_video_calling_long,
- null,
- false),
- PROFILES(286,
- new IntroPage(0xFF2090EA,
- BasicIntroFragment.newInstance(R.drawable.profile_splash,
- R.string.ExperienceUpgradeActivity_ready_for_your_closeup,
- R.string.ExperienceUpgradeActivity_now_you_can_share_a_profile_photo_and_name_with_friends_on_signal)),
- R.string.ExperienceUpgradeActivity_signal_profiles_are_here,
- R.string.ExperienceUpgradeActivity_now_you_can_share_a_profile_photo_and_name_with_friends_on_signal,
- R.string.ExperienceUpgradeActivity_now_you_can_share_a_profile_photo_and_name_with_friends_on_signal,
- CreateProfileActivity.class,
- false),
READ_RECEIPTS(299,
new IntroPage(0xFF2090EA,
ReadReceiptsIntroFragment.newInstance()),
diff --git a/app/src/main/java/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java b/app/src/main/java/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java
index 9d18cdd15a..b3ebc37845 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java
+++ b/app/src/main/java/org/thoughtcrime/securesms/PassphraseRequiredActionBarActivity.java
@@ -16,7 +16,6 @@ import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
import org.thoughtcrime.securesms.loki.activities.LandingActivity;
import org.thoughtcrime.securesms.loki.activities.SeedActivity;
-import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
import org.thoughtcrime.securesms.service.KeyCachingService;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
@@ -35,13 +34,11 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
private static final int STATE_EXPERIENCE_UPGRADE = 5;
private static final int STATE_WELCOME_SCREEN = 6;
- private SignalServiceNetworkAccess networkAccess;
private BroadcastReceiver clearKeyReceiver;
@Override
protected final void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "onCreate(" + savedInstanceState + ")");
- this.networkAccess = new SignalServiceNetworkAccess(this);
onPreCreate();
final boolean locked = KeyCachingService.isLocked(this);
@@ -58,16 +55,6 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
protected void onPreCreate() {}
protected void onCreate(Bundle savedInstanceState, boolean ready) {}
- @Override
- protected void onResume() {
- Log.i(TAG, "onResume()");
- super.onResume();
-
- if (networkAccess.isCensored(this)) {
- ApplicationContext.getInstance(this).getJobManager().add(new PushNotificationReceiveJob(this));
- }
- }
-
@Override
protected void onPause() {
Log.i(TAG, "onPause()");
@@ -186,11 +173,7 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
}
private Intent getPushRegistrationIntent() {
- return getRoutedIntent(SeedActivity.class, getCreateProfileIntent());
- }
-
- private Intent getCreateProfileIntent() {
- return getRoutedIntent(CreateProfileActivity.class, getConversationListIntent());
+ return getRoutedIntent(SeedActivity.class, getConversationListIntent());
}
private Intent getRoutedIntent(Class> destination, @Nullable Intent nextIntent) {
diff --git a/app/src/main/java/org/thoughtcrime/securesms/dependencies/SignalCommunicationModule.java b/app/src/main/java/org/thoughtcrime/securesms/dependencies/SignalCommunicationModule.java
index 9cd8a048b3..6d9ac6f0dc 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/dependencies/SignalCommunicationModule.java
+++ b/app/src/main/java/org/thoughtcrime/securesms/dependencies/SignalCommunicationModule.java
@@ -11,7 +11,6 @@ import org.session.libsignal.service.api.util.SleepTimer;
import org.session.libsignal.service.api.util.UptimeSleepTimer;
import org.session.libsignal.service.api.websocket.ConnectivityListener;
import org.thoughtcrime.securesms.ApplicationContext;
-import org.thoughtcrime.securesms.CreateProfileActivity;
import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.jobs.AttachmentDownloadJob;
@@ -85,7 +84,6 @@ import network.loki.messenger.BuildConfig;
RotateSignedPreKeyJob.class,
RetrieveProfileJob.class,
MultiDeviceVerifiedUpdateJob.class,
- CreateProfileActivity.class,
RetrieveProfileAvatarJob.class,
MultiDeviceProfileKeyUpdateJob.class,
SendReadReceiptJob.class,
@@ -121,6 +119,7 @@ public class SignalCommunicationModule {
public SignalCommunicationModule(Context context, SignalServiceNetworkAccess networkAccess) {
this.context = context;
this.networkAccess = networkAccess;
+
}
@Provides
diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/ContactPhotoLocalUriFetcher.java b/app/src/main/java/org/thoughtcrime/securesms/mms/ContactPhotoLocalUriFetcher.java
deleted file mode 100644
index 374800a61e..0000000000
--- a/app/src/main/java/org/thoughtcrime/securesms/mms/ContactPhotoLocalUriFetcher.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.thoughtcrime.securesms.mms;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.net.Uri;
-import android.os.Build.VERSION;
-import android.os.Build.VERSION_CODES;
-import android.provider.ContactsContract;
-
-import com.bumptech.glide.load.data.StreamLocalUriFetcher;
-
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
-class ContactPhotoLocalUriFetcher extends StreamLocalUriFetcher {
-
- private static final String TAG = ContactPhotoLocalUriFetcher.class.getSimpleName();
-
- ContactPhotoLocalUriFetcher(Context context, Uri uri) {
- super(context.getContentResolver(), uri);
- }
-
- @Override
- protected InputStream loadResource(Uri uri, ContentResolver contentResolver)
- throws FileNotFoundException
- {
- if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
- return ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri, true);
- } else {
- return ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri);
- }
- }
-}
diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/MediaNotFoundException.java b/app/src/main/java/org/thoughtcrime/securesms/mms/MediaNotFoundException.java
deleted file mode 100644
index 1215dda94d..0000000000
--- a/app/src/main/java/org/thoughtcrime/securesms/mms/MediaNotFoundException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (C) 2014 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 .
- */
-package org.thoughtcrime.securesms.mms;
-
-public class MediaNotFoundException extends Exception {
-
- public MediaNotFoundException() {
- }
-
- public MediaNotFoundException(String detailMessage) {
- super(detailMessage);
- }
-
- public MediaNotFoundException(Throwable throwable) {
- super(throwable);
- }
-
- public MediaNotFoundException(String detailMessage, Throwable throwable) {
- super(detailMessage, throwable);
- }
-
-}
diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/MediaTooLargeException.java b/app/src/main/java/org/thoughtcrime/securesms/mms/MediaTooLargeException.java
deleted file mode 100644
index 2b07920c99..0000000000
--- a/app/src/main/java/org/thoughtcrime/securesms/mms/MediaTooLargeException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright (C) 2011 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 .
- */
-package org.thoughtcrime.securesms.mms;
-
-public class MediaTooLargeException extends Exception {
-
- public MediaTooLargeException() {
- // TODO Auto-generated constructor stub
- }
-
- public MediaTooLargeException(String detailMessage) {
- super(detailMessage);
- // TODO Auto-generated constructor stub
- }
-
- public MediaTooLargeException(Throwable throwable) {
- super(throwable);
- // TODO Auto-generated constructor stub
- }
-
- public MediaTooLargeException(String detailMessage, Throwable throwable) {
- super(detailMessage, throwable);
- // TODO Auto-generated constructor stub
- }
-
-}
diff --git a/app/src/main/java/org/thoughtcrime/securesms/mms/TextTransport.java b/app/src/main/java/org/thoughtcrime/securesms/mms/TextTransport.java
deleted file mode 100644
index 47735ab37d..0000000000
--- a/app/src/main/java/org/thoughtcrime/securesms/mms/TextTransport.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright (C) 2011 Whisper Systems
- * Copyright (C) 2014 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 .
- */
-package org.thoughtcrime.securesms.mms;
-
-import org.thoughtcrime.securesms.util.Base64;
-
-import java.io.IOException;
-
-
-public class TextTransport {
-
- public byte[] getDecodedMessage(byte[] encodedMessageBytes) throws IOException {
- return Base64.decode(encodedMessageBytes);
- }
-
- public byte[] getEncodedMessage(byte[] messageWithMac) {
- return Base64.encodeBytes(messageWithMac).getBytes();
- }
-}
diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/widgets/ProfilePreference.java b/app/src/main/java/org/thoughtcrime/securesms/preferences/widgets/ProfilePreference.java
deleted file mode 100644
index f6c15d2ac5..0000000000
--- a/app/src/main/java/org/thoughtcrime/securesms/preferences/widgets/ProfilePreference.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package org.thoughtcrime.securesms.preferences.widgets;
-
-
-import android.content.ClipData;
-import android.content.ClipboardManager;
-import android.content.Context;
-import android.graphics.Outline;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewOutlineProvider;
-import android.widget.ImageView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.RequiresApi;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceViewHolder;
-
-import com.bumptech.glide.load.engine.DiskCacheStrategy;
-
-import org.thoughtcrime.securesms.database.Address;
-import org.thoughtcrime.securesms.mms.GlideApp;
-import org.thoughtcrime.securesms.recipients.Recipient;
-import org.thoughtcrime.securesms.util.TextSecurePreferences;
-
-import network.loki.messenger.R;
-
-public class ProfilePreference extends Preference {
-
- private View containerView;
- private ImageView avatarView;
- private TextView profileNameView;
- private TextView profileNumberView;
- private TextView profileTagView;
- private String shortDeviceMnemonic;
-
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
- public ProfilePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- initialize();
- }
-
- public ProfilePreference(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- initialize();
- }
-
- public ProfilePreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- initialize();
- }
-
- public ProfilePreference(Context context) {
- super(context);
- initialize();
- }
-
- private void initialize() {
- setLayoutResource(R.layout.profile_preference_view);
- }
-
- @Override
- public void onBindViewHolder(PreferenceViewHolder viewHolder) {
- super.onBindViewHolder(viewHolder);
-
- containerView = viewHolder.itemView;
- avatarView = (ImageView)viewHolder.findViewById(R.id.avatar);
- profileNameView = (TextView)viewHolder.findViewById(R.id.profile_name);
- profileNumberView = (TextView)viewHolder.findViewById(R.id.number);
- profileTagView = (TextView)viewHolder.findViewById(R.id.tag);
-
- refresh();
- }
-
- public void refresh() {
- if (profileNumberView == null) return;
-
- Context context = getContext();
- String userPublicKey = TextSecurePreferences.getLocalNumber(context);
- String userMasterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
- String publicKeyToUse = userMasterPublicKey != null ? userMasterPublicKey : userPublicKey;
- final Address address = Address.fromSerialized(publicKeyToUse);
- final Recipient recipient = Recipient.from(context, address, false);
- final String displayName = TextSecurePreferences.getProfileName(context);
-
- containerView.setOnLongClickListener(v -> {
- ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
- ClipData clip = ClipData.newPlainText("Public Key", publicKeyToUse);
- clipboard.setPrimaryClip(clip);
- Toast.makeText(context, R.string.activity_settings_public_key_copied_message, Toast.LENGTH_SHORT).show();
- return true;
- });
-
- avatarView.setOutlineProvider(new ViewOutlineProvider() {
-
- @Override
- public void getOutline(View view, Outline outline) {
- outline.setOval(0, 0, view.getWidth(), view.getHeight());
- }
- });
- avatarView.setClipToOutline(true);
-
- Drawable fallback = recipient.getFallbackContactPhotoDrawable(context, false);
- GlideApp.with(getContext().getApplicationContext())
- .load(recipient.getContactPhoto())
- .fallback(fallback)
- .error(fallback)
- .circleCrop()
- .diskCacheStrategy(DiskCacheStrategy.ALL)
- .into(avatarView);
-
-
- if (!TextUtils.isEmpty(displayName)) {
- profileNameView.setText(displayName);
- }
-
- profileNameView.setVisibility(TextUtils.isEmpty(displayName) ? View.GONE : View.VISIBLE);
- profileNumberView.setText(address.toPhoneString());
-
- profileTagView.setVisibility(userMasterPublicKey == null ? View.GONE : View.VISIBLE);
-
- if (userMasterPublicKey != null && shortDeviceMnemonic == null) {
- shortDeviceMnemonic = "";
- }
-
- String tag = context.getResources().getString(R.string.activity_settings_linked_device_tag);
- profileTagView.setText(String.format(tag, shortDeviceMnemonic != null ? shortDeviceMnemonic : "-"));
- }
-}
diff --git a/app/src/main/java/org/thoughtcrime/securesms/profiles/SystemProfileUtil.java b/app/src/main/java/org/thoughtcrime/securesms/profiles/SystemProfileUtil.java
deleted file mode 100644
index b75012e246..0000000000
--- a/app/src/main/java/org/thoughtcrime/securesms/profiles/SystemProfileUtil.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package org.thoughtcrime.securesms.profiles;
-
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.provider.ContactsContract;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import android.text.TextUtils;
-import org.thoughtcrime.securesms.logging.Log;
-
-import org.thoughtcrime.securesms.mms.MediaConstraints;
-import org.thoughtcrime.securesms.util.BitmapDecodingException;
-import org.thoughtcrime.securesms.util.BitmapUtil;
-import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
-import org.thoughtcrime.securesms.util.concurrent.SettableFuture;
-
-public class SystemProfileUtil {
-
- private static final String TAG = SystemProfileUtil.class.getSimpleName();
-
- @SuppressLint("StaticFieldLeak")
- public static ListenableFuture getSystemProfileAvatar(final @NonNull Context context, MediaConstraints mediaConstraints) {
- SettableFuture future = new SettableFuture<>();
-
- new AsyncTask() {
- @Override
- protected @Nullable byte[] doInBackground(Void... params) {
- try (Cursor cursor = context.getContentResolver().query(ContactsContract.Profile.CONTENT_URI, null, null, null, null)) {
- while (cursor != null && cursor.moveToNext()) {
- String photoUri = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Profile.PHOTO_URI));
-
- if (!TextUtils.isEmpty(photoUri)) {
- try {
- BitmapUtil.ScaleResult result = BitmapUtil.createScaledBytes(context, Uri.parse(photoUri), mediaConstraints);
- return result.getBitmap();
- } catch (BitmapDecodingException e) {
- Log.w(TAG, e);
- }
- }
- }
- } catch (SecurityException se) {
- Log.w(TAG, se);
- }
-
- return null;
- }
-
- @Override
- protected void onPostExecute(@Nullable byte[] result) {
- future.set(result);
- }
-
- }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
-
- return future;
- }
-
- @SuppressLint("StaticFieldLeak")
- public static ListenableFuture getSystemProfileName(final @NonNull Context context) {
- SettableFuture future = new SettableFuture<>();
-
- new AsyncTask() {
- @Override
- protected String doInBackground(Void... params) {
- String name = null;
-
- try (Cursor cursor = context.getContentResolver().query(ContactsContract.Profile.CONTENT_URI, null, null, null, null)) {
- if (cursor != null && cursor.moveToNext()) {
- name = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Profile.DISPLAY_NAME));
- }
- } catch (SecurityException se) {
- Log.w(TAG, se);
- }
-
- if (name == null) {
- AccountManager accountManager = AccountManager.get(context);
- Account[] accounts = accountManager.getAccountsByType("com.google");
-
- for (Account account : accounts) {
- if (!TextUtils.isEmpty(account.name)) {
- if (account.name.contains("@")) {
- name = account.name.substring(0, account.name.indexOf("@")).replace('.', ' ');
- } else {
- name = account.name.replace('.', ' ');
- }
-
- break;
- }
- }
- }
-
- return name;
- }
-
- @Override
- protected void onPostExecute(@Nullable String result) {
- future.set(result);
- }
- }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
-
- return future;
- }
-
-
-}
diff --git a/app/src/main/res/layout/profile_create_activity.xml b/app/src/main/res/layout/profile_create_activity.xml
deleted file mode 100644
index 7c5178d5a3..0000000000
--- a/app/src/main/res/layout/profile_create_activity.xml
+++ /dev/null
@@ -1,183 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
deleted file mode 100644
index 0710e1f03a..0000000000
--- a/app/src/main/res/xml/preferences.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-