@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    StrictMode.setThreadPolicy(
        new StrictMode.ThreadPolicy.Builder()
            .detectCustomSlowCalls()
            .detectDiskWrites()
            .penaltyDialog()
            .build());

    button = (Button) findViewById(R.id.buttonBlocked);
    button.setOnClickListener(this);

    ShowcaseView.ConfigOptions co = new ShowcaseView.ConfigOptions();
    co.hideOnClickOutside = true;
    sv =
        ShowcaseView.insertShowcaseView(
            R.id.buttonBlocked,
            this,
            "ShowcaseView Sample",
            "When the ShowcaseView is showing, "
                + "pressing the button will show a gesture. When it is hidden "
                + "it'll go to another Activity.",
            co);
    sv.setOnShowcaseEventListener(this);
  }
Exemple #2
0
  private void showcaseDrawerPress() {
    // only show on first boot
    if (alreadyShowcasedDrawer) {
      return;
    }

    final int vertDp = ViewsHelper.convertDip2Pixels(this, 110);
    final int horDp = ViewsHelper.convertDip2Pixels(this, 60);

    if (sv != null) {
      sv.setText(R.string.showcase_drawer_title, R.string.showcase_drawer_msg);
      sv.setShowcasePosition(horDp, vertDp);
      sv.show();
    } else {
      final ConfigOptions options = new ConfigOptions();
      options.shotType = ShowcaseView.TYPE_NO_LIMIT;
      options.block = true;
      // Used in saving state
      options.showcaseId = 2;
      sv =
          ShowcaseView.insertShowcaseView(
              horDp,
              vertDp,
              this,
              R.string.showcase_drawer_title,
              R.string.showcase_drawer_msg,
              options);
      sv.show();
    }
    PreferenceManager.getDefaultSharedPreferences(this)
        .edit()
        .putBoolean(SHOWCASED_DRAWER, true)
        .commit();
    alreadyShowcasedDrawer = true;
  }
Exemple #3
0
  /** On first load, show some functionality hints */
  private void showcaseDrawer() {
    if (alreadyShowcased) {
      return;
    }
    final ConfigOptions options = new ConfigOptions();
    options.shotType = ShowcaseView.TYPE_NO_LIMIT;
    options.block = true;
    // Used in saving state
    options.showcaseId = 1;
    final int vertDp = ViewsHelper.convertDip2Pixels(this, 200);
    final int horDp = ViewsHelper.convertDip2Pixels(this, 200);
    sv =
        ShowcaseView.insertShowcaseViewWithType(
            ShowcaseView.ITEM_ACTION_HOME,
            android.R.id.home,
            this,
            R.string.showcase_main_title,
            R.string.showcase_main_msg,
            options);
    sv.animateGesture(0, vertDp, horDp, vertDp);

    PreferenceManager.getDefaultSharedPreferences(this)
        .edit()
        .putBoolean(SHOWCASED_MAIN, true)
        .commit();
    alreadyShowcased = true;
  }
 @Override
 public void onClick(View view) {
   if (sv.isShown()) {
     sv.animateGesture(0, 0, 0, -400);
   } else {
     startActivity(new Intent(this, ActionItemsSampleActivity.class));
   }
 }
 /**
  * Quickly insert a ShowcaseView into an Activity, highlighting an item.
  *
  * @param type the type of item to showcase (can be ITEM_ACTION_HOME, ITEM_TITLE_OR_SPINNER,
  *     ITEM_ACTION_ITEM or ITEM_ACTION_OVERFLOW)
  * @param itemId the ID of an Action item to showcase (only required for ITEM_ACTION_ITEM
  * @param activity Activity to insert the ShowcaseView into
  * @param title Text to show as a title. Can be null.
  * @param detailText More detailed text. Can be null.
  * @param options A set of options to customise the ShowcaseView
  * @return the created ShowcaseView instance
  */
 public static ShowcaseView insertShowcaseViewWithType(
     int type, int itemId, Activity activity, int title, int detailText, ConfigOptions options) {
   ShowcaseView sv = new ShowcaseView(activity);
   if (options != null) sv.setConfigOptions(options);
   if (sv.getConfigOptions().insert == INSERT_TO_DECOR) {
     ((ViewGroup) activity.getWindow().getDecorView()).addView(sv);
   } else {
     ((ViewGroup) activity.findViewById(android.R.id.content)).addView(sv);
   }
   sv.setShowcaseItem(type, itemId, activity);
   sv.setText(title, detailText);
   return sv;
 }
 public static ShowcaseView insertShowcaseView(
     float x, float y, Activity activity, String title, String detailText, ConfigOptions options) {
   ShowcaseView sv = new ShowcaseView(activity);
   if (options != null) sv.setConfigOptions(options);
   if (sv.getConfigOptions().insert == INSERT_TO_DECOR) {
     ((ViewGroup) activity.getWindow().getDecorView()).addView(sv);
   } else {
     ((ViewGroup) activity.findViewById(android.R.id.content)).addView(sv);
   }
   sv.setShowcasePosition(x, y);
   sv.setText(title, detailText);
   return sv;
 }
  /**
   * Handles activity initialization when the Service has connected.
   *
   * <p>Should be called when there is a reason to believe that the connection might have became
   * valid. The connection MUST be established but other validity criteria may still be unfilled
   * such as server synchronization being complete.
   *
   * <p>The method implements the logic required for making sure that the Connected service is in
   * such a state that it fills all the connection criteria for ChannelList.
   *
   * <p>The method also takes care of making sure that its initialization code is executed only once
   * so calling it several times doesn't cause problems.
   */
  protected void onConnected() {
    // Tell the service that we are now visible.
    mService.setActivityVisible(true);

    // Update user control
    updateUserControlMenuItems();

    // Restore push to talk state, if toggled. Otherwise make sure it's turned off.
    if (settings.isPushToTalk() && mService.isRecording()) {
      if (settings.isPushToTalkToggle() && settings.isPushToTalkButtonShown()) setPushToTalk(true);
      else mService.setPushToTalk(false);
    }

    if (settings.isPushToTalk() && mService.isRecording())
      if (chatTarget != null) {
        listFragment.setChatTarget(chatTarget);
        chatFragment.setChatTarget(chatTarget);
      }

    // Showcase hints
    List<ShowcaseView> showcaseViews = new ArrayList<ShowcaseView>();
    if (settings.isPushToTalk() && settings.isPushToTalkButtonShown()) {
      ConfigOptions pttConfig = new ConfigOptions();
      pttConfig.shotType = ShowcaseView.TYPE_ONE_SHOT;
      pttConfig.showcaseId = Globals.SHOWCASE_PUSH_TO_TALK;
      showcaseViews.add(
          ShowcaseView.insertShowcaseView(
              pttView, this, R.string.hint_ptt, R.string.hint_ptt_summary, pttConfig));
    }

    if (mViewPager != null) {
      ConfigOptions switcherConfig = new ConfigOptions();
      switcherConfig.shotType = ShowcaseView.TYPE_ONE_SHOT;
      switcherConfig.showcaseId = Globals.SHOWCASE_SWITCHER;
      showcaseViews.add(
          ShowcaseView.insertShowcaseView(
              ShowcaseView.ITEM_ACTION_HOME,
              0,
              this,
              R.string.hint_switching,
              R.string.hint_switching_summary,
              switcherConfig));
    }

    ShowcaseViewQueue queue = new ShowcaseViewQueue(showcaseViews);
    queue.queueNext();
  }