@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mContext = this;
    setContentView(R.layout.activity_account_book_custom_view);

    mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);

    View view = mViewPager.getRootView();
    TextView title = (TextView) view.findViewById(R.id.logo_white);
    title.setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    title.setText(SettingManager.getInstance().getAccountBookName());

    mViewPager.getPagerTitleStrip().setTypeface(CoCoinUtil.GetTypeface(), Typeface.NORMAL);
    mViewPager.getPagerTitleStrip().setVisibility(View.INVISIBLE);

    setTitle("");

    toolbar = mViewPager.getToolbar();

    if (toolbar != null) {
      setSupportActionBar(toolbar);

      final ActionBar actionBar = getSupportActionBar();
      if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayUseLogoEnabled(false);
        actionBar.setHomeButtonEnabled(true);
      }
    }

    View logo = findViewById(R.id.logo_white);
    if (logo != null) {
      logo.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              mViewPager.notifyHeaderChanged();
            }
          });
    }

    customViewFragmentAdapter = new CustomViewFragmentAdapter(getSupportFragmentManager());
    mViewPager.getViewPager().setOffscreenPageLimit(1);
    mViewPager.getViewPager().setAdapter(customViewFragmentAdapter);
    mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());

    mViewPager.setMaterialViewPagerListener(
        new MaterialViewPager.Listener() {
          @Override
          public HeaderDesign getHeaderDesign(int page) {
            return HeaderDesign.fromColorAndDrawable(
                CoCoinUtil.GetTagColor(-3), CoCoinUtil.GetTagDrawable(-3));
          }
        });
  }
예제 #2
0
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    fragmentPosition = FragmentPagerItem.getPosition(getArguments());
    button0 = (RadioButton) view.findViewById(R.id.button0);
    button1 = (RadioButton) view.findViewById(R.id.button1);
    button2 = (RadioButton) view.findViewById(R.id.button2);
    button3 = (RadioButton) view.findViewById(R.id.button3);
    ly = (LinearLayout) view.findViewById(R.id.buttonLy);
    passwordTip = (TextView) view.findViewById(R.id.password_tip);
    passwordTip.setTypeface(CoCoinUtil.GetTypeface());
    switch (fragmentPosition) {
      case 0:
        if (SettingManager.getInstance().getFirstTime()) {
          passwordTip.setText(
              CoCoinApplication.getAppContext()
                  .getResources()
                  .getString(R.string.first_time_set_password));
        } else {
          passwordTip.setText(
              CoCoinApplication.getAppContext().getResources().getString(R.string.password_tip_0));
        }
        break;
      case 1:
        if (SettingManager.getInstance().getFirstTime()) {
          passwordTip.setText(
              CoCoinApplication.getAppContext()
                  .getResources()
                  .getString(R.string.first_time_set_password_again));
        } else {
          passwordTip.setText(
              CoCoinApplication.getAppContext().getResources().getString(R.string.password_tip_1));
        }
        break;
      case 2:
        passwordTip.setText(
            CoCoinApplication.getAppContext().getResources().getString(R.string.password_tip_2));
        break;
      default:
        break;
    }
  }
예제 #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_password);
    overridePendingTransition(R.anim.trans_left_in, R.anim.trans_left_out);

    mContext = this;

    int currentapiVersion = Build.VERSION.SDK_INT;

    if (currentapiVersion >= Build.VERSION_CODES.LOLLIPOP) {
      // Do something for lollipop and above versions
      Window window = this.getWindow();
      window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
      window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
      window.setStatusBarColor(ContextCompat.getColor(mContext, R.color.statusBarColor));
    } else {
      // do something for phones running an SDK before lollipop
    }

    viewPager = (ViewPager) findViewById(R.id.viewpager);

    try {
      Interpolator sInterpolator = new AccelerateInterpolator();
      Field mScroller;
      mScroller = ViewPager.class.getDeclaredField("mScroller");
      mScroller.setAccessible(true);
      FixedSpeedScroller scroller = new FixedSpeedScroller(viewPager.getContext(), sInterpolator);
      scroller.setmDuration(1000);
      mScroller.set(viewPager, scroller);
    } catch (NoSuchFieldException e) {
    } catch (IllegalArgumentException e) {
    } catch (IllegalAccessException e) {
    }

    passwordAdapter = new PasswordChangeFragmentAdapter(getSupportFragmentManager());

    viewPager.setOffscreenPageLimit(2);
    viewPager.setScrollBarFadeDuration(1000);

    viewPager.setAdapter(passwordAdapter);

    myGridView = (MyGridView) findViewById(R.id.gridview);
    myGridViewAdapter = new PasswordChangeButtonGridViewAdapter(this);
    myGridView.setAdapter(myGridViewAdapter);

    myGridView.setOnItemClickListener(gridViewClickListener);
    myGridView.setOnItemLongClickListener(gridViewLongClickListener);

    myGridView
        .getViewTreeObserver()
        .addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {
              @Override
              public void onGlobalLayout() {
                myGridView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                View lastChild = myGridView.getChildAt(myGridView.getChildCount() - 1);
                myGridView.setLayoutParams(
                    new LinearLayout.LayoutParams(
                        ViewGroup.LayoutParams.FILL_PARENT, lastChild.getBottom()));
              }
            });

    back = (MaterialIconView) findViewById(R.id.back);
    back.setVisibility(View.INVISIBLE);

    superToast = new SuperToast(this);

    title = (TextView) findViewById(R.id.title);
    title.setTypeface(CoCoinUtil.typefaceLatoLight);
    if (SettingManager.getInstance().getFirstTime()) {
      title.setText(mContext.getResources().getString(R.string.app_name));
    } else {
      title.setText(mContext.getResources().getString(R.string.change_password));
    }
  }
