예제 #1
0
  private void refreshChrome() {
    Drawable backgroundDrawable =
        mIsSelectable ? mSelectionModeBackgroundDrawable : mDefaultModeBackgroundDrawable;
    itemView.setBackgroundDrawable(backgroundDrawable);
    if (backgroundDrawable != null) {
      backgroundDrawable.jumpToCurrentState();
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      StateListAnimator animator =
          mIsSelectable ? mSelectionModeStateListAnimator : mDefaultModeStateListAnimator;

      itemView.setStateListAnimator(animator);
      if (animator != null) {
        animator.jumpToCurrentState();
      }
    }
  }
예제 #2
0
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  private void setMaterialLayout(View addButton) {
    addButton.setOutlineProvider(
        new ViewOutlineProvider() {
          @TargetApi(Build.VERSION_CODES.LOLLIPOP)
          @Override
          public void getOutline(View view, Outline outline) {
            int diameter = getResources().getDimensionPixelSize(R.dimen.button_diameter);
            outline.setOval(0, 0, diameter, diameter);
          }
        });
    addButton.setClipToOutline(true);

    addButton.setElevation(getResources().getDimension(R.dimen.elevation_low));

    // Dynamic add state list animator
    Animator press_animator =
        ObjectAnimator.ofFloat(
            addButton,
            "translationZ",
            getResources().getDimension(R.dimen.elevation_low),
            getResources().getDimension(R.dimen.elevation_high));
    press_animator.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));

    Animator normal_animator =
        ObjectAnimator.ofFloat(
            addButton,
            "translationZ",
            getResources().getDimension(R.dimen.elevation_high),
            getResources().getDimension(R.dimen.elevation_low));
    normal_animator.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));

    StateListAnimator animatorList = new StateListAnimator();
    animatorList.addState(new int[] {android.R.attr.state_pressed}, press_animator);
    animatorList.addState(new int[] {}, normal_animator);
    addButton.setStateListAnimator(animatorList);

    // Dnyamic setBackgroundResource
    addButton.setBackgroundResource(R.drawable.ripple_oval);
  }
예제 #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_TMessages);
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    if (AndroidUtilities.isTablet()) {
      setContentView(R.layout.intro_layout_tablet);
    } else {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
      setContentView(R.layout.intro_layout);
    }

    if (LocaleController.isRTL) {
      icons =
          new int[] {
            R.drawable.intro7,
            R.drawable.intro6,
            R.drawable.intro5,
            R.drawable.intro4,
            R.drawable.intro3,
            R.drawable.intro2,
            R.drawable.intro1
          };
      titles =
          new int[] {
            R.string.Page7Title,
            R.string.Page6Title,
            R.string.Page5Title,
            R.string.Page4Title,
            R.string.Page3Title,
            R.string.Page2Title,
            R.string.Page1Title
          };
      messages =
          new int[] {
            R.string.Page7Message,
            R.string.Page6Message,
            R.string.Page5Message,
            R.string.Page4Message,
            R.string.Page3Message,
            R.string.Page2Message,
            R.string.Page1Message
          };
    } else {
      icons =
          new int[] {
            R.drawable.intro1,
            R.drawable.intro2,
            R.drawable.intro3,
            R.drawable.intro4,
            R.drawable.intro5,
            R.drawable.intro6,
            R.drawable.intro7
          };
      titles =
          new int[] {
            R.string.Page1Title,
            R.string.Page2Title,
            R.string.Page3Title,
            R.string.Page4Title,
            R.string.Page5Title,
            R.string.Page6Title,
            R.string.Page7Title
          };
      messages =
          new int[] {
            R.string.Page1Message,
            R.string.Page2Message,
            R.string.Page3Message,
            R.string.Page4Message,
            R.string.Page5Message,
            R.string.Page6Message,
            R.string.Page7Message
          };
    }
    viewPager = (ViewPager) findViewById(R.id.intro_view_pager);
    TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button);
    startMessagingButton.setText(
        LocaleController.getString("StartMessaging", R.string.StartMessaging).toUpperCase());
    if (Build.VERSION.SDK_INT >= 21) {
      StateListAnimator animator = new StateListAnimator();
      animator.addState(
          new int[] {android.R.attr.state_pressed},
          ObjectAnimator.ofFloat(
                  startMessagingButton,
                  "translationZ",
                  AndroidUtilities.dp(2),
                  AndroidUtilities.dp(4))
              .setDuration(200));
      animator.addState(
          new int[] {},
          ObjectAnimator.ofFloat(
                  startMessagingButton,
                  "translationZ",
                  AndroidUtilities.dp(4),
                  AndroidUtilities.dp(2))
              .setDuration(200));
      startMessagingButton.setStateListAnimator(animator);
    }
    topImage1 = (ImageView) findViewById(R.id.icon_image1);
    topImage2 = (ImageView) findViewById(R.id.icon_image2);
    bottomPages = (ViewGroup) findViewById(R.id.bottom_pages);
    topImage2.setVisibility(View.GONE);
    viewPager.setAdapter(new IntroAdapter());
    viewPager.setPageMargin(0);
    viewPager.setOffscreenPageLimit(1);
    viewPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          @Override
          public void onPageSelected(int i) {}

          @Override
          public void onPageScrollStateChanged(int i) {
            if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) {
              if (lastPage != viewPager.getCurrentItem()) {
                lastPage = viewPager.getCurrentItem();

                final ImageView fadeoutImage;
                final ImageView fadeinImage;
                if (topImage1.getVisibility() == View.VISIBLE) {
                  fadeoutImage = topImage1;
                  fadeinImage = topImage2;

                } else {
                  fadeoutImage = topImage2;
                  fadeinImage = topImage1;
                }

                fadeinImage.bringToFront();
                fadeinImage.setImageResource(icons[lastPage]);
                fadeinImage.clearAnimation();
                fadeoutImage.clearAnimation();

                Animation outAnimation =
                    AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_out);
                outAnimation.setAnimationListener(
                    new Animation.AnimationListener() {
                      @Override
                      public void onAnimationStart(Animation animation) {}

                      @Override
                      public void onAnimationEnd(Animation animation) {
                        fadeoutImage.setVisibility(View.GONE);
                      }

                      @Override
                      public void onAnimationRepeat(Animation animation) {}
                    });

                Animation inAnimation =
                    AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_in);
                inAnimation.setAnimationListener(
                    new Animation.AnimationListener() {
                      @Override
                      public void onAnimationStart(Animation animation) {
                        fadeinImage.setVisibility(View.VISIBLE);
                      }

                      @Override
                      public void onAnimationEnd(Animation animation) {}

                      @Override
                      public void onAnimationRepeat(Animation animation) {}
                    });

                fadeoutImage.startAnimation(outAnimation);
                fadeinImage.startAnimation(inAnimation);
              }
            }
          }
        });

    startMessagingButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (startPressed) {
              return;
            }
            startPressed = true;
            Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class);
            intent2.putExtra("fromIntro", true);
            startActivity(intent2);
            finish();
          }
        });

    if (BuildVars.DEBUG_VERSION) {
      startMessagingButton.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              ConnectionsManager.getInstance().switchBackend();
              return true;
            }
          });
    }

    justCreated = true;
  }