X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/8d3b028e7215def932d499b9f54c57c8927acf4e..147227040b0b37f28d9819b6514ecf882be26547:/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java diff --git a/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java b/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java index 5245abf7..c94c27fa 100644 --- a/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java +++ b/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java @@ -33,11 +33,13 @@ import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.IntentFilter; +import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.preference.PreferenceManager; import android.provider.MediaStore; import android.support.v4.app.FragmentTransaction; import android.util.Log; @@ -129,6 +131,13 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements initDelayedTilAccountAvailabe(); + // PIN CODE request ; best location is to decide, let's try this first + //if (savedInstanceState == null) { + if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN) && savedInstanceState == null) { + requestPinCode(); + } + + } else { setContentView(R.layout.no_account_available); @@ -160,6 +169,8 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements break; } case R.id.startSync: { + // This could be interesting + //ContentResolver.cancelSync(null, "org.owncloud"); // cancel the current synchronizations of any other ownCloud account Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync( @@ -614,29 +625,28 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements Log.d("FileDisplay", "sync of account " + account_name + " is in_progress: " + inProgress); - //if (account_name.equals(AccountUtils.getCurrentOwnCloudAccount(context).name)) { // TODO - probably this check should be added, but won't push it until really tests are done; no time now + if (account_name.equals(AccountUtils.getCurrentOwnCloudAccount(context).name)) { - /// try to refresh the view with every message received from the FileSyncAdapter; brute, but more user friendly when there are a lot of files in the server - OCFile currentDir; - if (mCurrentDir == null) - currentDir = mStorageManager.getFileByPath("/"); - else - currentDir = mStorageManager.getFileByPath(mCurrentDir.getRemotePath()); - - if (currentDir != null) { - mCurrentDir = currentDir; + String synchFolderRemotePath = intent.getStringExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH); + + boolean fillBlankRoot = false; + if (mCurrentDir == null) { + mCurrentDir = mStorageManager.getFileByPath("/"); + fillBlankRoot = (mCurrentDir != null); + } + + if (synchFolderRemotePath != null && mCurrentDir != null && (mCurrentDir.getRemotePath().equals(synchFolderRemotePath) || fillBlankRoot) ) { FileListFragment fileListFragment = (FileListFragment) getSupportFragmentManager() .findFragmentById(R.id.fileList); + mCurrentDir = getStorageManager().getFileByPath(synchFolderRemotePath); if (fileListFragment != null) { - if (!mCurrentDir.equals(fileListFragment.getCurrentFile())) { - fileListFragment.listDirectory(mCurrentDir); // only set the directory in the fragment first time - } else - fileListFragment.listDirectory(); // enough to show new files in the current directory if they are added after + fileListFragment.listDirectory(mCurrentDir); } } setSupportProgressBarIndeterminateVisibility(inProgress); - //} + + } } } @@ -719,7 +729,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements // If we are on a large device -> update fragment if (mDualPane) { - // buttons in the details view a are problematic when trying to reuse an existing fragment; create always a new one solves some of them, BUT no all; downloads are 'dangerous' + // buttons in the details view are problematic when trying to reuse an existing fragment; create always a new one solves some of them, BUT no all; downloads are 'dangerous' FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.file_details_container, new FileDetailFragment(file, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); @@ -754,6 +764,21 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements } } + + + /** + * 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); + } + } }