[Replicant] [PATCH 6/9] Revert "Implement lookup provider for 4x3 and 3x3 widget"
belgin
belginstirbu at hotmail.com
Mon Nov 23 23:47:05 UTC 2020
This reverts commit 4052475dd64ecd5445c2f60edb6b644e47315a79.
---
AndroidManifest.xml | 2 -
res/layout/widget_conversation_list_item.xml | 12 +--
res/layout/widget_message_item_incoming.xml | 13 +--
res/layout/widget_message_item_outgoing.xml | 2 +-
res/values/cm_dimens.xml | 4 -
src/com/android/messaging/BugleApplication.java | 4 +-
.../messaging/widget/BaseWidgetFactory.java | 18 +---
.../messaging/widget/BaseWidgetProvider.java | 1 -
.../widget/WidgetConversationListService.java | 51 ++-------
.../widget/WidgetConversationService.java | 47 ++-------
.../messaging/lookup/ILookupClient.java | 20 ----
.../messaging/lookup/LookupProviderManager.java | 114 +--------------------
12 files changed, 25 insertions(+), 263 deletions(-)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 346f75b..d37b576 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -541,8 +541,6 @@
<receiver android:name="com.cyanogenmod.messaging.quickmessage.ClearAllReceiver" />
- <receiver android:name="com.cyanogenmod.messaging.lookup.LookupProviderManager" />
-
</application>
</manifest>
diff --git a/res/layout/widget_conversation_list_item.xml b/res/layout/widget_conversation_list_item.xml
index 8d3f5d4..ecb12ca 100644
--- a/res/layout/widget_conversation_list_item.xml
+++ b/res/layout/widget_conversation_list_item.xml
@@ -28,7 +28,7 @@
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
- <ImageView
+ <com.cyanogenmod.messaging.ui.AttributionContactIconView
android:id="@+id/avatarView"
style="@style/WidgetConversationListItemAvatar"
android:layout_width="@dimen/contact_icon_view_normal_size"
@@ -38,16 +38,6 @@
android:importantForAccessibility="no"
android:contentDescription="@null" />
<ImageView
- android:id="@+id/attribution_logo"
- android:layout_width="@dimen/attribution_logo_size"
- android:layout_height="@dimen/attribution_logo_size"
- android:src="@null"
- android:layout_gravity="bottom|right"
- android:layout_marginRight="@dimen/convolist_attribution_logo_marginRight"
- android:visibility="gone"
- android:importantForAccessibility="no"
- android:contentDescription="@null"/>
- <ImageView
android:id="@+id/conversation_failed_status_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/widget_message_item_incoming.xml b/res/layout/widget_message_item_incoming.xml
index c71e5ff..4dda740 100644
--- a/res/layout/widget_message_item_incoming.xml
+++ b/res/layout/widget_message_item_incoming.xml
@@ -39,7 +39,7 @@
android:layout_marginTop="-4dp"
android:importantForAccessibility="no"
android:contentDescription="@null" />
- <ImageView
+ <com.cyanogenmod.messaging.ui.AttributionContactIconView
android:id="@+id/avatarView"
style="@style/WidgetConversationItemAvatarIncoming"
android:layout_width="@dimen/contact_icon_view_normal_size"
@@ -49,17 +49,6 @@
android:importantForAccessibility="no"
android:contentDescription="@null" />
<ImageView
- android:id="@+id/attribution_logo"
- android:layout_width="@dimen/attribution_logo_size"
- android:layout_height="@dimen/attribution_logo_size"
- android:src="@null"
- android:layout_gravity="bottom|right"
- android:layout_marginRight="@dimen/convo_attribution_logo_marginRight"
- android:layout_marginBottom="@dimen/convo_attribution_logo_marginBottom"
- android:visibility="gone"
- android:importantForAccessibility="no"
- android:contentDescription="@null"/>
- <ImageView
android:id="@+id/conversation_failed_status_icon"
style="@style/WidgetConversationItemFailed"
android:layout_width="wrap_content"
diff --git a/res/layout/widget_message_item_outgoing.xml b/res/layout/widget_message_item_outgoing.xml
index 472b5a2..1c65ccb 100644
--- a/res/layout/widget_message_item_outgoing.xml
+++ b/res/layout/widget_message_item_outgoing.xml
@@ -40,7 +40,7 @@
android:layout_marginTop="-4dp"
android:importantForAccessibility="no"
android:contentDescription="@null" />
- <ImageView
+ <com.android.messaging.ui.AttributtionContactIconView
android:id="@+id/avatarView"
android:layout_width="@dimen/contact_icon_view_normal_size"
android:layout_height="@dimen/contact_icon_view_normal_size"
diff --git a/res/values/cm_dimens.xml b/res/values/cm_dimens.xml
index 2dc13c2..91a8488 100644
--- a/res/values/cm_dimens.xml
+++ b/res/values/cm_dimens.xml
@@ -15,8 +15,4 @@
<dimen name="qm_message_count_height">18dp</dimen>
<dimen name="qm_conversation_bubble_width_snap">15dp</dimen>
<dimen name="qm_conversation_bubble_padding">5dp</dimen>
- <dimen name="attribution_logo_size">16dp</dimen>
- <dimen name="convolist_attribution_logo_marginRight">13dp</dimen>
- <dimen name="convo_attribution_logo_marginRight">5dp</dimen>
- <dimen name="convo_attribution_logo_marginBottom">5dp</dimen>
</resources>
diff --git a/src/com/android/messaging/BugleApplication.java b/src/com/android/messaging/BugleApplication.java
index c95d75e..a3cdfa0 100644
--- a/src/com/android/messaging/BugleApplication.java
+++ b/src/com/android/messaging/BugleApplication.java
@@ -282,9 +282,9 @@ public class BugleApplication extends Application implements UncaughtExceptionHa
}
/**
- * Get the reference to the lookup provider manager
+ * Get the reference to
*
- * @return {@link ILookupClient} or null
+ * @return {@link LookupProviderManager} or null
*/
public static ILookupClient getLookupProviderClient() {
return mLookupProviderManager;
diff --git a/src/com/android/messaging/widget/BaseWidgetFactory.java b/src/com/android/messaging/widget/BaseWidgetFactory.java
index c87a100..30b80ae 100644
--- a/src/com/android/messaging/widget/BaseWidgetFactory.java
+++ b/src/com/android/messaging/widget/BaseWidgetFactory.java
@@ -37,10 +37,8 @@ import com.android.messaging.datamodel.media.ImageRequestDescriptor;
import com.android.messaging.datamodel.media.ImageResource;
import com.android.messaging.datamodel.media.MediaRequest;
import com.android.messaging.datamodel.media.MediaResourceManager;
-import com.android.messaging.datamodel.media.UriImageRequestDescriptor;
import com.android.messaging.util.AvatarUriUtil;
import com.android.messaging.util.LogUtil;
-import com.cyanogenmod.messaging.lookup.LookupProviderManager;
/**
* Remote Views Factory for Bugle Widget.
@@ -81,7 +79,6 @@ abstract class BaseWidgetFactory implements RemoteViewsService.RemoteViewsFactor
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
LogUtil.v(TAG, "onCreate");
}
- mContext.sendBroadcast(new Intent(LookupProviderManager.ACTION_CREATED));
}
@Override
@@ -94,7 +91,6 @@ abstract class BaseWidgetFactory implements RemoteViewsService.RemoteViewsFactor
mCursor.close();
mCursor = null;
}
- mContext.sendBroadcast(new Intent(LookupProviderManager.ACTION_DESTROYED));
}
}
@@ -170,23 +166,13 @@ abstract class BaseWidgetFactory implements RemoteViewsService.RemoteViewsFactor
}
protected Bitmap getAvatarBitmap(final Uri avatarUri) {
- if (avatarUri == null) {
- return null;
- }
final String avatarType = avatarUri == null ?
null : AvatarUriUtil.getAvatarType(avatarUri);
-
ImageRequestDescriptor descriptor;
- boolean isAvatarUri = AvatarUriUtil.isAvatarUri(avatarUri);
- boolean isGroupAvatar = AvatarUriUtil.TYPE_GROUP_URI.equals(
- AvatarUriUtil.getAvatarType(avatarUri));
-
- if (isAvatarUri && isGroupAvatar) {
+ if (AvatarUriUtil.TYPE_GROUP_URI.equals(avatarType)) {
descriptor = new AvatarGroupRequestDescriptor(avatarUri, mIconSize, mIconSize);
- } else if (isAvatarUri) {
- descriptor = new AvatarRequestDescriptor(avatarUri, mIconSize, mIconSize);
} else {
- descriptor = new UriImageRequestDescriptor(avatarUri, mIconSize, mIconSize, true, 0, 0);
+ descriptor = new AvatarRequestDescriptor(avatarUri, mIconSize, mIconSize);
}
final MediaRequest<ImageResource> imageRequest =
diff --git a/src/com/android/messaging/widget/BaseWidgetProvider.java b/src/com/android/messaging/widget/BaseWidgetProvider.java
index c56a36f..431a6c7 100644
--- a/src/com/android/messaging/widget/BaseWidgetProvider.java
+++ b/src/com/android/messaging/widget/BaseWidgetProvider.java
@@ -24,7 +24,6 @@ import android.content.Intent;
import android.os.Bundle;
import com.android.messaging.util.LogUtil;
-import com.cyanogenmod.messaging.lookup.LookupProviderManager;
public abstract class BaseWidgetProvider extends AppWidgetProvider {
protected static final String TAG = LogUtil.BUGLE_WIDGET_TAG;
diff --git a/src/com/android/messaging/widget/WidgetConversationListService.java b/src/com/android/messaging/widget/WidgetConversationListService.java
index 0748757..264b98c 100644
--- a/src/com/android/messaging/widget/WidgetConversationListService.java
+++ b/src/com/android/messaging/widget/WidgetConversationListService.java
@@ -20,7 +20,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
-import android.graphics.Bitmap;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
@@ -32,9 +31,8 @@ import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.View;
import android.widget.RemoteViews;
-
import android.widget.RemoteViewsService;
-import com.android.messaging.BugleApplication;
+
import com.android.messaging.R;
import com.android.messaging.datamodel.MessagingContentProvider;
import com.android.messaging.datamodel.data.ConversationListData;
@@ -42,19 +40,17 @@ import com.android.messaging.datamodel.data.ConversationListItemData;
import com.android.messaging.sms.MmsUtils;
import com.android.messaging.ui.UIIntents;
import com.android.messaging.ui.conversationlist.ConversationListItemView;
-import com.android.messaging.util.ContactUtil;
import com.android.messaging.util.ContentType;
import com.android.messaging.util.Dates;
import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils;
-import com.cyanogen.lookup.phonenumber.response.LookupResponse;
public class WidgetConversationListService extends RemoteViewsService {
private static final String TAG = LogUtil.BUGLE_WIDGET_TAG;
@Override
- public RemoteViewsService.RemoteViewsFactory onGetViewFactory(Intent intent) {
+ public RemoteViewsFactory onGetViewFactory(Intent intent) {
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
LogUtil.v(TAG, "onGetViewFactory intent: " + intent);
}
@@ -104,14 +100,6 @@ public class WidgetConversationListService extends RemoteViewsService {
final ConversationListItemData conv = new ConversationListItemData();
conv.bind(mCursor);
- LookupResponse lookupResponse = null;
- if (!ContactUtil.isValidContactId(conv.getParticipantContactId())) {
- // Make blocking call
- lookupResponse = BugleApplication.getLookupProviderClient()
- .blockingLookupInfoForPhoneNumber(conv
- .getOtherParticipantNormalizedDestination());
- }
-
// Inflate and fill out the remote view
final RemoteViews remoteViews = new RemoteViews(
mContext.getPackageName(), R.layout.widget_conversation_list_item);
@@ -129,17 +117,8 @@ public class WidgetConversationListService extends RemoteViewsService {
boldifyIfUnread(timeStamp, hasUnreadMessages));
// From
- if (lookupResponse != null) {
- // Fix default if blank
- if (TextUtils.isEmpty(lookupResponse.mName)) {
- lookupResponse.mName = conv.getOtherParticipantNormalizedDestination();
- }
- remoteViews.setTextViewText(R.id.from,
- boldifyIfUnread(lookupResponse.mName, hasUnreadMessages));
- } else {
- remoteViews.setTextViewText(R.id.from,
- boldifyIfUnread(conv.getName(), hasUnreadMessages));
- }
+ remoteViews.setTextViewText(R.id.from,
+ boldifyIfUnread(conv.getName(), hasUnreadMessages));
// Notifications turned off mini-bell icon
remoteViews.setViewVisibility(R.id.conversation_notification_bell,
@@ -171,30 +150,12 @@ public class WidgetConversationListService extends RemoteViewsService {
View.VISIBLE : View.GONE);
Uri iconUri = null;
- if (lookupResponse != null
- && !TextUtils.isEmpty(lookupResponse.mPhotoUrl)) {
- iconUri = Uri.parse(lookupResponse.mPhotoUrl);
- } else {
- if (conv.getIcon() != null) {
- iconUri = Uri.parse(conv.getIcon());
- }
+ if (conv.getIcon() != null) {
+ iconUri = Uri.parse(conv.getIcon());
}
remoteViews.setImageViewBitmap(R.id.avatarView, includeAvatar ?
getAvatarBitmap(iconUri) : null);
- // Attribution logo
- if (lookupResponse != null) {
- Bitmap bitmap = BugleApplication.getLookupProviderClient()
- .getCachedAttributionLogoBitmap(lookupResponse.mProviderName);
- if (bitmap != null) {
- remoteViews.setImageViewBitmap(R.id.attribution_logo, bitmap);
- }
- remoteViews.setViewVisibility(R.id.attribution_logo, (bitmap == null) ? View
- .GONE : View.VISIBLE);
- } else {
- remoteViews.setViewVisibility(R.id.attribution_logo, View.GONE);
- }
-
// Error
// Only show the fail icon if it is not a group conversation.
// And also require that we be the default sms app.
diff --git a/src/com/android/messaging/widget/WidgetConversationService.java b/src/com/android/messaging/widget/WidgetConversationService.java
index 94dc545..4fd3934 100644
--- a/src/com/android/messaging/widget/WidgetConversationService.java
+++ b/src/com/android/messaging/widget/WidgetConversationService.java
@@ -30,9 +30,8 @@ import android.text.format.Formatter;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.RemoteViews;
-
import android.widget.RemoteViewsService;
-import com.android.messaging.BugleApplication;
+
import com.android.messaging.R;
import com.android.messaging.datamodel.MessagingContentProvider;
import com.android.messaging.datamodel.data.ConversationMessageData;
@@ -48,20 +47,15 @@ import com.android.messaging.datamodel.media.VideoThumbnailRequest;
import com.android.messaging.sms.MmsUtils;
import com.android.messaging.ui.UIIntents;
import com.android.messaging.util.AvatarUriUtil;
-import com.android.messaging.util.ContactUtil;
import com.android.messaging.util.Dates;
import com.android.messaging.util.LogUtil;
import com.android.messaging.util.OsUtil;
import com.android.messaging.util.PhoneUtils;
-import com.cyanogen.lookup.phonenumber.response.LookupResponse;
-import java.util.LinkedHashMap;
import java.util.List;
public class WidgetConversationService extends RemoteViewsService {
private static final String TAG = LogUtil.BUGLE_WIDGET_TAG;
- private static final LinkedHashMap<String, Bitmap> sAttributionLogoCache = new
- LinkedHashMap<>(5);
private static final int IMAGE_ATTACHMENT_SIZE = 400;
@@ -146,21 +140,13 @@ public class WidgetConversationService extends RemoteViewsService {
final ConversationMessageData message = new ConversationMessageData();
message.bind(mCursor);
- LookupResponse lookupResponse = null;
- if (!ContactUtil.isValidContactId(message.getSenderContactId())) {
- // Make blocking call
- lookupResponse = BugleApplication.getLookupProviderClient()
- .blockingLookupInfoForPhoneNumber(
- message.getSenderNormalizedDestination());
- }
-
// Inflate and fill out the remote view
final RemoteViews remoteViews = new RemoteViews(
mContext.getPackageName(), message.getIsIncoming() ?
R.layout.widget_message_item_incoming :
R.layout.widget_message_item_outgoing);
- final boolean hasUnreadMessages = !message.getIsRead();
+ final boolean hasUnreadMessages = false; //!message.getIsRead();
// Date
remoteViews.setTextViewText(R.id.date, boldifyIfUnread(
@@ -249,34 +235,15 @@ public class WidgetConversationService extends RemoteViewsService {
remoteViews.setViewVisibility(R.id.avatarShadow, includeAvatar ?
View.VISIBLE : View.GONE);
- final Uri avatarUri;
- if (lookupResponse != null
- && !TextUtils.isEmpty(lookupResponse.mPhotoUrl)) {
- avatarUri = Uri.parse(lookupResponse.mPhotoUrl);
- } else {
- avatarUri = AvatarUriUtil.createAvatarUri(
- message.getSenderProfilePhotoUri(),
- message.getSenderFullName(),
- message.getSenderNormalizedDestination(),
- message.getSenderContactLookupKey());
- }
+ final Uri avatarUri = AvatarUriUtil.createAvatarUri(
+ message.getSenderProfilePhotoUri(),
+ message.getSenderFullName(),
+ message.getSenderNormalizedDestination(),
+ message.getSenderContactLookupKey());
remoteViews.setImageViewBitmap(R.id.avatarView, includeAvatar ?
getAvatarBitmap(avatarUri) : null);
- // Attribution logo
- if (lookupResponse != null) {
- Bitmap bitmap = BugleApplication.getLookupProviderClient()
- .getCachedAttributionLogoBitmap(lookupResponse.mProviderName);
- if (bitmap != null) {
- remoteViews.setImageViewBitmap(R.id.attribution_logo, bitmap);
- }
- remoteViews.setViewVisibility(R.id.attribution_logo, (bitmap == null) ? View
- .GONE : View.VISIBLE);
- } else {
- remoteViews.setViewVisibility(R.id.attribution_logo, View.GONE);
- }
-
String text = message.getText();
if (attachmentStringId != 0) {
final String attachment = mContext.getString(attachmentStringId);
diff --git a/src/com/cyanogenmod/messaging/lookup/ILookupClient.java b/src/com/cyanogenmod/messaging/lookup/ILookupClient.java
index e3cd13a..a66b230 100644
--- a/src/com/cyanogenmod/messaging/lookup/ILookupClient.java
+++ b/src/com/cyanogenmod/messaging/lookup/ILookupClient.java
@@ -15,9 +15,6 @@
*/
package com.cyanogenmod.messaging.lookup;
-import android.graphics.Bitmap;
-import com.cyanogen.lookup.phonenumber.response.LookupResponse;
-
/**
* <pre>
* Client interface for talking to lookup provider
@@ -43,23 +40,6 @@ public interface ILookupClient {
void lookupInfoForPhoneNumber(String phoneNumber, boolean requery);
/**
- * Will call for lookup and allow requery of possibly stale data
- *
- * @param phoneNumber {@link String} not null or empty
- *
- * @return {@link com.cyanogen.lookup.phonenumber.response.LookupResponse}
- */
- LookupResponse blockingLookupInfoForPhoneNumber(String phoneNumber);
-
- /**
- * Fetches the possibly cached bitmap for a lookup provider of the given name
- *
- * @param providerName {@link String }
- * @return {@link Bitmap} or null
- */
- Bitmap getCachedAttributionLogoBitmap(String providerName);
-
- /**
* Will mark number as spam
*
* This will automatically format to E164
diff --git a/src/com/cyanogenmod/messaging/lookup/LookupProviderManager.java b/src/com/cyanogenmod/messaging/lookup/LookupProviderManager.java
index 63e2689..8649b6a 100644
--- a/src/com/cyanogenmod/messaging/lookup/LookupProviderManager.java
+++ b/src/com/cyanogenmod/messaging/lookup/LookupProviderManager.java
@@ -17,12 +17,6 @@ package com.cyanogenmod.messaging.lookup;
import android.app.Activity;
import android.app.Application;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -31,14 +25,12 @@ import android.text.TextUtils;
import android.util.Log;
import com.cyanogen.lookup.phonenumber.provider.LookupProviderImpl;
-import com.cyanogen.lookup.phonenumber.response.StatusCode;
import com.cyanogen.lookup.phonenumber.util.LookupHandlerThread;
import com.cyanogen.lookup.phonenumber.request.LookupRequest;
import com.cyanogen.lookup.phonenumber.response.LookupResponse;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@@ -52,29 +44,20 @@ import java.util.concurrent.ConcurrentHashMap;
* @see {@link LookupRequest.Callback}
* @see {@link ILookupClient}
*/
-public class LookupProviderManager extends BroadcastReceiver implements Application
- .ActivityLifecycleCallbacks, LookupRequest.Callback, ILookupClient {
+public class LookupProviderManager implements Application.ActivityLifecycleCallbacks,
+ LookupRequest.Callback, ILookupClient {
private static final String TAG = "LookupProviderManager";
private static final String THREAD_NAME = "PhoneLookupProviderThread";
// Members
private static final Handler sHandler = new Handler(Looper.getMainLooper());
- private static final LinkedHashMap<String, Bitmap> sAttributionLogoBitmapCache = new
- LinkedHashMap<>(1);
private Application mApplication;
private ConcurrentHashMap<String, LookupResponse> mPhoneNumberLookupCache;
private ConcurrentHashMap<String, HashSet<LookupProviderListener>> mLookupListeners;
private LookupHandlerThread mLookupHandlerThread;
private boolean mIsPhoneNumberLookupInitialized;
private short mActivityCount = 0;
- private short mServiceCount = 0;
-
- public static final String ACTION_CREATED = "service_created";
- public static final String ACTION_DESTROYED = "service_destroyed";
-
- public LookupProviderManager() {
- }
/**
* Constructor
@@ -89,10 +72,6 @@ public class LookupProviderManager extends BroadcastReceiver implements Applicat
mPhoneNumberLookupCache = new ConcurrentHashMap<String, LookupResponse>();
mLookupListeners = new ConcurrentHashMap<String, HashSet<LookupProviderListener>>();
application.registerActivityLifecycleCallbacks(this);
- IntentFilter filter = new IntentFilter();
- filter.addAction(ACTION_CREATED);
- filter.addAction(ACTION_DESTROYED);
- application.registerReceiver(this, filter);
mApplication = application;
}
@@ -124,12 +103,7 @@ public class LookupProviderManager extends BroadcastReceiver implements Applicat
}
mPhoneNumberLookupCache.clear();
mLookupListeners.clear();
- for (Bitmap bitmap : sAttributionLogoBitmapCache.values()) {
- if (bitmap != null && !bitmap.isRecycled()) {
- bitmap.recycle();
- }
- }
- sAttributionLogoBitmapCache.clear();
+ mIsPhoneNumberLookupInitialized = false;
}
/**
@@ -179,17 +153,6 @@ public class LookupProviderManager extends BroadcastReceiver implements Applicat
public void onNewInfo(LookupRequest lookupRequest, final LookupResponse response) {
log("onNewInfo(" + lookupRequest + ", " + response + ")");
mPhoneNumberLookupCache.put(lookupRequest.mPhoneNumber, response);
- // Cache the attribution logo as a bitmap since needed by widget's remoteviews
- if (!sAttributionLogoBitmapCache.containsKey(response.mProviderName)) {
- Bitmap bitmap = Bitmap.createBitmap(response.mAttributionLogo
- .getIntrinsicWidth(), response.mAttributionLogo
- .getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
- Canvas c = new Canvas(bitmap);
- response.mAttributionLogo
- .setBounds(0, 0, c.getWidth(), c.getHeight());
- response.mAttributionLogo.draw(c);
- sAttributionLogoBitmapCache.put(response.mProviderName, bitmap);
- }
if (mLookupListeners.containsKey(lookupRequest.mPhoneNumber)) {
int i = 0;
List<Integer> removalIndexes = new ArrayList<Integer>();
@@ -214,46 +177,13 @@ public class LookupProviderManager extends BroadcastReceiver implements Applicat
}
}
- /* --------------------- Private level service count methods -------------------------------*/
-
- private void onServiceCreated() {
- ++mServiceCount;
- if (mServiceCount == 1) {
- if (!mIsPhoneNumberLookupInitialized) {
- mIsPhoneNumberLookupInitialized = start();
- }
- }
- }
-
- private void onServiceDestroyed() {
- --mServiceCount;
- if (mServiceCount == 0 && mActivityCount == 0) {
- if (mIsPhoneNumberLookupInitialized) {
- stop();
- mIsPhoneNumberLookupInitialized = false;
- }
- }
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (ACTION_CREATED.equalsIgnoreCase(action)) {
- onServiceCreated();
- } else if (ACTION_DESTROYED.equalsIgnoreCase(action)) {
- onServiceDestroyed();
- }
- }
-
/* --------------------- Activity callback interfaces -------------------------------------*/
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
log("onActivityCreated(" + activity + ", " + savedInstanceState + ")");
++mActivityCount;
if (mActivityCount == 1) {
- if (!mIsPhoneNumberLookupInitialized) {
- mIsPhoneNumberLookupInitialized = start();
- }
+ mIsPhoneNumberLookupInitialized = start();
}
}
@@ -277,7 +207,7 @@ public class LookupProviderManager extends BroadcastReceiver implements Applicat
public void onActivityDestroyed(Activity activity) {
log("onActivityCreated(" + activity + ")");
--mActivityCount;
- if (mActivityCount == 0 && mServiceCount == 0) {
+ if (mActivityCount == 0) {
if (mIsPhoneNumberLookupInitialized) {
stop();
mIsPhoneNumberLookupInitialized = false;
@@ -286,40 +216,6 @@ public class LookupProviderManager extends BroadcastReceiver implements Applicat
}
@Override
- public LookupResponse blockingLookupInfoForPhoneNumber(String phoneNumber) {
- LookupResponse response = null;
- if (mLookupHandlerThread != null) {
- response = mLookupHandlerThread.blockingFetchInfoForPhoneNumber(new
- LookupRequest(phoneNumber, this));
- if (response != null && response.mStatusCode != StatusCode.SUCCESS) {
- response = null;
- }
- }
- if (response != null) {
- // Cache the attribution logos as bitmaps since widget needs it
- if (!sAttributionLogoBitmapCache.containsKey(response.mProviderName)) {
- Bitmap bitmap = Bitmap.createBitmap(response.mAttributionLogo
- .getIntrinsicWidth(), response.mAttributionLogo
- .getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
- Canvas c = new Canvas(bitmap);
- response.mAttributionLogo
- .setBounds(0, 0, c.getWidth(), c.getHeight());
- response.mAttributionLogo.draw(c);
- sAttributionLogoBitmapCache.put(response.mProviderName, bitmap);
- }
- }
- return response;
- }
-
- @Override
- public Bitmap getCachedAttributionLogoBitmap(String providerName) {
- if (!TextUtils.isEmpty(providerName)) {
- return sAttributionLogoBitmapCache.get(providerName);
- }
- return null;
- }
-
- @Override
public void lookupInfoForPhoneNumber(String phoneNumber) {
log("lookupInfoForPhoneNumber(" + phoneNumber + ")");
lookupInfoForPhoneNumber(phoneNumber, false);
--
2.11.0
More information about the Replicant
mailing list