public void updateButtonsOnKeyboardAndInvalidateOptionsMenu() {
    getActivity().invalidateOptionsMenu();

    ImageButton backspaceOnKeyboard =
        (ImageButton) getActivity().findViewById(R.id.formula_editor_keyboard_delete);
    if (!formulaEditorEditText.isThereSomethingToDelete()) {
      backspaceOnKeyboard.setAlpha(255 / 3);
      backspaceOnKeyboard.setEnabled(false);
    } else {
      backspaceOnKeyboard.setAlpha(255);
      backspaceOnKeyboard.setEnabled(true);
    }
  }
 public void enableFilterButtons() {
   for (ImageButton b : mBottomPanelButtons) {
     b.setEnabled(true);
     b.setClickable(true);
     b.setAlpha(1.0f);
   }
 }
 public void disableFilterButtons() {
   for (ImageButton b : mBottomPanelButtons) {
     b.setEnabled(false);
     b.setClickable(false);
     b.setAlpha(0.4f);
   }
 }
  @Override
  public void onResume() {

    // to fade the settings button
    ImageButton settingsButton = (ImageButton) getActivity().findViewById(R.id.button_settings);

    switch (mCurrentMode) {
      case R.id.mode_lightswitch:
        mLightswitch = (LightSwitch) getActivity().findViewById(R.id.button_lightswitch);
        mLightswitch.setChecked(false);
        if (mOn) mLightswitch.setChecked(true);
        mLightswitch.setOnCheckedChangeListener(
            new OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton button, boolean isChecked) {
                mListener.onLightControlClick(isChecked);
              }
            });
        settingsButton.setAlpha(255);
        break;
      case R.id.mode_blackout:
        Button image = (Button) getActivity().findViewById(R.id.button_black);
        Animation fadeOut = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_out);
        image.startAnimation(fadeOut);
        settingsButton.setAlpha(90);
        break;
      case R.id.mode_viewfinder:
      case R.id.mode_lightbulb:
        mBulb = (ImageButton) getActivity().findViewById(R.id.button_bulb);
        mDrawable = (TransitionDrawable) mBulb.getDrawable();
        mDrawable.setCrossFadeEnabled(true);
        if (mOn) mDrawable.startTransition(0);
        settingsButton.setAlpha(255);

        break;
    }

    PreviewSurface surface = (PreviewSurface) getActivity().findViewById(R.id.surface);
    if (mCurrentMode == R.id.mode_viewfinder) {
      surface.setLayoutParams(
          new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    } else {
      surface.setLayoutParams(new LayoutParams(1, 1));
    }

    super.onResume();
  }
 /**
  * Disables the ability to edit enrollment info Program stages can still be viewed but not
  * changed.
  */
 public void setCompleted() {
   completeButton.setEnabled(false);
   completeButton.setAlpha(0x40);
   terminateButton.setEnabled(false);
   terminateButton.setAlpha(0x40);
   followupButton.setEnabled(false);
   followupButton.setAlpha(0x40);
 }
 public void refreshButtons() {
   if (mNumberofButtons == 0) {
     return;
   }
   int navBarColor = Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_COLOR, -1);
   int navButtonColor =
       Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_TINT, -1);
   float navButtonAlpha =
       Settings.System.getFloat(
           mContentRes, Settings.System.NAVIGATION_BAR_BUTTON_ALPHA, STOCK_ALPHA);
   int glowColor =
       Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_GLOW_TINT, 0);
   float BarAlpha = 1.0f;
   String alphas[];
   String settingValue =
       Settings.System.getString(mContentRes, Settings.System.NAVIGATION_BAR_ALPHA_CONFIG);
   if (!TextUtils.isEmpty(settingValue)) {
     alphas = settingValue.split(";");
     BarAlpha = Float.parseFloat(alphas[0]) / 255;
   }
   int a = Math.round(BarAlpha * 255);
   Drawable mBackground =
       AwesomeConstants.getSystemUIDrawable(mContext, "com.android.systemui:drawable/nav_bar_bg");
   if (mBackground instanceof ColorDrawable) {
     BackgroundAlphaColorDrawable bacd =
         new BackgroundAlphaColorDrawable(
             navBarColor > 0 ? navBarColor : ((ColorDrawable) mBackground).getColor());
     bacd.setAlpha(a);
     mNavBarContainer.setBackground(bacd);
   } else {
     mBackground.setAlpha(a);
     mNavBarContainer.setBackground(mBackground);
   }
   for (int i = 0; i < mNumberofButtons; i++) {
     ImageButton ib = mButtonViews.get(i);
     Drawable d = mButtons.get(i).getIcon();
     if (navButtonColor != -1) {
       d.setColorFilter(navButtonColor, PorterDuff.Mode.SRC_ATOP);
     }
     ib.setImageDrawable(d);
     ib.setOnClickListener(mNavBarClickListener);
     ib.setVisibility(View.VISIBLE);
     ib.setAlpha(navButtonAlpha);
     StateListDrawable sld = new StateListDrawable();
     sld.addState(new int[] {android.R.attr.state_pressed}, new ColorDrawable(glowColor));
     sld.addState(StateSet.WILD_CARD, mNavBarContainer.getBackground());
     ib.setBackground(sld);
   }
   for (int i = mNumberofButtons; i < mButtonViews.size(); i++) {
     ImageButton ib = mButtonViews.get(i);
     ib.setVisibility(View.GONE);
   }
   int menuloc = Settings.System.getInt(mContentRes, Settings.System.MENU_LOCATION, 0);
   switch (menuloc) {
     case SHOW_BOTH_MENU:
       mLeftMenu.setVisibility(View.VISIBLE);
       mRightMenu.setVisibility(View.VISIBLE);
       break;
     case SHOW_LEFT_MENU:
       mLeftMenu.setVisibility(View.VISIBLE);
       mRightMenu.setVisibility(View.INVISIBLE);
       break;
     case SHOW_RIGHT_MENU:
       mLeftMenu.setVisibility(View.INVISIBLE);
       mRightMenu.setVisibility(View.VISIBLE);
       break;
     case SHOW_DONT:
       mLeftMenu.setVisibility(View.GONE);
       mRightMenu.setVisibility(View.GONE);
       break;
   }
   if (navButtonColor != -1) {
     mLeftMenu.setColorFilter(navButtonColor);
     mRightMenu.setColorFilter(navButtonColor);
   }
 }
  @Override
  public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final LayoutInflater inflater = LayoutInflater.from(this);
    scrollView = (MyHorizontalScrollView) inflater.inflate(R.layout.horz_scroll_view, null);
    setContentView(scrollView);

    filterView = inflater.inflate(R.layout.place_types_list, null);
    mainView = inflater.inflate(R.layout.places_view, null);

    // search
    placeSearchButton = (ImageButton) mainView.findViewById(R.id.places_search);
    placeSearchButton.setAlpha(200);
    placeSearchButton.setOnClickListener(new SearchClickListener());

    // spinner
    spinnerPlaceType = (Spinner) filterView.findViewById(R.id.spinner_place_types);
    // seekbar
    rangeSeekBar = (SeekBar) filterView.findViewById(R.id.range_slider);
    rangeSeekBar.setOnSeekBarChangeListener(this);
    rangeProgressText = (TextView) filterView.findViewById(R.id.range_progress);
    rangeProgressText.setText(Integer.toString(rangeSeekBar.getProgress()));

    // Adapter para implementar o layout customizado de cada item
    final ArrayAdapter<String> placeTypesAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, getPlacesTypesLabel());
    placeTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerPlaceType.setAdapter(placeTypesAdapter);
    // attach the listener to the spinner
    spinnerPlaceType.setOnItemSelectedListener(new FilterOnItemSelectedListener());
    spinnerPlaceType.setSelection(7); // establishment

    final ClickListenerForScrolling clickListenerForScrolling =
        new ClickListenerForScrolling(scrollView, filterView);
    filterSliderButton = (ImageView) mainView.findViewById(R.id.btnPlaceTypes);
    filterSliderButton.setOnClickListener(clickListenerForScrolling);
    menuPanel = (SlidingPanel) mainView.findViewById(R.id.panel);
    filterView.setOnClickListener(clickListenerForScrolling);

    final View[] children = new View[] {filterView, mainView};
    // Scroll to placesView (view[1]) when layout finished.
    final int scrollToViewIdx = 1;
    scrollView.initViews(children, scrollToViewIdx, new SizeCallbackForMenu(filterSliderButton));

    // map view
    placesView = (TapControlledMapView) findViewById(R.id.places_view);
    placesView.setBuiltInZoomControls(true);
    placesView.getController().setZoom(13);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);

    myLocationOverlay = new MyLocationOverlay(this, placesView);
    placesView.getOverlays().add(myLocationOverlay);
    myLocationOverlay.runOnFirstFix(
        new Runnable() {
          public void run() {
            placesView.getController().animateTo(myLocationOverlay.getMyLocation());
          }
        });
    // dismiss balloon upon single tap of MapView (iOS behavior)
    placesView.setOnSingleTapListener(this);

    // places marker
    defaultPlacesMarker = getResources().getDrawable(R.drawable.places_pin);

    final ImageButton btnCheckin = (ImageButton) findViewById(R.id.btnCheckin);
    btnCheckin.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(final View v) {
            checkinService.execute(PlacesViewActivity.this);
          }
        });
  }
  private void updateUI(final int position) {
    if (!weatherForecast.isSuccessed() || weatherForecast == WeatherForecast.NULL) return;

    swipeIndicatorPresenter.setCurrentActivePosition(position);
    int size = weatherForecast.getForecastList().size();

    if (position == 0) ibPrevious.setAlpha(128);
    else if (position == size - 1) ibNext.setAlpha(128);
    else {
      ibPrevious.setAlpha(255);
      ibNext.setAlpha(255);
    }

    WeatherModel model = weatherForecast.getForecastList().get(position);

    DateUtils utils = new DateUtils();
    String nameOfDay = utils.getDayName(model.getDate());

    tvDate.setText(nameOfDay);

    int currentTemp = Integer.parseInt(model.getMaxTemperature());

    if (currentTemp < 0) tvMinus.setVisibility(View.VISIBLE);
    else {
      int invis = mConfiguration.isTablet() ? View.GONE : View.INVISIBLE;
      tvMinus.setVisibility(invis);
    }
    currentTemp = Math.abs(currentTemp);
    // int margin = resolveMargin(currentTemp);

    tvCurrentTemp.setText("" + currentTemp);

    // setMarginParams(margin, tvCurrentTemp);

    if (mConfiguration.isTablet()) {
      String locationName = mConfiguration.getLocationName();
      locationName = (locationName == null) ? "" : locationName;
      tvLocation.setText(locationName);
    }

    tvNightTemp.setText(model.getMinTemperature());
    if (position == 0) {
      tvHumidity.setText(model.getHumidity() + " %");
      ivHumidity.setImageResource(getHumidityResource((model.getHumidity())));
    } else {
      tvHumidity.setText(model.getPrecipitation());
      ivHumidity.setImageResource(R.drawable.precipmm);
    }

    tvWindSpeed.setText(model.getWindSpeed());
    tvWindDirection.setText(model.getWindDirection().getDisplayName());
    ivLunarState.setImageResource(
        ResourcesCodeUtils.getLunarStateImageResource(model.getLunarState()));

    WeatherState weatherState = model.getState();
    tvWeatherDescription.setText(weatherState.getDisplayName());
    int backgroundColor = ResourcesCodeUtils.getWeatherBackgroundColor(weatherState);

    OWAnimationUtils.rotate(ivWindDirection, Float.parseFloat(model.getWindDegree()) + 180);
    weatherContainer.setBackgroundColor(getResources().getColor(backgroundColor));
  }
 private void enableArrow(ImageButton arrow, boolean enabled) {
   arrow.setEnabled(enabled);
   arrow.setAlpha(enabled ? ARROW_ALPHA_ENABLED : ARROW_ALPHA_DISABLED);
 }
  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    mContext = getApplicationContext();
    mApp = (Common) getApplicationContext();
    mApp.setNowPlayingActivity(this);
    setNowPlayingActivityListener(mApp.getPlaybackKickstarter());

    // Set the UI theme.
    setTheme();

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_now_playing);

    // Set the volume stream for this activity.
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // Drawer layout.
    if (!mApp.isTabletInLandscape()) {
      mDrawerLayout = (DrawerLayout) findViewById(R.id.main_activity_drawer_root);
      mDrawerParentLayout = (FrameLayout) findViewById(R.id.now_playing_drawer_frame_root);
      mCurrentQueueLayout = (RelativeLayout) findViewById(R.id.queue_drawer);
      mDrawerLayout.setDrawerListener(mDrawerListener);
      mDrawerLayout.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext));

    } else {
      mCurrentQueueLayout = (RelativeLayout) findViewById(R.id.queue_drawer);
    }

    // ViewPager.
    mViewPager = (VelocityViewPager) findViewById(R.id.nowPlayingPlaylistPager);

    // Seekbar indicator.
    mSeekbarIndicatorLayoutParent = (RelativeLayout) findViewById(R.id.seekbarIndicatorParent);
    mSeekbarIndicatorLayout = (RelativeLayout) findViewById(R.id.seekbarIndicator);
    mSeekbarIndicatorText = (TextView) findViewById(R.id.seekbarIndicatorText);

    mSeekbarIndicatorLayoutParent.setVisibility(View.GONE);
    mSeekbarIndicatorLayout.setBackgroundResource(
        UIElementsHelper.getGridViewCardBackground(mContext));
    mSeekbarIndicatorText.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    mSeekbarIndicatorText.setTextColor(UIElementsHelper.getThemeBasedTextColor(mContext));

    // Playback Controls.
    mControlsLayoutHeaderParent =
        (RelativeLayout) findViewById(R.id.now_playing_controls_header_parent);
    mControlsLayoutHeader = (RelativeLayout) findViewById(R.id.now_playing_controls_header);
    mPlayPauseButtonBackground = (RelativeLayout) findViewById(R.id.playPauseButtonBackground);
    mPlayPauseButton = (ImageButton) findViewById(R.id.playPauseButton);
    mNextButton = (ImageButton) findViewById(R.id.nextButton);
    mPreviousButton = (ImageButton) findViewById(R.id.previousButton);
    mShuffleButton = (ImageButton) findViewById(R.id.shuffleButton);
    mRepeatButton = (ImageButton) findViewById(R.id.repeatButton);

    // Song info/seekbar elements.
    mSeekbar = (SeekBar) findViewById(R.id.nowPlayingSeekBar);
    mStreamingProgressBar = (ProgressBar) findViewById(R.id.startingStreamProgressBar);
    mStreamingProgressBar.setVisibility(View.GONE);

    try {
      mSeekbar.setThumb(getResources().getDrawable(R.drawable.transparent_drawable));
    } catch (Exception e) {
      e.printStackTrace();
    }

    mPlayPauseButtonBackground.setBackgroundResource(UIElementsHelper.getShadowedCircle(mContext));
    mPlayPauseButton.setImageResource(R.drawable.pause_light);
    mPlayPauseButton.setId(R.drawable.pause_light);
    mNextButton.setImageResource(UIElementsHelper.getIcon(mContext, "btn_playback_next"));
    mPreviousButton.setImageResource(UIElementsHelper.getIcon(mContext, "btn_playback_previous"));

    if (mApp.getCurrentTheme() == Common.DARK_THEME) {
      mNextButton.setAlpha(1f);
      mPreviousButton.setAlpha(1f);
    }

    // KitKat specific layout code.
    setKitKatTranslucentBars();

    // Set the control buttons and background.
    setControlButtonsBackground();
    setPlayPauseButton();
    setShuffleButtonIcon();
    setRepeatButtonIcon();

    // Set the click listeners.
    mSeekbar.setOnSeekBarChangeListener(seekBarChangeListener);
    mNextButton.setOnClickListener(mOnClickNextListener);
    mPreviousButton.setOnClickListener(mOnClickPreviousListener);
    mPlayPauseButton.setOnClickListener(playPauseClickListener);
    mPlayPauseButtonBackground.setOnClickListener(playPauseClickListener);
    mShuffleButton.setOnClickListener(shuffleButtonClickListener);
    mRepeatButton.setOnClickListener(repeatButtonClickListener);

    // Apply haptic feedback to the play/pause button.
    mPlayPauseButtonBackground.setHapticFeedbackEnabled(true);
    mPlayPauseButton.setHapticFeedbackEnabled(true);
  }
