diff options
author | steckbrief <steckbrief@chefmail.de> | 2017-08-06 01:15:13 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2017-08-06 01:15:13 +0200 |
commit | 867afe4c5b888ce3f4f9a867906cc8edb86e7aba (patch) | |
tree | 82d17b5fcb4471ae884a548fa815a653cb00e000 /src/main/java/de/thedevstack/conversationsplus/ui | |
parent | 6f588444a953a54543661f7603d45a9093b7196a (diff) |
avatar handling refactored
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/ui')
9 files changed, 28 insertions, 24 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ConferenceDetailsActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/ConferenceDetailsActivity.java index 2a3cd7fe..7ea83b92 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/ConferenceDetailsActivity.java @@ -41,7 +41,8 @@ import de.thedevstack.conversationsplus.entities.Contact; import de.thedevstack.conversationsplus.entities.Conversation; import de.thedevstack.conversationsplus.entities.MucOptions; import de.thedevstack.conversationsplus.entities.MucOptions.User; -import de.thedevstack.conversationsplus.services.AvatarService; +import de.thedevstack.conversationsplus.services.avatar.AvatarCache; +import de.thedevstack.conversationsplus.services.avatar.AvatarService; import de.thedevstack.conversationsplus.services.XmppConnectionService; import de.thedevstack.conversationsplus.services.XmppConnectionService.OnConversationUpdate; import de.thedevstack.conversationsplus.services.XmppConnectionService.OnMucRosterUpdate; @@ -528,7 +529,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers account = mConversation.getAccount().getJid().toBareJid().toString(); } mAccountJid.setText(getString(R.string.using_account, account)); - mYourPhoto.setImageBitmap(AvatarService.getInstance().get(mConversation.getAccount(), getPixel(48))); + mYourPhoto.setImageBitmap(AvatarCache.get(mConversation.getAccount(), getPixel(48))); setTitle(mConversation.getName()); if (Config.LOCK_DOMAINS_IN_CONVERSATIONS && mConversation.getJid().getDomainpart().equals(Config.CONFERENCE_DOMAIN_LOCK)) { mFullJid.setText(mConversation.getJid().getLocalpart()); @@ -622,7 +623,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } ImageView iv = (ImageView) view.findViewById(R.id.contact_photo); - iv.setImageBitmap(AvatarService.getInstance().get(user, getPixel(48), false)); + iv.setImageBitmap(AvatarCache.get(user, getPixel(48), false)); membersView.addView(view); if (mConversation.getMucOptions().canInvite()) { mInviteButton.setVisibility(View.VISIBLE); diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ContactDetailsActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/ContactDetailsActivity.java index 6577c9ce..be6a5994 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/ContactDetailsActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/ContactDetailsActivity.java @@ -34,6 +34,7 @@ import java.util.List; import de.thedevstack.conversationsplus.ConversationsPlusPreferences; import de.thedevstack.conversationsplus.generator.PresenceGenerator; +import de.thedevstack.conversationsplus.services.avatar.AvatarCache; import de.thedevstack.conversationsplus.ui.listeners.ShowResourcesListDialogListener; import de.thedevstack.conversationsplus.Config; import de.thedevstack.conversationsplus.R; @@ -43,7 +44,7 @@ import de.thedevstack.conversationsplus.crypto.axolotl.XmppAxolotlSession; import de.thedevstack.conversationsplus.entities.Account; import de.thedevstack.conversationsplus.entities.Contact; import de.thedevstack.conversationsplus.entities.ListItem; -import de.thedevstack.conversationsplus.services.AvatarService; +import de.thedevstack.conversationsplus.services.avatar.AvatarService; import de.thedevstack.conversationsplus.services.XmppConnectionService.OnAccountUpdate; import de.thedevstack.conversationsplus.services.XmppConnectionService.OnRosterUpdate; import de.thedevstack.conversationsplus.utils.CryptoHelper; @@ -364,7 +365,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd } contactJidTv.setOnClickListener(new ShowResourcesListDialogListener(ContactDetailsActivity.this, contact)); accountJidTv.setText(getString(R.string.using_account, account)); - badge.setImageBitmap(AvatarService.getInstance().get(contact, getPixel(72))); + badge.setImageBitmap(AvatarCache.get(contact, getPixel(72))); badge.setOnClickListener(this.onBadgeClick); keys.removeAllViews(); diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/EditAccountActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/EditAccountActivity.java index 1a868949..1e81603f 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/EditAccountActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/EditAccountActivity.java @@ -5,7 +5,6 @@ import android.app.AlertDialog.Builder; import android.app.PendingIntent; import android.content.DialogInterface; import android.content.Intent; -import android.content.SharedPreferences; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; @@ -40,12 +39,13 @@ import java.util.concurrent.atomic.AtomicInteger; import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.ConversationsPlusPreferences; +import de.thedevstack.conversationsplus.services.avatar.AvatarCache; import de.thedevstack.conversationsplus.ui.listeners.ShowResourcesListDialogListener; import de.thedevstack.conversationsplus.Config; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.crypto.axolotl.AxolotlService; import de.thedevstack.conversationsplus.entities.Account; -import de.thedevstack.conversationsplus.services.AvatarService; +import de.thedevstack.conversationsplus.services.avatar.AvatarService; import de.thedevstack.conversationsplus.services.XmppConnectionService; import de.thedevstack.conversationsplus.services.XmppConnectionService.OnAccountUpdate; import de.thedevstack.conversationsplus.services.XmppConnectionService.OnCaptchaRequested; @@ -624,7 +624,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate if (!mInitMode) { this.mAvatar.setVisibility(View.VISIBLE); - this.mAvatar.setImageBitmap(AvatarService.getInstance().get(this.mAccount, getPixel(72))); + this.mAvatar.setImageBitmap(AvatarCache.get(this.mAccount, getPixel(72))); } else { this.mAvatar.setVisibility(View.GONE); } diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/PublishProfilePictureActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/PublishProfilePictureActivity.java index 6793d882..b41511de 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/PublishProfilePictureActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/PublishProfilePictureActivity.java @@ -4,7 +4,6 @@ import android.app.PendingIntent; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Bundle; import android.view.Menu; @@ -20,15 +19,14 @@ import android.widget.Toast; import com.soundcloud.android.crop.Crop; import java.io.File; -import java.io.FileNotFoundException; import de.thedevstack.conversationsplus.ConversationsPlusColors; +import de.thedevstack.conversationsplus.services.avatar.AvatarCache; import de.thedevstack.conversationsplus.utils.ImageUtil; import de.thedevstack.conversationsplus.Config; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.entities.Account; -import de.thedevstack.conversationsplus.services.AvatarService; -import de.thedevstack.conversationsplus.utils.ExifHelper; +import de.thedevstack.conversationsplus.services.avatar.AvatarService; import de.thedevstack.conversationsplus.utils.FileUtils; import de.thedevstack.conversationsplus.utils.PhoneHelper; import de.thedevstack.conversationsplus.utils.ui.TextViewUtil; @@ -236,7 +234,7 @@ public class PublishProfilePictureActivity extends XmppActivity { if (this.avatarUri == null) { if (this.account.getAvatar() != null || this.defaultUri == null) { - this.avatar.setImageBitmap(AvatarService.getInstance().get(account, getPixel(192))); + this.avatar.setImageBitmap(AvatarCache.get(account, getPixel(192))); if (this.defaultUri != null) { this.avatar .setOnLongClickListener(this.backToDefaultListener); diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/AccountAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/AccountAdapter.java index ee209576..960cb00d 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/AccountAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/AccountAdapter.java @@ -16,7 +16,8 @@ import de.thedevstack.conversationsplus.Config; import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.entities.Account; -import de.thedevstack.conversationsplus.services.AvatarService; +import de.thedevstack.conversationsplus.services.avatar.AvatarCache; +import de.thedevstack.conversationsplus.services.avatar.AvatarService; import de.thedevstack.conversationsplus.ui.ManageAccountActivity; import de.thedevstack.conversationsplus.ui.XmppActivity; @@ -45,7 +46,7 @@ public class AccountAdapter extends ArrayAdapter<Account> { } TextView statusView = (TextView) view.findViewById(R.id.account_status); ImageView imageView = (ImageView) view.findViewById(R.id.account_image); - imageView.setImageBitmap(AvatarService.getInstance().get(account, activity.getPixel(48))); + imageView.setImageBitmap(AvatarCache.get(account, activity.getPixel(48))); statusView.setText(getContext().getString(account.getStatus().getReadableId())); switch (account.getStatus()) { case ONLINE: diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java index 8388d449..e87cb052 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java @@ -23,7 +23,7 @@ import de.thedevstack.conversationsplus.entities.Account; import de.thedevstack.conversationsplus.entities.Conversation; import de.thedevstack.conversationsplus.entities.Message; import de.thedevstack.conversationsplus.entities.Transferable; -import de.thedevstack.conversationsplus.services.AvatarService; +import de.thedevstack.conversationsplus.services.avatar.AvatarService; import de.thedevstack.conversationsplus.ui.ConversationActivity; import de.thedevstack.conversationsplus.ui.XmppActivity; import de.thedevstack.conversationsplus.utils.UIHelper; diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ListItemAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ListItemAdapter.java index a67f5bcd..49d88712 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ListItemAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ListItemAdapter.java @@ -19,10 +19,11 @@ import java.util.List; import java.util.concurrent.RejectedExecutionException; import de.thedevstack.conversationsplus.ConversationsPlusPreferences; +import de.thedevstack.conversationsplus.services.avatar.AvatarCache; import de.tzur.conversations.Settings; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.entities.ListItem; -import de.thedevstack.conversationsplus.services.AvatarService; +import de.thedevstack.conversationsplus.services.avatar.AvatarService; import de.thedevstack.conversationsplus.ui.XmppActivity; import de.thedevstack.conversationsplus.utils.UIHelper; @@ -111,7 +112,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> { @Override protected Bitmap doInBackground(ListItem... params) { - return AvatarService.getInstance().get(params[0], activity.getPixel(48)); + return AvatarCache.get(params[0], activity.getPixel(48)); } @Override @@ -128,7 +129,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> { public void loadAvatar(ListItem item, ImageView imageView) { if (cancelPotentialWork(item, imageView)) { - final Bitmap bm = AvatarService.getInstance().get(item,activity.getPixel(48),true); + final Bitmap bm = AvatarCache.get(item,activity.getPixel(48),true); if (bm != null) { imageView.setImageBitmap(bm); imageView.setBackgroundColor(0x00000000); diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java index 3cf50925..4c2917e3 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java @@ -47,7 +47,8 @@ import de.thedevstack.conversationsplus.entities.Transferable; import de.thedevstack.conversationsplus.enums.FileStatus; import de.thedevstack.conversationsplus.persistance.FileBackend; import de.thedevstack.conversationsplus.providers.ConversationsPlusFileProvider; -import de.thedevstack.conversationsplus.services.AvatarService; +import de.thedevstack.conversationsplus.services.avatar.AvatarCache; +import de.thedevstack.conversationsplus.services.avatar.AvatarService; import de.thedevstack.conversationsplus.services.filetransfer.http.download.AutomaticFileDownload; import de.thedevstack.conversationsplus.ui.ConversationActivity; import de.thedevstack.conversationsplus.utils.CryptoHelper; @@ -511,7 +512,7 @@ public class MessageAdapter extends ArrayAdapter<Message> { viewHolder.status_message.setVisibility(View.VISIBLE); viewHolder.contact_picture.setVisibility(View.VISIBLE); if (conversation.getMode() == Conversation.MODE_SINGLE) { - viewHolder.contact_picture.setImageBitmap(AvatarService.getInstance().get(conversation.getContact(), + viewHolder.contact_picture.setImageBitmap(AvatarCache.get(conversation.getContact(), activity.getPixel(32))); viewHolder.contact_picture.setAlpha(0.5f); } diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/tasks/AvatarBitmapTask.java b/src/main/java/de/thedevstack/conversationsplus/ui/tasks/AvatarBitmapTask.java index ec89b001..b20985a4 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/tasks/AvatarBitmapTask.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/tasks/AvatarBitmapTask.java @@ -9,7 +9,8 @@ import java.lang.ref.WeakReference; import de.thedevstack.conversationsplus.dto.LoadAvatarFor; import de.thedevstack.conversationsplus.entities.Conversation; import de.thedevstack.conversationsplus.entities.Message; -import de.thedevstack.conversationsplus.services.AvatarService; +import de.thedevstack.conversationsplus.services.avatar.AvatarCache; +import de.thedevstack.conversationsplus.services.avatar.AvatarService; /** * @@ -26,9 +27,9 @@ public class AvatarBitmapTask<T extends LoadAvatarFor> extends AsyncTask<T, Void @Override protected Bitmap doInBackground(T... params) { if (params[0] instanceof Conversation) { - return AvatarService.getInstance().get((Conversation)params[0], this.avatarSize); + return AvatarCache.get((Conversation)params[0], this.avatarSize); } else if (params[0] instanceof Message) { - return AvatarService.getInstance().get((Message) params[0], this.avatarSize, isCancelled()); // Wirklich die richtige Nutzung von isCancelled()??? + return AvatarCache.get((Message) params[0], this.avatarSize, isCancelled()); // Wirklich die richtige Nutzung von isCancelled()??? } else { return null; } |