mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Display user profile information in settings activity
Allow for editing // FREEBIE
This commit is contained in:
parent
df99deb480
commit
c11f2eddf5
@ -388,6 +388,18 @@
|
|||||||
android:theme="@style/TextSecure.LightTheme"
|
android:theme="@style/TextSecure.LightTheme"
|
||||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
|
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
|
||||||
|
|
||||||
|
<activity android:name=".ClearProfileAvatarActivity"
|
||||||
|
android:theme="@style/Theme.AppCompat.Dialog.Alert"
|
||||||
|
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
|
||||||
|
android:icon="@drawable/clear_profile_avatar"
|
||||||
|
android:label="@string/AndroidManifest_remove_photo">
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="org.thoughtcrime.securesms.action.CLEAR_PROFILE_PHOTO"/>
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<service android:enabled="true" android:name="org.thoughtcrime.securesms.service.WebRtcCallService"/>
|
<service android:enabled="true" android:name="org.thoughtcrime.securesms.service.WebRtcCallService"/>
|
||||||
|
|
||||||
<service android:enabled="true" android:name=".service.ApplicationMigrationService"/>
|
<service android:enabled="true" android:name=".service.ApplicationMigrationService"/>
|
||||||
|
BIN
res/drawable-hdpi/clear_profile_avatar.png
Normal file
BIN
res/drawable-hdpi/clear_profile_avatar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 851 B |
BIN
res/drawable-mdpi/clear_profile_avatar.png
Normal file
BIN
res/drawable-mdpi/clear_profile_avatar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 690 B |
BIN
res/drawable-xhdpi/clear_profile_avatar.png
Normal file
BIN
res/drawable-xhdpi/clear_profile_avatar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
res/drawable-xxhdpi/clear_profile_avatar.png
Normal file
BIN
res/drawable-xxhdpi/clear_profile_avatar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
res/drawable-xxxhdpi/clear_profile_avatar.png
Normal file
BIN
res/drawable-xxxhdpi/clear_profile_avatar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
<ImageView android:id="@+id/avatar"
|
<ImageView android:id="@+id/avatar"
|
||||||
android:layout_width="64dp"
|
android:layout_width="64dp"
|
||||||
android:layout_height="64dp"/>
|
android:layout_height="64dp"
|
||||||
|
android:transitionName="avatar"/>
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
|
<org.thoughtcrime.securesms.components.emoji.EmojiEditText
|
||||||
android:id="@+id/name"
|
android:id="@+id/name"
|
||||||
|
35
res/layout/profile_preference_view.xml
Normal file
35
res/layout/profile_preference_view.xml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/avatar"
|
||||||
|
android:layout_width="64dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:transitionName="avatar"/>
|
||||||
|
|
||||||
|
<LinearLayout android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginStart="10dp">
|
||||||
|
|
||||||
|
<TextView android:id="@+id/profile_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
tools:text="Voltarine DeClyre"/>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/number"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:text="+14151231234"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -73,6 +73,10 @@
|
|||||||
<!-- CallScreen -->
|
<!-- CallScreen -->
|
||||||
<string name="CallScreen_Incoming_call">Incoming call</string>
|
<string name="CallScreen_Incoming_call">Incoming call</string>
|
||||||
|
|
||||||
|
<!-- ClearProfileActivity -->
|
||||||
|
<string name="ClearProfileActivity_remove">Remove</string>
|
||||||
|
<string name="ClearProfileActivity_remove_profile_photo">Remove profile photo?</string>
|
||||||
|
|
||||||
<!-- ConfirmIdentityDialog -->
|
<!-- ConfirmIdentityDialog -->
|
||||||
<string name="ConfirmIdentityDialog_your_safety_number_with_s_has_changed">Your safety number with %1$s has changed. This could either mean that someone is trying to intercept your communication, or that %2$s simply reinstalled Signal.</string>
|
<string name="ConfirmIdentityDialog_your_safety_number_with_s_has_changed">Your safety number with %1$s has changed. This could either mean that someone is trying to intercept your communication, or that %2$s simply reinstalled Signal.</string>
|
||||||
<string name="ConfirmIdentityDialog_you_may_wish_to_verify_your_safety_number_with_this_contact">You may wish to verify your safety number with this contact.</string>
|
<string name="ConfirmIdentityDialog_you_may_wish_to_verify_your_safety_number_with_this_contact">You may wish to verify your safety number with this contact.</string>
|
||||||
@ -613,6 +617,14 @@
|
|||||||
<string name="UpdateApkReadyListener_Signal_update">Signal update</string>
|
<string name="UpdateApkReadyListener_Signal_update">Signal update</string>
|
||||||
<string name="UpdateApkReadyListener_a_new_version_of_signal_is_available_tap_to_update">A new version of Signal is available, tap to update</string>
|
<string name="UpdateApkReadyListener_a_new_version_of_signal_is_available_tap_to_update">A new version of Signal is available, tap to update</string>
|
||||||
|
|
||||||
|
<!-- UntrustedSendDialog -->
|
||||||
|
<string name="UntrustedSendDialog_send_message">Send message?</string>
|
||||||
|
<string name="UntrustedSendDialog_send">Send</string>
|
||||||
|
|
||||||
|
<!-- UnverifiedSendDialog -->
|
||||||
|
<string name="UnverifiedSendDialog_send_message">Send message?</string>
|
||||||
|
<string name="UnverifiedSendDialog_send">Send</string>
|
||||||
|
|
||||||
<!-- VerifyIdentityActivity -->
|
<!-- VerifyIdentityActivity -->
|
||||||
<string name="VerifyIdentityActivity_your_contact_is_running_an_old_version_of_signal">Your contact is running an old version of Signal. Please ask them to update before verifying your safety number.</string>
|
<string name="VerifyIdentityActivity_your_contact_is_running_an_old_version_of_signal">Your contact is running an old version of Signal. Please ask them to update before verifying your safety number.</string>
|
||||||
<string name="VerifyIdentityActivity_your_contact_is_running_a_newer_version_of_Signal">Your contact is running a newer version of Signal with an incompatible QR code format. Please update to compare.</string>
|
<string name="VerifyIdentityActivity_your_contact_is_running_a_newer_version_of_Signal">Your contact is running a newer version of Signal with an incompatible QR code format. Please update to compare.</string>
|
||||||
@ -1087,6 +1099,7 @@
|
|||||||
<string name="AndroidManifest__linked_devices">Linked devices</string>
|
<string name="AndroidManifest__linked_devices">Linked devices</string>
|
||||||
<string name="AndroidManifest__invite_friends">Invite friends</string>
|
<string name="AndroidManifest__invite_friends">Invite friends</string>
|
||||||
<string name="AndroidManifest_archived_conversations">Archived conversations</string>
|
<string name="AndroidManifest_archived_conversations">Archived conversations</string>
|
||||||
|
<string name="AndroidManifest_remove_photo">Remove photo</string>
|
||||||
|
|
||||||
<!-- arrays.xml -->
|
<!-- arrays.xml -->
|
||||||
<string name="arrays__import_export">Import / export</string>
|
<string name="arrays__import_export">Import / export</string>
|
||||||
@ -1409,10 +1422,7 @@
|
|||||||
|
|
||||||
<!-- transport_selection_list_item -->
|
<!-- transport_selection_list_item -->
|
||||||
<string name="transport_selection_list_item__transport_icon">Transport icon</string>
|
<string name="transport_selection_list_item__transport_icon">Transport icon</string>
|
||||||
<string name="UntrustedSendDialog_send_message">Send message?</string>
|
|
||||||
<string name="UntrustedSendDialog_send">Send</string>
|
|
||||||
<string name="UnverifiedSendDialog_send_message">Send message?</string>
|
|
||||||
<string name="UnverifiedSendDialog_send">Send</string>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- EOF -->
|
<!-- EOF -->
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<org.thoughtcrime.securesms.preferences.ProfilePreference
|
||||||
|
android:key="preference_category_profile"/>
|
||||||
|
|
||||||
<Preference android:key="preference_category_sms_mms"
|
<Preference android:key="preference_category_sms_mms"
|
||||||
android:title="@string/preferences__sms_mms"
|
android:title="@string/preferences__sms_mms"
|
||||||
android:icon="@drawable/ic_textsms_24dp"/>
|
android:icon="@drawable/ic_textsms_24dp"/>
|
||||||
|
@ -34,6 +34,7 @@ import android.support.v4.app.FragmentManager;
|
|||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.preferences.AdvancedPreferenceFragment;
|
import org.thoughtcrime.securesms.preferences.AdvancedPreferenceFragment;
|
||||||
@ -60,6 +61,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
|||||||
{
|
{
|
||||||
private static final String TAG = ApplicationPreferencesActivity.class.getSimpleName();
|
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_SMS_MMS = "preference_category_sms_mms";
|
||||||
private static final String PREFERENCE_CATEGORY_NOTIFICATIONS = "preference_category_notifications";
|
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_APP_PROTECTION = "preference_category_app_protection";
|
||||||
@ -138,6 +140,8 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
|||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
|
|
||||||
MasterSecret masterSecret = getArguments().getParcelable("master_secret");
|
MasterSecret masterSecret = getArguments().getParcelable("master_secret");
|
||||||
|
this.findPreference(PREFERENCE_CATEGORY_PROFILE)
|
||||||
|
.setOnPreferenceClickListener(new ProfileClickListener());
|
||||||
this.findPreference(PREFERENCE_CATEGORY_SMS_MMS)
|
this.findPreference(PREFERENCE_CATEGORY_SMS_MMS)
|
||||||
.setOnPreferenceClickListener(new CategoryClickListener(masterSecret, PREFERENCE_CATEGORY_SMS_MMS));
|
.setOnPreferenceClickListener(new CategoryClickListener(masterSecret, PREFERENCE_CATEGORY_SMS_MMS));
|
||||||
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS)
|
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS)
|
||||||
@ -273,5 +277,17 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
|||||||
return true;
|
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);
|
||||||
|
|
||||||
|
((BaseActionBarActivity)getActivity()).startActivitySceneTransition(intent, getActivity().findViewById(R.id.avatar), "avatar");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
|
|
||||||
|
public class ClearProfileAvatarActivity extends Activity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
new AlertDialog.Builder(this)
|
||||||
|
.setTitle(R.string.ClearProfileActivity_remove_profile_photo)
|
||||||
|
.setNegativeButton(android.R.string.cancel, (dialog, which) -> finish())
|
||||||
|
.setPositiveButton(R.string.ClearProfileActivity_remove, (dialog, which) -> {
|
||||||
|
Intent result = new Intent();
|
||||||
|
result.putExtra("delete", true);
|
||||||
|
setResult(Activity.RESULT_OK, result);
|
||||||
|
finish();
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -53,6 +53,8 @@ import org.whispersystems.signalservice.api.util.StreamDetails;
|
|||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -63,6 +65,9 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
|
|
||||||
private static final String TAG = CreateProfileActivity.class.getSimpleName();
|
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 static final int REQUEST_CODE_AVATAR = 1;
|
private static final int REQUEST_CODE_AVATAR = 1;
|
||||||
|
|
||||||
@Inject SignalServiceAccountManager accountManager;
|
@Inject SignalServiceAccountManager accountManager;
|
||||||
@ -74,8 +79,9 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
private EmojiToggle emojiToggle;
|
private EmojiToggle emojiToggle;
|
||||||
private EmojiDrawer emojiDrawer;
|
private EmojiDrawer emojiDrawer;
|
||||||
|
|
||||||
|
private Intent nextIntent;
|
||||||
private byte[] avatarBytes;
|
private byte[] avatarBytes;
|
||||||
private File captureFile;
|
private File captureFile;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle bundle, @NonNull MasterSecret masterSecret) {
|
public void onCreate(Bundle bundle, @NonNull MasterSecret masterSecret) {
|
||||||
@ -88,8 +94,8 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
|
|
||||||
initializeResources();
|
initializeResources();
|
||||||
initializeEmojiInput();
|
initializeEmojiInput();
|
||||||
initializeProfileName();
|
initializeProfileName(getIntent().getBooleanExtra(EXCLUDE_SYSTEM, false));
|
||||||
initializeProfileAvatar();
|
initializeProfileAvatar(getIntent().getBooleanExtra(EXCLUDE_SYSTEM, false));
|
||||||
|
|
||||||
ApplicationContext.getInstance(this).injectDependencies(this);
|
ApplicationContext.getInstance(this).injectDependencies(this);
|
||||||
}
|
}
|
||||||
@ -123,7 +129,13 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
inputFile = Uri.fromFile(captureFile);
|
inputFile = Uri.fromFile(captureFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
new Crop(inputFile).output(outputFile).asSquare().start(this);
|
if (data.getBooleanExtra("delete", false)) {
|
||||||
|
avatarBytes = null;
|
||||||
|
avatar.setImageDrawable(ContactPhotoFactory.getResourceContactPhoto(R.drawable.ic_camera_alt_white_24dp)
|
||||||
|
.asDrawable(this, getResources().getColor(R.color.grey_400)));
|
||||||
|
} else {
|
||||||
|
new Crop(inputFile).output(outputFile).asSquare().start(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -148,6 +160,7 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
this.emojiDrawer = ViewUtil.findById(this, R.id.emoji_drawer);
|
this.emojiDrawer = ViewUtil.findById(this, R.id.emoji_drawer);
|
||||||
this.container = ViewUtil.findById(this, R.id.container);
|
this.container = ViewUtil.findById(this, R.id.container);
|
||||||
this.finishButton = ViewUtil.findById(this, R.id.finish_button);
|
this.finishButton = ViewUtil.findById(this, R.id.finish_button);
|
||||||
|
this.nextIntent = getIntent().getParcelableExtra(NEXT_INTENT);
|
||||||
|
|
||||||
this.avatar.setImageDrawable(ContactPhotoFactory.getResourceContactPhoto(R.drawable.ic_camera_alt_white_24dp)
|
this.avatar.setImageDrawable(ContactPhotoFactory.getResourceContactPhoto(R.drawable.ic_camera_alt_white_24dp)
|
||||||
.asDrawable(this, getResources().getColor(R.color.grey_400)));
|
.asDrawable(this, getResources().getColor(R.color.grey_400)));
|
||||||
@ -160,7 +173,7 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
captureFile = null;
|
captureFile = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent chooserIntent = createAvatarSelectionIntent(captureFile);
|
Intent chooserIntent = createAvatarSelectionIntent(captureFile, avatarBytes != null);
|
||||||
startActivityForResult(chooserIntent, REQUEST_CODE_AVATAR);
|
startActivityForResult(chooserIntent, REQUEST_CODE_AVATAR);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -169,13 +182,13 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeProfileName() {
|
private void initializeProfileName(boolean excludeSystem) {
|
||||||
if (!TextUtils.isEmpty(TextSecurePreferences.getProfileName(this))) {
|
if (!TextUtils.isEmpty(TextSecurePreferences.getProfileName(this))) {
|
||||||
String profileName = TextSecurePreferences.getProfileName(this);
|
String profileName = TextSecurePreferences.getProfileName(this);
|
||||||
|
|
||||||
name.setText(profileName);
|
name.setText(profileName);
|
||||||
name.setSelection(profileName.length(), profileName.length());
|
name.setSelection(profileName.length(), profileName.length());
|
||||||
} else {
|
} else if (!excludeSystem) {
|
||||||
SystemProfileUtil.getSystemProfileName(this).addListener(new ListenableFuture.Listener<String>() {
|
SystemProfileUtil.getSystemProfileName(this).addListener(new ListenableFuture.Listener<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String result) {
|
public void onSuccess(String result) {
|
||||||
@ -193,7 +206,7 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeProfileAvatar() {
|
private void initializeProfileAvatar(boolean excludeSystem) {
|
||||||
Address ourAddress = Address.fromSerialized(TextSecurePreferences.getLocalNumber(this));
|
Address ourAddress = Address.fromSerialized(TextSecurePreferences.getLocalNumber(this));
|
||||||
|
|
||||||
if (AvatarHelper.getAvatarFile(this, ourAddress).exists() && AvatarHelper.getAvatarFile(this, ourAddress).length() > 0) {
|
if (AvatarHelper.getAvatarFile(this, ourAddress).exists() && AvatarHelper.getAvatarFile(this, ourAddress).length() > 0) {
|
||||||
@ -217,7 +230,7 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
} else {
|
} else if (!excludeSystem) {
|
||||||
SystemProfileUtil.getSystemProfileAvatar(this, new ProfileMediaConstraints()).addListener(new ListenableFuture.Listener<byte[]>() {
|
SystemProfileUtil.getSystemProfileAvatar(this, new ProfileMediaConstraints()).addListener(new ListenableFuture.Listener<byte[]>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(byte[] result) {
|
public void onSuccess(byte[] result) {
|
||||||
@ -266,8 +279,9 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
this.name.setOnClickListener(v -> container.showSoftkey(name));
|
this.name.setOnClickListener(v -> container.showSoftkey(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Intent createAvatarSelectionIntent(@Nullable File captureFile) {
|
private Intent createAvatarSelectionIntent(@Nullable File captureFile, boolean includeClear) {
|
||||||
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
|
List<Intent> extraIntents = new LinkedList<>();
|
||||||
|
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
|
||||||
galleryIntent.setType("image/*");
|
galleryIntent.setType("image/*");
|
||||||
|
|
||||||
if (!IntentUtils.isResolvable(CreateProfileActivity.this, galleryIntent)) {
|
if (!IntentUtils.isResolvable(CreateProfileActivity.this, galleryIntent)) {
|
||||||
@ -276,23 +290,23 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
}
|
}
|
||||||
|
|
||||||
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
cameraIntent.putExtra(EXTRA_OUTPUT, Uri.fromFile(captureFile));
|
||||||
|
|
||||||
if (captureFile != null && cameraIntent.resolveActivity(getPackageManager()) != null) {
|
if (captureFile != null && cameraIntent.resolveActivity(getPackageManager()) != null) {
|
||||||
cameraIntent.putExtra(EXTRA_OUTPUT, Uri.fromFile(captureFile));
|
extraIntents.add(cameraIntent);
|
||||||
} else {
|
}
|
||||||
cameraIntent = null;
|
|
||||||
|
if (includeClear) {
|
||||||
|
extraIntents.add(new Intent("org.thoughtcrime.securesms.action.CLEAR_PROFILE_PHOTO"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.CreateProfileActivity_profile_photo));
|
Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.CreateProfileActivity_profile_photo));
|
||||||
|
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents.toArray(new Intent[0]));
|
||||||
|
|
||||||
if (cameraIntent != null) {
|
|
||||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] {cameraIntent});
|
|
||||||
}
|
|
||||||
|
|
||||||
return chooserIntent;
|
return chooserIntent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void handleUpload() {
|
private void handleUpload() {
|
||||||
final String name;
|
final String name;
|
||||||
final StreamDetails avatar;
|
final StreamDetails avatar;
|
||||||
@ -342,7 +356,8 @@ public class CreateProfileActivity extends PassphraseRequiredActionBarActivity i
|
|||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
if (captureFile != null) captureFile.delete();
|
if (captureFile != null) captureFile.delete();
|
||||||
startActivity(new Intent(CreateProfileActivity.this, ConversationListActivity.class));
|
if (nextIntent != null) startActivity(nextIntent);
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(CreateProfileActivity.this, R.string.CreateProfileActivity_problem_setting_profile, Toast.LENGTH_LONG).show();
|
Toast.makeText(CreateProfileActivity.this, R.string.CreateProfileActivity_problem_setting_profile, Toast.LENGTH_LONG).show();
|
||||||
|
@ -342,7 +342,9 @@ public class RegistrationProgressActivity extends BaseActionBarActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shutdownService();
|
shutdownService();
|
||||||
startActivity(new Intent(this, CreateProfileActivity.class));
|
Intent intent = new Intent(this, CreateProfileActivity.class);
|
||||||
|
intent.putExtra(CreateProfileActivity.NEXT_INTENT, new Intent(this, ConversationListActivity.class));
|
||||||
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
package org.thoughtcrime.securesms.preferences;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.support.annotation.RequiresApi;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
|
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||||
|
import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory;
|
||||||
|
import org.thoughtcrime.securesms.database.Address;
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
|
|
||||||
|
public class ProfilePreference extends Preference {
|
||||||
|
|
||||||
|
@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
|
||||||
|
protected void onBindView(View view) {
|
||||||
|
super.onBindView(view);
|
||||||
|
|
||||||
|
final ImageView avatar = ViewUtil.findById(view, R.id.avatar);
|
||||||
|
final TextView profileName = ViewUtil.findById(view, R.id.profile_name);
|
||||||
|
final TextView profileNumber = ViewUtil.findById(view, R.id.number);
|
||||||
|
final Address localAddress = Address.fromSerialized(TextSecurePreferences.getLocalNumber(getContext()));
|
||||||
|
|
||||||
|
new AsyncTask<Void, Void, ContactPhoto>() {
|
||||||
|
@Override
|
||||||
|
protected ContactPhoto doInBackground(Void... params) {
|
||||||
|
return ContactPhotoFactory.getSignalAvatarContactPhoto(getContext(), localAddress, null, getContext().getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(ContactPhoto contactPhoto) {
|
||||||
|
avatar.setImageDrawable(contactPhoto.asDrawable(getContext(), 0));
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(TextSecurePreferences.getProfileName(getContext()))) {
|
||||||
|
profileName.setText(TextSecurePreferences.getProfileName(getContext()));
|
||||||
|
}
|
||||||
|
|
||||||
|
profileNumber.setText(localAddress.toPhoneString());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user