private void updateViews() {
    Step step = getCurrentStep();

    if (stepIndex + 1 >= steps.size()) {
      nextButton.setImageDrawable(buttonFinishIcon);
      nextButton.setContentDescription(getString(R.string.finish));
      step.updateView(true);
    } else {
      nextButton.setImageDrawable(buttonNextIcon);
      nextButton.setContentDescription(getString(R.string.next_step));
      step.updateView(false);
    }

    step.restore(setupData);

    setTextFieldBackgroundDrawable();

    inputSwitcher.setDisplayedChild(stepIndex);
    errorSwitcher.setText("");
    detailsSwitcher.setText(step.getDetails(this));
    titleSwitcher.setText(step.getTitle(this));
    stepText.setText(getString(R.string.page_number, stepIndex + 1, steps.size()));

    stepText.setTextColor(detailsTextColor);

    updateProgressbar();
  }
  private void updatePausePlay() {
    if (mRoot == null || mPauseButton == null) return;

    if (mPlayer.isPlaying()) {
      mPauseButton.setImageResource(com.android.internal.R.drawable.ic_media_pause);
      mPauseButton.setContentDescription(mPauseDescription);
    } else {
      mPauseButton.setImageResource(com.android.internal.R.drawable.ic_media_play);
      mPauseButton.setContentDescription(mPlayDescription);
    }
  }
  @Override
  public void onClick(View v) {
    boolean isPlaying = mMediaPlayer.isPlaying();
    if (v == mButtonPlayPause) {
      if (isPlaying) {
        mMediaPlayer.pause();
        mChronometer.stop();
        mButtonPlayPause.setImageResource(R.drawable.media_play);
        mButtonPlayPause.setContentDescription(getResources().getText(R.string.play));
      } else {
        mMediaPlayer.start();
        mChronometer.setBase(SystemClock.elapsedRealtime() - mMediaPlayer.getCurrentPosition());
        mChronometer.start();
        mButtonPlayPause.setImageResource(R.drawable.media_pause);
        mButtonPlayPause.setContentDescription(getResources().getText(R.string.pause));
      }
    } else if (v == mButtonSkip) {
      mIndex = (mIndex + 1) % mItems.size();
      onClick(mButtonStop);
      if (isPlaying) {
        onClick(mButtonPlayPause);
      }
    } else if (v == mButtonRewind) {
      // mMediaPlayer.seekTo(0);
      mChronometer.setBase(SystemClock.elapsedRealtime());

      if (mIndex == 0) {
        mIndex = mItems.size();
      }

      if (mIndex > 0) {
        mIndex = (mIndex - 1) % mItems.size();
      }

      onClick(mButtonStop);
      if (isPlaying) {
        onClick(mButtonPlayPause);
      }

    } else if (v == mButtonStop) {
      mMediaPlayer.stop();
      mMediaPlayer.reset();
      mChronometer.stop();
      mChronometer.setBase(SystemClock.elapsedRealtime());
      prepare();
    } else if (v == mButtonConfig) {

      Intent i = new Intent(this, ConfigActivity.class);
      startActivity(i);
      Toast.makeText(this, "Config", Toast.LENGTH_LONG).show();
    }
  }
 public ChattingFooterMoreBtnBar(Context paramContext, AttributeSet paramAttributeSet) {
   super(paramContext, paramAttributeSet);
   setOrientation(0);
   setGravity(16);
   setBackgroundResource(a.h.bottombar_bg);
   int i = getResources().getDimensionPixelSize(a.g.SmallListHeight);
   paramAttributeSet = new LinearLayout.LayoutParams(0, i, 1.0F);
   topMargin = a.fromDPToPix(getContext(), 0);
   iTV = new ImageButton(getContext());
   iTV.setImageResource(a.h.chat_more_tran_btn);
   iTV.setScaleType(ImageView.ScaleType.CENTER);
   iTV.setBackgroundResource(0);
   iTV.setContentDescription(paramContext.getString(a.n.chatting_more_share));
   addView(iTV, paramAttributeSet);
   paramAttributeSet = new LinearLayout.LayoutParams(0, i, 1.0F);
   topMargin = a.fromDPToPix(getContext(), 0);
   iTY = new ImageButton(getContext());
   iTY.setImageResource(a.h.chat_more_fav_btn);
   iTY.setScaleType(ImageView.ScaleType.CENTER);
   iTY.setBackgroundResource(0);
   iTY.setContentDescription(paramContext.getString(a.n.chatting_more_favorite));
   addView(iTY, paramAttributeSet);
   paramAttributeSet = new LinearLayout.LayoutParams(0, i, 1.0F);
   topMargin = a.fromDPToPix(getContext(), 0);
   dii = new ImageButton(getContext());
   dii.setImageResource(a.h.chat_more_del_btn);
   dii.setScaleType(ImageView.ScaleType.CENTER);
   dii.setBackgroundResource(0);
   dii.setContentDescription(paramContext.getString(a.n.chatting_more_delete));
   addView(dii, paramAttributeSet);
   if (au.aOj().size() > 0) {
     paramAttributeSet = new LinearLayout.LayoutParams(0, i, 1.0F);
     topMargin = a.fromDPToPix(getContext(), 0);
     iTX = new ImageButton(getContext());
     iTX.setImageResource(a.h.chat_more_more_btn);
     iTX.setScaleType(ImageView.ScaleType.CENTER);
     iTX.setBackgroundResource(0);
     iTX.setContentDescription(paramContext.getString(a.n.chatting_more));
     addView(iTX, paramAttributeSet);
     return;
   }
   paramAttributeSet = new LinearLayout.LayoutParams(0, i, 1.0F);
   topMargin = a.fromDPToPix(getContext(), 0);
   iTW = new ImageButton(getContext());
   iTW.setImageResource(a.h.chat_more_email_btn);
   iTW.setScaleType(ImageView.ScaleType.CENTER);
   iTW.setBackgroundResource(0);
   iTW.setContentDescription(paramContext.getString(a.n.chatting_more_email));
   addView(iTW, paramAttributeSet);
 }
  private void prepare() {
    setEnabledButton(false);

    mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    Item playingItem = mItems.get(mIndex);
    try {
      mMediaPlayer.setDataSource(getApplicationContext(), playingItem.getURI());
      mMediaPlayer.prepare();
    } catch (IllegalArgumentException e) {
      Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
      e.printStackTrace();
    } catch (SecurityException e) {
      Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
      e.printStackTrace();
    } catch (IllegalStateException e) {
      Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
      e.printStackTrace();
    } catch (IOException e) {
      Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
      e.printStackTrace();
    }
    mTextViewArtist.setText(playingItem.artist);
    mTextViewAlbum.setText(playingItem.album);
    mTextViewTitle.setText(playingItem.title);
    mButtonPlayPause.setImageResource(R.drawable.media_play);
    mButtonPlayPause.setContentDescription(getResources().getText(R.string.play));
    mChronometer.setBase(SystemClock.elapsedRealtime());
  }
