diff options
26 files changed, 24 insertions, 1012 deletions
@@ -51,7 +51,6 @@ LOCAL_STATIC_JAVA_LIBRARIES += guava LOCAL_STATIC_JAVA_LIBRARIES += libchips LOCAL_STATIC_JAVA_LIBRARIES += libphotoviewer LOCAL_STATIC_JAVA_LIBRARIES += libphonenumber -LOCAL_STATIC_JAVA_LIBRARIES += play LOCAL_STATIC_JAVA_LIBRARIES += colorpicker LOCAL_STATIC_JAVA_LIBRARIES += contacts-picaso @@ -68,7 +67,6 @@ LOCAL_AAPT_FLAGS += --extra-packages com.android.ex.photo LOCAL_AAPT_FLAGS += --extra-packages com.android.colorpicker LOCAL_AAPT_FLAGS += --extra-packages com.android.contacts.common LOCAL_AAPT_FLAGS += --extra-packages com.android.phone.common -LOCAT_AAPT_FLAGS += --extra-packages com.google.android.gms ifdef TARGET_BUILD_APPS LOCAL_JNI_SHARED_LIBRARIES := libframesequence libgiftranscode @@ -77,7 +75,11 @@ else endif # utilize ContactsCommon's phone-number-based contact-info lookup -include $(LOCAL_PATH)/../ContactsCommon/info_lookup/phonenumber_lookup_provider.mk +ifeq ($(contacts_common_dir),) + contacts_common_dir := ../ContactsCommon +endif +CONTACTS_COMMON_LOOKUP_PROVIDER ?= $(LOCAL_PATH)/$(contacts_common_dir)/info_lookup +include $(CONTACTS_COMMON_LOOKUP_PROVIDER)/phonenumber_lookup_provider.mk LOCAL_PROGUARD_FLAGS := -ignorewarnings -include build/core/proguard_basic_keeps.flags diff --git a/AndroidManifest.xml b/AndroidManifest.xml index e7731cb..09a3a8d 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -55,8 +55,6 @@ <uses-permission android:name="com.cyanogen.ambient.permission.BIND_RIDEINPROGRESS_SERVICE" /> <uses-permission android:name="com.cyanogen.ambient.permission.BIND_RIDESHARING_SERVICE" /> - <uses-permission android:name="android.permission.BIND_JOB_SERVICE" /> - <!-- Optional features --> <uses-feature android:name="android.hardware.camera" android:required="false" /> <uses-feature android:name="android.hardware.camera.front" android:required="false" /> @@ -554,13 +552,6 @@ android:launchMode="singleTop" android:configChanges="orientation|screenSize|keyboardHidden" android:label="@string/sim_manage_messages_title" /> - - <meta-data android:name="com.cyanogen.ambient.analytics.key" - android:value="6l2dXt9DFioFa1Mfb4eZsM9l87Rl9hp1UL75tO9w"/> - - <service android:name="com.cyanogenmod.messaging.util.MetricsJob" - android:permission="android.permission.BIND_JOB_SERVICE" /> - </application> </manifest> diff --git a/res/drawable-hdpi/ic_map_placeholder.png b/res/drawable-hdpi/ic_map_placeholder.png Binary files differdeleted file mode 100644 index 4b40b16..0000000 --- a/res/drawable-hdpi/ic_map_placeholder.png +++ /dev/null diff --git a/res/drawable-mdpi/ic_map_placeholder.png b/res/drawable-mdpi/ic_map_placeholder.png Binary files differdeleted file mode 100644 index bd551a5..0000000 --- a/res/drawable-mdpi/ic_map_placeholder.png +++ /dev/null diff --git a/res/drawable-xhdpi/ic_map_placeholder.png b/res/drawable-xhdpi/ic_map_placeholder.png Binary files differdeleted file mode 100644 index b6d5bf9..0000000 --- a/res/drawable-xhdpi/ic_map_placeholder.png +++ /dev/null diff --git a/res/drawable-xxhdpi/ic_map_placeholder.png b/res/drawable-xxhdpi/ic_map_placeholder.png Binary files differdeleted file mode 100644 index 8bba6c2..0000000 --- a/res/drawable-xxhdpi/ic_map_placeholder.png +++ /dev/null diff --git a/res/drawable/directions_button_background.xml b/res/drawable/directions_button_background.xml deleted file mode 100644 index d7f56d6..0000000 --- a/res/drawable/directions_button_background.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ripple xmlns:android="http://schemas.android.com/apk/res/android" - android:color="?android:colorControlHighlight"> - <item> - <shape android:shape="rectangle"> - <corners android:bottomLeftRadius="2dp" android:topLeftRadius="2dp" /> - <solid android:color="@color/white_54" /> - </shape> - </item> -</ripple>
\ No newline at end of file diff --git a/res/drawable/ic_generic_transport_icon.xml b/res/drawable/ic_generic_transport_icon.xml deleted file mode 100644 index dd26431..0000000 --- a/res/drawable/ic_generic_transport_icon.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (c) 2016 The CyanogenMod Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="24dp" - android:height="24dp" - android:viewportWidth="24" - android:viewportHeight="24"> - - <path - android:fillColor="@color/black_54" - android:pathData="M18.9,6c-0.2-0.6-0.8-1-1.4-1h-11C5.8,5,5.3,5.4,5.1,6L3,12v8c0,0.5,0.5,1,1,1h1c0.6,0,1-0.5,1-1v-1h12v1c0,0.5,0.5,1,1,1h1 -c0.5,0,1-0.5,1-1v-8L18.9,6z -M6.5,16C5.7,16,5,15.3,5,14.5S5.7,13,6.5,13S8,13.7,8,14.5S7.3,16,6.5,16z M17.5,16 -c-0.8,0-1.5-0.7-1.5-1.5s0.7-1.5,1.5-1.5s1.5,0.7,1.5,1.5S18.3,16,17.5,16z -M5,11l1.5-4.5h11L19,11H5z M11,9.5 -c0,0.8-0.7,1.5-1.5,1.5S8,10.3,8,9.5S8.7,8,9.5,8S11,8.7,11,9.5z -M16,9.5c0,0.8-0.7,1.5-1.5,1.5S13,10.3,13,9.5S13.7,8,14.5,8 S16,8.7,16,9.5z" /> -</vector>
\ No newline at end of file diff --git a/res/drawable/ic_get_directions.xml b/res/drawable/ic_get_directions.xml deleted file mode 100755 index 46c6fb6..0000000 --- a/res/drawable/ic_get_directions.xml +++ /dev/null @@ -1,7 +0,0 @@ -<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:height="24dp"
- android:width="24dp"
- android:viewportWidth="24"
- android:viewportHeight="24">
- <path android:fillColor="#000000" android:fillAlpha=".54" android:pathData="M14,14.5V12H10V15H8V11A1,1 0 0,1 9,10H14V7.5L17.5,11M21.71,11.29L12.71,2.29H12.7C12.31,1.9 11.68,1.9 11.29,2.29L2.29,11.29C1.9,11.68 1.9,12.32 2.29,12.71L11.29,21.71C11.68,22.09 12.31,22.1 12.71,21.71L21.71,12.71C22.1,12.32 22.1,11.68 21.71,11.29Z" />
-</vector>
\ No newline at end of file diff --git a/res/drawable/maps_button_container_background.xml b/res/drawable/maps_button_container_background.xml deleted file mode 100644 index 6e3a3a1..0000000 --- a/res/drawable/maps_button_container_background.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<shape xmlns:android="http://schemas.android.com/apk/res/android" - android:shape="rectangle"> - <corners android:radius="2dp" /> - <solid android:color="@android:color/transparent" /> -</shape>
\ No newline at end of file diff --git a/res/drawable/request_ride_button_background.xml b/res/drawable/request_ride_button_background.xml deleted file mode 100644 index d7f56d6..0000000 --- a/res/drawable/request_ride_button_background.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ripple xmlns:android="http://schemas.android.com/apk/res/android" - android:color="?android:colorControlHighlight"> - <item> - <shape android:shape="rectangle"> - <corners android:bottomLeftRadius="2dp" android:topLeftRadius="2dp" /> - <solid android:color="@color/white_54" /> - </shape> - </item> -</ripple>
\ No newline at end of file diff --git a/res/layout/attachment_maps.xml b/res/layout/attachment_maps.xml deleted file mode 100644 index aa5b353..0000000 --- a/res/layout/attachment_maps.xml +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2016 The CyanogenMod Project (DvTonder) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:visibility="gone" - android:layout_marginBottom="@dimen/conversation_maps_margin" - android:layout_width="@dimen/conversation_maps_width" - android:layout_height="@dimen/conversation_maps_height"> - <ImageView - android:id="@+id/maps_image" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:minWidth="@dimen/conversation_maps_width" - android:minHeight="@dimen/conversation_maps_height" - android:adjustViewBounds="true" - android:scaleType="fitCenter" - android:layout_gravity="center_vertical"/> - <RelativeLayout - android:background="@drawable/maps_button_container_background" - android:elevation="@dimen/maps_button_elevation" - android:layout_width="match_parent" - android:layout_height="@dimen/maps_button_height" - android:layout_alignParentBottom="true" - android:layout_marginLeft="@dimen/conversation_maps_margin" - android:layout_marginBottom="@dimen/conversation_maps_margin" - android:layout_marginRight="@dimen/conversation_maps_margin" - android:minWidth="@dimen/maps_button_width"> - - <ImageView - android:id="@+id/directions_button" - android:layout_width="@dimen/directions_button_width" - android:layout_height="match_parent" - android:background="@drawable/directions_button_background" - android:layout_alignParentRight="true" - android:padding="@dimen/directions_button_padding" - android:layout_centerVertical="true" - android:src="@drawable/ic_get_directions"/> - <View - android:id="@+id/button_divider" - android:layout_toLeftOf="@id/directions_button" - android:layout_width="@dimen/maps_button_divider_width" - android:layout_height="match_parent" - android:background="@color/transparent_gray" /> - <Button - style="?android:attr/borderlessButtonStyle" - android:id="@+id/request_ride_button" - android:background="@drawable/request_ride_button_background" - android:layout_alignParentLeft="true" - android:layout_toLeftOf="@id/button_divider" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:paddingLeft="28dp" - android:paddingRight="50dp" - android:textColor="@color/black_54" - android:textSize="@dimen/request_ride_text_size" - android:fontFamily="sans-serif-medium" - android:text="@string/request_ride"/> - - <ImageView - android:id="@+id/brand_image" - android:layout_width="@dimen/brand_image_width" - android:layout_height="@dimen/brand_image_height" - android:layout_alignParentLeft="true" - android:layout_marginLeft="@dimen/brand_image_margin" - android:layout_marginRight="@dimen/brand_image_margin" - android:layout_centerVertical="true" - android:focusable="false" - android:clickable="false" - android:src="@drawable/ic_generic_transport_icon"/> - </RelativeLayout> -</RelativeLayout>
\ No newline at end of file diff --git a/res/layout/conversation_message_view.xml b/res/layout/conversation_message_view.xml index 004028d..8d10c84 100644 --- a/res/layout/conversation_message_view.xml +++ b/res/layout/conversation_message_view.xml @@ -66,10 +66,6 @@ app:cornerRadius="@dimen/attachment_rounded_corner_radius" android:contentDescription="@string/message_image_content_description" /> - <include - android:id="@+id/message_maps" - layout="@layout/attachment_maps" /> - </LinearLayout> <com.android.messaging.ui.conversation.MessageBubbleBackground diff --git a/res/values/cm_colors.xml b/res/values/cm_colors.xml index 3af3a08..0342f85 100755 --- a/res/values/cm_colors.xml +++ b/res/values/cm_colors.xml @@ -56,9 +56,4 @@ <color name="snack_bar_action_text_color">#EEFF41</color> <color name="mic_recording_color">#ffffff</color> <color name="mic_background_color">#ffffff</color> - - <!-- Ridesharing --> - <color name="transparent_gray">#1F000000</color> - <color name="white_54">#8BFFFFFF</color> - <color name="black_54">#8B000000</color> </resources> diff --git a/res/values/cm_dimens.xml b/res/values/cm_dimens.xml index 9ce1bf5..2dc13c2 100644 --- a/res/values/cm_dimens.xml +++ b/res/values/cm_dimens.xml @@ -19,25 +19,4 @@ <dimen name="convolist_attribution_logo_marginRight">13dp</dimen> <dimen name="convo_attribution_logo_marginRight">5dp</dimen> <dimen name="convo_attribution_logo_marginBottom">5dp</dimen> - - <!-- Ride sharing --> - <dimen name="conversation_maps_width">221dp</dimen> - <dimen name="conversation_maps_height">144dp</dimen> - <dimen name="conversation_maps_margin">8dp</dimen> - <dimen name="maps_button_elevation">2dp</dimen> - <dimen name="maps_button_width">205dp</dimen> - <dimen name="maps_button_height">32dp</dimen> - <dimen name="request_ride_button_width">172dp</dimen> - <dimen name="request_ride_text_size">12sp</dimen> - <dimen name="brand_image_width">18dp</dimen> - <dimen name="brand_image_height">18dp</dimen> - <dimen name="brand_image_margin">7dp</dimen> - <dimen name="directions_button_width">32dp</dimen> - <dimen name="directions_button_padding">4dp</dimen> - <dimen name="maps_button_divider_width">1dp</dimen> - <dimen name="maps_error_icon_width">1dp</dimen> - <dimen name="maps_error_icon_height">1dp</dimen> - <dimen name="maps_corner_radius">3dp</dimen> - <dimen name="map_request_width">221px</dimen> - <dimen name="map_request_height">144px</dimen> </resources> diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index e48c45c..4d6d424 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -155,7 +155,4 @@ <string name="mediapicker_audio_list_item_selected_content_description">The audio is selected.</string> <string name="mediapicker_audio_list_item_unselected_content_description">The audio is unselected.</string> <string name="mediapicker_audio_list_title_selection"><xliff:g id="count">%d</xliff:g> selected</string> - - <!-- Ride sharing --> - <string name="request_ride">Request Ride</string> </resources> diff --git a/res/values/google_maps_api.xml b/res/values/google_maps_api.xml deleted file mode 100644 index f165a09..0000000 --- a/res/values/google_maps_api.xml +++ /dev/null @@ -1,3 +0,0 @@ -<resources> - <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false"></string> -</resources> diff --git a/src/com/android/messaging/ui/AsyncImageView.java b/src/com/android/messaging/ui/AsyncImageView.java index f2394d0..e18d677 100644 --- a/src/com/android/messaging/ui/AsyncImageView.java +++ b/src/com/android/messaging/ui/AsyncImageView.java @@ -113,6 +113,8 @@ public class AsyncImageView extends ImageView implements MediaResourceLoadListen attr.recycle(); } + + /** * The main entrypoint for AsyncImageView to load image resource given an ImageRequestDescriptor * @param descriptor the request descriptor, or null if no image should be displayed diff --git a/src/com/android/messaging/ui/conversation/ConversationActivity.java b/src/com/android/messaging/ui/conversation/ConversationActivity.java index 20f857d..66310ea 100644 --- a/src/com/android/messaging/ui/conversation/ConversationActivity.java +++ b/src/com/android/messaging/ui/conversation/ConversationActivity.java @@ -16,20 +16,14 @@ package com.android.messaging.ui.conversation; -import android.app.AlarmManager; -import android.app.job.JobInfo; -import android.app.job.JobScheduler; import android.app.FragmentManager; import android.app.FragmentTransaction; -import android.content.ComponentName; -import android.content.Context; import android.content.Intent; import android.graphics.Rect; import android.net.Uri; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.text.TextUtils; -import android.util.Log; import android.view.MenuItem; import com.android.messaging.R; @@ -48,13 +42,9 @@ import com.android.messaging.util.LogUtil; import com.android.messaging.util.OsUtil; import com.android.messaging.util.UiUtils; -import com.cyanogenmod.messaging.util.MetricsJob; - public class ConversationActivity extends BugleActionBarActivity implements ContactPickerFragmentHost, ConversationFragmentHost, ConversationActivityUiStateHost { - public static final String TAG = "ConversationActivity"; - public static final int FINISH_RESULT_CODE = 1; private static final String SAVED_INSTANCE_STATE_UI_STATE_KEY = "uistate"; @@ -127,39 +117,6 @@ public class ConversationActivity extends BugleActionBarActivity UIIntents.get().launchFullScreenVideoViewer(this, Uri.parse(extraToDisplay)); } } - - // Schedule a Job for Metrics Service - JobScheduler jobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE); - - if (jobScheduler != null) { - boolean jobExists = false; - for (JobInfo ji : jobScheduler.getAllPendingJobs()) { - if (ji.getId() != MetricsJob.METRICS_JOB_ID) { - // Job exists - jobExists = true; - break; - } - } - if (!jobExists) { - // We need a job to send our aggregated events to our metrics service every 24 hours. - // As long as this service has been used, we know we'll need this data. - ComponentName jobComponent = new ComponentName(this, MetricsJob.class); - - JobInfo job = new JobInfo.Builder(MetricsJob.METRICS_JOB_ID, jobComponent) - .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) - .setPersisted(true) - .setPeriodic(AlarmManager.INTERVAL_DAY) - .setBackoffCriteria(AlarmManager.INTERVAL_FIFTEEN_MINUTES, - JobInfo.BACKOFF_POLICY_EXPONENTIAL) - .build(); - jobScheduler.schedule(job); - } else { - Log.v(TAG, "Messaging Metrics job " + MetricsJob.METRICS_JOB_ID + " already exists"); - } - } else { - Log.e(TAG, "Running on a device without JobScheduler." + - " Messaging Metrics will fail to collect."); - } } @Override diff --git a/src/com/android/messaging/ui/conversation/ConversationMessageAdapter.java b/src/com/android/messaging/ui/conversation/ConversationMessageAdapter.java index f740f39..3d50252 100644 --- a/src/com/android/messaging/ui/conversation/ConversationMessageAdapter.java +++ b/src/com/android/messaging/ui/conversation/ConversationMessageAdapter.java @@ -28,7 +28,6 @@ import com.android.messaging.ui.CursorRecyclerAdapter; import com.android.messaging.ui.AsyncImageView.AsyncImageViewDelayLoader; import com.android.messaging.ui.conversation.ConversationMessageView.ConversationMessageViewHost; import com.android.messaging.util.Assert; -import com.cyanogenmod.messaging.util.RidesharingUtil; import java.util.HashSet; import java.util.List; @@ -41,7 +40,6 @@ public class ConversationMessageAdapter extends CursorRecyclerAdapter<ConversationMessageAdapter.ConversationMessageViewHolder> { private final ConversationMessageViewHost mHost; - private final RidesharingUtil mRidesharingUtil; private final AsyncImageViewDelayLoader mImageViewDelayLoader; private final View.OnClickListener mViewClickListener; private final View.OnLongClickListener mViewLongClickListener; @@ -56,7 +54,6 @@ public class ConversationMessageAdapter extends final View.OnLongClickListener longClickListener) { super(context, cursor, 0); mHost = host; - mRidesharingUtil = new RidesharingUtil(context); mViewClickListener = viewClickListener; mViewLongClickListener = longClickListener; mImageViewDelayLoader = imageViewDelayLoader; @@ -94,7 +91,6 @@ public class ConversationMessageAdapter extends final ConversationMessageView conversationMessageView = (ConversationMessageView) layoutInflater.inflate(R.layout.conversation_message_view, null); conversationMessageView.setHost(mHost); - conversationMessageView.setRidesharingUtil(mRidesharingUtil); conversationMessageView.setImageViewDelayLoader(mImageViewDelayLoader); return new ConversationMessageViewHolder(conversationMessageView, mViewClickListener, mViewLongClickListener); diff --git a/src/com/android/messaging/ui/conversation/ConversationMessageView.java b/src/com/android/messaging/ui/conversation/ConversationMessageView.java index bf82983..22128bc 100644 --- a/src/com/android/messaging/ui/conversation/ConversationMessageView.java +++ b/src/com/android/messaging/ui/conversation/ConversationMessageView.java @@ -17,8 +17,6 @@ package com.android.messaging.ui.conversation; import android.content.Context; -import android.content.ComponentName; -import android.content.Intent; import android.content.res.Resources; import android.database.Cursor; import android.graphics.Rect; @@ -33,19 +31,15 @@ import android.text.style.URLSpan; import android.text.util.Linkify; import android.util.AttributeSet; import android.util.DisplayMetrics; -import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; -import android.widget.Button; import android.widget.FrameLayout; -import android.widget.ImageView; import android.widget.ImageView.ScaleType; import android.widget.LinearLayout; -import android.widget.RelativeLayout; import android.widget.TextView; import com.android.messaging.BugleApplication; @@ -79,20 +73,11 @@ import com.android.messaging.util.OsUtil; import com.android.messaging.util.PhoneUtils; import com.android.messaging.util.UiUtils; import com.android.messaging.util.YouTubeUtil; -import com.cyanogen.ambient.ridesharing.core.RidesharingContract; import com.cyanogen.lookup.phonenumber.response.LookupResponse; import com.cyanogenmod.messaging.lookup.LookupProviderManager.LookupProviderListener; import com.cyanogenmod.messaging.ui.AttributionContactIconView; -import com.cyanogenmod.messaging.util.GoogleStaticMapsUtil; -import com.cyanogenmod.messaging.util.MetricsHelper; -import com.cyanogenmod.messaging.util.RidesharingUtil; -import com.cyanogenmod.messaging.util.RoundedCornerTransformation; import com.google.common.base.Predicate; -import com.squareup.picasso.*; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -110,22 +95,13 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick boolean excludeDefault); } - private static final String TAG = ConversationMessageView.class.getSimpleName(); - private final ConversationMessageData mData; private LinearLayout mMessageAttachmentsView; private MultiAttachmentLayout mMultiAttachmentView; private AsyncImageView mMessageImageView; - private RelativeLayout mMessageMapsView; - private ImageView mMessageMapsImageView; - private Button mRequestRideButton; - private ImageView mBrandImageView; - private ImageView mDirectionsButton; - private View mButtonDivider; private TextView mMessageTextView; private boolean mMessageTextHasLinks; - private boolean mMessageHasMapsLink; private boolean mMessageHasYouTubeLink; private TextView mStatusTextView; private TextView mTitleTextView; @@ -144,13 +120,11 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick private boolean mOneOnOne; private ConversationMessageViewHost mHost; - private RidesharingUtil mRidesharingUtil; public ConversationMessageView(final Context context, final AttributeSet attrs) { super(context, attrs); // TODO: we should switch to using Binding and DataModel factory methods. mData = new ConversationMessageData(); - mRidesharingUtil = new RidesharingUtil(context); } @Override @@ -172,13 +146,6 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick mMessageImageView.setOnClickListener(this); mMessageImageView.setOnLongClickListener(this); - mMessageMapsView = (RelativeLayout) findViewById(R.id.message_maps); - mMessageMapsImageView = (ImageView) findViewById(R.id.maps_image); - mRequestRideButton = (Button) findViewById(R.id.request_ride_button); - mBrandImageView = (ImageView) findViewById(R.id.brand_image); - mDirectionsButton= (ImageView) findViewById(R.id.directions_button); - mButtonDivider = findViewById(R.id.button_divider); - mMessageTextView = (TextView) findViewById(R.id.message_text); mMessageTextView.setOnClickListener(this); IgnoreLinkLongClickHelper.ignoreLinkLongClick(mMessageTextView, this); @@ -321,13 +288,6 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick } /** - * Sets a ridesharing util to get data from ridesharing services - */ - public void setRidesharingUtil(final RidesharingUtil ridesharingUtil) { - mRidesharingUtil = ridesharingUtil; - } - - /** * Sets a delay loader instance to manage loading / resuming of image attachments. */ public void setImageViewDelayLoader(final AsyncImageViewDelayLoader delayLoader) { @@ -354,7 +314,7 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick */ private boolean shouldShowMessageBubbleArrow() { return !shouldShowSimplifiedVisualStyle() - && !(mData.hasAttachments() || mMessageHasMapsLink || mMessageHasYouTubeLink); + && !(mData.hasAttachments() || mMessageHasYouTubeLink); } /** @@ -583,11 +543,6 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick mMultiAttachmentView.setVisibility(View.GONE); } - // In the case that we have no image attachments and a maps url then we will show a map - // preview - String mapsUrlString = null; - final String mapsUrlPrefix = "geo:0,0?q="; - // In the case that we have no image attachments and exactly one youtube link in a message // then we will show a preview. String youtubeThumbnailUrl = null; @@ -598,35 +553,28 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick messageTextWithSpans.length(), URLSpan.class); for (URLSpan span : spans) { String url = span.getURL(); - if (url.startsWith(mapsUrlPrefix)) { - mapsUrlString = url; - break; - } else { - String youtubeLinkForUrl = YouTubeUtil.getYoutubePreviewImageLink(url); - if (!TextUtils.isEmpty(youtubeLinkForUrl)) { - if (TextUtils.isEmpty(youtubeThumbnailUrl)) { - // Save the youtube link if we don't already have one - youtubeThumbnailUrl = youtubeLinkForUrl; - originalYoutubeLink = url; - } else { - // We already have a youtube link. This means we have two youtube links so - // we shall show none. - youtubeThumbnailUrl = null; - originalYoutubeLink = null; - break; - } + String youtubeLinkForUrl = YouTubeUtil.getYoutubePreviewImageLink(url); + if (!TextUtils.isEmpty(youtubeLinkForUrl)) { + if (TextUtils.isEmpty(youtubeThumbnailUrl)) { + // Save the youtube link if we don't already have one + youtubeThumbnailUrl = youtubeLinkForUrl; + originalYoutubeLink = url; + } else { + // We already have a youtube link. This means we have two youtube links so + // we shall show none. + youtubeThumbnailUrl = null; + originalYoutubeLink = null; + break; } } } } // We need to keep track if we have a youtube link in the message so that we will not show // the arrow - mMessageHasMapsLink = !TextUtils.isEmpty(mapsUrlString); mMessageHasYouTubeLink = !TextUtils.isEmpty(youtubeThumbnailUrl); - // We will show the message image view if there is one attachment or one maps link or - // one youtube link - if (imageParts.size() == 1 || mMessageHasMapsLink || mMessageHasYouTubeLink) { + // We will show the message image view if there is one attachment or one youtube link + if (imageParts.size() == 1 || mMessageHasYouTubeLink) { // Get the display metrics for a hint for how large to pull the image data into final WindowManager windowManager = (WindowManager) getContext(). getSystemService(Context.WINDOW_SERVICE); @@ -649,10 +597,6 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick adjustImageViewBounds(imagePart); mMessageImageView.setImageResourceId(imageRequest); mMessageImageView.setTag(imagePart); - mMessageImageView.setVisibility(View.VISIBLE); - } else if (mMessageHasMapsLink) { - // Maps image and buttons - showMapsPreview(mapsUrlString, mapsUrlPrefix, desiredWidth); } else { // Youtube Thumbnail image final ImageRequestDescriptor imageRequest = @@ -663,11 +607,9 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick ImageUtils.DEFAULT_CIRCLE_STROKE_COLOR /* circleStrokeColor */); mMessageImageView.setImageResourceId(imageRequest); mMessageImageView.setTag(originalYoutubeLink); - mMessageImageView.setVisibility(View.VISIBLE); } + mMessageImageView.setVisibility(View.VISIBLE); } else { - mMessageMapsView.setVisibility(View.GONE); - mMessageImageView.setImageResourceId(null); mMessageImageView.setVisibility(View.GONE); } @@ -684,112 +626,6 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick mMessageAttachmentsView.setVisibility(attachmentsVisible ? View.VISIBLE : View.GONE); } - /** - * Shows a maps preview and provides buttons for requesting a ride to the location and - * directions to the location - * @param mapsUrlString Encoded map url string - * @param mapsUrlPrefix Prefix for the map url string (such as geo:0,0?q=) - * @param desiredWidth Desired width of the maps preview - */ - private void showMapsPreview(String mapsUrlString, String mapsUrlPrefix, int desiredWidth) { - final int unspecifiedMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - final int mapsWidthMeasureSpec = MeasureSpec.makeMeasureSpec(desiredWidth, - MeasureSpec.EXACTLY); - final int mapsHeightMeasureSpec = MeasureSpec.makeMeasureSpec(getResources() - .getDimensionPixelSize(R.dimen.conversation_maps_height), MeasureSpec.EXACTLY); - - mMessageMapsView.measure(mapsWidthMeasureSpec, mapsHeightMeasureSpec); - - // Reset view visibility to gone - mRequestRideButton.setVisibility(View.GONE); - mBrandImageView.setVisibility(View.GONE); - mDirectionsButton.setVisibility(View.GONE); - mButtonDivider.setVisibility(View.GONE); - - final String encodedAddress = mapsUrlString.substring(mapsUrlPrefix.length()); - - String staticMapsUrl = GoogleStaticMapsUtil.getStaticMapsUrl(mContext, - getResources().getDimensionPixelSize(R.dimen.map_request_width), - getResources().getDimensionPixelSize(R.dimen.map_request_height), encodedAddress); - RoundedCornerTransformation transformation = - new RoundedCornerTransformation(mContext.getApplicationContext(), staticMapsUrl); - Picasso.with(mContext.getApplicationContext()) - .load(staticMapsUrl) - .placeholder(R.drawable.ic_map_placeholder) - .transform(transformation) - .into(mMessageMapsImageView, new ImageLoadedCallback()); - final Uri mapsUri = Uri.parse(mapsUrlString); - mMessageMapsImageView.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(Intent.ACTION_VIEW, mapsUri); - mContext.startActivity(intent); - } - }); - - final String directionsPrefix = "google.navigation:q="; - final Uri directionsUri = Uri.parse(directionsPrefix + encodedAddress); - mDirectionsButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(Intent.ACTION_VIEW, directionsUri); - mContext.startActivity(intent); - } - }); - - final String encodingFormat = "UTF-8"; - mRequestRideButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - String decodedAddress = null; - try { - decodedAddress = URLDecoder.decode(encodedAddress, encodingFormat); - } catch (UnsupportedEncodingException e) { - Log.e(TAG, "Unable to decode address: " + encodedAddress, e); - } - - if (!TextUtils.isEmpty(decodedAddress)) { - RidesharingContract.RideRequest.Builder builder = - new RidesharingContract.RideRequest.Builder(); - builder.addDropoffLocation(decodedAddress); - Intent intent = builder.build(); - mContext.startActivity(intent); - - MetricsHelper.increaseCountOfEventMetricAfterValidate(mContext.getApplicationContext(), new ComponentName(mContext.getApplicationContext(), ConversationActivity.class), - MetricsHelper.MetricEvent.UBER_RIDE_REQUESTED); - } - } - }); - - mRidesharingUtil.setBrandBitmap(mBrandImageView); - - final int dividerWidth = getResources() - .getDimensionPixelSize(R.dimen.maps_button_divider_width); - final int dividerWidthMeasureSpec = MeasureSpec.makeMeasureSpec(dividerWidth, - MeasureSpec.EXACTLY); - mButtonDivider.measure(dividerWidthMeasureSpec, unspecifiedMeasureSpec); - - mMessageMapsView.setVisibility(View.VISIBLE); - - MetricsHelper.increaseCountOfEventMetricAfterValidate(mContext.getApplicationContext(), new ComponentName(mContext.getApplicationContext(), ConversationActivity.class), - MetricsHelper.MetricEvent.RIDESHARING_MAP_SHOWN); - } - - private class ImageLoadedCallback implements com.squareup.picasso.Callback { - @Override - public void onSuccess() { - mRequestRideButton.setVisibility(View.VISIBLE); - mBrandImageView.setVisibility(View.VISIBLE); - mDirectionsButton.setVisibility(View.VISIBLE); - mButtonDivider.setVisibility(View.VISIBLE); - } - - @Override - public void onError() { - Log.e(TAG, "Unable to load static map"); - } - } - private void bindAttachmentsOfSameType(final Predicate<MessagePartData> attachmentTypeFilter, final int attachmentViewLayoutRes, final AttachmentViewBinder viewBinder, final Class<?> attachmentViewClass) { @@ -1049,16 +885,6 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick // Tint image/video attachments when selected final int selectedImageTint = getResources().getColor(R.color.message_image_selected_tint); - if (mMessageMapsImageView.getVisibility() == View.VISIBLE && - mDirectionsButton.getVisibility() == View.VISIBLE) { - if (isSelected()) { - mMessageMapsImageView.setColorFilter(selectedImageTint); - mDirectionsButton.setColorFilter(selectedImageTint); - } else { - mMessageMapsImageView.clearColorFilter(); - mDirectionsButton.clearColorFilter(); - } - } if (mMessageImageView.getVisibility() == View.VISIBLE) { if (isSelected()) { mMessageImageView.setColorFilter(selectedImageTint); @@ -1438,4 +1264,5 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick } } } + } diff --git a/src/com/cyanogenmod/messaging/util/GoogleStaticMapsUtil.java b/src/com/cyanogenmod/messaging/util/GoogleStaticMapsUtil.java deleted file mode 100644 index cb1b0c7..0000000 --- a/src/com/cyanogenmod/messaging/util/GoogleStaticMapsUtil.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2016 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cyanogenmod.messaging.util; - -import android.content.Context; -import com.android.messaging.R; - -public class GoogleStaticMapsUtil { - private static final String STATIC_MAPS_URL = "https://maps.googleapis.com/maps/api/staticmap?"; - - private static final String AND = "&"; - private static final String PIPE = "|"; - private static final String X = "x"; - - private static final String SIZE = "size="; - private static final String ZOOM = "zoom=17"; - private static final String SCALE = "scale=4"; - private static final String API_KEY = "key="; - - private static final String PICK_UP_MARKER = - "markers=icon:http://cdn.cyngn.com/ridesharing/pickup_marker.png"; - - public static String getStaticMapsUrl(Context context, int width, int height, String encodedAddress) { - final StringBuilder sb = new StringBuilder(STATIC_MAPS_URL); - sb.append(AND); - sb.append(SIZE); - sb.append(width); - sb.append(X); - sb.append(height); - sb.append(AND); - sb.append(ZOOM); - sb.append(AND); - sb.append(SCALE); - sb.append(AND); - sb.append(API_KEY); - sb.append(context.getString(R.string.google_maps_key)); - sb.append(AND); - sb.append(PICK_UP_MARKER); - sb.append(PIPE); - sb.append(encodedAddress); - - return sb.toString(); - } -} diff --git a/src/com/cyanogenmod/messaging/util/MetricsHelper.java b/src/com/cyanogenmod/messaging/util/MetricsHelper.java deleted file mode 100644 index aff2e32..0000000 --- a/src/com/cyanogenmod/messaging/util/MetricsHelper.java +++ /dev/null @@ -1,223 +0,0 @@ -/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* - * Copyright (c) 2016 Cyanogen Inc. - * All Rights Reserved. - * Cyanogen Confidential and Proprietary. - * =========================================================================*/ - -package com.cyanogenmod.messaging.util; - -import android.content.SharedPreferences; -import android.util.Log; - -//import com.android.internal.annotations.VisibleForTesting; -import com.cyanogen.ambient.analytics.Event; -import android.content.ComponentName; -import android.content.Context; - -import java.util.HashMap; -import java.util.Map; - -public final class MetricsHelper { - - private static final String TAG = "MetricsHelper"; - private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); - - public static final String METRICS_SHARED_PREFERENCES = "messaging_metrics"; - public static final String METRICS_VALIDATION = "messaging_metrics_validation"; - public static final String DELIMIT = ":"; - private static final String CATEGORY_BASE = "messaging.metrics."; - - // Positions in our shared preference keys - private static final int POS_COMPONENT_NAME = 0; - private static final int POS_CATEGORY_VALUE = 1; - private static final int POS_EVENT_VALUE = 2; - private static final int POS_PARAM_VALUE = 3; - - public static final String CATEGORY_MESSAGING_RIDESHARING_INTEGRATION = "category_messaging_ridesharing_integration"; - public static final String EVENT_RIDESHARING_MAP_SHOWN = "event_ridesharing_map_shown"; - public static final String EVENT_UBER_RIDE_REQUESTED = "event_uber_ride_requested"; - public static final String PARAM_COUNT = "param_count"; - public static final String PARAM_PROVIDER = "provider"; - - public static enum MetricEvent { - RIDESHARING_MAP_SHOWN, - UBER_RIDE_REQUESTED; - } - - //@VisibleForTesting - /* package */ static void storeEvent(Context context, ComponentName cn, - HashMap<String, String> data, String category, String event) { - - SharedPreferences sp = context.getSharedPreferences( - METRICS_SHARED_PREFERENCES, Context.MODE_PRIVATE); - - SharedPreferences.Editor editor = sp.edit(); - - for (String param : data.keySet()) { - StringBuilder sb = new StringBuilder(); - sb.append(cn.flattenToShortString()); // Add ComponentName String - sb.append(DELIMIT); - sb.append(category); // Add our category value - sb.append(DELIMIT); - sb.append(event); // Add our event value - sb.append(DELIMIT); - sb.append(param); // add our param value - editor.putString(sb.toString(), data.get(param)); - } - editor.apply(); - } - - /** - * Get the sharedpreferences events and output a hashmap for the event's values. - * - * @param context the current context - * @param componentName ComponentName who created the event - * - * @return HashMap of our params and their values. - */ - /* package*/ static HashMap<String, String> getStoredEventParams(Context context, - ComponentName componentName, String category, String event) { - - SharedPreferences sp = context.getSharedPreferences( - METRICS_SHARED_PREFERENCES, Context.MODE_PRIVATE); - - StringBuilder sb = new StringBuilder(); - sb.append(componentName.flattenToShortString()); // Add ComponentName String - sb.append(DELIMIT); - sb.append(category); // Add our category value - sb.append(DELIMIT); - sb.append(event); // Add our event value - sb.append(DELIMIT); - - HashMap<String, String> eventMap = new HashMap<>(); - Map<String, ?> map = sp.getAll(); - - for(Map.Entry<String,?> entry : map.entrySet()) { - if (entry.getKey().startsWith(sb.toString())) { - String[] keyParts = entry.getKey().split(DELIMIT); - String key = keyParts[POS_PARAM_VALUE]; - eventMap.put(key, String.valueOf(entry.getValue())); - } - } - return eventMap; - } - - /** - * Helper method to increase the count of event metric if the last action was not - * the same as the current action. - * - * @param context - */ - public static void increaseCountOfEventMetricAfterValidate(Context context, ComponentName componentName, - MetricEvent metricEvent) { - - StringBuilder sb = new StringBuilder(); - sb.append(componentName.flattenToShortString()); // Add ComponentName String - sb.append(DELIMIT); - sb.append(CATEGORY_MESSAGING_RIDESHARING_INTEGRATION); // Add our category value - - String validationKey = sb.toString(); - String event; - switch (metricEvent) { - case UBER_RIDE_REQUESTED: - event = EVENT_UBER_RIDE_REQUESTED; - break; - case RIDESHARING_MAP_SHOWN: - default: - event = EVENT_RIDESHARING_MAP_SHOWN; - break; - } - - if (checkLastEvent(context, validationKey, event)) { - HashMap<String, String> metricsData - = getStoredEventParams(context, componentName, CATEGORY_MESSAGING_RIDESHARING_INTEGRATION, - event); - - int count = 1; - if (metricsData.containsKey(PARAM_COUNT)) { - count += Integer.valueOf(metricsData.get(PARAM_COUNT)); - } - - metricsData.put(PARAM_COUNT, String.valueOf(count)); - storeEvent(context, componentName, metricsData, CATEGORY_MESSAGING_RIDESHARING_INTEGRATION, event); - } - } - - /* package */ static boolean checkLastEvent(Context context, String validationKey, String event) { - SharedPreferences preferences = context.getSharedPreferences(METRICS_VALIDATION, - Context.MODE_PRIVATE); - - SharedPreferences.Editor editor = preferences.edit(); - String lastEvent = preferences.getString(validationKey, null); - - if (lastEvent != null && lastEvent.equals(event)) { - return false; - } else { - editor.putString(validationKey, event); - } - - editor.apply(); - return true; - } - - - /** - * Prepares all our metrics for sending. - */ - public static HashMap<String, Event.Builder> getEventsToSend(Context c) { - SharedPreferences sp = c.getSharedPreferences(METRICS_SHARED_PREFERENCES, - Context.MODE_PRIVATE); - - Map<String, ?> map = sp.getAll(); - - HashMap<String, Event.Builder> unBuiltEvents = new HashMap<>(); - - for(Map.Entry<String,?> entry : map.entrySet()){ - String[] keyParts = entry.getKey().split(DELIMIT); - - if (keyParts.length == POS_PARAM_VALUE + 1) { - String componentString = keyParts[POS_COMPONENT_NAME]; - String eventCategory = keyParts[POS_CATEGORY_VALUE]; - String parameter = keyParts[POS_PARAM_VALUE]; - String eventAction = keyParts[POS_EVENT_VALUE]; - - StringBuilder sb = new StringBuilder(); - sb.append(componentString); // Add ComponentName String - sb.append(DELIMIT); - sb.append(eventCategory); // Add our category value - sb.append(DELIMIT); - sb.append(eventAction); // Add our event value - String eventKey = sb.toString(); - - Event.Builder eventBuilder; - if (unBuiltEvents.containsKey(eventKey)) { - eventBuilder = unBuiltEvents.get(eventKey); - } else { - eventBuilder = new Event.Builder(CATEGORY_BASE + eventCategory, eventAction); - eventBuilder.addField(PARAM_PROVIDER, componentString); - } - - eventBuilder.addField(parameter, String.valueOf(entry.getValue())); - unBuiltEvents.put(eventKey, eventBuilder); - } - } - return unBuiltEvents; - } - - public static void clearEventData(Context c, String key) { - SharedPreferences sp = c.getSharedPreferences(METRICS_SHARED_PREFERENCES, - Context.MODE_PRIVATE); - - Map<String, ?> map = sp.getAll(); - SharedPreferences.Editor editor = sp.edit(); - - for(Map.Entry<String,?> entry : map.entrySet()){ - String storedKey = entry.getKey(); - if (storedKey.startsWith(key)) { - editor.remove(storedKey); - } - } - editor.apply(); - } - -} diff --git a/src/com/cyanogenmod/messaging/util/MetricsJob.java b/src/com/cyanogenmod/messaging/util/MetricsJob.java deleted file mode 100644 index 8b623a7..0000000 --- a/src/com/cyanogenmod/messaging/util/MetricsJob.java +++ /dev/null @@ -1,139 +0,0 @@ -/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* - * Copyright (c) 2016 Cyanogen Inc. - * All Rights Reserved. - * Cyanogen Confidential and Proprietary. - * =========================================================================*/ - -package com.cyanogenmod.messaging.util; - -import android.app.job.JobParameters; -import android.app.job.JobService; -import android.os.AsyncTask; -import android.util.Log; - -import com.cyanogen.ambient.common.ConnectionResult; -import com.cyanogen.ambient.common.ConnectionResult; -import com.cyanogen.ambient.common.api.AmbientApiClient; -import com.cyanogen.ambient.analytics.AnalyticsServices; -import com.cyanogen.ambient.analytics.Event; -import com.cyanogen.ambient.common.api.Result; - -import java.util.HashMap; -import java.util.concurrent.TimeUnit; - -/** - * MetricsJob is an aggregation and shipping service that is fired - * once every 24 hours to pass Metrics to ModCore's analytics service. - */ -public final class MetricsJob extends JobService { - - private static final String TAG = "MetricsJob"; - private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); - - private static final long TIMEOUT_MILLIS = 1000; - - public static final int METRICS_JOB_ID = 1441; - - private MetricsTask mUploadTask; - - private AmbientApiClient ambientApiClient; - - public MetricsJob() { - super(); - } - - @Override - public boolean onStartJob(JobParameters params) { - if (DEBUG) Log.v(TAG, "sending events"); - - // AmbientClient - ambientApiClient = new AmbientApiClient.Builder(this) - .addApi(AnalyticsServices.API) - .addOnConnectionFailedListener(new AmbientApiClient.OnConnectionFailedListener() { - @Override - public void onConnectionFailed(ConnectionResult result) { - Log.e(TAG, "Failed to connect to Ambient. reason: " + result.getErrorCode()); - } - }).build(); - - // Send stored Specific events - mUploadTask = new MetricsTask(params); - mUploadTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, (Void) null); - - // Running on another thread, return true. - return true; - } - - @Override - public boolean onStopJob(JobParameters params) { - - if (ambientApiClient != null && (ambientApiClient.isConnected() || ambientApiClient.isConnecting())) { - ambientApiClient.disconnect(); - } - - // Cancel our async task - mUploadTask.cancel(true); - - // report that we should try again soon. - return true; - } - - - class MetricsTask extends AsyncTask<Void, Void, Boolean> { - - JobParameters mMetricsJobParams; - - public MetricsTask(JobParameters params) { - this.mMetricsJobParams = params; - } - - @Override - protected Boolean doInBackground(Void... params) { - - HashMap<String, Event.Builder> eventsToSend - = MetricsHelper.getEventsToSend(MetricsJob.this); - - for (String key : eventsToSend.keySet()) { - - Event.Builder eventBuilder = eventsToSend.get(key); - - if (DEBUG) Log.v(TAG, "sending:" + eventBuilder.toString()); - - if (isCancelled()) { - return false; - } - - Result r = AnalyticsServices.AnalyticsApi.sendEvent( - ambientApiClient, - eventBuilder.build()) - .await(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); - - // if any of our results were not successful, something is wrong. - // Stop this job for now. - if (!r.getStatus().isSuccess()) { - return false; - } - - // We sent all the data we had for this event to the database. So clear it from our - // SharedPreferences. - MetricsHelper.clearEventData(MetricsJob.this, key); - } - return true; - } - - @Override - protected void onCancelled() { - if (DEBUG) Log.w(TAG, "Messaging Metrics Job Cancelled"); - // do nothing - } - - @Override - protected void onPostExecute(Boolean success) { - if (DEBUG) Log.v(TAG, "was success: " + success); - - // attempt to reschedule if analytics service is unavailable for our events - jobFinished(mMetricsJobParams, !success /* reschedule */); - } - } - -} diff --git a/src/com/cyanogenmod/messaging/util/RidesharingUtil.java b/src/com/cyanogenmod/messaging/util/RidesharingUtil.java deleted file mode 100644 index 844cf97..0000000 --- a/src/com/cyanogenmod/messaging/util/RidesharingUtil.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.cyanogenmod.messaging.util; - -import android.content.Context; -import android.graphics.Bitmap; -import android.os.Bundle; -import android.util.Log; -import android.widget.ImageView; -import com.cyanogen.ambient.common.ConnectionResult; -import com.cyanogen.ambient.common.api.AmbientApiClient; -import com.cyanogen.ambient.common.api.ComponentNameResult; -import com.cyanogen.ambient.common.api.PendingResult; -import com.cyanogen.ambient.common.api.ResultCallback; -import com.cyanogen.ambient.ridesharing.RideSharingApi; -import com.cyanogen.ambient.ridesharing.RideSharingServices; -import com.cyanogen.ambient.ridesharing.results.ProviderInfoResult; - -/** - * Ridesharing services util - */ -public class RidesharingUtil { - private static final String TAG = RidesharingUtil.class.getSimpleName(); - - private Context mContext; - private AmbientApiClient mAmbientApiClient; - private RideSharingApi mRideSharingApi; - - private Bitmap mBrandBitmap; - - public RidesharingUtil(Context context) { - mContext = context; - connectAmbientApiClientIfNeeded(); - } - - /** - * Sets brand bitmap from the active ridesharing provider to the specified {@link ImageView} - * @param imageView ImageView to set the brand bitmap on - */ - public void setBrandBitmap(final ImageView imageView) { - if (mBrandBitmap == null) { - connectAmbientApiClientIfNeeded(); - - PendingResult<ComponentNameResult> pendingComponentResult = - mRideSharingApi.getActivePlugin(mAmbientApiClient); - pendingComponentResult.setResultCallback(new ResultCallback<ComponentNameResult>() { - @Override - public void onResult(final ComponentNameResult componentResult) { - if (componentResult != null && componentResult.component != null) { - PendingResult<ProviderInfoResult> pendingInfoResult = - mRideSharingApi.getPluginInfo(mAmbientApiClient, - componentResult.component); - pendingInfoResult.setResultCallback(new ResultCallback<ProviderInfoResult>() { - @Override - public void onResult(ProviderInfoResult infoResult) { - if (infoResult != null && infoResult.getProviderInfo() != null) { - mBrandBitmap = infoResult.getProviderInfo().getBrandIcon(); - imageView.setImageBitmap(mBrandBitmap); - } else { - Log.e(TAG, "Unable to get provider info for active plugin: " - + componentResult.component); - } - } - }); - } else { - Log.e(TAG, "Unable to get active plugin"); - } - } - }); - } else { - imageView.setImageBitmap(mBrandBitmap); - } - } - - /** - * Helper method to initialize AmbientApiClient if it is null and connect AmbientApiClient if - * it is not connected and not currently trying to connect - */ - private void connectAmbientApiClientIfNeeded() { - if (mAmbientApiClient == null) { - Log.d(TAG, "mAmbientApiClient is null, initializing"); - mAmbientApiClient = new AmbientApiClient.Builder(mContext) - .addApi(RideSharingServices.API) - .build(); - if (mAmbientApiClient == null) { - Log.e(TAG, "AmbientApiClient couldn't initialize, returning"); - return; - } - mAmbientApiClient.registerConnectionFailedListener(new AmbientApiClient.OnConnectionFailedListener() { - @Override - public void onConnectionFailed(ConnectionResult connectionResult) { - Log.e(TAG, "Unable to connect with Ambient. ConnectionResult.ErrorCode : " + connectionResult.getErrorCode()); - } - }); - mAmbientApiClient.registerConnectionCallbacks(new AmbientApiClient.ConnectionCallbacks() { - @Override - public void onConnected(Bundle bundle) { - Log.d(TAG, "Connected with Ambient."); - } - - @Override - public void onConnectionSuspended(int i) { - Log.d(TAG, "Ambient client disconnected."); - } - }); - } - - if (!mAmbientApiClient.isConnected() && !mAmbientApiClient.isConnecting()) { - Log.d(TAG, "ambientApiClient is not connect or connecting, attempting to connect now"); - mAmbientApiClient.connect(); - mRideSharingApi = RideSharingServices.getInstance(); - } - } -} diff --git a/src/com/cyanogenmod/messaging/util/RoundedCornerTransformation.java b/src/com/cyanogenmod/messaging/util/RoundedCornerTransformation.java deleted file mode 100644 index 197a774..0000000 --- a/src/com/cyanogenmod/messaging/util/RoundedCornerTransformation.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.cyanogenmod.messaging.util; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapShader; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.RectF; -import android.graphics.Shader; -import android.support.v7.appcompat.R; - -public class RoundedCornerTransformation implements com.squareup.picasso.Transformation { - private Context mContext; - private String mTag; - - public RoundedCornerTransformation(Context context, String tag) { - mContext = context; - mTag = tag; - } - - @Override - public Bitmap transform(Bitmap source) { - int width = source.getWidth(); - int height = source.getHeight(); - - Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - final RectF rect = new RectF(0, 0, width, height); - - final int radius = - mContext.getResources().getDimensionPixelSize(R.dimen.maps_corner_radius); - Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); - BitmapShader shader = new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); - paint.setShader(shader); - canvas.drawRoundRect(rect, radius, radius, paint); - - source.recycle(); - - return bitmap; - } - - @Override - public String key() { - return mTag; - } -} |