Search in sources :

Example 6 with JamorhamShowcaseDrawer

use of com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer in project xDrip-plus by jamorham.

the class StatsActivity method showStartupInfo.

private void showStartupInfo() {
    // if (swipeInfoNotNeeded) {
    // //show info only if user didn't swipe already.
    // return;
    // }
    final boolean oneshot = true;
    final int option = Home.SHOWCASE_STATISTICS;
    if ((oneshot) && (ShotStateStore.hasShot(option)))
        return;
    // This could do with being in a utility static method also used in Home
    final int size1 = 50;
    final int size2 = 20;
    final String title = "Swipe for Different Reports";
    final String message = "Swipe left and right to see different report tabs.\n\nChoose time period for Today, Yesterday, 7 Days etc.\n\nFull screen mode, print colors and Sharing are supported from the butttons and 3 dot menu.";
    final ViewTarget target = new ViewTarget(R.id.button_stats_7d, this);
    final Activity activity = this;
    JoH.runOnUiThreadDelayed(new Runnable() {

        @Override
        public void run() {
            final ShowcaseView myShowcase = new ShowcaseView.Builder(activity).setTarget(target).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(title).setContentText("\n" + message).setShowcaseDrawer(new JamorhamShowcaseDrawer(getResources(), getTheme(), size1, size2)).singleShot(oneshot ? option : -1).build();
            myShowcase.setBackgroundColor(Color.TRANSPARENT);
            myShowcase.show();
        }
    }, 3000);
// TextView tv = new TextView(this);
// tv.setText("Swipe left/right to switch between reports!");
// tv.setTextColor(Color.GREEN);
// tv.setTextSize(25);
// for (int i = 0; i < 2; i++) {
// Show toast twice the "long" period
// Toast toast = new Toast(getApplicationContext());
// toast.setView(tv);
// toast.setGravity(Gravity.CENTER, 0, 0);
// toast.show();
// }
}
Also used : Activity(android.app.Activity) ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) JamorhamShowcaseDrawer(com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer)

Example 7 with JamorhamShowcaseDrawer

use of com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer in project xDrip-plus by jamorham.

the class MegaStatus method startupInfo.

private void startupInfo() {
    final boolean oneshot = true;
    final int option = Home.SHOWCASE_MEGASTATUS;
    if ((oneshot) && (ShotStateStore.hasShot(option)))
        return;
    // This could do with being in a utility static method also used in Home
    final int size1 = 300;
    final int size2 = 130;
    final String title = "Swipe for Different Pages";
    final String message = "Swipe left and right to see different status tabs.\n\n";
    final ViewTarget target = new ViewTarget(R.id.pager_title_strip, this);
    final Activity activity = this;
    JoH.runOnUiThreadDelayed(new Runnable() {

        @Override
        public void run() {
            final ShowcaseView myShowcase = new ShowcaseView.Builder(activity).setTarget(target).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(title).setContentText("\n" + message).setShowcaseDrawer(new JamorhamShowcaseDrawer(getResources(), getTheme(), size1, size2, 255)).singleShot(oneshot ? option : -1).build();
            myShowcase.setBackgroundColor(Color.TRANSPARENT);
            myShowcase.show();
        }
    }, 1500);
}
Also used : Activity(android.app.Activity) ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) JamorhamShowcaseDrawer(com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer)

Example 8 with JamorhamShowcaseDrawer

use of com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer 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 9 with JamorhamShowcaseDrawer

use of com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer in project xDrip by NightscoutFoundation.

the class LanguageEditor method showcasemenu.

private synchronized void showcasemenu(final int option) {
    if ((myShowcase != null) && (myShowcase.isShowing()))
        return;
    if (ShotStateStore.hasShot(option))
        return;
    if (!JoH.ratelimit("language-showcase", 2))
        return;
    try {
        ToolbarActionItemTarget target = null;
        ViewTarget viewtarget = null;
        String title = "";
        String message = "";
        switch(option) {
            case SHOWCASE_LANGUAGE_INTRO:
                target = new ToolbarActionItemTarget(toolbar, R.id.action_language_search);
                // these messages always appear in english only
                title = "Search and Submit Translations";
                message = "You can help crowd-source better translations for xDrip+\n\nSimply find and edit the text, click ✔ or ➡ on your keyboard to save. Match as closely as possible the English version (including preserving punctuation symbols and capitalisation) and then use Save button to Upload your suggested changes.\n\nIt is not yet possible to preview your changes in the App, but if accepted they will appear in future updates.";
                break;
            case SHOWCASE_LANGUAGE_ELEMENT_UNDO:
                // done inside the adapter
                break;
        }
        // seems a bit excessive just to delay the lookup of the view to avoid it failing sometimes
        final ToolbarActionItemTarget finaltarget = target;
        final ViewTarget finalviewtarget = viewtarget;
        final String finalmessage = message;
        final String finaltitle = title;
        final Activity finalactivity = this;
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {

            @Override
            public void run() {
                if ((finaltarget != null) || (finalviewtarget != null)) {
                    myShowcase = new ShowcaseView.Builder(finalactivity).setTarget((finaltarget != null) ? finaltarget : finalviewtarget).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(finaltitle).setContentText("\n" + finalmessage).setShowcaseDrawer(new JamorhamShowcaseDrawer(getResources(), getTheme(), 90, 14)).singleShot(oneshot ? option : -1).build();
                    myShowcase.setBackgroundColor(Color.TRANSPARENT);
                    myShowcase.show();
                }
            }
        }, 100);
    } catch (Exception e) {
        Log.e(TAG, "Exception in showcase: " + e.toString());
    }
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) BaseAppCompatActivity(com.eveningoutpost.dexdrip.BaseAppCompatActivity) Activity(android.app.Activity) Handler(android.os.Handler) ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) JamorhamShowcaseDrawer(com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer)