Esempio n. 6
0
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();

    if (!mMerging) {

      if (Config.GD_INFO_LOGS_ENABLED) {
        Log.i(LOG_TAG, "onFinishInflate() - not merging");
      }

      // Work done for both Dashboard and Normal type
      mHomeButton = (ImageButton) findViewById(R.id.gd_action_bar_home_item);
      mHomeButton.setOnClickListener(mClickHandler);

      switch (mType) {
        case Normal:
          mHomeButton.setImageDrawable(mHomeDrawable);
          mHomeButton.setContentDescription(getContext().getString(R.string.gd_go_home));
          mTitleView = (TextView) findViewById(R.id.gd_action_bar_title);
          if (mTitle != null) {
            setTitle(mTitle);
          }

        default:
          // Do nothing
          break;
      }
    }
  }
  public void updateTabCountAndAnimate(int count) {
    if (mCount > count) {
      mTabsCount.setInAnimation(mSlideDownIn);
      mTabsCount.setOutAnimation(mSlideDownOut);
    } else if (mCount < count) {
      mTabsCount.setInAnimation(mSlideUpIn);
      mTabsCount.setOutAnimation(mSlideUpOut);
    } else {
      return;
    }

    mTabsCount.setText(String.valueOf(count));
    mCount = count;
    mTabs.setContentDescription(mContext.getString(R.string.num_tabs, count));

    mHandler.postDelayed(
        new Runnable() {
          public void run() {
            ((TextView) mTabsCount.getCurrentView())
                .setTextColor(mContext.getResources().getColor(R.color.url_bar_text_highlight));
          }
        },
        mDuration);

    mHandler.postDelayed(
        new Runnable() {
          public void run() {
            ((TextView) mTabsCount.getCurrentView())
                .setTextColor(mContext.getResources().getColor(R.color.tabs_counter_color));
          }
        },
        2 * mDuration);
  }
  private void updateGoButton(String text) {
    if (text.length() == 0) {
      mGoButton.setVisibility(View.GONE);
      return;
    }

    mGoButton.setVisibility(View.VISIBLE);

    int imageResource = R.drawable.ic_awesomebar_go;
    String contentDescription = getString(R.string.go);
    int imeAction = EditorInfo.IME_ACTION_GO;
    if (isSearchUrl(text)) {
      imageResource = R.drawable.ic_awesomebar_search;
      contentDescription = getString(R.string.search);
      imeAction = EditorInfo.IME_ACTION_SEARCH;
    }
    mGoButton.setImageResource(imageResource);
    mGoButton.setContentDescription(contentDescription);

    int actionBits = mText.getImeOptions() & EditorInfo.IME_MASK_ACTION;
    if (actionBits != imeAction) {
      InputMethodManager imm =
          (InputMethodManager) mText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
      int optionBits = mText.getImeOptions() & ~EditorInfo.IME_MASK_ACTION;
      mText.setImeOptions(optionBits | imeAction);
      imm.restartInput(mText);
    }
  }
  private void addIconTab(final int position, int resId, String contentDescription) {

    ImageButton tab = new ImageButton(getContext());
    tab.setContentDescription(contentDescription);
    tab.setImageResource(resId);

    addTab(position, tab);
  }
