Refactored location of passcode check: a callback to rule them all
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / FileDisplayActivity.java
index 83a4902..a94e978 100644 (file)
@@ -65,6 +65,7 @@ import com.actionbarsherlock.view.Window;
 import com.owncloud.android.BuildConfig;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
+import com.owncloud.android.authentication.PinCheck;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.services.FileDownloader;
 import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
@@ -153,6 +154,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
 
 
     private OCFile mWaitingToSend;
+    
+    private Boolean mUnlocked = false;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -161,14 +164,15 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
 
         super.onCreate(savedInstanceState); // this calls onAccountChanged() when ownCloud Account is valid
 
-        // PIN CODE request ;  best location is to decide, let's try this first
-        if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN) && savedInstanceState == null) {
-            requestPinCode();
-        } else if (getIntent().getAction() == null && savedInstanceState == null) {
-            requestPinCode();
+        /* TODO remove
+        if (PinCheck.checkIfPinEntry()){
+            Intent i = new Intent(MainApp.getAppContext(), PinCodeActivity.class);
+            i.putExtra(PinCodeActivity.EXTRA_ACTIVITY, "FileDisplayActivity");
+            startActivity(i);
         }
+        */
 
-        /// grant that FileObserverService is watching favourite files
+        /// grant that FileObserverService is watching favorite files
         if (savedInstanceState == null) {
             Intent initObserversIntent = FileObserverService.makeInitIntent(this);
             startService(initObserversIntent);
@@ -532,10 +536,6 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
                         sortByDate(false);
                         break;
                         
-// TODO re-enable when server-side folder size calculation is available                       
-//                    case 2:
-//                        sortBySize(false);
-//                        break;
                     }
                     
                     dialog.dismiss();
@@ -843,7 +843,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
             mDownloadFinishReceiver = null;
         }
         
-        
+        PinCheck.setUnlockTimestamp();
+
         super.onPause();
         Log_OC.d(TAG, "onPause() end");
     }
@@ -1324,23 +1325,6 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
         }
     };    
 
-
-
-    /**
-     * Launch an intent to request the PIN code to the user before letting him use the app
-     */
-    private void requestPinCode() {
-        boolean pinStart = false;
-        SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
-        pinStart = appPrefs.getBoolean("set_pincode", false);
-        if (pinStart) {
-            Intent i = new Intent(getApplicationContext(), PinCodeActivity.class);
-            i.putExtra(PinCodeActivity.EXTRA_ACTIVITY, "FileDisplayActivity");
-            startActivity(i);
-        }
-    }
-
-
     @Override
     public void onSavedCertificate() {
         startSyncFolderOperation(getCurrentDir(), false);