Esempio n. 11
0
  /** Returns view for {@link GameFragment}. */
  @SuppressWarnings("deprecation")
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mView = inflater.inflate(R.layout.game, container, false);
    mResources = getResources();

    int[][] actions = {
      {R.id.button_left, GameEngine.ACTION_LEFT},
      {R.id.button_right, GameEngine.ACTION_RIGHT},
      {R.id.button_down, GameEngine.ACTION_DOWN},
      {R.id.button_up, GameEngine.ACTION_UP},
      {R.id.button_fire, GameEngine.ACTION_FIRE}
    };
    for (int[] action : actions) {
      int buttonId = action[0];
      final int userAction = action[1];
      ImageButton button = (ImageButton) mView.findViewById(buttonId);

      button.setOnClickListener(
          new OnClickListener() {

            // @Override
            public void onClick(View v) {
              mGameEngine.setUserAction(userAction);
            }
          });

      // set button press feedback based on transparency
      button.setAlpha(64);
      button.setOnTouchListener(
          new OnTouchListener() {

            // @Override
            public boolean onTouch(View v, MotionEvent event) {
              ImageButton imageButton = (ImageButton) v;
              if (event.getAction() == MotionEvent.ACTION_DOWN) {
                imageButton.setAlpha(255);
              }
              if (event.getAction() == MotionEvent.ACTION_UP) {
                imageButton.setAlpha(64);
              }
              return false;
            }
          });
    }

    mUpdateGameBoard =
        new Runnable() {

          // @Override
          public void run() {
            RelativeLayout gameBoard = (RelativeLayout) mView.findViewById(R.id.game_board);
            if (gameBoard != null) {
              Bitmap bitmap = mGameEngine.getGameBoard();
              Drawable background = new BitmapDrawable(mResources, bitmap);
              gameBoard.setBackgroundDrawable(background);
            }
          }
        };

    return mView;
  }