コード例 #1
0
 private void doUpdate() {
   AppLockApplication appLockApplication = AppLockApplication.getInstance();
   if (System.currentTimeMillis() - SharedPreferenceUtil.readUpdateTipTime() >= 1000 * 60 * 60 * 20
       && appLockApplication.hasNewVersion()) {
     downLoadFileUrl = appLockApplication.getUpdateVersionUrl();
     showUpdateDialog(appLockApplication.getUpdateVersionIntro());
     SharedPreferenceUtil.editUpdateTipTime(System.currentTimeMillis());
   }
 }
コード例 #2
0
 void checkVersion() {
   AppLockApplication appLockApplication = AppLockApplication.getInstance();
   if (appLockApplication.hasNewVersion()) {
     downLoadFileUrl = appLockApplication.getUpdateVersionUrl();
     showUpdateDialog(appLockApplication.getUpdateVersionIntro());
   } else {
     ToastUtils.showToast(R.string.no_new_version);
   }
 }
コード例 #3
0
 @Override
 protected void onStop() {
   cameraFuncation.clearCamera();
   appLockApplication.setLastAppEnterPwdState(
       bPwdIsCorrent, new Date().getTime(), errorCount, lastDelayTime);
   if (!unGoHome) {
     AppLockApplication.getInstance().goHome(this);
   }
   super.onStop();
 }
コード例 #4
0
  @Override
  protected void onResume() {
    super.onResume();
    // 保险箱数据初始化
    mainAdapter.resetSafeBox();
    if (AppLockApplication.getInstance().isNeedSetSecret()) {
      startActivity(new Intent(this, SecretConfig.class));
      AppLockApplication.getInstance().setStartGuide(false);
    }

    sysFeedback();
  }
コード例 #5
0
  /** 反馈意见收到条目数 */
  private void sysFeedback() {

    AppLockApplication appLockApplication = AppLockApplication.getInstance();
    txt_drawer_version_num.setText(
        getString(R.string.version_now) + appLockApplication.getApplicationVersion());

    setReplySize(appLockApplication.getReplySize());

    mAgent = new FeedbackAgent(this);
    mComversation = mAgent.getDefaultConversation();
    sync();
  }
コード例 #6
0
 @Override
 public void onClickEvent(View view) {
   switch (view.getId()) {
     case R.id.btn_more:
       btnClickMore();
       break;
     case R.id.btn_user_model:
       AppLockApplication.getInstance().setVisitorState(true);
       finish();
       break;
     case R.id.gesturepwd_unlock_forget:
       unGoHome = true;
       Intent intent = new Intent(this, SecretCheckActivity.class);
       startActivity(intent);
       closePopView();
       break;
     case R.id.btn_user_check:
       boolean flag = SharedPreferenceUtil.readUnlockUserByEnter();
       SharedPreferenceUtil.editUnlockUserByEnter(!flag);
       if (SharedPreferenceUtil.readUnlockUserByEnter()) {
         iv_user_check.setImageResource(R.drawable.checkbox_select);
       } else {
         iv_user_check.setImageResource(R.drawable.checkbox_unselect);
       }
       break;
     default:
       break;
   }
   super.onClickEvent(view);
 }
コード例 #7
0
        @Override
        public void run() {
          numberDisable = true;
          long millsInFature = 0;
          if (bIsFalseStart) {
            bIsFalseStart = false;
            long defauleTime =
                new Date().getTime() - appLockApplication.getLastAppEnterPwdLeaverDateMiliseconds();
            if (defauleTime < appLockApplication.getLastAppEnterPwdDelayTime() * 1000) {
              millsInFature = appLockApplication.getLastAppEnterPwdDelayTime() * 1000 - defauleTime;
            }
          } else {
            millsInFature = delayTime[errorCount] + 1;
          }
          LogUtil.e("colin", "attemptLockout处理:" + millsInFature);
          mCountdownTimer =
              new CountDownTimer(millsInFature, 1000) {

                @Override
                public void onTick(long millisUntilFinished) {
                  int secondsRemaining = (int) (millisUntilFinished / 1000) - 1;
                  lastDelayTime = secondsRemaining;
                  if (secondsRemaining > 0) {
                    String format = getResources().getString(R.string.password_time);
                    String str = String.format(format, secondsRemaining);
                    mHeadTextView.setText(str);
                  } else {
                    mHeadTextView.setText(R.string.num_create_text_01);
                    mHeadTextView.setTextColor(Color.WHITE);
                  }
                }

                @Override
                public void onFinish() {
                  for (ImageView iv : pointList) {
                    iv.setImageResource(R.drawable.num_point);
                  }
                  numberDisable = false;
                  mFailedPatternAttemptsSinceLastTimeout = 0;
                  errorCount += 1;
                  if (errorCount > 4) {
                    errorCount = 0;
                  }
                }
              }.start();
        }
コード例 #8
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   cameraFuncation.clearCamera();
   appLockApplication.setLastAppEnterPwdState(
       bPwdIsCorrent, new Date().getTime(), errorCount, lastDelayTime);
   if (mCountdownTimer != null) mCountdownTimer.cancel();
 }
コード例 #9
0
 private void updateLockStatus() {
   AppLockApplication appLockApplication = AppLockApplication.getInstance();
   if (appLockApplication.appLockState) {
     tv_lock_status.setText(R.string.server_startlock_detail);
     drawer_logo.setImageResource(R.drawable.slide_logo);
   } else {
     tv_lock_status.setText(R.string.server_unlock_detail);
     drawer_logo.setImageResource(R.drawable.slide_logo_un);
   }
 }
コード例 #10
0
 public void setHideAppIcon() {
   PackageManager packageManager = getPackageManager();
   ComponentName componentName = new ComponentName(AppSettingActivity.this, SplashActivity.class);
   int res = packageManager.getComponentEnabledSetting(componentName);
   if (res == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
       || res == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
     // 隐藏应用图标
     packageManager.setComponentEnabledSetting(
         componentName,
         PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
         PackageManager.DONT_KILL_APP);
     appLockApplication.appIconIsHided = true;
     LogUtil.e("colin", "隐藏应用图标");
   } else {
     // 显示应用图标
     packageManager.setComponentEnabledSetting(
         componentName,
         PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
         PackageManager.DONT_KILL_APP);
     appLockApplication.appIconIsHided = false;
     LogUtil.e("colin", "显示应用图标");
   }
 }
コード例 #11
0
public class NumberCheckActivity extends BaseActivity {

  public static final String CHANGE_PASSWORD = "******";

  private TextView mHeadTextView;
  private Animation mShakeAnim;

  private Handler mHandler = new Handler();

  private boolean changeFlag;
  private boolean numberDisable = false;
  private CountDownTimer mCountdownTimer = null;

  private int mFailedPatternAttemptsSinceLastTimeout = 0;

  private ImageView iv_user_check;

  private int[] delayTime = {60000, 120000, 180000, 600000, 1800000};
  private int errorCount = 0;
  private boolean bPwdIsCorrent = true;
  private boolean bIsFalseStart = false;
  private int lastDelayTime = 0;
  private AppLockApplication appLockApplication = AppLockApplication.getInstance();

  private CameraFuncation cameraFuncation;
  private SurfaceView surfaceView;
  private LookMyPrivateService pService;
  private PlayWarringSoundService playWarringSoundService;

