import android.content.DialogInterface.OnClickListener;\r
import android.content.Intent;\r
import android.content.IntentFilter;\r
+import android.content.SharedPreferences;\r
import android.content.pm.PackageInfo;\r
import android.content.pm.PackageManager.NameNotFoundException;\r
import android.database.Cursor;\r
import android.net.Uri;\r
import android.os.Bundle;\r
+import android.preference.PreferenceManager;\r
import android.provider.MediaStore;\r
import android.support.v4.app.FragmentTransaction;\r
import android.util.Log;\r
super.onCreate(savedInstanceState);\r
\r
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);\r
- setSupportProgressBarIndeterminateVisibility(false);\r
\r
Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(getApplicationContext()));\r
\r
\r
initDelayedTilAccountAvailabe();\r
\r
+ // PIN CODE request ; best location is to decide, let's try this first\r
+ //if (savedInstanceState == null) {\r
+ if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN) && savedInstanceState == null) {\r
+ requestPinCode();\r
+ }\r
+ \r
+ \r
} else {\r
\r
setContentView(R.layout.no_account_available);\r
getSupportActionBar().setNavigationMode(ActionBar.DISPLAY_SHOW_TITLE);\r
findViewById(R.id.setup_account).setOnClickListener(this);\r
- \r
+\r
+ setSupportProgressBarIndeterminateVisibility(false);\r
+\r
Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);\r
intent.putExtra(android.provider.Settings.EXTRA_AUTHORITIES, new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE });\r
startActivity(intent); // although the code is here, the activity won't be created until this.onStart() and this.onResume() are finished;\r
break;\r
}\r
case R.id.startSync: {\r
+ // This could be interesting\r
+ //ContentResolver.cancelSync(null, "org.owncloud"); // cancel the current synchronizations of any other ownCloud account\r
Bundle bundle = new Bundle();\r
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);\r
ContentResolver.requestSync(\r
FileSyncService.IN_PROGRESS, false);\r
String account_name = intent\r
.getStringExtra(FileSyncService.ACCOUNT_NAME);\r
+\r
Log.d("FileDisplay", "sync of account " + account_name\r
+ " is in_progress: " + inProgress);\r
- setSupportProgressBarIndeterminateVisibility(inProgress);\r
+\r
+ if (account_name.equals(AccountUtils.getCurrentOwnCloudAccount(context).name)) { \r
\r
- long OCDirId = intent.getLongExtra(FileSyncService.SYNC_FOLDER, -1);\r
- if (OCDirId >= 0) {\r
- OCFile syncDir = mStorageManager.getFileById(OCDirId);\r
- if (syncDir != null && (\r
- (mCurrentDir == null && syncDir.getFileName().equals("/")) ||\r
- syncDir.equals(mCurrentDir))\r
- ) {\r
- FileListFragment fileListFragment = (FileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);\r
- if (fileListFragment != null) { \r
- fileListFragment.listDirectory();\r
+ String synchFolderRemotePath = intent.getStringExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH); \r
+ \r
+ boolean fillBlankRoot = false;\r
+ if (mCurrentDir == null) {\r
+ mCurrentDir = mStorageManager.getFileByPath("/");\r
+ fillBlankRoot = (mCurrentDir != null);\r
+ }\r
+\r
+ if (synchFolderRemotePath != null && mCurrentDir != null && (mCurrentDir.getRemotePath().equals(synchFolderRemotePath) || fillBlankRoot) ) {\r
+ FileListFragment fileListFragment = (FileListFragment) getSupportFragmentManager()\r
+ .findFragmentById(R.id.fileList);\r
+ mCurrentDir = getStorageManager().getFileByPath(synchFolderRemotePath);\r
+ if (fileListFragment != null) {\r
+ fileListFragment.listDirectory(mCurrentDir); \r
}\r
}\r
- }\r
- \r
- if (!inProgress) {\r
- FileListFragment fileListFragment = (FileListFragment) getSupportFragmentManager()\r
- .findFragmentById(R.id.fileList);\r
- if (fileListFragment != null)\r
- fileListFragment.listDirectory();\r
+ \r
+ setSupportProgressBarIndeterminateVisibility(inProgress);\r
+ \r
}\r
}\r
-\r
}\r
\r
\r
\r
// If we are on a large device -> update fragment\r
if (mDualPane) {\r
- FileDetailFragment fileDetails = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);\r
- if (fileDetails == null) {\r
- // first selected file since the current directory was listed\r
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();\r
- transaction.replace(R.id.file_details_container, new FileDetailFragment(file, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG);\r
- transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);\r
- transaction.commit();\r
- } else {\r
- // another select file\r
- fileDetails.updateFileDetails(file, AccountUtils.getCurrentOwnCloudAccount(this));\r
- } \r
+ // 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'\r
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();\r
+ transaction.replace(R.id.file_details_container, new FileDetailFragment(file, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG);\r
+ transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);\r
+ transaction.commit();\r
\r
} else { // small or medium screen device -> new Activity\r
Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);\r
transaction.replace(R.id.file_details_container, new FileDetailFragment(null, null)); // empty FileDetailFragment\r
transaction.commit();\r
}\r
+ setSupportProgressBarIndeterminateVisibility(false);\r
+ }\r
+ \r
\r
+ /**\r
+ * Launch an intent to request the PIN code to the user before letting him use the app\r
+ */\r
+ private void requestPinCode() {\r
+ boolean pinStart = false;\r
+ SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());\r
+ pinStart = appPrefs.getBoolean("set_pincode", false);\r
+ if (pinStart) {\r
+ Intent i = new Intent(getApplicationContext(), PinCodeActivity.class);\r
+ i.putExtra(PinCodeActivity.EXTRA_ACTIVITY, "FileDisplayActivity");\r
+ startActivity(i);\r
+ }\r
}\r
\r
\r