Esempio n. 10
0
 @Override
 protected void updateTabCountVisuals(int numberOfTabs) {
   mAccessibilitySwitcherButton.setContentDescription(
       getResources()
           .getString(R.string.accessibility_toolbar_btn_tabswitcher_toggle, numberOfTabs));
   mTabSwitcherButtonDrawable.updateForTabCount(numberOfTabs, isIncognito());
   mTabSwitcherButtonDrawableLight.updateForTabCount(numberOfTabs, isIncognito());
 }
Esempio n. 11
0
  private View addMenuButton(final MenuItem item) {

    final ImageButton actionButton = new ImageButton(mContext, null, R.attr.actionBarItemStyle);

    final LayoutParams params =
        new LayoutParams(
            (int) getResources().getDimension(R.dimen.actionbar_button_width),
            ViewGroup.LayoutParams.MATCH_PARENT);
    params.weight = 1;

    actionButton.setLayoutParams(params);

    actionButton.setImageDrawable(item.getIcon());
    actionButton.setScaleType(ScaleType.CENTER);
    actionButton.setContentDescription(item.getTitle());
    actionButton.setEnabled(item.isEnabled());
    actionButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(final View view) {
            if (!item.isEnabled()) return;
            if (item.hasSubMenu()) {
              mPopupMenu = PopupMenu.getInstance(mContext, view);
              mPopupMenu.setOnMenuItemClickListener(MenuBar.this);
              mPopupMenu.setMenu(item.getSubMenu());
              mPopupMenu.show();
            } else {
              if (mItemClickListener != null) {
                mItemClickListener.onMenuItemClick(item);
              }
            }
          }
        });
    actionButton.setOnLongClickListener(
        new View.OnLongClickListener() {

          @Override
          public boolean onLongClick(final View v) {
            if (item.getItemId() == android.R.id.home) return false;

            final Toast t = Toast.makeText(mContext, item.getTitle(), Toast.LENGTH_SHORT);
            final int[] screenPos = new int[2];
            v.getLocationOnScreen(screenPos);

            final int height = v.getHeight();

            t.setGravity(
                Gravity.TOP | Gravity.LEFT, screenPos[0], (int) (screenPos[1] - height * 1.5));
            t.show();
            return true;
          }
        });

    addView(actionButton);
    return actionButton;
  }
Esempio n. 12
0
 /**
  * @param resId if <=0 then hide the button
  * @param hintRes
  */
 public void setRightImg(int resId, int hintRes) {
   if (resId > 0) {
     imgRight.setImageResource(resId);
     imgRight.setVisibility(View.VISIBLE);
     imgRight.setContentDescription(getContext().getString(hintRes));
   } else {
     imgRight.setVisibility(View.INVISIBLE);
   }
   btnRight.setVisibility(View.INVISIBLE);
 }