  private View popView;
  private ActionView actionView;
  private ScaleAnimation pop_in;
  private ScaleAnimation pop_out;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_num_check);

    pService = new LookMyPrivateService(getApplicationContext());
    playWarringSoundService = new PlayWarringSoundService(getApplicationContext());
    surfaceView = (SurfaceView) findViewById(R.id.picSurfaceView);
    cameraFuncation = new CameraFuncation(getApplicationContext(), surfaceView, pService);
    mHeadTextView = (TextView) findViewById(R.id.tv_text);
    mShakeAnim = AnimationUtils.loadAnimation(this, R.anim.shake_x);
    iv_user_check = (ImageView) findViewById(R.id.iv_user_check);

    initNumLayout();
    changeFlag = getIntent().getBooleanExtra(CHANGE_PASSWORD, false);
    unGoHome = changeFlag;
    VisitorModelService visitorModelService = new VisitorModelService(getApplicationContext());
    if (changeFlag || !visitorModelService.hasLockedPackage()) {
      findViewById(R.id.btn_user_model).setVisibility(View.INVISIBLE);
    } else if (AppLockApplication.getInstance().getVisitorState()) {
      findViewById(R.id.btn_user_check).setVisibility(View.VISIBLE);
      if (SharedPreferenceUtil.readUnlockUserByEnter()) {
        iv_user_check.setImageResource(R.drawable.checkbox_select);
      } else {
        iv_user_check.setImageResource(R.drawable.checkbox_unselect);
      }
    }

    bPwdIsCorrent = appLockApplication.getLastAppEnterCorrentPwd();
    errorCount = appLockApplication.getLastAppEnterPwdErrorCount();
    if (!bPwdIsCorrent) {
      bIsFalseStart = true;
      long defauleTime =
          new Date().getTime() - appLockApplication.getLastAppEnterPwdLeaverDateMiliseconds();
      LogUtil.e(
          "colin",
          "上次解锁密码错误,到现在的时间为:"
              + defauleTime
              + "上次时间为:"
              + appLockApplication.getLastAppEnterPwdDelayTime());
      if (defauleTime < appLockApplication.getLastAppEnterPwdDelayTime() * 1000) {
        LogUtil.e("colin", "上次解锁密码错误,时间孙艳");
        mHandler.postDelayed(attemptLockout, 100);
      } else {
        LogUtil.e("colin", "上次解锁密码错误,时间不孙艳");
        bIsFalseStart = false;
        errorCount += 1;
        if (errorCount > 4) {
          errorCount = 0;
        }
        appLockApplication.setLastAppEnterPwdErrorCount(errorCount);
      }
    }

    // pop
    popView = findViewById(R.id.layout_pop);
    actionView = (ActionView) findViewById(R.id.btn_more);

    initAnim();
    String secretQuestion = AppLockApplication.getInstance().getSecretQuestionString();
    if (!TextUtils.isEmpty(secretQuestion)) {
      actionView.setVisibility(View.VISIBLE);
    } else {
      actionView.setVisibility(View.INVISIBLE);
    }
    super.onCreate(savedInstanceState);
  }

  private void closePopView() {
    if (View.VISIBLE == popView.getVisibility()) {
      actionView.setAction(new MoreAction(), ActionView.ROTATE_COUNTER_CLOCKWISE);
      popView.clearAnimation();
      popView.startAnimation(pop_out);
    }
  }

  private void initAnim() {

    long durationS = 160;
    AccelerateInterpolator accInterpolator = new AccelerateInterpolator();

    pop_in =
        new ScaleAnimation(
            0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);
    pop_out =
        new ScaleAnimation(
            1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);

    pop_in.setDuration(durationS);
    pop_in.setInterpolator(accInterpolator);
    pop_in.setAnimationListener(new PopListener(popView, PopListener.TYPE_IN));

    pop_out.setDuration(durationS);
    pop_out.setInterpolator(accInterpolator);
    pop_out.setAnimationListener(new PopListener(popView, PopListener.TYPE_OUT));
  }

  private void btnClickMore() {
    if (View.VISIBLE == popView.getVisibility()) {
      actionView.setAction(new MoreAction(), ActionView.ROTATE_COUNTER_CLOCKWISE);
      popView.clearAnimation();
      popView.startAnimation(pop_out);
    } else {
      actionView.setAction(new CloseAction(), ActionView.ROTATE_COUNTER_CLOCKWISE);
      popView.clearAnimation();
      popView.startAnimation(pop_in);
    }
  }

  @Override
  protected void onDestroy() {
    super.onDestroy();
    cameraFuncation.clearCamera();
    appLockApplication.setLastAppEnterPwdState(
        bPwdIsCorrent, new Date().getTime(), errorCount, lastDelayTime);
    if (mCountdownTimer != null) mCountdownTimer.cancel();
  }

  @Override
  protected void onResume() {
    super.onResume();
  }

  @Override
  public void onClickEvent(View view) {
    switch (view.getId()) {
      case R.id.btn_more:
        btnClickMore();
        break;
      case R.id.btn_user_model:
        AppLockApplication.getInstance().setVisitorState(true);
        finish();
        break;
      case R.id.gesturepwd_unlock_forget:
        unGoHome = true;
        Intent intent = new Intent(this, SecretCheckActivity.class);
        startActivity(intent);
        closePopView();
        break;
      case R.id.btn_user_check:
        boolean flag = SharedPreferenceUtil.readUnlockUserByEnter();
        SharedPreferenceUtil.editUnlockUserByEnter(!flag);
        if (SharedPreferenceUtil.readUnlockUserByEnter()) {
          iv_user_check.setImageResource(R.drawable.checkbox_select);
        } else {
          iv_user_check.setImageResource(R.drawable.checkbox_unselect);
        }
        break;
      default:
        break;
    }
    super.onClickEvent(view);
  }

  boolean unGoHome = false;

  @Override
  protected void onStop() {
    cameraFuncation.clearCamera();
    appLockApplication.setLastAppEnterPwdState(
        bPwdIsCorrent, new Date().getTime(), errorCount, lastDelayTime);
    if (!unGoHome) {
      AppLockApplication.getInstance().goHome(this);
    }
    super.onStop();
  }

  private static final int COUNT = 4;
  private List<String> numInput;
  private List<ImageView> pointList;

  private void initNumLayout() {
    numInput = new ArrayList<String>();
    pointList = new ArrayList<ImageView>(COUNT);
    pointList.add((ImageView) findViewById(R.id.num_point_1));
    pointList.add((ImageView) findViewById(R.id.num_point_2));
    pointList.add((ImageView) findViewById(R.id.num_point_3));
    pointList.add((ImageView) findViewById(R.id.num_point_4));
    for (ImageView iv : pointList) {
      iv.setImageResource(R.drawable.num_point);
    }
  }

  public void onNumClick(View view) {

    if (numberDisable) {
      return;
    }

    switch (view.getId()) {
      case R.id.number_1:
      case R.id.number_2:
      case R.id.number_3:
      case R.id.number_4:
      case R.id.number_5:
      case R.id.number_6:
      case R.id.number_7:
      case R.id.number_8:
      case R.id.number_9:
      case R.id.number_0:
        clickNumber((Button) view);
        break;

      case R.id.number_del:
        deleteNumber();
        break;

      default:
        break;
    }
    super.onClickEvent(view);
  }

  private void clickNumber(Button btn) {

    if (numInput.size() < COUNT) {
      numInput.add(btn.getText().toString());
    }
    int index = 0;
    for (ImageView iv : pointList) {
      if (index++ < numInput.size()) {
        iv.setImageResource(R.drawable.num_point_check);
      } else {
        iv.setImageResource(R.drawable.num_point);
      }
    }
    StringBuffer pBuffer = new StringBuffer();
    for (String s : numInput) {
      pBuffer.append(s);
    }
    doForResult(inputCheck(pBuffer.toString()));
  }

  enum InputResult {
    SUCCESS,
    ERROR,
    CONTINUE
  }

  private void doForResult(InputResult result) {
    switch (result) {
      case CONTINUE:
        break;
      case SUCCESS:
        unGoHome = true;
        bPwdIsCorrent = true;
        if (changeFlag) {
          Intent intent = new Intent(NumberCheckActivity.this, NumberCreateActivity.class);
          intent.putExtra(GestureCreateActivity.CHANGE_FLAG, true);
          startActivity(intent);
        } else {
          if (AppLockApplication.getInstance().getVisitorState()
              && SharedPreferenceUtil.readUnlockUserByEnter()) {
            AppLockApplication.getInstance().setVisitorState(false);
          }
          Intent intent = new Intent(NumberCheckActivity.this, LockMainActivity.class);
          AppLockApplication.getInstance().setStartGuide(true);
          startActivity(intent);
        }
        finish();
        break;

      case ERROR:
        bPwdIsCorrent = false;
        mFailedPatternAttemptsSinceLastTimeout++;
        int retry =
            LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT
                - mFailedPatternAttemptsSinceLastTimeout;
        if (retry >= 0) {
          if (retry == 0)
            ToastUtils.showToast(
                String.format(
                    getResources().getString(R.string.password_error_wait),
                    delayTime[errorCount] / 1000 / 60));
          String format = getResources().getString(R.string.password_error_count);
          String str = String.format(format, retry);
          mHeadTextView.setText(str);
          mHeadTextView.setTextColor(getResources().getColor(R.color.text_red));
          mHeadTextView.startAnimation(mShakeAnim);
        }

        if (mFailedPatternAttemptsSinceLastTimeout >= 3) {
          LookMyPrivate lookMyPrivate = new LookMyPrivate();
          lookMyPrivate.setLookDate(new Date());
          lookMyPrivate.setResolver("com.cleanwiz.applock");
          long id = pService.addNewLookMyPrivate(lookMyPrivate);
          lookMyPrivate.setId(id);
          if (appLockApplication.getAutoRecordPic()) {
            if (cameraFuncation != null) {
              cameraFuncation.lookMyPrivate = lookMyPrivate;
              LogUtil.e("colin", "解锁失败,拍照来哦啦");
              cameraFuncation.tackPicture();
            }
          }
          // 播放声音
          if (appLockApplication.getPlayWarringSoundState()) {
            playWarringSoundService.playSound();
          }
        }
        if (mFailedPatternAttemptsSinceLastTimeout
            >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
          mHandler.postDelayed(attemptLockout, 2000);
        } else {
          numberDisable = true;
          mHandler.postDelayed(clearPassword, 2000);
        }

        break;

      default:
        break;
    }
  }

  private InputResult inputCheck(String password) {
    InputResult result;
    LogUtil.d("demo3", "input:" + password);
    if (numInput.size() == COUNT) {
      numInput.clear();
      String md5 = StringUtils.toMD5(password);
      if (md5.equals(SharedPreferenceUtil.readNumPassword())) {
        result = InputResult.SUCCESS;
      } else {
        result = InputResult.ERROR;
      }
    } else {
      result = InputResult.CONTINUE;
    }
    return result;
  }

  private void deleteNumber() {

    if (numInput.size() == 0) {
      return;
    }
    pointList.get(numInput.size() - 1).setImageResource(R.drawable.num_point);
    numInput.remove(numInput.size() - 1);
  }

  private Runnable clearPassword =
      new Runnable() {
        public void run() {
          for (ImageView iv : pointList) {
            iv.setImageResource(R.drawable.num_point);
          }
          numberDisable = false;
        }
      };

  Runnable attemptLockout =
      new Runnable() {

        @Override
        public void run() {
          numberDisable = true;
          long millsInFature = 0;
          if (bIsFalseStart) {
            bIsFalseStart = false;
            long defauleTime =
                new Date().getTime() - appLockApplication.getLastAppEnterPwdLeaverDateMiliseconds();
            if (defauleTime < appLockApplication.getLastAppEnterPwdDelayTime() * 1000) {
              millsInFature = appLockApplication.getLastAppEnterPwdDelayTime() * 1000 - defauleTime;
            }
          } else {
            millsInFature = delayTime[errorCount] + 1;
          }
          LogUtil.e("colin", "attemptLockout处理:" + millsInFature);
          mCountdownTimer =
              new CountDownTimer(millsInFature, 1000) {

                @Override
                public void onTick(long millisUntilFinished) {
                  int secondsRemaining = (int) (millisUntilFinished / 1000) - 1;
                  lastDelayTime = secondsRemaining;
                  if (secondsRemaining > 0) {
                    String format = getResources().getString(R.string.password_time);
                    String str = String.format(format, secondsRemaining);
                    mHeadTextView.setText(str);
                  } else {
                    mHeadTextView.setText(R.string.num_create_text_01);
                    mHeadTextView.setTextColor(Color.WHITE);
                  }
                }

                @Override
                public void onFinish() {
                  for (ImageView iv : pointList) {
                    iv.setImageResource(R.drawable.num_point);
                  }
                  numberDisable = false;
                  mFailedPatternAttemptsSinceLastTimeout = 0;
                  errorCount += 1;
                  if (errorCount > 4) {
                    errorCount = 0;
                  }
                }
              }.start();
        }
      };
}
コード例 #12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_num_check);

    pService = new LookMyPrivateService(getApplicationContext());
    playWarringSoundService = new PlayWarringSoundService(getApplicationContext());
    surfaceView = (SurfaceView) findViewById(R.id.picSurfaceView);
    cameraFuncation = new CameraFuncation(getApplicationContext(), surfaceView, pService);
    mHeadTextView = (TextView) findViewById(R.id.tv_text);
    mShakeAnim = AnimationUtils.loadAnimation(this, R.anim.shake_x);
    iv_user_check = (ImageView) findViewById(R.id.iv_user_check);

    initNumLayout();
    changeFlag = getIntent().getBooleanExtra(CHANGE_PASSWORD, false);
    unGoHome = changeFlag;
    VisitorModelService visitorModelService = new VisitorModelService(getApplicationContext());
    if (changeFlag || !visitorModelService.hasLockedPackage()) {
      findViewById(R.id.btn_user_model).setVisibility(View.INVISIBLE);
    } else if (AppLockApplication.getInstance().getVisitorState()) {
      findViewById(R.id.btn_user_check).setVisibility(View.VISIBLE);
      if (SharedPreferenceUtil.readUnlockUserByEnter()) {
        iv_user_check.setImageResource(R.drawable.checkbox_select);
      } else {
        iv_user_check.setImageResource(R.drawable.checkbox_unselect);
      }
    }

    bPwdIsCorrent = appLockApplication.getLastAppEnterCorrentPwd();
    errorCount = appLockApplication.getLastAppEnterPwdErrorCount();
    if (!bPwdIsCorrent) {
      bIsFalseStart = true;
      long defauleTime =
          new Date().getTime() - appLockApplication.getLastAppEnterPwdLeaverDateMiliseconds();
      LogUtil.e(
          "colin",
          "上次解锁密码错误,到现在的时间为:"
              + defauleTime
              + "上次时间为:"
              + appLockApplication.getLastAppEnterPwdDelayTime());
      if (defauleTime < appLockApplication.getLastAppEnterPwdDelayTime() * 1000) {
        LogUtil.e("colin", "上次解锁密码错误,时间孙艳");
        mHandler.postDelayed(attemptLockout, 100);
      } else {
        LogUtil.e("colin", "上次解锁密码错误,时间不孙艳");
        bIsFalseStart = false;
        errorCount += 1;
        if (errorCount > 4) {
          errorCount = 0;
        }
        appLockApplication.setLastAppEnterPwdErrorCount(errorCount);
      }
    }

    // pop
    popView = findViewById(R.id.layout_pop);
    actionView = (ActionView) findViewById(R.id.btn_more);

    initAnim();
    String secretQuestion = AppLockApplication.getInstance().getSecretQuestionString();
    if (!TextUtils.isEmpty(secretQuestion)) {
      actionView.setVisibility(View.VISIBLE);
    } else {
      actionView.setVisibility(View.INVISIBLE);
    }
    super.onCreate(savedInstanceState);
  }
