Search in sources :

Example 6 with PreferencesManager

use of com.wooplr.spotlight.prefs.PreferencesManager in project ChatExchange by HueToYou.

the class TutorialStuff method homeFragTutorial.

/*
     * Home fragment
     */
public static void homeFragTutorial(final MainActivity activity) {
    if (mSharedPreferences == null) {
        mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
    }
    if (mCategoryConfig == null) {
        setCategoryConfig(activity);
    }
    // SpotlightSequence.getInstance(activity, mCategoryConfig)
    // .addSpotlight(Utils.getActionBar(activity.getWindow().getDecorView()).getChildAt(1),
    // activity.getResources().getString(R.string.tutorial_drawer),
    // activity.getResources().getString(R.string.homeFrag_hamburger_tutorial_text),
    // MAIN_DRAWER)
    // .addSpotlight(Utils.getActionBar(activity.getWindow().getDecorView()).getChildAt(2),
    // activity.getResources().getString(R.string.tutorial_menu),
    // activity.getResources().getString(R.string.homeFrag_options_menu_tutorial_text),
    // MAIN_MENU)
    // .startSequence();
    PreferencesManager manager = new PreferencesManager(activity);
    if (!manager.isDisplayed(MAIN_DRAWER)) {
        MainActivity.touchesBlocked = true;
    }
    SpotlightView drawer = new SpotlightView.Builder(activity).target(Utils.getActionBar(activity.getWindow().getDecorView()).getChildAt(1)).setConfiguration(mCategoryConfig).headingTvText(activity.getResources().getString(R.string.tutorial_drawer)).subHeadingTvText(activity.getResources().getString(R.string.homeFrag_hamburger_tutorial_text)).usageId(MAIN_DRAWER).show();
    final SpotlightView.Builder menu = new SpotlightView.Builder(activity).setConfiguration(mCategoryConfig).headingTvText(activity.getResources().getString(R.string.tutorial_menu)).subHeadingTvText(activity.getResources().getString(R.string.homeFrag_options_menu_tutorial_text)).usageId(MAIN_MENU);
    SpotlightListener listener = new SpotlightListener() {

        @Override
        public void onUserClicked(String s) {
            switch(s) {
                case MAIN_DRAWER:
                    menu.target(Utils.getActionBar(activity.getWindow().getDecorView()).getChildAt(2)).show();
                    MainActivity.touchesBlocked = true;
                    break;
                case MAIN_MENU:
                    MainActivity.touchesBlocked = false;
                    break;
            }
        }

        @Override
        public void onFinishedDrawingSpotlight() {
            MainActivity.touchesBlocked = false;
        }

        @Override
        public void onStartedDrawingSpotlight() {
            MainActivity.touchesBlocked = false;
        }
    };
    drawer.setListener(listener);
    menu.setListener(listener);
}
Also used : SpotlightListener(com.wooplr.spotlight.utils.SpotlightListener) SpotlightView(com.wooplr.spotlight.SpotlightView) PreferencesManager(com.wooplr.spotlight.prefs.PreferencesManager)

Example 7 with PreferencesManager

use of com.wooplr.spotlight.prefs.PreferencesManager in project ChatExchange by HueToYou.

the class TutorialStuff method showUsersTutorial.