Esempio n. 13
0
  /**
   * Adds an action button to the compatibility action bar, using menu information from a {@link
   * android.view.MenuItem}. If the menu item ID is <code>menu_refresh</code>, the menu item's state
   * can be changed to show a loading spinner using {@link
   * com.lsn.LoadSensing.actionbar.example.android.actionbarcompat.ActionBarHelperBase#setRefreshActionItemState(boolean)}
   * .
   */
  private View addActionItemCompatFromMenuItem(final MenuItem item) {
    final int itemId = item.getItemId();

    final ViewGroup actionBar = getActionBarCompat();
    if (actionBar == null) {
      return null;
    }

    // Create the button
    ImageButton actionButton =
        new ImageButton(
            mActivity,
            null,
            itemId == android.R.id.home
                ? R.attr.actionbarCompatItemHomeStyle
                : R.attr.actionbarCompatItemStyle);
    actionButton.setLayoutParams(
        new ViewGroup.LayoutParams(
            (int)
                mActivity
                    .getResources()
                    .getDimension(
                        itemId == android.R.id.home
                            ? R.dimen.actionbar_compat_button_home_width
                            : R.dimen.actionbar_compat_button_width),
            ViewGroup.LayoutParams.MATCH_PARENT));

    actionButton.setImageDrawable(item.getIcon());
    actionButton.setScaleType(ImageView.ScaleType.CENTER);
    actionButton.setContentDescription(item.getTitle());

    if (itemId == R.id.menu_star) {
      actionButton.setId(R.id.actionbar_compat_item_faves);
      if (trobat) {
        actionButton.setImageResource(R.drawable.ic_action_star_on);
      } else {
        actionButton.setImageResource(R.drawable.ic_action_star_off);
      }
    }

    actionButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            mActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
          }
        });

    actionBar.addView(actionButton);

    return actionButton;
  }