コード例 #13
0
 @Override
 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
   // TODO Auto-generated method stub
   SwitchButton switchButton = (SwitchButton) buttonView;
   LogUtil.e("colin", "switch is changed:" + switchButton.getId());
   switch (switchButton.getId()) {
     case 2: // 启用加锁
       {
         boolean bIsState = !switchButton.isChecked();
         appLockApplication.setAppLockState(bIsState);
         break;
       }
     case 8: // 新应用加锁提示
       {
         break;
       }
     case 9: // 允许短暂退出
       {
         boolean bIsState = !switchButton.isChecked();
         appLockApplication.setAllowedLeaveAment(bIsState);
         Intent intent = new Intent(LockService.LOCK_SERVICE_LEAVEAMENT);
         intent.putExtra(LockService.LOCK_SERVICE_LEAVEAMENT, bIsState);
         sendBroadcast(intent);
         LogUtil.d("demo3", "bIsState:" + bIsState);
         break;
       }
     case 11: // 锁锁图标的隐藏和显示
       {
         setHideAppIcon();
         break;
       }
     case 12: // 防卸载
       {
         if (!switchButton.isChecked()
             && !devicePolicyManager.isAdminActive(componentName)) {
           enableDeviceManager();
         } else if (switchButton.isChecked()
             && devicePolicyManager.isAdminActive(componentName)) {
           disableDeviceManager();
         }
         break;
       }
     case 18: // 自动拍照
       {
         appLockApplication.setAutoRecordPic(!switchButton.isChecked());
         if (appLockApplication.getAutoRecordPic()) {
           WarringDialog warringDialog = new WarringDialog();
           warringDialog.switchButton = switchButton;
           warringDialog.show();
         }
         break;
       }
     case 19: // 播放告警声音
       {
         appLockApplication.setPlayWarringSoundState(!switchButton.isChecked());
         break;
       }
     default:
       break;
   }
   appSettingAdapter.notifyDataSetChanged();
 }