예제 #4
0
  private void buttonClickOperation(boolean longClick, int position) {
    switch (CURRENT_STATE) {
      case NEW_PASSWORD:
        if (CoCoinUtil.ClickButtonDelete(position)) {
          if (longClick) {
            ((PasswordChangeFragment) passwordAdapter.getItem(CURRENT_STATE)).init();
            newPassword = "";
          } else {
            ((PasswordChangeFragment) passwordAdapter.getItem(CURRENT_STATE))
                .clear(newPassword.length() - 1);
            if (newPassword.length() != 0)
              newPassword = newPassword.substring(0, newPassword.length() - 1);
          }
        } else if (CoCoinUtil.ClickButtonCommit(position)) {

        } else {
          ((PasswordChangeFragment) passwordAdapter.getItem(CURRENT_STATE))
              .set(newPassword.length());
          newPassword += CoCoinUtil.BUTTONS[position];
          if (newPassword.length() == 4) {
            // finish the new password input
            CURRENT_STATE = PASSWORD_AGAIN;
            viewPager.setCurrentItem(PASSWORD_AGAIN, true);
          }
        }
        break;
      case PASSWORD_AGAIN:
        if (CoCoinUtil.ClickButtonDelete(position)) {
          if (longClick) {
            ((PasswordChangeFragment) passwordAdapter.getItem(CURRENT_STATE)).init();
            againPassword = "";
          } else {
            ((PasswordChangeFragment) passwordAdapter.getItem(CURRENT_STATE))
                .clear(againPassword.length() - 1);
            if (againPassword.length() != 0)
              againPassword = againPassword.substring(0, againPassword.length() - 1);
          }
        } else if (CoCoinUtil.ClickButtonCommit(position)) {

        } else {
          ((PasswordChangeFragment) passwordAdapter.getItem(CURRENT_STATE))
              .set(againPassword.length());
          againPassword += CoCoinUtil.BUTTONS[position];
          if (againPassword.length() == 4) {
            // if the password again is equal to the new password
            if (againPassword.equals(newPassword)) {
              CURRENT_STATE = -1;
              showToast(2);
              SettingManager.getInstance().setPassword(newPassword);
              SettingManager.getInstance().setFirstTime(false);
              if (SettingManager.getInstance().getLoggenOn()) {
                User currentUser =
                    BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
                currentUser.setAccountBookPassword(newPassword);
                currentUser.update(
                    CoCoinApplication.getAppContext(),
                    currentUser.getObjectId(),
                    new UpdateListener() {
                      @Override
                      public void onSuccess() {
                        Log.d("Saver", "Set password successfully.");
                      }

                      @Override
                      public void onFailure(int code, String msg) {
                        Log.d("Saver", "Set password failed.");
                      }
                    });
              }
              final Handler handler = new Handler();
              handler.postDelayed(
                  new Runnable() {
                    @Override
                    public void run() {
                      finish();
                    }
                  },
                  1000);
            } else {
              ((PasswordChangeFragment) passwordAdapter.getItem(CURRENT_STATE)).clear(4);
              ((PasswordChangeFragment) passwordAdapter.getItem(CURRENT_STATE - 1)).init();
              CURRENT_STATE = NEW_PASSWORD;
              viewPager.setCurrentItem(NEW_PASSWORD, true);
              newPassword = "";
              againPassword = "";
              showToast(1);
            }
          }
        }
        break;
      default:
        break;
    }
  }