Esempio n. 1
0
 protected internal override void onPause()
 {
     if (Finishing)
     {
         long id = Intent.getLongExtra(INTENT_EXTRA_CONTENT_ID, -1);
         EngagementReachAgent.getInstance(this).exitLoading(id);
     }
     base.onPause();
 }
Esempio n. 2
0
        protected internal override void onResume()
        {
            long id = Intent.getLongExtra(INTENT_EXTRA_CONTENT_ID, -1);

            if (!EngagementReachAgent.getInstance(this).isLoading(id))
            {
                finish();
            }
            base.onResume();
        }
Esempio n. 3
0
        /// <summary>
        /// Called when download times out. </summary>
        /// <param name="context"> application context. </param>
        /// <param name="intent"> timeout intent containing content identifier. </param>
        private void onDownloadTimeout(Context context, Intent intent)
        {
            /* Delegate to agent */
            EngagementReachAgent reachAgent           = EngagementReachAgent.getInstance(context);
            EngagementReachInteractiveContent content = reachAgent.getContent(intent);

            if (content != null)
            {
                reachAgent.onDownloadTimeout(content);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Called when a notification has been exited (clear button from notification panel). </summary>
        /// <param name="context"> context. </param>
        /// <param name="intent"> intent containing the content identifier to exit. </param>
        private void onNotificationExited(Context context, Intent intent)
        {
            /* Get content */
            EngagementReachAgent reachAgent           = EngagementReachAgent.getInstance(context);
            EngagementReachInteractiveContent content = reachAgent.getContent(intent);

            /* Exit it if found */
            if (content != null)
            {
                content.exitNotification(context);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Report content has been displayed. </summary>
        /// <param name="context"> any application context. </param>
        public virtual void displayContent(Context context)
        {
            /* Notify reach agent */
            EngagementReachAgent.getInstance(context).onContentDisplayed(this);

            /* Guard against multiple calls for feedback */
            if (!mContentDisplayed)
            {
                mCampaignId.sendFeedBack(context, "content-displayed", null);
                mContentDisplayed = true;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Action the notification: this will display the announcement or poll, or will launch the action
        /// URL associated to the notification, depending of the content kind. This will also report the
        /// notification has been actioned. </summary>
        /// <param name="context"> any application context. </param>
        /// <param name="launchIntent"> true to launch intent, false to just report the notification action and
        ///          change internal state. If you call this method passing false, be sure that the content
        ///          is either a notification only announcement or that you properly manage the content
        ///          display and its life cycle (by calling actionContent or exitContent when the user is
        ///          done viewing the content). </param>
        public virtual void actionNotification(Context context, bool launchIntent)
        {
            /* Notify agent if intent must be launched */
            EngagementReachAgent.getInstance(context).onNotificationActioned(this, launchIntent);

            /* Send feedback */
            if (!mNotificationActioned)
            {
                mCampaignId.sendFeedBack(context, NotificationStatusPrefix + "actioned", null);
                mNotificationActioned = true;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Called when a push message is received or message download completes. </summary>
        /// <param name="context"> context. </param>
        /// <param name="intent"> intent. </param>
        private void onMessage(Context context, Intent intent)
        {
            string type = intent.getStringExtra(INTENT_EXTRA_TYPE);

            if (INTENT_EXTRA_TYPE_PUSH.Equals(type))
            {
                EngagementReachAgent.getInstance(context).onContentReceived(intent.Extras);
            }
            else if (INTENT_EXTRA_TYPE_DLC.Equals(type))
            {
                EngagementReachAgent.getInstance(context).onMessageDownloaded(intent.Extras);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Called when a system notification for a content has been actioned. </summary>
        /// <param name="context"> context. </param>
        /// <param name="intent"> intent describing the content. </param>
        private void onNotificationActioned(Context context, Intent intent)
        {
            /* Get content */
            EngagementReachAgent reachAgent           = EngagementReachAgent.getInstance(context);
            EngagementReachInteractiveContent content = reachAgent.getContent(intent);

            /* If content retrieved successfully */
            if (content != null)

            /* Tell reach to start the content activity */
            {
                content.actionNotification(context, true);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Report notification has been displayed. </summary>
        /// <param name="context"> any application context. </param>
        public virtual void displayNotification(Context context)
        {
            /* Update last displayed date */
            mNotificationLastDisplayedDate = DateTimeHelperClass.CurrentUnixTimeMillis();

            /* First date and reach feedback the first time */
            if (mNotificationFirstDisplayedDate == null)
            {
                mNotificationFirstDisplayedDate = mNotificationLastDisplayedDate;
                mCampaignId.sendFeedBack(context, NotificationStatusPrefix + "displayed", null);
            }

            /* Notify reach agent */
            EngagementReachAgent.getInstance(context).onNotificationDisplayed(this);
        }
Esempio n. 10
0
        public override void onReceive(Context context, Intent intent)
        {
            /* Big picture downloaded */
            if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.Equals(intent.Action))
            {
                /* Get content by download id */
                long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
                EngagementReachAgent reachAgent           = EngagementReachAgent.getInstance(context);
                EngagementReachInteractiveContent content = reachAgent.getContentByDownloadId(downloadId);

                /* Delegate to agent if content found */
                if (content != null)
                {
                    reachAgent.onDownloadComplete(content);
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Dispose of this content so that new content can be notified. Possibly send feedback to the
        /// service that sent it. </summary>
        /// <param name="context"> application context. </param>
        /// <param name="status"> feedback status if any (null not to send anything). </param>
        /// <param name="extras"> extra information like poll answers. </param>
        internal virtual void process(Context context, string status, Bundle extras)
        {
            /* Do it once */
            if (!mProcessed)
            {
                /* Send feedback if any */
                if (status != null)
                {
                    mCampaignId.sendFeedBack(context, status, extras);
                }

                /* Mark this announcement as processed */
                mProcessed = true;

                /* Tell the reach application manager that announcement has been processed */
                EngagementReachAgent.getInstance(context).onContentProcessed(this);
            }
        }
Esempio n. 12
0
        public override void onReceive(Context context, Intent intent)
        {
            /* Boot: restore system notifications */
            string action = intent.Action;

            if (Intent.ACTION_BOOT_COMPLETED.Equals(action))
            {
                EngagementReachAgent.getInstance(context).onDeviceBoot();
            }

            /* Just ensure the reach agent is loaded for checking pending contents in SQLite */
            else if (EngagementAgent.INTENT_ACTION_AGENT_CREATED.Equals(action))
            {
                EngagementReachAgent.getInstance(context);
            }

            /* Notification actioned e.g. clicked (from the system notification) */
            else if (EngagementReachAgent.INTENT_ACTION_ACTION_NOTIFICATION.Equals(action))
            {
                onNotificationActioned(context, intent);
            }

            /* System notification exited (clear button) */
            else if (EngagementReachAgent.INTENT_ACTION_EXIT_NOTIFICATION.Equals(action))
            {
                onNotificationExited(context, intent);
            }

            /* Called when download takes too much time to complete */
            else if (EngagementReachAgent.INTENT_ACTION_DOWNLOAD_TIMEOUT.Equals(action))
            {
                onDownloadTimeout(context, intent);
            }

            /* Called when we receive GCM or ADM push with azme parameters or message download completes. */
            else if (EngagementIntents.INTENT_ACTION_MESSAGE.Equals(action))
            {
                onMessage(context, intent);
            }
        }
Esempio n. 13
0
        protected internal override void onCreate(Bundle savedInstanceState)
        {
            /* No title section on the top */
            base.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);

            /* Get content */
            mContent = EngagementReachAgent.getInstance(this).getContent(Intent);
            if (mContent == null)
            {
                /* If problem with content, exit */
                finish();
                return;
            }

            /* Inflate layout */
            ContentView = getLayoutId(LayoutName);

            /* Set title */
            TextView titleView = getView("title");
            string   title     = mContent.Title;

            if (title != null)
            {
                titleView.Text = title;
            }
            else
            {
                titleView.Visibility = View.GONE;
            }

            /* Set body */
            setBody(mContent.Body, getView("body"));

            /* Action button */
            mActionButton = getView("action");
            string actionLabel = mContent.ActionLabel;

            if (actionLabel != null)
            {
                mActionButton.Text            = actionLabel;
                mActionButton.OnClickListener = new OnClickListenerAnonymousInnerClassHelper(this);
            }

            /* No action label means no action button */
            else
            {
                mActionButton.Visibility = View.GONE;
            }

            /* Exit button */
            Button exitButton = getView("exit");
            string exitLabel  = mContent.ExitLabel;

            if (exitLabel != null)
            {
                exitButton.Text            = exitLabel;
                exitButton.OnClickListener = new OnClickListenerAnonymousInnerClassHelper2(this);
            }

            /* No exit label means no exit button */
            else
            {
                exitButton.Visibility = View.GONE;
            }

            /* Hide spacers if only one button is visible (or none) */
            ViewGroup layout     = getView("engagement_button_bar");
            bool      hideSpacer = actionLabel == null || exitLabel == null;

            for (int i = 0; i < layout.ChildCount; i++)
            {
                View view = layout.getChildAt(i);
                if ("spacer".Equals(view.Tag))
                {
                    if (hideSpacer)
                    {
                        view.Visibility = View.VISIBLE;
                    }
                    else
                    {
                        view.Visibility = View.GONE;
                    }
                }
            }

            /* Hide button bar if both action and exit buttons are hidden */
            if (actionLabel == null && exitLabel == null)
            {
                layout.Visibility = View.GONE;
            }
        }
Esempio n. 14
0
 /// <summary>
 /// Set download identifier for this content. </summary>
 /// <param name="context"> any application context. </param>
 /// <param name="downloadId"> download identifier. </param>
 public virtual void setDownloadId(Context context, long downloadId)
 {
     mDownloadId = downloadId;
     EngagementReachAgent.getInstance(context).onDownloadScheduled(this, downloadId);
 }