import java.io.File;\r
import java.io.InputStreamReader;\r
import java.lang.Thread.UncaughtExceptionHandler;\r
-import java.net.URLEncoder;\r
import java.util.ArrayList;\r
\r
import android.accounts.Account;\r
import android.content.DialogInterface.OnClickListener;\r
import android.content.Intent;\r
import android.content.IntentFilter;\r
+import android.content.pm.PackageInfo;\r
+import android.content.pm.PackageManager;\r
+import android.content.pm.PackageManager.NameNotFoundException;\r
import android.database.Cursor;\r
import android.net.Uri;\r
import android.os.Bundle;\r
\r
private static final int DIALOG_SETUP_ACCOUNT = 0;\r
private static final int DIALOG_CREATE_DIR = 1;\r
+ private static final int DIALOG_ABOUT_APP = 2;\r
private static final int ACTION_SELECT_FILE = 1;\r
\r
@Override\r
public void onCreate(Bundle savedInstanceState) {\r
super.onCreate(savedInstanceState);\r
\r
- requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);\r
- setProgressBarIndeterminateVisibility(false);\r
+ // TODO: fix hack: workaround for bug in actionbar sherlock\r
+ // it always shows indeterminate progress bar\r
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {\r
+ requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);\r
+ setProgressBarIndeterminateVisibility(false);\r
+ }\r
\r
Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(getApplicationContext()));\r
\r
case R.id.action_settings: {\r
Intent settingsIntent = new Intent(this, Preferences.class);\r
startActivity(settingsIntent);\r
+ break;\r
+ }\r
+ case R.id.about_app : {\r
+ showDialog(DIALOG_ABOUT_APP);\r
+ break;\r
}\r
case android.R.id.home: {\r
if(mCurrentDir != null && mCurrentDir.getParentId() != 0){\r
AccountUtils.getCurrentOwnCloudAccount(this));\r
String remotepath = new String();\r
for (int j = mDirectories.getCount() - 2; j >= 0; --j) {\r
- remotepath += "/" + URLEncoder.encode(mDirectories.getItem(j));\r
+ remotepath += "/" + mDirectories.getItem(j);\r
}\r
if (!remotepath.endsWith("/"))\r
remotepath += "/";\r
- remotepath += URLEncoder.encode(new File(filepath).getName());\r
+ remotepath += new File(filepath).getName();\r
+ remotepath = Uri.encode(remotepath, "/");\r
\r
i.putExtra(FileUploader.KEY_LOCAL_FILE, filepath);\r
i.putExtra(FileUploader.KEY_REMOTE_FILE, remotepath);\r
if (mDirs != null)\r
for (String s : mDirs)\r
mDirectories.insert(s, 0);\r
- mCurrentDir = savedInstanceState.getParcelable(KEY_CURRENT_DIR);\r
+ mCurrentDir = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_FILE);\r
}\r
\r
@Override\r
}\r
}\r
outState.putStringArray(KEY_DIR_ARRAY, mDirs);\r
- outState.putParcelable(KEY_CURRENT_DIR, mCurrentDir);\r
+ outState.putParcelable(FileDetailFragment.EXTRA_FILE, mCurrentDir);\r
}\r
\r
@Override\r
protected void onResume() {\r
super.onResume();\r
- \r
+\r
if (accountsAreSetup()) {\r
- \r
+\r
setContentView(mLayoutView); // this should solve the crash by repeated inflating in big screens (DROIDCLOUD-27)\r
\r
// Listen for sync messages\r
\r
// File list\r
mFileList = (FileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);\r
- mFileList.updateAccount();\r
- \r
+ \r
// Figure out what directory to list. \r
// Priority: Intent (here), savedInstanceState (onCreate), root dir (dir is null)\r
if(getIntent().hasExtra(FileDetailFragment.EXTRA_FILE)){\r
mCurrentDir = (OCFile) getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE);\r
- if(!mCurrentDir.isDirectory()){\r
+ if(mCurrentDir != null && !mCurrentDir.isDirectory()){\r
mCurrentDir = mStorageManager.getFileById(mCurrentDir.getParentId());\r
}\r
\r
// Clear intent extra, so rotating the screen will not return us to this directory\r
getIntent().removeExtra(FileDetailFragment.EXTRA_FILE);\r
- } else {\r
- mCurrentDir = mStorageManager.getFileByPath("/");\r
}\r
+ \r
+ if (mCurrentDir == null)\r
+ mCurrentDir = mStorageManager.getFileByPath("/");\r
\r
// Drop-Down navigation and file list restore\r
mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);\r
unregisterReceiver(syncBroadcastRevceiver);\r
syncBroadcastRevceiver = null;\r
}\r
+ getIntent().putExtra(FileDetailFragment.EXTRA_FILE, mCurrentDir);\r
}\r
\r
@Override\r
protected Dialog onCreateDialog(int id) {\r
- Dialog dialog;\r
+ Dialog dialog = null;\r
AlertDialog.Builder builder;\r
switch (id) {\r
case DIALOG_SETUP_ACCOUNT:\r
builder.setNegativeButton(android.R.string.cancel, this);\r
dialog = builder.create();\r
break;\r
+ case DIALOG_ABOUT_APP: {\r
+ builder = new AlertDialog.Builder(this);\r
+ builder.setTitle("About");\r
+ PackageInfo pkg;\r
+ try {\r
+ pkg = getPackageManager().getPackageInfo(getPackageName(), 0);\r
+ builder.setMessage("ownCloud android client\n\nversion: " + pkg.versionName );\r
+ builder.setIcon(android.R.drawable.ic_menu_info_details);\r
+ dialog = builder.create();\r
+ } catch (NameNotFoundException e) {\r
+ builder = null;\r
+ dialog = null;\r
+ e.printStackTrace();\r
+ }\r
+ break;\r
+ }\r
case DIALOG_CREATE_DIR: {\r
builder = new Builder(this);\r
final EditText dirNameInput = new EditText(getBaseContext());\r
}\r
\r
// Figure out the path where the dir needs to be created\r
- String path = FileDisplayActivity.this.mCurrentDir.getRemotePath();\r
+ String path;\r
+ if (mCurrentDir == null) {\r
+ // this is just a patch; we should ensure that mCurrentDir never is null\r
+ if (!mStorageManager.fileExists("/")) {\r
+ OCFile file = new OCFile("/");\r
+ mStorageManager.saveFile(file);\r
+ }\r
+ mCurrentDir = mStorageManager.getFileByPath("/");\r
+ }\r
+ path = FileDisplayActivity.this.mCurrentDir.getRemotePath();\r
\r
// Create directory\r
- path += directoryName + "/";\r
+ path += Uri.encode(directoryName) + "/";\r
Thread thread = new Thread(new DirectoryCreator(path, a));\r
thread.start();\r
\r
intent.putExtra("authorities", new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE });\r
startActivity(intent);\r
}\r
+ }\r
+\r
+ public DataStorageManager getStorageManager() {\r
+ return mStorageManager;\r
} \r
}\r