Example 10 with JamorhamShowcaseDrawer

use of com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer in project xDrip by NightscoutFoundation.

the class Home method showcasemenu.

private synchronized void showcasemenu(int option) {
    if ((myShowcase != null) && (myShowcase.isShowing()))
        return;
    if (ShotStateStore.hasShot(option))
        return;
    // if (showcaseblocked) return;
    try {
        ViewTarget target = null;
        String title = "";
        String message = "";
        int size1 = 90;
        int size2 = 14;
        switch(option) {
            case SHOWCASE_MOTION_DETECTION:
                // dummy
                target = new ViewTarget(R.id.btnNote, this);
                size1 = 0;
                size2 = 0;
                title = getString(R.string.title_motion_detection_warning);
                message = getString(R.string.message_motion_detection_warning);
                break;
            case SHOWCASE_VARIANT:
                // dummy
                target = new ViewTarget(R.id.btnNote, this);
                size1 = 0;
                size2 = 0;
                title = getString(R.string.title_variant);
                message = getString(R.string.message_variant);
                break;
            case SHOWCASE_NOTE_LONG:
                target = new ViewTarget(R.id.btnNote, this);
                title = getString(R.string.note_button);
                message = getString(R.string.showcase_note_long);
                break;
            case SHOWCASE_REDO:
                target = new ViewTarget(R.id.btnRedo, this);
                title = getString(R.string.redo_button);
                message = getString(R.string.showcase_redo);
                break;
            case SHOWCASE_UNDO:
                target = new ViewTarget(R.id.btnUndo, this);
                title = getString(R.string.undo_button);
                message = getString(R.string.showcase_undo);
                break;
            case 3:
                target = new ViewTarget(R.id.btnTreatment, this);
                break;
            case 1:
                Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
                List<View> views = toolbar.getTouchables();
                // Log.d("xxy", Integer.toString(views.size()));
                for (View view : views) {
                    Log.d("jamhorham showcase", view.getClass().getSimpleName());
                    if (view.getClass().getSimpleName().equals("OverflowMenuButton")) {
                        target = new ViewTarget(view);
                        break;
                    }
                }
                break;
        }
        if (target != null) {
            // showcaseblocked = true;
            myShowcase = new ShowcaseView.Builder(this).setTarget(target).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(title).setContentText("\n" + message).setShowcaseDrawer(new JamorhamShowcaseDrawer(getResources(), getTheme(), size1, size2)).singleShot(oneshot ? option : -1).build();
            myShowcase.setBackgroundColor(Color.TRANSPARENT);
            myShowcase.show();
        }
    } catch (Exception e) {
        Log.e(TAG, "Exception in showcase: " + e.toString());
    }
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) BgGraphBuilder(com.eveningoutpost.dexdrip.UtilityModels.BgGraphBuilder) ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) LineChartView(lecho.lib.hellocharts.view.LineChartView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) PreviewLineChartView(lecho.lib.hellocharts.view.PreviewLineChartView) TextView(android.widget.TextView) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) JamorhamShowcaseDrawer(com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer) IOException(java.io.IOException) ParseException(java.text.ParseException) ActivityNotFoundException(android.content.ActivityNotFoundException) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

JamorhamShowcaseDrawer (com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer)14 ShowcaseView (com.github.amlcurran.showcaseview.ShowcaseView)14 ViewTarget (com.github.amlcurran.showcaseview.targets.ViewTarget)14 Activity (android.app.Activity)10 SuppressLint (android.annotation.SuppressLint)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 Paint (android.graphics.Paint)2 Point (android.graphics.Point)2 Handler (android.os.Handler)2 AppCompatActivity (android.support.v7.app.AppCompatActivity)2 Toolbar (android.support.v7.widget.Toolbar)2 MotionEvent (android.view.MotionEvent)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 RelativeLayout (android.widget.RelativeLayout)2 TextView (android.widget.TextView)2 BaseAppCompatActivity (com.eveningoutpost.dexdrip.BaseAppCompatActivity)2 BgGraphBuilder (com.eveningoutpost.dexdrip.UtilityModels.BgGraphBuilder)2 OnShowcaseEventListener (com.github.amlcurran.showcaseview.OnShowcaseEventListener)2 GsonBuilder (com.google.gson.GsonBuilder)2