コード例 #14
0
  private void doForResult(InputResult result) {
    switch (result) {
      case CONTINUE:
        break;
      case SUCCESS:
        unGoHome = true;
        bPwdIsCorrent = true;
        if (changeFlag) {
          Intent intent = new Intent(NumberCheckActivity.this, NumberCreateActivity.class);
          intent.putExtra(GestureCreateActivity.CHANGE_FLAG, true);
          startActivity(intent);
        } else {
          if (AppLockApplication.getInstance().getVisitorState()
              && SharedPreferenceUtil.readUnlockUserByEnter()) {
            AppLockApplication.getInstance().setVisitorState(false);
          }
          Intent intent = new Intent(NumberCheckActivity.this, LockMainActivity.class);
          AppLockApplication.getInstance().setStartGuide(true);
          startActivity(intent);
        }
        finish();
        break;

      case ERROR:
        bPwdIsCorrent = false;
        mFailedPatternAttemptsSinceLastTimeout++;
        int retry =
            LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT
                - mFailedPatternAttemptsSinceLastTimeout;
        if (retry >= 0) {
          if (retry == 0)
            ToastUtils.showToast(
                String.format(
                    getResources().getString(R.string.password_error_wait),
                    delayTime[errorCount] / 1000 / 60));
          String format = getResources().getString(R.string.password_error_count);
          String str = String.format(format, retry);
          mHeadTextView.setText(str);
          mHeadTextView.setTextColor(getResources().getColor(R.color.text_red));
          mHeadTextView.startAnimation(mShakeAnim);
        }

        if (mFailedPatternAttemptsSinceLastTimeout >= 3) {
          LookMyPrivate lookMyPrivate = new LookMyPrivate();
          lookMyPrivate.setLookDate(new Date());
          lookMyPrivate.setResolver("com.cleanwiz.applock");
          long id = pService.addNewLookMyPrivate(lookMyPrivate);
          lookMyPrivate.setId(id);
          if (appLockApplication.getAutoRecordPic()) {
            if (cameraFuncation != null) {
              cameraFuncation.lookMyPrivate = lookMyPrivate;
              LogUtil.e("colin", "解锁失败,拍照来哦啦");
              cameraFuncation.tackPicture();
            }
          }
          // 播放声音
          if (appLockApplication.getPlayWarringSoundState()) {
            playWarringSoundService.playSound();
          }
        }
        if (mFailedPatternAttemptsSinceLastTimeout
            >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
          mHandler.postDelayed(attemptLockout, 2000);
        } else {
          numberDisable = true;
          mHandler.postDelayed(clearPassword, 2000);
        }

        break;

      default:
        break;
    }
  }
