mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
Fix profile out of memory errors on low mem devices
Fixes #7094 // FREEBIE
This commit is contained in:
parent
4bd3094bad
commit
5711adb2c9
@ -13,7 +13,7 @@
|
|||||||
<dimen name="transport_selection_popup_width">200sp</dimen>
|
<dimen name="transport_selection_popup_width">200sp</dimen>
|
||||||
<dimen name="transport_selection_popup_xoff">2dp</dimen>
|
<dimen name="transport_selection_popup_xoff">2dp</dimen>
|
||||||
<dimen name="transport_selection_popup_yoff">2dp</dimen>
|
<dimen name="transport_selection_popup_yoff">2dp</dimen>
|
||||||
<dimen name="contact_photo_target_size">300dp</dimen>
|
<dimen name="contact_photo_target_size">64dp</dimen>
|
||||||
<dimen name="contact_selection_photo_size">50dp</dimen>
|
<dimen name="contact_selection_photo_size">50dp</dimen>
|
||||||
<dimen name="thumbnail_max_size">230dp</dimen>
|
<dimen name="thumbnail_max_size">230dp</dimen>
|
||||||
<dimen name="preference_fragment_padding_side">8dp</dimen>
|
<dimen name="preference_fragment_padding_side">8dp</dimen>
|
||||||
|
@ -13,6 +13,7 @@ import android.net.Uri;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.provider.ContactsContract;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
@ -26,6 +27,7 @@ import android.support.v7.preference.ListPreference;
|
|||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceCategory;
|
import android.support.v7.preference.PreferenceCategory;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -37,6 +39,7 @@ import org.thoughtcrime.securesms.color.MaterialColor;
|
|||||||
import org.thoughtcrime.securesms.color.MaterialColors;
|
import org.thoughtcrime.securesms.color.MaterialColors;
|
||||||
import org.thoughtcrime.securesms.components.ThreadPhotoRailView;
|
import org.thoughtcrime.securesms.components.ThreadPhotoRailView;
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||||
|
import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory;
|
||||||
import org.thoughtcrime.securesms.crypto.IdentityKeyParcelable;
|
import org.thoughtcrime.securesms.crypto.IdentityKeyParcelable;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.database.Address;
|
import org.thoughtcrime.securesms.database.Address;
|
||||||
@ -205,15 +208,29 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setHeader(@NonNull Recipient recipient) {
|
private void setHeader(@NonNull Recipient recipient) {
|
||||||
ContactPhoto contactPhoto = recipient.getContactPhoto();
|
new AsyncTask<Void, Void, ContactPhoto>() {
|
||||||
|
@Override
|
||||||
|
protected @NonNull ContactPhoto doInBackground(Void... params) {
|
||||||
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
|
WindowManager windowManager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
|
||||||
|
Uri contentUri = ContactsContract.Contacts.lookupContact(getContentResolver(), recipient.getContactUri());
|
||||||
|
windowManager.getDefaultDisplay().getMetrics(metrics);
|
||||||
|
|
||||||
if (contactPhoto.isGenerated() || contactPhoto.isResource()) this.avatar.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
return ContactPhotoFactory.getContactPhoto(RecipientPreferenceActivity.this, contentUri,
|
||||||
else this.avatar.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
recipient.getAddress(), recipient.getName(),
|
||||||
|
metrics.widthPixels);
|
||||||
|
}
|
||||||
|
|
||||||
this.avatar.setImageDrawable(contactPhoto.asCallCard(this));
|
protected void onPostExecute(@NonNull ContactPhoto contactPhoto) {
|
||||||
this.avatar.setBackgroundColor(recipient.getColor().toActionBarColor(this));
|
if (contactPhoto.isGenerated() || contactPhoto.isResource()) avatar.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||||
this.toolbarLayout.setTitle(recipient.toShortString());
|
else avatar.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
this.toolbarLayout.setContentScrimColor(recipient.getColor().toActionBarColor(this));
|
|
||||||
|
avatar.setImageDrawable(contactPhoto.asCallCard(RecipientPreferenceActivity.this));
|
||||||
|
avatar.setBackgroundColor(recipient.getColor().toActionBarColor(RecipientPreferenceActivity.this));
|
||||||
|
toolbarLayout.setTitle(recipient.toShortString());
|
||||||
|
toolbarLayout.setContentScrimColor(recipient.getColor().toActionBarColor(RecipientPreferenceActivity.this));
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user