+++ /dev/null
-/* ownCloud Android client application\r
- * Copyright (C) 2011 Bartek Przybylski\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- *\r
- */\r
-package eu.alefzero.owncloud.ui.activity;\r
-\r
-import android.accounts.Account;\r
-import android.app.Dialog;\r
-import android.app.ProgressDialog;\r
-import android.content.Intent;\r
-import android.content.res.Configuration;\r
-import android.os.Bundle;\r
-import android.support.v4.app.FragmentTransaction;\r
-\r
-import com.actionbarsherlock.app.ActionBar;\r
-import com.actionbarsherlock.app.SherlockFragmentActivity;\r
-import com.actionbarsherlock.view.MenuItem;\r
-\r
-import eu.alefzero.owncloud.R;\r
-import eu.alefzero.owncloud.datamodel.OCFile;\r
-import eu.alefzero.owncloud.files.services.FileDownloader;\r
-import eu.alefzero.owncloud.ui.fragment.FileDetailFragment;\r
-\r
-/**\r
- * This activity displays the details of a file like its name, its size and so\r
- * on.\r
- * \r
- * @author Bartek Przybylski\r
- * \r
- */\r
-public class FileDetailActivity extends SherlockFragmentActivity implements FileDetailFragment.ContainerActivity {\r
- \r
- public static final int DIALOG_SHORT_WAIT = 0;\r
- \r
- private boolean mConfigurationChangedToLandscape = false;\r
-\r
- @Override\r
- protected void onCreate(Bundle savedInstanceState) {\r
- super.onCreate(savedInstanceState);\r
-\r
- // check if configuration changed to large-land ; for a tablet being changed from portrait to landscape when in FileDetailActivity \r
- Configuration conf = getResources().getConfiguration();\r
- mConfigurationChangedToLandscape = (conf.orientation == Configuration.ORIENTATION_LANDSCAPE && \r
- (conf.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE\r
- );\r
-\r
- if (!mConfigurationChangedToLandscape) {\r
- setContentView(R.layout.file_activity_details);\r
- \r
- ActionBar actionBar = getSupportActionBar();\r
- actionBar.setDisplayHomeAsUpEnabled(true);\r
- \r
- OCFile file = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE);\r
- Account account = getIntent().getParcelableExtra(FileDownloader.EXTRA_ACCOUNT);\r
- FileDetailFragment mFileDetail = new FileDetailFragment(file, account);\r
- \r
- FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\r
- ft.replace(R.id.fragment, mFileDetail, FileDetailFragment.FTAG);\r
- ft.commit();\r
- \r
- } else {\r
- backToDisplayActivity(); // the 'back' won't be effective until this.onStart() and this.onResume() are completed;\r
- }\r
- \r
- \r
- }\r
-\r
- @Override\r
- public boolean onOptionsItemSelected(MenuItem item) {\r
- boolean returnValue = false;\r
- \r
- switch(item.getItemId()){\r
- case android.R.id.home:\r
- backToDisplayActivity();\r
- returnValue = true;\r
- }\r
- \r
- return returnValue;\r
- }\r
-\r
-\r
-\r
- @Override\r
- protected void onResume() {\r
- \r
- super.onResume();\r
- if (!mConfigurationChangedToLandscape) { \r
- FileDetailFragment fragment = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);\r
- fragment.updateFileDetails();\r
- }\r
- }\r
- \r
-\r
- private void backToDisplayActivity() {\r
- Intent intent = new Intent(this, FileDisplayActivity.class);\r
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);\r
- intent.putExtra(FileDetailFragment.EXTRA_FILE, getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE));\r
- startActivity(intent);\r
- finish();\r
- }\r
- \r
- \r
- @Override\r
- protected Dialog onCreateDialog(int id) {\r
- Dialog dialog = null;\r
- switch (id) {\r
- case DIALOG_SHORT_WAIT: {\r
- ProgressDialog working_dialog = new ProgressDialog(this);\r
- working_dialog.setMessage(getResources().getString(\r
- R.string.wait_a_moment));\r
- working_dialog.setIndeterminate(true);\r
- working_dialog.setCancelable(false);\r
- dialog = working_dialog;\r
- break;\r
- }\r
- default:\r
- dialog = null;\r
- }\r
- return dialog;\r
- }\r
- \r
- \r
- /**\r
- * {@inheritDoc}\r
- */\r
- @Override\r
- public void onFileStateChanged() {\r
- // nothing to do here!\r
- }\r
-\r
-}\r