コード例 #15
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_appsetting);
    context = this;
    devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    componentName = new ComponentName(this, DeviceMyReceiver.class);
    appLockApplication.appIconIsHided = getHideAppIcon();

    appSettingListView = (ListView) findViewById(R.id.appsettinglistview);
    appSettingAdapter = new AppSettingAdapter(context, mCheckedChangeListener, appLockApplication);
    appSettingAdapter.setComponentName(componentName);
    appSettingAdapter.setDevicePolicyManager(devicePolicyManager);
    appSettingListView.setAdapter(appSettingAdapter);
    appSettingListView.setOnItemClickListener(itemClickListener);

    AppSettingItemInfo appSettingItemInfo =
        new AppSettingItemInfo(
            1, 0, true, false, false, getString(R.string.server_title), "", "", "");
    AppSettingItemInfo appSettingItemInfo1 =
        new AppSettingItemInfo(
            2,
            1,
            false,
            true,
            false,
            "",
            getString(R.string.server_startlock_title),
            getString(R.string.server_startlock_detail),
            "");
    AppSettingItemInfo appSettingItemInfo2 =
        new AppSettingItemInfo(
            3, 3000, true, false, false, getString(R.string.pwdsetting_title), "", "", "");
    AppSettingItemInfo appSettingItemInfo3 =
        new AppSettingItemInfo(
            4,
            3,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_modify_title),
            getString(R.string.pwdsetting_modify_detail),
            getString(R.string.pwdsetting_modify_handler));
    AppSettingItemInfo appSettingItemInfo4 =
        new AppSettingItemInfo(
            5,
            3,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_notrue_title),
            getString(R.string.pwdsetting_notrue_detail),
            "");
    AppSettingItemInfo appSettingItemInfo5 =
        new AppSettingItemInfo(
            6,
            3,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_secret_title),
            getString(R.string.pwdsetting_secret_detail),
            "");
    AppSettingItemInfo appSettingItemInfo6 =
        new AppSettingItemInfo(
            7, 3001, true, false, false, getString(R.string.pwdsetting_advance_title), "", "", "");
    AppSettingItemInfo appSettingItemInfo17 =
        new AppSettingItemInfo(
            18,
            7,
            false,
            true,
            false,
            "",
            getString(R.string.pwdsetting_advance_aoturecordpic__title),
            getString(R.string.pwdsetting_advance_aoturecordpic__detail),
            "");
    AppSettingItemInfo appSettingItemInfo18 =
        new AppSettingItemInfo(
            19,
            7,
            false,
            true,
            false,
            "",
            getString(R.string.pwdsetting_advance_playwarringsound__title),
            getString(R.string.pwdsetting_advance_playwarringsound__detail),
            "");
    AppSettingItemInfo appSettingItemInfo7 =
        new AppSettingItemInfo(
            8,
            7,
            false,
            true,
            false,
            "",
            getString(R.string.pwdsetting_advance_tipsnewapp_title),
            getString(R.string.pwdsetting_advance_tipsnewapp_detail),
            "");
    AppSettingItemInfo appSettingItemInfo8 =
        new AppSettingItemInfo(
            9,
            7,
            false,
            true,
            false,
            "",
            getString(R.string.pwdsetting_advance_allowleave_title),
            getString(R.string.pwdsetting_advance_allowleave_detail),
            "");
    AppSettingItemInfo appSettingItemInfo9 =
        new AppSettingItemInfo(
            10,
            7,
            false,
            false,
            false,
            "",
            getString(R.string.pwdsetting_advance_allowleavetime_title),
            getString(R.string.pwdsetting_advance_allowleavetime_detail_30second),
            "");
    AppSettingItemInfo appSettingItemInfo10 =
        new AppSettingItemInfo(
            11,
            7,
            false,
            true,
            false,
            "",
            getString(R.string.pwdsetting_advance_hideappicon_title),
            getString(R.string.pwdsetting_advance_hideappicon__detail),
            "");
    AppSettingItemInfo appSettingItemInfo11 =
        new AppSettingItemInfo(
            12,
            7,
            false,
            true,
            false,
            "",
            getString(R.string.pwdsetting_advance_uninstallapp_title),
            getString(R.string.pwdsetting_advance_uninstallapp_detail),
            "");
    AppSettingItemInfo appSettingItemInfo12 =
        new AppSettingItemInfo(
            13,
            3002,
            true,
            false,
            false,
            getString(R.string.pwdsetting_aboutour_title),
            "",
            "",
            "");
    AppSettingItemInfo appSettingItemInfo21 =
        new AppSettingItemInfo(
            22,
            13,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_aboutour_apps_title),
            getString(R.string.pwdsetting_aboutour_apps_detail),
            "");
    AppSettingItemInfo appSettingItemInfo13 =
        new AppSettingItemInfo(
            14,
            13,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_aboutour_feedback_title),
            getString(R.string.pwdsetting_aboutour_feedback_detail),
            "");
    AppSettingItemInfo appSettingItemInfo14 =
        new AppSettingItemInfo(
            15,
            13,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_aboutour_qa_title),
            getString(R.string.pwdsetting_aboutour_qa_detail),
            "");
    AppSettingItemInfo appSettingItemInfo15 =
        new AppSettingItemInfo(
            16,
            13,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_aboutour_version_title),
            getString(R.string.pwdsetting_aboutour_version_detail),
            getString(R.string.pwdsetting_aboutour_version_hasnew));
    AppSettingItemInfo appSettingItemInfo16 =
        new AppSettingItemInfo(
            17,
            13,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_aboutour_lookmyprivate_title),
            getString(R.string.pwdsetting_aboutour_lookmyprivate_detail),
            "");

    AppSettingItemInfo appSettingItemInfo19 =
        new AppSettingItemInfo(
            20,
            1,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_share_title),
            getString(R.string.pwdsetting_share_detail),
            "");

    dataAppSettingItemInfos.add(appSettingItemInfo);
    dataAppSettingItemInfos.add(appSettingItemInfo1);
    dataAppSettingItemInfos.add(appSettingItemInfo16);
    dataAppSettingItemInfos.add(appSettingItemInfo2);
    dataAppSettingItemInfos.add(appSettingItemInfo3);
    dataAppSettingItemInfos.add(appSettingItemInfo5);
    dataAppSettingItemInfos.add(appSettingItemInfo6);
    dataAppSettingItemInfos.add(appSettingItemInfo17);
    dataAppSettingItemInfos.add(appSettingItemInfo18);
    dataAppSettingItemInfos.add(appSettingItemInfo7);
    dataAppSettingItemInfos.add(appSettingItemInfo8);
    dataAppSettingItemInfos.add(appSettingItemInfo9);
    dataAppSettingItemInfos.add(appSettingItemInfo12);
    dataAppSettingItemInfos.add(appSettingItemInfo21);
    dataAppSettingItemInfos.add(appSettingItemInfo13);
    dataAppSettingItemInfos.add(appSettingItemInfo15);

    addAdapter(dataAppSettingItemInfos);

    leaveTimeStrings.add(getString(R.string.pwdsetting_advance_allowleavetime_detail_30second));
    leaveTimeStrings.add(getString(R.string.pwdsetting_advance_allowleavetime_detail_1minute));
    leaveTimeStrings.add(getString(R.string.pwdsetting_advance_allowleavetime_detail_2minute));
    leaveTimeStrings.add(getString(R.string.pwdsetting_advance_allowleavetime_detail_5minute));
  }
コード例 #16
0
 public void checkVersion() {
   if (appLockApplication.hasNewVersion()) {
     downLoadFileUrl = appLockApplication.getUpdateVersionUrl();
     showUpdateDialog(appLockApplication.getUpdateVersionIntro());
   }
 }
コード例 #17
0
public class AppSettingActivity extends BaseActivity {

  private Context context = null;
  private ListView appSettingListView = null;
  private AppSettingAdapter appSettingAdapter = null;
  private AppLockApplication appLockApplication = AppLockApplication.getInstance();
  private Vector<AppSettingItemInfo> allItemInfos = new Vector<AppSettingItemInfo>();
  private List<String> leaveTimeStrings = new ArrayList<String>();
  private Vector<AppSettingItemInfo> dataAppSettingItemInfos = new Vector<AppSettingItemInfo>();

  private final int SETLEAVEDIALOG_DISS = 100;
  private final int UPDATEADAPTER = 101;

