Search in sources :

Example 1 with OnShowcaseEventListener

use of com.github.amlcurran.showcaseview.OnShowcaseEventListener in project xDrip by NightscoutFoundation.

the class Reminders method showcase.

private static void showcase(final Activity activity, final int which) {
    final ViewTarget target;
    final String title;
    final String message;
    int size1 = 200;
    int size2 = 70;
    long delay = 1000;
    final boolean oneshot = true;
    final int option = which;
    if ((oneshot) && (ShotStateStore.hasShot(option)))
        return;
    switch(which) {
        case Home.SHOWCASE_REMINDER1:
            target = new ViewTarget(R.id.fab, activity);
            title = xdrip.getAppContext().getString(R.string.title_You_have_no_reminders_yet);
            message = xdrip.getAppContext().getString(R.string.message_reminders_explanation);
            delay = 200;
            break;
        case Home.SHOWCASE_REMINDER2:
            target = null;
            title = xdrip.getAppContext().getString(R.string.title_swipe_reminder);
            message = xdrip.getAppContext().getString(R.string.message_swipe_explanation);
            break;
        case Home.SHOWCASE_REMINDER3:
            target = new ViewTarget(R.id.imageButton5, activity);
            title = xdrip.getAppContext().getString(R.string.title_reminder_snooze_undo);
            message = xdrip.getAppContext().getString(R.string.message_snooze_explanaition_undo);
            break;
        case Home.SHOWCASE_REMINDER4:
            target = new ViewTarget(R.id.reminderTrashButton, activity);
            title = xdrip.getAppContext().getString(R.string.title_snooze_trash);
            message = xdrip.getAppContext().getString(R.string.message_snooze_trash);
            delay = 10;
            break;
        case Home.SHOWCASE_REMINDER5:
            target = new ViewTarget(R.id.imageButton7, activity);
            title = xdrip.getAppContext().getString(R.string.title_snooze_hide);
            message = xdrip.getAppContext().getString(R.string.message_snooze_hide);
            delay = 10;
            break;
        case Home.SHOWCASE_REMINDER6:
            target = new ViewTarget(R.id.button5, activity);
            title = xdrip.getAppContext().getString(R.string.title_snooze_times);
            message = xdrip.getAppContext().getString(R.string.message_snooze_times);
            delay = 10;
            break;
        default:
            return;
    }
    final int f_size1 = size1;
    final int f_size2 = size2;
    JoH.runOnUiThreadDelayed(new Runnable() {

        @Override
        public void run() {
            final ShowcaseView myShowcase;
            if (target != null) {
                myShowcase = new ShowcaseView.Builder(activity).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(title).setTarget(target).blockAllTouches().setContentText("\n" + message).setShowcaseDrawer(new JamorhamShowcaseDrawer(activity.getResources(), activity.getTheme(), f_size1, f_size2, 255)).singleShot(oneshot ? option : -1).build();
            } else {
                myShowcase = new ShowcaseView.Builder(activity).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(title).blockAllTouches().setContentText("\n" + message).setShowcaseDrawer(new JamorhamShowcaseDrawer(activity.getResources(), activity.getTheme(), f_size1, f_size2, 255)).singleShot(oneshot ? option : -1).build();
            }
            myShowcase.setTag(which);
            myShowcase.setBackgroundColor(Color.TRANSPARENT);
            myShowcase.setShouldCentreText(false);
            myShowcase.setOnShowcaseEventListener(new OnShowcaseEventListener() {

                @Override
                public void onShowcaseViewHide(ShowcaseView showcaseView) {
                }

                @Override
                public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
                    switch((int) showcaseView.getTag()) {
                        case Home.SHOWCASE_REMINDER3:
                            showcase(activity, Home.SHOWCASE_REMINDER4);
                            break;
                        case Home.SHOWCASE_REMINDER4:
                            showcase(activity, Home.SHOWCASE_REMINDER5);
                            break;
                        case Home.SHOWCASE_REMINDER5:
                            showcase(activity, Home.SHOWCASE_REMINDER6);
                            break;
                    }
                }

                @Override
                public void onShowcaseViewShow(ShowcaseView showcaseView) {
                }

                @Override
                public void onShowcaseViewTouchBlocked(MotionEvent motionEvent) {
                }
            });
            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            int margin = (int) activity.getResources().getDimension(R.dimen.button_margin);
            params.setMargins(margin, margin, margin, margin);
            params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            myShowcase.setButtonPosition(params);
            myShowcase.show();
        }
    }, delay);
}
Also used : OnShowcaseEventListener(com.github.amlcurran.showcaseview.OnShowcaseEventListener) ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) JamorhamShowcaseDrawer(com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer) MotionEvent(android.view.MotionEvent) RelativeLayout(android.widget.RelativeLayout) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView)

Example 2 with OnShowcaseEventListener

use of com.github.amlcurran.showcaseview.OnShowcaseEventListener in project xDrip-plus by jamorham.

the class Reminders method showcase.

