<commit_before>package com.mapswithme.maps.widget.menu;

import android.animation.ValueAnimator;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.mapswithme.maps.R;
import com.mapswithme.maps.sound.TtsPlayer;
import com.mapswithme.maps.widget.RotateDrawable;
import com.mapswithme.util.Graphics;
import com.mapswithme.util.UiUtils;

public class NavMenu extends BaseMenu
{
  private final RotateDrawable mToggleImage;
  private final ImageView mTts;

  public enum Item implements BaseMenu.Item
  {
    TOGGLE(R.id.toggle),
    TTS_VOLUME(R.id.tts_volume),
    STOP(R.id.stop),
    SETTINGS(R.id.settings);

    private final int mViewId;

    Item(int viewId)
    {
      mViewId = viewId;
    }

    @Override
    public int getViewId()
    {
      return mViewId;
    }
  }

  public NavMenu(View frame, ItemClickListener<Item> listener)
  {
    super(frame, listener);

    mToggleImage = new RotateDrawable(Graphics.tint(mFrame.getContext(), R.drawable.ic_menu_close, R.attr.iconTintLight));
    ImageView toggle = (ImageView) mLineFrame.findViewById(R.id.toggle);
    toggle.setImageDrawable(mToggleImage);

    setToggleState(false, false);

    mapItem(Item.TOGGLE, mLineFrame);
    Button stop = (Button) mapItem(Item.STOP, mFrame);
    UiUtils.updateRedButton(stop);

    mapItem(Item.SETTINGS, mFrame);
    mTts = (ImageView) mapItem(Item.TTS_VOLUME, mFrame);
  }

  @Override
  public void onResume(@Nullable Runnable procAfterMeasurement)
  {
    super.onResume(procAfterMeasurement);
    refreshTts();
  }

  public void refreshTts()
  {
    mTts.setImageDrawable(TtsPlayer.isEnabled() ? Graphics.tint(mFrame.getContext(), R.drawable.ic_voice_on,
                                                                R.attr.colorAccent)
                                                : Graphics.tint(mFrame.getContext(), R.drawable.ic_voice_off));

  }

  @Override
  protected void setToggleState(boolean open, boolean animate)
  {
    final float to = open ? -90.0f : 90.0f;
    if (!animate)
    {
      mToggleImage.setAngle(to);
      return;
    }

    final float from = -to;
    ValueAnimator animator = ValueAnimator.ofFloat(from, to);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
    {
      @Override
      public void onAnimationUpdate(ValueAnimator animation)
      {
        mToggleImage.setAngle((float) animation.getAnimatedValue());
      }
    });

    animator.setDuration(ANIMATION_DURATION);
    animator.start();
  }

  @Override
  protected int getHeightResId()
  {
    return R.dimen.nav_menu_height;
  }

  @Override
  protected void adjustTransparency() {}

  @Override
  public void show(boolean show)
  {
    super.show(show);
    measureContent(null);
  }
}<commit_msg>[android] Hide enable/disable tts button in pedestrian routing mode.<commit_after>package com.mapswithme.maps.widget.menu;

import android.animation.ValueAnimator;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.mapswithme.maps.Framework;
import com.mapswithme.maps.R;
import com.mapswithme.maps.sound.TtsPlayer;
import com.mapswithme.maps.widget.RotateDrawable;
import com.mapswithme.util.Graphics;
import com.mapswithme.util.UiUtils;

public class NavMenu extends BaseMenu
{
  private final RotateDrawable mToggleImage;
  private final ImageView mTts;

  public enum Item implements BaseMenu.Item
  {
    TOGGLE(R.id.toggle),
    TTS_VOLUME(R.id.tts_volume),
    STOP(R.id.stop),
    SETTINGS(R.id.settings);

    private final int mViewId;

    Item(int viewId)
    {
      mViewId = viewId;
    }

    @Override
    public int getViewId()
    {
      return mViewId;
    }
  }

  public NavMenu(View frame, ItemClickListener<Item> listener)
  {
    super(frame, listener);

    mToggleImage = new RotateDrawable(Graphics.tint(mFrame.getContext(), R.drawable.ic_menu_close, R.attr.iconTintLight));
    ImageView toggle = (ImageView) mLineFrame.findViewById(R.id.toggle);
    toggle.setImageDrawable(mToggleImage);

    setToggleState(false, false);

    mapItem(Item.TOGGLE, mLineFrame);
    Button stop = (Button) mapItem(Item.STOP, mFrame);
    UiUtils.updateRedButton(stop);

    mapItem(Item.SETTINGS, mFrame);

    mTts = (ImageView) mapItem(Item.TTS_VOLUME, mFrame);
  }

  @Override
  public void onResume(@Nullable Runnable procAfterMeasurement)
  {
    super.onResume(procAfterMeasurement);
    refreshTts();
  }

  public void refreshTts()
  {
    mTts.setImageDrawable(TtsPlayer.isEnabled() ? Graphics.tint(mFrame.getContext(), R.drawable.ic_voice_on,
                                                                R.attr.colorAccent)
                                                : Graphics.tint(mFrame.getContext(), R.drawable.ic_voice_off));
  }

  @Override
  protected void setToggleState(boolean open, boolean animate)
  {
    final float to = open ? -90.0f : 90.0f;
    if (!animate)
    {
      mToggleImage.setAngle(to);
      return;
    }

    final float from = -to;
    ValueAnimator animator = ValueAnimator.ofFloat(from, to);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
    {
      @Override
      public void onAnimationUpdate(ValueAnimator animation)
      {
        mToggleImage.setAngle((float) animation.getAnimatedValue());
      }
    });

    animator.setDuration(ANIMATION_DURATION);
    animator.start();
  }

  @Override
  protected int getHeightResId()
  {
    return R.dimen.nav_menu_height;
  }

  @Override
  protected void adjustTransparency() {}

  @Override
  public void show(boolean show)
  {
    super.show(show);
    measureContent(null);

    UiUtils.showIf(show && Framework.nativeGetRouter() != Framework.ROUTER_TYPE_PEDESTRIAN, mTts);
  }
}
{'fraction_non_alphanumeric': 0.1043196175516476, 'fraction_numerical': 0.002048830459279495, 'mean_word_length': 3.1783166904422253, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5392465', 'n_tokens_mistral': 1919, 'n_tokens_neox': 1839, 'n_words': 336}