  private String downLoadFileUrl = "";
  private DevicePolicyManager devicePolicyManager;
  private ComponentName componentName;

  private Handler mHandler =
      new Handler() {
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case SETLEAVEDIALOG_DISS:
              {
                appSettingAdapter.notifyDataSetChanged();
                break;
              }
            case SplashActivity.CHECKVERSION_CANCEL:
            case SplashActivity.CHECKVERSION_EOOR:
              break;
            case SplashActivity.CHECKVERSION_DOWN:
              {
                // 通知栏更新,下载文件
                Intent updateIntent = new Intent(AppSettingActivity.this, UpdateService.class);
                updateIntent.putExtra("appUrl", downLoadFileUrl);
                startService(updateIntent);
                break;
              }
            case UPDATEADAPTER:
              {
                appSettingAdapter.notifyDataSetChanged();
                break;
              }
            default:
              break;
          }
        }
      };

  private OnCheckedChangeListener mCheckedChangeListener =
      new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
          // TODO Auto-generated method stub
          SwitchButton switchButton = (SwitchButton) buttonView;
          LogUtil.e("colin", "switch is changed:" + switchButton.getId());
          switch (switchButton.getId()) {
            case 2: // 启用加锁
              {
                boolean bIsState = !switchButton.isChecked();
                appLockApplication.setAppLockState(bIsState);
                break;
              }
            case 8: // 新应用加锁提示
              {
                break;
              }
            case 9: // 允许短暂退出
              {
                boolean bIsState = !switchButton.isChecked();
                appLockApplication.setAllowedLeaveAment(bIsState);
                Intent intent = new Intent(LockService.LOCK_SERVICE_LEAVEAMENT);
                intent.putExtra(LockService.LOCK_SERVICE_LEAVEAMENT, bIsState);
                sendBroadcast(intent);
                LogUtil.d("demo3", "bIsState:" + bIsState);
                break;
              }
            case 11: // 锁锁图标的隐藏和显示
              {
                setHideAppIcon();
                break;
              }
            case 12: // 防卸载
              {
                if (!switchButton.isChecked()
                    && !devicePolicyManager.isAdminActive(componentName)) {
                  enableDeviceManager();
                } else if (switchButton.isChecked()
                    && devicePolicyManager.isAdminActive(componentName)) {
                  disableDeviceManager();
                }
                break;
              }
            case 18: // 自动拍照
              {
                appLockApplication.setAutoRecordPic(!switchButton.isChecked());
                if (appLockApplication.getAutoRecordPic()) {
                  WarringDialog warringDialog = new WarringDialog();
                  warringDialog.switchButton = switchButton;
                  warringDialog.show();
                }
                break;
              }
            case 19: // 播放告警声音
              {
                appLockApplication.setPlayWarringSoundState(!switchButton.isChecked());
                break;
              }
            default:
              break;
          }
          appSettingAdapter.notifyDataSetChanged();
        }
      };

  private OnItemClickListener itemClickListener =
      new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
          // TODO Auto-generated method stub
          ViewHoder appSettingItemInfo = (ViewHoder) view.getTag();
          LogUtil.e("colin", "ll:" + appSettingItemInfo.id);
          switch (appSettingItemInfo.id) {
            case 4:
              {
                changePassword();
                break;
              }
            case 6: // 密保设置
              {
                showSetSecretDialog();
                break;
              }
            case 10: // 短暂退出时间
              {
                LogUtil.e("colin", "短暂退出时间");
                if (appLockApplication.allowedLeaveAment) {
                  showSetLeaveTimeDialog();
                }
                break;
              }
            case 14: // 用户反馈
              {
                setUpUmengFeedback();
                break;
              }
            case 15: // 常见问题
              {
                startActivity(new Intent(AppSettingActivity.this, NormalQAActivity.class));
                break;
              }
            case 16: // 版本更新
              {
                checkVersion();
                break;
              }
            case 17: // 错误解锁日志
              {
                startActivity(new Intent(AppSettingActivity.this, LookMyPrivateActivity.class));
                break;
              }
            case 22: // 精品推荐
              {
                startActivity(new Intent(AppSettingActivity.this, AppsLinkActivity.class));
                break;
              }
            case 20: // 分享
              {
                systemShare();
                break;
              }
            default:
              break;
          }
        }
      };

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_appsetting);
    context = this;
    devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    componentName = new ComponentName(this, DeviceMyReceiver.class);
    appLockApplication.appIconIsHided = getHideAppIcon();

    appSettingListView = (ListView) findViewById(R.id.appsettinglistview);
    appSettingAdapter = new AppSettingAdapter(context, mCheckedChangeListener, appLockApplication);
    appSettingAdapter.setComponentName(componentName);
    appSettingAdapter.setDevicePolicyManager(devicePolicyManager);
    appSettingListView.setAdapter(appSettingAdapter);
    appSettingListView.setOnItemClickListener(itemClickListener);

    AppSettingItemInfo appSettingItemInfo =
        new AppSettingItemInfo(
            1, 0, true, false, false, getString(R.string.server_title), "", "", "");
    AppSettingItemInfo appSettingItemInfo1 =
        new AppSettingItemInfo(
            2,
            1,
            false,
            true,
            false,
            "",
            getString(R.string.server_startlock_title),
            getString(R.string.server_startlock_detail),
            "");
    AppSettingItemInfo appSettingItemInfo2 =
        new AppSettingItemInfo(
            3, 3000, true, false, false, getString(R.string.pwdsetting_title), "", "", "");
    AppSettingItemInfo appSettingItemInfo3 =
        new AppSettingItemInfo(
            4,
            3,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_modify_title),
            getString(R.string.pwdsetting_modify_detail),
            getString(R.string.pwdsetting_modify_handler));
    AppSettingItemInfo appSettingItemInfo4 =
        new AppSettingItemInfo(
            5,
            3,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_notrue_title),
            getString(R.string.pwdsetting_notrue_detail),
            "");
    AppSettingItemInfo appSettingItemInfo5 =
        new AppSettingItemInfo(
            6,
            3,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_secret_title),
            getString(R.string.pwdsetting_secret_detail),
            "");
    AppSettingItemInfo appSettingItemInfo6 =
        new AppSettingItemInfo(
            7, 3001, true, false, false, getString(R.string.pwdsetting_advance_title), "", "", "");
    AppSettingItemInfo appSettingItemInfo17 =
        new AppSettingItemInfo(
            18,
            7,
            false,
            true,
            false,
            "",
            getString(R.string.pwdsetting_advance_aoturecordpic__title),
            getString(R.string.pwdsetting_advance_aoturecordpic__detail),
            "");
    AppSettingItemInfo appSettingItemInfo18 =
        new AppSettingItemInfo(
            19,
            7,
            false,
            true,
            false,
            "",
            getString(R.string.pwdsetting_advance_playwarringsound__title),
            getString(R.string.pwdsetting_advance_playwarringsound__detail),
            "");
    AppSettingItemInfo appSettingItemInfo7 =
        new AppSettingItemInfo(
            8,
            7,
            false,
            true,
            false,
            "",
            getString(R.string.pwdsetting_advance_tipsnewapp_title),
            getString(R.string.pwdsetting_advance_tipsnewapp_detail),
            "");
    AppSettingItemInfo appSettingItemInfo8 =
        new AppSettingItemInfo(
            9,
            7,
            false,
            true,
            false,
            "",
            getString(R.string.pwdsetting_advance_allowleave_title),
            getString(R.string.pwdsetting_advance_allowleave_detail),
            "");
    AppSettingItemInfo appSettingItemInfo9 =
        new AppSettingItemInfo(
            10,
            7,
            false,
            false,
            false,
            "",
            getString(R.string.pwdsetting_advance_allowleavetime_title),
            getString(R.string.pwdsetting_advance_allowleavetime_detail_30second),
            "");
    AppSettingItemInfo appSettingItemInfo10 =
        new AppSettingItemInfo(
            11,
            7,
            false,
            true,
            false,
            "",
            getString(R.string.pwdsetting_advance_hideappicon_title),
            getString(R.string.pwdsetting_advance_hideappicon__detail),
            "");
    AppSettingItemInfo appSettingItemInfo11 =
        new AppSettingItemInfo(
            12,
            7,
            false,
            true,
            false,
            "",
            getString(R.string.pwdsetting_advance_uninstallapp_title),
            getString(R.string.pwdsetting_advance_uninstallapp_detail),
            "");
    AppSettingItemInfo appSettingItemInfo12 =
        new AppSettingItemInfo(
            13,
            3002,
            true,
            false,
            false,
            getString(R.string.pwdsetting_aboutour_title),
            "",
            "",
            "");
    AppSettingItemInfo appSettingItemInfo21 =
        new AppSettingItemInfo(
            22,
            13,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_aboutour_apps_title),
            getString(R.string.pwdsetting_aboutour_apps_detail),
            "");
    AppSettingItemInfo appSettingItemInfo13 =
        new AppSettingItemInfo(
            14,
            13,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_aboutour_feedback_title),
            getString(R.string.pwdsetting_aboutour_feedback_detail),
            "");
    AppSettingItemInfo appSettingItemInfo14 =
        new AppSettingItemInfo(
            15,
            13,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_aboutour_qa_title),
            getString(R.string.pwdsetting_aboutour_qa_detail),
            "");
    AppSettingItemInfo appSettingItemInfo15 =
        new AppSettingItemInfo(
            16,
            13,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_aboutour_version_title),
            getString(R.string.pwdsetting_aboutour_version_detail),
            getString(R.string.pwdsetting_aboutour_version_hasnew));
    AppSettingItemInfo appSettingItemInfo16 =
        new AppSettingItemInfo(
            17,
            13,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_aboutour_lookmyprivate_title),
            getString(R.string.pwdsetting_aboutour_lookmyprivate_detail),
            "");

    AppSettingItemInfo appSettingItemInfo19 =
        new AppSettingItemInfo(
            20,
            1,
            false,
            false,
            true,
            "",
            getString(R.string.pwdsetting_share_title),
            getString(R.string.pwdsetting_share_detail),
            "");

    dataAppSettingItemInfos.add(appSettingItemInfo);
    dataAppSettingItemInfos.add(appSettingItemInfo1);
    dataAppSettingItemInfos.add(appSettingItemInfo16);
    dataAppSettingItemInfos.add(appSettingItemInfo2);
    dataAppSettingItemInfos.add(appSettingItemInfo3);
    dataAppSettingItemInfos.add(appSettingItemInfo5);
    dataAppSettingItemInfos.add(appSettingItemInfo6);
    dataAppSettingItemInfos.add(appSettingItemInfo17);
    dataAppSettingItemInfos.add(appSettingItemInfo18);
    dataAppSettingItemInfos.add(appSettingItemInfo7);
    dataAppSettingItemInfos.add(appSettingItemInfo8);
    dataAppSettingItemInfos.add(appSettingItemInfo9);
    dataAppSettingItemInfos.add(appSettingItemInfo12);
    dataAppSettingItemInfos.add(appSettingItemInfo21);
    dataAppSettingItemInfos.add(appSettingItemInfo13);
    dataAppSettingItemInfos.add(appSettingItemInfo15);

    addAdapter(dataAppSettingItemInfos);

    leaveTimeStrings.add(getString(R.string.pwdsetting_advance_allowleavetime_detail_30second));
    leaveTimeStrings.add(getString(R.string.pwdsetting_advance_allowleavetime_detail_1minute));
    leaveTimeStrings.add(getString(R.string.pwdsetting_advance_allowleavetime_detail_2minute));
    leaveTimeStrings.add(getString(R.string.pwdsetting_advance_allowleavetime_detail_5minute));
  }

  private void addAdapter(Vector<AppSettingItemInfo> itemInfos) {
    Vector<AppSettingItemInfo> appSettingItemInfos = new Vector<AppSettingItemInfo>();
    appSettingItemInfos.removeAllElements();

    AppSettingItemInfo tmp = null;
    Set<Integer> set = new HashSet<Integer>();
    if (itemInfos != null && itemInfos.size() > 0) {
      for (int i = 0; i < itemInfos.size(); i++) {
        tmp = itemInfos.get(i);
        if (set.contains(tmp.parentID)) {
          appSettingItemInfos.add(tmp);
        } else {
          set.add(tmp.parentID);
          appSettingItemInfos.add(tmp);
        }
      }
      appSettingAdapter.removeAll();
      allItemInfos = appSettingItemInfos;
      for (AppSettingItemInfo appSettingItemInfo : appSettingItemInfos) {
        appSettingAdapter.addItem(appSettingItemInfo);
      }
    }
  }

  @Override
  public void onClickEvent(View view) {
    switch (view.getId()) {
      case R.id.btn_back:
        finish();
        break;

      default:
        break;
    }
    super.onClickEvent(view);
  }

  private void setUpUmengFeedback() {
    startActivity(new Intent(AppSettingActivity.this, FeedbackActivity.class));
  }

  private void showSetLeaveTimeDialog() {
    final AlertDialog updateDialogDlg = new AlertDialog.Builder(this).create();
    updateDialogDlg.show();
    Window win = updateDialogDlg.getWindow();
    win.setContentView(R.layout.dialog_setleavetime);
    WheelView wheelView = (WheelView) win.findViewById(R.id.wv_leavetime);
    TextView titleTextView = (TextView) win.findViewById(R.id.update_title);
    titleTextView.setText(R.string.setleavetimetitle);
    AbstractWheelTextAdapter adapter =
        new AbstractWheelTextAdapter(getApplicationContext()) {

          @Override
          public int getItemsCount() {
            // TODO Auto-generated method stub
            return leaveTimeStrings.size();
          }

          @Override
          protected CharSequence getItemText(int index) {
            // TODO Auto-generated method stub
            return leaveTimeStrings.get(index);
          }
        };
    OnWheelChangedListener wheelListener =
        new OnWheelChangedListener() {
          public void onChanged(WheelView wheel, int oldValue, int newValue) {
            String setTimeString = leaveTimeStrings.get(wheel.getCurrentItem());
            appLockApplication.setAllowedLeaveTime(setTimeString);
          }
        };
    adapter.setItemResource(R.layout.item_wheel_leavetime);
    adapter.setItemTextResource(R.id.tv_text);
    wheelView.setViewAdapter(adapter);
    wheelView.setCyclic(true);
    wheelView.addChangingListener(wheelListener);

    ImageView closeImageView = (ImageView) win.findViewById(R.id.updateclose);
    closeImageView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            updateDialogDlg.dismiss();
            Message msg = new Message();
            msg.what = SETLEAVEDIALOG_DISS;
            mHandler.sendMessage(msg);
          }
        });

    updateDialogDlg.setOnDismissListener(
        new OnDismissListener() {

          @Override
          public void onDismiss(DialogInterface dialog) {
            // TODO Auto-generated method stub
            Message msg = new Message();
            msg.what = SETLEAVEDIALOG_DISS;
            mHandler.sendMessage(msg);
          }
        });
  }

  private void showSetSecretDialog() {
    startActivity(new Intent(AppSettingActivity.this, SecretConfig.class));
  }

  public String getApplicationVersion() {
    PackageManager packageManager = getPackageManager();
    PackageInfo packageInfo;
    try {
      packageInfo = packageManager.getPackageInfo(getPackageName(), 0);
      return packageInfo.versionName;
    } catch (NameNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return "";
  }

  public void checkVersion() {
    if (appLockApplication.hasNewVersion()) {
      downLoadFileUrl = appLockApplication.getUpdateVersionUrl();
      showUpdateDialog(appLockApplication.getUpdateVersionIntro());
    }
  }

  public void showUpdateDialog(String intro) {
    final AlertDialog updateDialogDlg = new AlertDialog.Builder(this).create();
    updateDialogDlg.show();
    Window win = updateDialogDlg.getWindow();
    win.setContentView(R.layout.dialog_update);
    TextView tvMsg = (TextView) win.findViewById(R.id.tvMsg);
    tvMsg.setText(intro);
    Button btOk = (Button) win.findViewById(R.id.btOk);
    ImageView closeImageView = (ImageView) win.findViewById(R.id.updateclose);
    closeImageView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            updateDialogDlg.dismiss();
            Message msg = new Message();
            msg.what = SplashActivity.CHECKVERSION_CANCEL;
            mHandler.sendMessage(msg);
          }
        });

    btOk.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View arg0) {
            updateDialogDlg.dismiss();
            Message msg = new Message();
            msg.what = SplashActivity.CHECKVERSION_DOWN;
            mHandler.sendMessage(msg);
          }
        });

    updateDialogDlg.setOnDismissListener(
        new OnDismissListener() {

          @Override
          public void onDismiss(DialogInterface dialog) {
            // TODO Auto-generated method stub
            Message msg = new Message();
            msg.what = SplashActivity.CHECKVERSION_CANCEL;
            mHandler.sendMessage(msg);
          }
        });
  }

  public void setHideAppIcon() {
    PackageManager packageManager = getPackageManager();
    ComponentName componentName = new ComponentName(AppSettingActivity.this, SplashActivity.class);
    int res = packageManager.getComponentEnabledSetting(componentName);
    if (res == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
        || res == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
      // 隐藏应用图标
      packageManager.setComponentEnabledSetting(
          componentName,
          PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
          PackageManager.DONT_KILL_APP);
      appLockApplication.appIconIsHided = true;
      LogUtil.e("colin", "隐藏应用图标");
    } else {
      // 显示应用图标
      packageManager.setComponentEnabledSetting(
          componentName,
          PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
          PackageManager.DONT_KILL_APP);
      appLockApplication.appIconIsHided = false;
      LogUtil.e("colin", "显示应用图标");
    }
  }

  public boolean getHideAppIcon() {
    PackageManager packageManager = getPackageManager();
    ComponentName componentName = new ComponentName(AppSettingActivity.this, SplashActivity.class);
    int res = packageManager.getComponentEnabledSetting(componentName);
    if (res == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
        || res == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
      LogUtil.e("colin", "获取到应用图标显示在桌面上");
      return true;
    } else {
      LogUtil.e("colin", "获取到应用图标不显示在桌面上");
      return false;
    }
  }

  private void changePassword() {
    if (SharedPreferenceUtil.readIsNumModel()) {
      Intent intent = new Intent(context, NumberCheckActivity.class);
      intent.putExtra(NumberCheckActivity.CHANGE_PASSWORD, true);
      startActivity(intent);
    } else {
      Intent intent = new Intent(context, GestureCheckActivity.class);
      intent.putExtra(GestureCheckActivity.CHANGE_PASSWORD, true);
      startActivity(intent);
    }
  }

  private void hideLeaverTime() {
    for (AppSettingItemInfo appSettingItemInfo : dataAppSettingItemInfos) {
      if (appSettingItemInfo.getClassID() == 10) {
        dataAppSettingItemInfos.remove(appSettingItemInfo);
        appSettingAdapter.notifyDataSetChanged();
        break;
      }
    }
  }

  private void showLeaverTime() {
    AppSettingItemInfo appSettingItemInfo9 =
        new AppSettingItemInfo(
            10,
            7,
            false,
            false,
            false,
            "",
            getString(R.string.pwdsetting_advance_allowleavetime_title),
            getString(R.string.pwdsetting_advance_allowleavetime_detail_30second),
            "");
    dataAppSettingItemInfos.add(appSettingItemInfo9);
    appSettingAdapter.notifyDataSetChanged();
  }

  class WarringDialog extends Dialog implements View.OnClickListener {

    public SwitchButton switchButton;

    public WarringDialog() {
      super(context, R.style.MyDialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
      setContentView(R.layout.dialog_warring);
      findViewById(R.id.btn_cancel).setOnClickListener(this);
      findViewById(R.id.btn_ok).setOnClickListener(this);
      super.onCreate(savedInstanceState);
    }

    @Override
    public void onClick(View v) {
      switch (v.getId()) {
        case R.id.btn_cancel:
          switchButton.setChecked(true);
          appLockApplication.setAutoRecordPic(false);
          appSettingAdapter.notifyDataSetChanged();
          dismiss();
          break;
        case R.id.btn_ok:
          dismiss();
          break;

        default:
          break;
      }
    }
  }

  private void systemShare() {
    Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
    String imgPath = FileService.createShareImage(bm, context);
    String title = getString(R.string.pwdsetting_share_detail);
    String text = getString(R.string.pwdsetting_share_text);

    shareMsg(title, title, text, imgPath);
  }

  public void shareMsg(String activityTitle, String msgTitle, String msgText, String imgPath) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    if (imgPath == null || imgPath.equals("")) {
      intent.setType("text/plain"); // 纯文本
    } else {
      File f = new File(imgPath);
      if (f != null && f.exists() && f.isFile()) {
        intent.setType("image/jpg");
        Uri uri = Uri.fromFile(f);
        intent.putExtra(Intent.EXTRA_STREAM, uri);
      }
    }
    intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle);
    intent.putExtra(Intent.EXTRA_TEXT, msgText);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(Intent.createChooser(intent, activityTitle));
  }

  public void enableDeviceManager() {
    Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
    intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName);
    intent.putExtra(
        DevicePolicyManager.EXTRA_ADD_EXPLANATION,
        getString(R.string.pwdsetting_advance_uninstallapp_detail));
    context.startActivity(intent);
  }

  public void disableDeviceManager() {
    devicePolicyManager.removeActiveAdmin(componentName);
    mHandler.sendEmptyMessageDelayed(UPDATEADAPTER, 1500);
  }

  @Override
  protected void onResume() {
    // TODO Auto-generated method stub
    appSettingAdapter.notifyDataSetChanged();
    super.onResume();
  }
}