Esempio n. 14
0
  /////////////////  Transparency bar /////////////////////////
  private void initTransparencyBar(final OsmandMapTileView view, FrameLayout parent) {
    int minimumHeight = view.getResources().getDrawable(R.drawable.map_zoom_in).getMinimumHeight();
    android.widget.FrameLayout.LayoutParams params =
        new FrameLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.CENTER);
    params.setMargins(0, 0, 0, minimumHeight + 3);
    transparencyBarLayout = new LinearLayout(view.getContext());
    transparencyBarLayout.setVisibility(settingsToTransparency != null ? View.VISIBLE : View.GONE);
    parent.addView(transparencyBarLayout, params);

    transparencyBar = new SeekBar(view.getContext());
    transparencyBar.setMax(255);
    if (settingsToTransparency != null) {
      transparencyBar.setProgress(settingsToTransparency.get());
    }
    transparencyBar.setOnSeekBarChangeListener(
        new SeekBar.OnSeekBarChangeListener() {

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (settingsToTransparency != null) {
              settingsToTransparency.set(progress);
              mapActivity.getMapView().refreshMap();
            }
          }
        });
    android.widget.LinearLayout.LayoutParams prms =
        new LinearLayout.LayoutParams((int) (scaleCoefficient * 100), LayoutParams.WRAP_CONTENT);
    transparencyBarLayout.addView(transparencyBar, prms);
    ImageButton imageButton = new ImageButton(view.getContext());
    prms = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    prms.setMargins((int) (2 * scaleCoefficient), (int) (2 * scaleCoefficient), 0, 0);
    imageButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            transparencyBarLayout.setVisibility(View.GONE);
            hideTransparencyBar(settingsToTransparency);
          }
        });
    imageButton.setContentDescription(view.getContext().getString(R.string.close));
    imageButton.setBackgroundResource(R.drawable.headliner_close);
    transparencyBarLayout.addView(imageButton, prms);
  }
  /**
   * Constructs a layout for the specified InfoBar. After calling this, be sure to set the message,
   * the buttons, and/or the custom content using setMessage(), setButtons(), and
   * setCustomContent().
   *
   * @param context The context used to render.
   * @param infoBarView InfoBarView that listens to events.
   * @param iconResourceId ID of the icon to use for the InfoBar.
   * @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
   * @param message The message to show in the infobar.
   */
  public InfoBarLayout(
      Context context,
      InfoBarView infoBarView,
      int iconResourceId,
      Bitmap iconBitmap,
      CharSequence message) {
    super(context);
    mInfoBarView = infoBarView;

    // Grab the dimensions.
    Resources res = getResources();
    mMargin = res.getDimensionPixelOffset(R.dimen.infobar_margin);
    mIconSize = res.getDimensionPixelSize(R.dimen.infobar_icon_size);
    mMinWidth = res.getDimensionPixelSize(R.dimen.infobar_min_width);
    mAccentColor = ApiCompatibilityUtils.getColor(res, R.color.infobar_accent_blue);

    // Set up the close button. Apply padding so it has a big touch target.
    mCloseButton = new ImageButton(context);
    mCloseButton.setId(R.id.infobar_close_button);
    mCloseButton.setImageResource(R.drawable.btn_close);
    TypedArray a = getContext().obtainStyledAttributes(new int[] {R.attr.selectableItemBackground});
    Drawable closeButtonBackground = a.getDrawable(0);
    a.recycle();
    mCloseButton.setBackground(closeButtonBackground);
    mCloseButton.setPadding(mMargin, mMargin, mMargin, mMargin);
    mCloseButton.setOnClickListener(this);
    mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
    mCloseButton.setLayoutParams(new LayoutParams(0, -mMargin, -mMargin, -mMargin));

    // Set up the icon.
    if (iconResourceId != 0 || iconBitmap != null) {
      mIconView = new ImageView(context);
      if (iconResourceId != 0) {
        mIconView.setImageResource(iconResourceId);
      } else if (iconBitmap != null) {
        mIconView.setImageBitmap(iconBitmap);
      }
      mIconView.setLayoutParams(new LayoutParams(0, 0, mMargin / 2, 0));
      mIconView.getLayoutParams().width = mIconSize;
      mIconView.getLayoutParams().height = mIconSize;
      mIconView.setFocusable(false);
    }

    // Set up the message view.
    mMessageTextView = (TextView) LayoutInflater.from(context).inflate(R.layout.infobar_text, null);
    mMessageTextView.setText(message, TextView.BufferType.SPANNABLE);
    mMessageTextView.setMovementMethod(LinkMovementMethod.getInstance());
    mMessageTextView.setLinkTextColor(mAccentColor);
    mMessageView = mMessageTextView;
  }
 private void addBackButton() {
   mBackButton = new ImageButton(mContext);
   mBackButton.setImageResource(R.drawable.ic_back_hierarchy_holo_dark);
   TypedValue outValue = new TypedValue();
   getContext()
       .getTheme()
       .resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
   int resid = outValue.resourceId;
   mBackButton.setBackgroundResource(resid);
   mBackButton.setLayoutParams(
       new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
   mBackButton.setOnClickListener(this);
   mBackButton.setVisibility(View.GONE);
   mBackButton.setContentDescription(
       mContext.getText(R.string.accessibility_button_bookmarks_folder_up));
   addView(mBackButton, 0);
 }
  @Override
  public void addCustomActionButton(
      Drawable drawable, String description, OnClickListener listener) {
    Resources resources = getResources();

    // The height will be scaled to match spec while keeping the aspect ratio, so get the scaled
    // width through that.
    int sourceHeight = drawable.getIntrinsicHeight();
    int sourceScaledHeight = resources.getDimensionPixelSize(R.dimen.toolbar_icon_height);
    int sourceWidth = drawable.getIntrinsicWidth();
    int sourceScaledWidth = sourceWidth * sourceScaledHeight / sourceHeight;
    int minPadding = resources.getDimensionPixelSize(R.dimen.min_toolbar_icon_side_padding);

    int sidePadding = Math.max((2 * sourceScaledHeight - sourceScaledWidth) / 2, minPadding);
    int topPadding = mCustomActionButton.getPaddingTop();
    int bottomPadding = mCustomActionButton.getPaddingBottom();
    mCustomActionButton.setPadding(sidePadding, topPadding, sidePadding, bottomPadding);
    mCustomActionButton.setImageDrawable(drawable);

    mCustomActionButton.setContentDescription(description);
    mCustomActionButton.setOnClickListener(listener);
    mCustomActionButton.setVisibility(VISIBLE);
  }
  /**
   * Adds an action button to the compatibility action bar, using menu information from a {@link
   * android.view.MenuItem}. If the menu item ID is <code>menu_refresh</code>, the menu item's state
   * can be changed to show a loading spinner using {@link
   * com.example.android.actionbarcompat.ActionBarHelperBase#setRefreshActionItemState(boolean)}.
   */
  private View addActionItemCompatFromMenuItem(final MenuItem item) {
    final int itemId = item.getItemId();

    final ViewGroup actionBar = getActionBarCompat();
    if (actionBar == null) {
      return null;
    }

    // Create the button
    ImageButton actionButton =
        new ImageButton(
            mActivity,
            null,
            itemId == android.R.id.home
                ? R.attr.actionbarCompatItemHomeStyle
                : R.attr.actionbarCompatItemStyle);
    actionButton.setLayoutParams(
        new ViewGroup.LayoutParams(
            (int)
                mActivity
                    .getResources()
                    .getDimension(
                        itemId == android.R.id.home
                            ? R.dimen.actionbar_compat_button_home_width
                            : R.dimen.actionbar_compat_button_width),
            ViewGroup.LayoutParams.FILL_PARENT));
    if (itemId == R.id.menu_refresh) {
      actionButton.setId(R.id.actionbar_compat_item_refresh);
    }
    actionButton.setImageDrawable(item.getIcon());
    actionButton.setScaleType(ImageView.ScaleType.CENTER);
    actionButton.setContentDescription(item.getTitle());
    actionButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            mActivity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, item);
          }
        });

    actionBar.addView(actionButton);

    if (item.getItemId() == R.id.menu_refresh) {
      // Refresh buttons should be stateful, and allow for indeterminate progress indicators,
      // so add those.
      ProgressBar indicator =
          new ProgressBar(mActivity, null, R.attr.actionbarCompatProgressIndicatorStyle);

      final int buttonWidth =
          mActivity.getResources().getDimensionPixelSize(R.dimen.actionbar_compat_button_width);
      final int buttonHeight =
          mActivity.getResources().getDimensionPixelSize(R.dimen.actionbar_compat_height);
      final int progressIndicatorWidth = buttonWidth / 2;

      LinearLayout.LayoutParams indicatorLayoutParams =
          new LinearLayout.LayoutParams(progressIndicatorWidth, progressIndicatorWidth);
      indicatorLayoutParams.setMargins(
          (buttonWidth - progressIndicatorWidth) / 2,
          (buttonHeight - progressIndicatorWidth) / 2,
          (buttonWidth - progressIndicatorWidth) / 2,
          0);
      indicator.setLayoutParams(indicatorLayoutParams);
      indicator.setVisibility(View.GONE);
      indicator.setId(R.id.actionbar_compat_item_refresh_progress);
      actionBar.addView(indicator);
    }

    return actionButton;
  }