public static void showUsersTutorial(final Activity activity) {
    if (mSharedPreferences == null) {
        mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
    }
    if (mCategoryConfig == null) {
        setCategoryConfig(activity);
    }
    if (mItemConfig == null) {
        setItemConfig(activity);
    }
    Bundle args = new Bundle();
    args.putString(USER_NAME_KEY, "Edwinksl");
    args.putString(USER_AVATAR_URL_KEY, "https://images.duckduckgo.com/iu/?u=http%3A%2F%2Fimages.clipshrine.com%2Fdownload%2Fdownloadpnglarge%2FBlack-Question-Mark-2269-large.png&f=1");
    args.putString(USER_URL_KEY, "https://example.stackexchange.com");
    args.putBoolean("IsExampleTile", true);
    args.putInt("ExampleNum", 0);
    args.putInt(USER_ID_KEY, 12345);
    args.putInt(USER_LAST_POST_KEY, 0);
    args.putInt(USER_REP_KEY, 123);
    args.putBoolean(USER_IS_MOD_KEY, false);
    args.putBoolean(USER_IS_OWNER_KEY, false);
    final UserTileFragment userTileFragment = new UserTileFragment();
    userTileFragment.setArguments(args);
    args = new Bundle();
    args.putString(USER_NAME_KEY, "Thomas Ward");
    args.putString(USER_AVATAR_URL_KEY, "https://images.duckduckgo.com/iu/?u=http%3A%2F%2Fimages.clipshrine.com%2Fdownload%2Fdownloadpnglarge%2FBlack-Question-Mark-2269-large.png&f=1");
    args.putString(USER_URL_KEY, "https://example.stackexchange.com");
    args.putBoolean("IsExampleTile", true);
    args.putInt("ExampleNum", 1);
    args.putInt(USER_ID_KEY, 12346);
    args.putInt(USER_LAST_POST_KEY, 0);
    args.putInt(USER_REP_KEY, 123);
    args.putBoolean(USER_IS_MOD_KEY, true);
    args.putBoolean(USER_IS_OWNER_KEY, false);
    final UserTileFragment userTileFragment1 = new UserTileFragment();
    userTileFragment1.setArguments(args);
    args = new Bundle();
    args.putString(USER_NAME_KEY, "Rinzwind");
    args.putString(USER_AVATAR_URL_KEY, "https://images.duckduckgo.com/iu/?u=http%3A%2F%2Fimages.clipshrine.com%2Fdownload%2Fdownloadpnglarge%2FBlack-Question-Mark-2269-large.png&f=1");
    args.putString(USER_URL_KEY, "https://example.stackexchange.com");
    args.putBoolean("IsExampleTile", true);
    args.putInt("ExampleNum", 2);
    args.putInt(USER_ID_KEY, 12347);
    args.putInt(USER_LAST_POST_KEY, 0);
    args.putInt(USER_REP_KEY, 123);
    args.putBoolean(USER_IS_MOD_KEY, false);
    args.putBoolean(USER_IS_OWNER_KEY, true);
    final UserTileFragment userTileFragment2 = new UserTileFragment();
    userTileFragment2.setArguments(args);
    PreferencesManager manager = new PreferencesManager(activity);
    LinearLayout users = activity.findViewById(R.id.users_scroll_slide);
    if (!manager.isDisplayed(USERS_SLIDE_INTRO)) {
        List<android.support.v4.app.Fragment> fragments = ((AppCompatActivity) activity).getSupportFragmentManager().getFragments();
        for (int i = 0; i < fragments.size(); i++) {
            ((AppCompatActivity) activity).getSupportFragmentManager().beginTransaction().hide(fragments.get(i)).commit();
        }
        ((AppCompatActivity) activity).getSupportFragmentManager().beginTransaction().add(R.id.users_scroll_slide, userTileFragment, "user_" + 12345).commit();
        ((AppCompatActivity) activity).getSupportFragmentManager().beginTransaction().add(R.id.users_scroll_slide, userTileFragment1, "user_" + 12346).commit();
        ((AppCompatActivity) activity).getSupportFragmentManager().beginTransaction().add(R.id.users_scroll_slide, userTileFragment2, "user_" + 12347).commit();
        MainActivity.touchesBlocked = true;
    }
    SpotlightView usersOverview = new SpotlightView.Builder(activity).target(users).setConfiguration(mCategoryConfig).headingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text_title_main)).subHeadingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text)).usageId(USERS_SLIDE_INTRO).targetPadding(Util.dpToPx(activity, 50)).show();
    final SpotlightView.Builder overviewMore = new SpotlightView.Builder(activity).target(users).setConfiguration(mCategoryConfig).headingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text_title_main)).subHeadingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text_more)).usageId(USERS_SLIDE_INTRO_MORE).targetPadding(Util.dpToPx(activity, 50));
    final SpotlightView.Builder user1 = new SpotlightView.Builder(activity).target(users.getChildAt(0)).setConfiguration(mCategoryConfig).headingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text_title_user_normal)).subHeadingTvText(activity.getResources().getString(R.string.chatFrag_normalUser_tutorial_text)).usageId(USER_ONE);
    final SpotlightView.Builder userMod = new SpotlightView.Builder(activity).target(users.getChildAt(1)).setConfiguration(mCategoryConfig).headingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text_title_user_mod)).subHeadingTvText(activity.getResources().getString(R.string.chatFrag_modUser_tutorial_text)).usageId(USER_MOD);
    final SpotlightView.Builder userOwner = new SpotlightView.Builder(activity).setConfiguration(mCategoryConfig).target(users.getChildAt(2)).headingTvText(activity.getResources().getString(R.string.chatFrag_usersSlidingPanel_tutorial_text_title_user_owner)).subHeadingTvText(activity.getResources().getString(R.string.chatFrag_ROuser_tutorial_text)).usageId(USER_OWNER);
    SpotlightListener listener = new SpotlightListener() {

        @Override
        public void onUserClicked(String s) {
            Log.e("Which", s);
            switch(s) {
                case USERS_SLIDE_INTRO:
                    overviewMore.show();
                    MainActivity.touchesBlocked = true;
                    break;
                case USERS_SLIDE_INTRO_MORE:
                    user1.show();
                    MainActivity.touchesBlocked = true;
                    break;
                case USER_ONE:
                    userMod.show();
                    MainActivity.touchesBlocked = true;
                    break;
                case USER_MOD:
                    userOwner.show();
                    MainActivity.touchesBlocked = true;
                    break;
                case USER_OWNER:
                    List<android.support.v4.app.Fragment> fragments = ((AppCompatActivity) activity).getSupportFragmentManager().getFragments();
                    for (int i = 0; i < fragments.size(); i++) {
                        ((AppCompatActivity) activity).getSupportFragmentManager().beginTransaction().show(fragments.get(i)).commit();
                    }
                    ((AppCompatActivity) activity).getSupportFragmentManager().beginTransaction().remove(userTileFragment).remove(userTileFragment1).remove(userTileFragment2).commit();
                    MainActivity.touchesBlocked = false;
                    break;
            }
        }

        @Override
        public void onFinishedDrawingSpotlight() {
            MainActivity.touchesBlocked = false;
        }

        @Override
        public void onStartedDrawingSpotlight() {
            MainActivity.touchesBlocked = false;
        }
    };
    usersOverview.setListener(listener);
    overviewMore.setListener(listener);
    user1.setListener(listener);
    userMod.setListener(listener);
    userOwner.setListener(listener);
}
Also used : UserTileFragment(com.huetoyou.chatexchange.ui.frags.UserTileFragment) Bundle(android.os.Bundle) PreferencesManager(com.wooplr.spotlight.prefs.PreferencesManager) UserTileFragment(com.huetoyou.chatexchange.ui.frags.UserTileFragment) SpotlightListener(com.wooplr.spotlight.utils.SpotlightListener) SpotlightView(com.wooplr.spotlight.SpotlightView) LinearLayout(android.widget.LinearLayout)

Aggregations

PreferencesManager (com.wooplr.spotlight.prefs.PreferencesManager)7 SpotlightView (com.wooplr.spotlight.SpotlightView)5 SpotlightListener (com.wooplr.spotlight.utils.SpotlightListener)5 RecyclerView (android.support.v7.widget.RecyclerView)2 FloatingActionButton (com.github.clans.fab.FloatingActionButton)2 FloatingActionMenu (com.github.clans.fab.FloatingActionMenu)2 Paint (android.graphics.Paint)1 PorterDuffXfermode (android.graphics.PorterDuffXfermode)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)1 View (android.view.View)1 EditText (android.widget.EditText)1 ImageButton (android.widget.ImageButton)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 RecyclerViewSwipeManager (com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager)1 MainActivity (com.huetoyou.chatexchange.ui.activity.main.MainActivity)1