private static void showcase(final Activity activity, final int which) {
    final ViewTarget target;
    final String title;
    final String message;
    int size1 = 200;
    int size2 = 70;
    long delay = 1000;
    final boolean oneshot = true;
    final int option = which;
    if ((oneshot) && (ShotStateStore.hasShot(option)))
        return;
    switch(which) {
        case Home.SHOWCASE_REMINDER1:
            target = new ViewTarget(R.id.fab, activity);
            title = xdrip.getAppContext().getString(R.string.title_You_have_no_reminders_yet);
            message = xdrip.getAppContext().getString(R.string.message_reminders_explanation);
            delay = 200;
            break;
        case Home.SHOWCASE_REMINDER2:
            target = null;
            title = xdrip.getAppContext().getString(R.string.title_swipe_reminder);
            message = xdrip.getAppContext().getString(R.string.message_swipe_explanation);
            break;
        case Home.SHOWCASE_REMINDER3:
            target = new ViewTarget(R.id.imageButton5, activity);
            title = xdrip.getAppContext().getString(R.string.title_reminder_snooze_undo);
            message = xdrip.getAppContext().getString(R.string.message_snooze_explanaition_undo);
            break;
        case Home.SHOWCASE_REMINDER4:
            target = new ViewTarget(R.id.reminderTrashButton, activity);
            title = xdrip.getAppContext().getString(R.string.title_snooze_trash);
            message = xdrip.getAppContext().getString(R.string.message_snooze_trash);
            delay = 10;
            break;
        case Home.SHOWCASE_REMINDER5:
            target = new ViewTarget(R.id.imageButton7, activity);
            title = xdrip.getAppContext().getString(R.string.title_snooze_hide);
            message = xdrip.getAppContext().getString(R.string.message_snooze_hide);
            delay = 10;
            break;
        case Home.SHOWCASE_REMINDER6:
            target = new ViewTarget(R.id.button5, activity);
            title = xdrip.getAppContext().getString(R.string.title_snooze_times);
            message = xdrip.getAppContext().getString(R.string.message_snooze_times);
            delay = 10;
            break;
        default:
            return;
    }
    final int f_size1 = size1;
    final int f_size2 = size2;
    JoH.runOnUiThreadDelayed(new Runnable() {

        @Override
        public void run() {
            final ShowcaseView myShowcase;
            if (target != null) {
                myShowcase = new ShowcaseView.Builder(activity).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(title).setTarget(target).blockAllTouches().setContentText("\n" + message).setShowcaseDrawer(new JamorhamShowcaseDrawer(activity.getResources(), activity.getTheme(), f_size1, f_size2, 255)).singleShot(oneshot ? option : -1).build();
            } else {
                myShowcase = new ShowcaseView.Builder(activity).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(title).blockAllTouches().setContentText("\n" + message).setShowcaseDrawer(new JamorhamShowcaseDrawer(activity.getResources(), activity.getTheme(), f_size1, f_size2, 255)).singleShot(oneshot ? option : -1).build();
            }
            myShowcase.setTag(which);
            myShowcase.setBackgroundColor(Color.TRANSPARENT);
            myShowcase.setShouldCentreText(false);
            myShowcase.setOnShowcaseEventListener(new OnShowcaseEventListener() {

                @Override
                public void onShowcaseViewHide(ShowcaseView showcaseView) {
                }

                @Override
                public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
                    switch((int) showcaseView.getTag()) {
                        case Home.SHOWCASE_REMINDER3:
                            showcase(activity, Home.SHOWCASE_REMINDER4);
                            break;
                        case Home.SHOWCASE_REMINDER4:
                            showcase(activity, Home.SHOWCASE_REMINDER5);
                            break;
                        case Home.SHOWCASE_REMINDER5:
                            showcase(activity, Home.SHOWCASE_REMINDER6);
                            break;
                    }
                }

                @Override
                public void onShowcaseViewShow(ShowcaseView showcaseView) {
                }

                @Override
                public void onShowcaseViewTouchBlocked(MotionEvent motionEvent) {
                }
            });
            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            int margin = (int) activity.getResources().getDimension(R.dimen.button_margin);
            params.setMargins(margin, margin, margin, margin);
            params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            myShowcase.setButtonPosition(params);
            myShowcase.show();
        }
    }, delay);
}
Also used : OnShowcaseEventListener(com.github.amlcurran.showcaseview.OnShowcaseEventListener) ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) JamorhamShowcaseDrawer(com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer) MotionEvent(android.view.MotionEvent) RelativeLayout(android.widget.RelativeLayout) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView)

Aggregations

MotionEvent (android.view.MotionEvent)2 RelativeLayout (android.widget.RelativeLayout)2 JamorhamShowcaseDrawer (com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer)2 OnShowcaseEventListener (com.github.amlcurran.showcaseview.OnShowcaseEventListener)2 ShowcaseView (com.github.amlcurran.showcaseview.ShowcaseView)2 ViewTarget (com.github.amlcurran.showcaseview.targets.ViewTarget)2