Esempio n. 19
0
  private void init(Context context) {
    int width = (int) context.getResources().getDimension(R.dimen.title_button_width);
    LayoutParams leftLayoutParams = new LayoutParams(width, LayoutParams.MATCH_PARENT);
    imgLeft = new ImageButton(context);
    imgLeft.setId(R.id.common_title_left_img);
    imgLeft.setPadding(padding, padding, padding, padding);
    imgLeft.setLayoutParams(leftLayoutParams);
    imgLeft.setScaleType(ScaleType.CENTER_INSIDE);
    imgLeft.setBackgroundResource(R.drawable.b_button);
    imgLeft.setOnClickListener(this);
    if (leftDrawable == null && TextUtils.isEmpty(leftText)) {
      imgLeft.setImageResource(R.drawable.backarrow);
      imgLeft.setContentDescription("Back");
    } else {
      imgLeft.setImageDrawable(leftDrawable);
    }

    LayoutParams leftLayoutParams2 =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    btnLeft = new Button(context);
    btnLeft.setId(R.id.common_title_left_txt);
    btnLeft.setTextColor(getResources().getColor(R.color.blue));
    btnLeft.setLayoutParams(leftLayoutParams2);
    btnLeft.setMinimumWidth(width);
    btnLeft.setBackgroundResource(R.drawable.b_button);
    btnLeft.setOnClickListener(this);
    if (!TextUtils.isEmpty(leftText)) {
      btnLeft.setText(leftText);
    } else {
      btnLeft.setVisibility(View.INVISIBLE);
    }

    LayoutParams rightLayoutParams = new LayoutParams(width, LayoutParams.MATCH_PARENT);
    rightLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    imgRight = new ImageButton(context);
    imgRight.setId(R.id.common_title_right_img);
    imgRight.setPadding(padding, padding, padding, padding);
    imgRight.setLayoutParams(rightLayoutParams);
    imgRight.setScaleType(ScaleType.CENTER_INSIDE);
    imgRight.setBackgroundResource(R.drawable.b_button);
    if (rightDrawable != null) {
      imgRight.setImageDrawable(rightDrawable);
    } else {
      imgRight.setVisibility(View.INVISIBLE);
    }

    LayoutParams rightLayoutParams2 =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    rightLayoutParams2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    btnRight = new Button(context);
    btnRight.setId(R.id.common_title_right_txt);
    btnRight.setTextColor(getResources().getColor(R.color.blue));
    btnRight.setLayoutParams(rightLayoutParams2);
    btnRight.setMinimumWidth(width);
    btnRight.setBackgroundResource(R.drawable.b_button);
    if (!TextUtils.isEmpty(rightText)) {
      btnRight.setText(rightText);
    } else {
      btnRight.setVisibility(View.INVISIBLE);
    }

    LayoutParams titleLayoutParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    titleLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    titleLayoutParams.addRule(RelativeLayout.RIGHT_OF, R.id.common_title_left_img);
    titleLayoutParams.addRule(RelativeLayout.LEFT_OF, R.id.common_title_right_img);
    txtTitle = new TextView(context);
    txtTitle.setId(R.id.common_title_title_txt);
    txtTitle.setTextSize(
        TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.font_size_large_x));
    txtTitle.setLayoutParams(titleLayoutParams);
    txtTitle.setTextColor(getResources().getColor(R.color.blue));
    txtTitle.setBackgroundColor(0x00000000);
    txtTitle.setSingleLine();
    txtTitle.setEllipsize(TruncateAt.MARQUEE);
    txtTitle.setGravity(Gravity.CENTER);
    txtTitle.setSelected(true);
    if (title == null) {
      txtTitle.setText("");
    } else {
      txtTitle.setText(title);
    }

    LayoutParams divisionLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 2);
    divisionLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    View division = new View(context);
    division.setLayoutParams(divisionLayoutParams);
    division.setBackgroundColor(getResources().getColor(R.color.gray_division));
    this.addView(imgLeft);
    this.addView(btnLeft);
    this.addView(txtTitle);
    this.addView(imgRight);
    this.addView(btnRight);
    this.addView(division);
    setBackgroundColor(0xffffffff);
  }
