fix double pin entry on start
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / PinCheck.java
1 package com.owncloud.android.authentication;
2
3 import android.app.Activity;
4 import android.content.SharedPreferences;
5 import android.preference.PreferenceManager;
6
7 import com.owncloud.android.MainApp;
8
9 public class PinCheck extends Activity {
10
11 private static Long timestamp = 0l;
12 private static Long lastStart = 0l;
13
14 public static void setUnlockTimestamp() {
15 timestamp = System.currentTimeMillis();
16 }
17
18 public static boolean checkIfPinEntry(){
19 if ((System.currentTimeMillis() - timestamp) > 10000 &&
20 (System.currentTimeMillis() - lastStart) > 10000){
21 SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(MainApp.getAppContext());
22 if (appPrefs.getBoolean("set_pincode", false)) {
23 lastStart = System.currentTimeMillis();
24 return true;
25 }
26 }
27 return false;
28 }
29 }