Esempio n. 20
0
 /**
  * * Set a single button with the string and states provided.
  *
  * @param b - Button view to update
  * @param text - Text in button
  * @param enabled - enable/disables the button
  * @param visibility - Show/hide the button
  */
 private void setButton(ImageButton b, int text, int drawableId, boolean enabled, int visibility) {
   b.setContentDescription(getActivity().getResources().getString(text));
   b.setImageResource(drawableId);
   b.setVisibility(visibility);
   b.setEnabled(enabled);
 }
Esempio n. 21
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.map_main);
    floorMapView = (FloorMapView) findViewById(R.id.floormapview);
    mapView = (PtolemyMapView) floorMapView.getMapView();
    configureFloorMapView(floorMapView);

    ActionBar.setTitle(this, ACTIVITY_TITLE);

    // Set up meOverlay:
    // Show user
    meOverlay = new XPSOverlay(mapView);
    mapView.getOverlays().add(meOverlay);

    // Start Location data
    LocationSetter.getInstance(this, meOverlay).resume();

    final ImageButton compassButton =
        (ImageButton) getLayoutInflater().inflate(R.layout.menu_nav_button, null);
    compassButton.setImageResource(R.drawable.ic_menu_compass);
    compassButton.setContentDescription(getString(R.string.centre));
    final Context c = this;
    compassButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            final APGeoPoint gp =
                LocationSetter.getInstance(PtolemyMapActivity.this, null).getPoint(c);
            if (gp != null) {
              mapView
                  .getController()
                  .animateTo(
                      gp,
                      new Runnable() {
                        @Override
                        public void run() {
                          floorMapView.updateToFloor(gp.getFloor());
                        }
                      });
            }
          }
        });

    final ImageButton searchButton =
        (ImageButton) getLayoutInflater().inflate(R.layout.menu_nav_button, null);
    searchButton.setImageResource(R.drawable.ic_menu_search);
    searchButton.setContentDescription(getString(R.string.search));
    searchButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            onSearchRequested();
          }
        });

    final ImageButton bookmarksButton =
        (ImageButton) getLayoutInflater().inflate(R.layout.menu_nav_button, null);
    bookmarksButton.setImageResource(R.drawable.ic_menu_bookmark);
    bookmarksButton.setContentDescription(getString(R.string.bookmarks));
    bookmarksButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            startActivityForResult(
                new Intent(v.getContext(), BookmarksActivity.class), BOOKMARKS_RESULT);
          }
        });

    final ImageButton nearestButton =
        (ImageButton) getLayoutInflater().inflate(R.layout.menu_nav_button, null);
    nearestButton.setImageResource(R.drawable.ic_menu_goto);
    nearestButton.setContentDescription(getString(R.string.bookmarks));
    nearestButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {

            Intent intent = new Intent(v.getContext(), NearbyActivity.class);
            LocationSetter setter = LocationSetter.getInstance(v.getContext(), null);
            APGeoPoint p = setter.getPoint(v.getContext());
            if (p != null) {
              intent.putExtra(NearbyActivity.LAT, p.getLatitudeE6());
              intent.putExtra(NearbyActivity.LON, p.getLongitudeE6());
              intent.putExtra(NearbyActivity.FLOOR, p.getFloor());
            }
            startActivityForResult(intent, NEAREST_RESULT);
          }
        });

    ActionBar.setButtons(
        this, new View[] {compassButton, nearestButton, searchButton, bookmarksButton});

    athenaFilterButton = (PlaceFilterButton) findViewById(R.id.athena_filter_btn);
    setupFilterButton(athenaFilterButton, PlaceType.ATHENA);
    athenaFilterButton.setChecked(Config.getFilter(this, PlaceType.ATHENA));

    classroomFilterButton = (PlaceFilterButton) findViewById(R.id.classroom_filter_btn);
    setupFilterButton(classroomFilterButton, PlaceType.CLASSROOM);
    classroomFilterButton.setChecked(Config.getFilter(this, PlaceType.CLASSROOM));

    brMaleFilterButton = (PlaceFilterButton) findViewById(R.id.br_male_filter_btn);
    setupFilterButton(brMaleFilterButton, PlaceType.MTOILET);
    brMaleFilterButton.setChecked(Config.getFilter(this, PlaceType.MTOILET));

    brFemaleFilterButton = (PlaceFilterButton) findViewById(R.id.br_female_filter_btn);
    setupFilterButton(brFemaleFilterButton, PlaceType.FTOILET);
    brFemaleFilterButton.setChecked(Config.getFilter(this, PlaceType.FTOILET));

    if (!handleIntent(getIntent())) {
      mapView.getController().setCenter(Config.DEFAULT_POINT);
    }

    if (!Config.isTourTaken(this)) {
      // Prevent user from clicking a button until the first
      // tutorial page comes up.
      compassButton.setClickable(false);
      searchButton.setClickable(false);
      bookmarksButton.setClickable(false);
      new Thread(
              new Runnable() {
                public void run() {
                  try {
                    Thread.sleep(1000);
                  } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                  }
                  PtolemyMapActivity.this.runOnUiThread(
                      new Runnable() {
                        public void run() {
                          startActivityForResult(
                              new Intent(PtolemyMapActivity.this, TourActivity.class),
                              TUTORIAL_INTRO_RESULT);
                          compassButton.setClickable(true);
                          searchButton.setClickable(true);
                          bookmarksButton.setClickable(true);
                        }
                      });
                }
              })
          .start();
    }
    APGeoPoint point = Config.getLocation(this);
    mapView.getController().setCenter(new GeoPoint(point.getLatitudeE6(), point.getLongitudeE6()));
    floorMapView.getSeekBar().setFloor(point.getFloor());
  }
Esempio n. 22
0
 public void updateTabCount(int count) {
   mTabsCount.setCurrentText(String.valueOf(count));
   mTabs.setContentDescription(mContext.getString(R.string.num_tabs, count));
   mCount = count;
   updateTabs(GeckoApp.mAppContext.areTabsShown());
 }
Esempio n. 23
0
    @Override
    protected void onPostExecute(List<Action> actions) {
      if (actions == null) {
        statusLabel.setText("Unable to get actions");
        return;
      }

      // all is ok, replace start pane
      LinearLayout contentPane = (LinearLayout) findViewById(R.id.contentPane);
      contentPane.removeView(startPane);

      LinearLayout buttonsLayout = new LinearLayout(getApplicationContext());
      buttonsLayout.setGravity(Gravity.CENTER);

      TableLayout buttonsTable = new TableLayout(getApplicationContext());
      TableRow currentTableRow = new TableRow(getApplicationContext());

      TableRow.LayoutParams buttonMarginParams =
          new TableRow.LayoutParams(
              TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
      int marginPx =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics());
      buttonMarginParams.setMargins(marginPx, marginPx, marginPx, marginPx);

      for (final Action action : actions) {
        ImageButton actionButton = new ImageButton(getApplicationContext());
        int drawableId = getResources().getIdentifier(action.icon, "drawable", getPackageName());
        actionButton.setImageDrawable(getResources().getDrawable(drawableId));
        actionButton.setContentDescription(action.description);
        actionButton.setLayoutParams(buttonMarginParams);
        actionButton.setBackgroundResource(R.drawable.button);
        actionButton.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                new PerformActionAsyncTask().execute(action.name);
              }
            });

        currentTableRow.addView(actionButton);
        if (currentTableRow.getChildCount() == 3) {
          buttonsTable.addView(currentTableRow);
          currentTableRow = new TableRow(getApplicationContext());
        }
      }

      if (currentTableRow.getChildCount() > 0) {
        buttonsTable.addView(currentTableRow);
      }

      buttonsLayout.addView(buttonsTable);

      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
      contentPane.addView(buttonsLayout, params);

      runStatusUpdateTimer();
    }