1 /* ownCloud Android client application
2 * Copyright (C) 2011 Bartek Przybylski
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package eu
.alefzero
.owncloud
.ui
.activity
;
20 import android
.accounts
.Account
;
21 import android
.content
.Intent
;
22 import android
.content
.res
.Configuration
;
23 import android
.os
.Bundle
;
24 import android
.support
.v4
.app
.FragmentTransaction
;
25 import android
.util
.Log
;
27 import com
.actionbarsherlock
.app
.ActionBar
;
28 import com
.actionbarsherlock
.app
.SherlockFragmentActivity
;
29 import com
.actionbarsherlock
.view
.MenuItem
;
31 import eu
.alefzero
.owncloud
.R
;
32 import eu
.alefzero
.owncloud
.datamodel
.OCFile
;
33 import eu
.alefzero
.owncloud
.files
.services
.FileDownloader
;
34 import eu
.alefzero
.owncloud
.ui
.fragment
.FileDetailFragment
;
35 import eu
.alefzero
.owncloud
.ui
.fragment
.FileListFragment
;
38 * This activity displays the details of a file like its name, its size and so
41 * @author Bartek Przybylski
44 public class FileDetailActivity
extends SherlockFragmentActivity
implements FileDetailFragment
.ContainerActivity
{
46 private boolean mConfigurationChangedToLandscape
= false
;
49 protected void onCreate(Bundle savedInstanceState
) {
50 super.onCreate(savedInstanceState
);
52 // check if configuration changed to large-land ; for a tablet being changed from portrait to landscape when in FileDetailActivity
53 Configuration conf
= getResources().getConfiguration();
54 mConfigurationChangedToLandscape
= (conf
.orientation
== Configuration
.ORIENTATION_LANDSCAPE
&&
55 (conf
.screenLayout
& Configuration
.SCREENLAYOUT_SIZE_MASK
) >= Configuration
.SCREENLAYOUT_SIZE_LARGE
58 if (!mConfigurationChangedToLandscape
) {
59 setContentView(R
.layout
.file_activity_details
);
61 ActionBar actionBar
= getSupportActionBar();
62 actionBar
.setDisplayHomeAsUpEnabled(true
);
64 OCFile file
= getIntent().getParcelableExtra(FileDetailFragment
.EXTRA_FILE
);
65 Account account
= getIntent().getParcelableExtra(FileDownloader
.EXTRA_ACCOUNT
);
66 FileDetailFragment mFileDetail
= new FileDetailFragment(file
, account
);
68 FragmentTransaction ft
= getSupportFragmentManager().beginTransaction();
69 ft
.replace(R
.id
.fragment
, mFileDetail
, FileDetailFragment
.FTAG
);
73 backToDisplayActivity(); // the 'back' won't be effective until this.onStart() and this.onResume() are completed;
80 public boolean onOptionsItemSelected(MenuItem item
) {
81 boolean returnValue
= false
;
83 switch(item
.getItemId()){
84 case android
.R
.id
.home
:
85 backToDisplayActivity();
95 protected void onResume() {
98 if (!mConfigurationChangedToLandscape
) {
99 FileDetailFragment fragment
= (FileDetailFragment
) getSupportFragmentManager().findFragmentByTag(FileDetailFragment
.FTAG
);
100 fragment
.updateFileDetails();
105 private void backToDisplayActivity() {
106 Intent intent
= new Intent(this, FileDisplayActivity
.class);
107 intent
.addFlags(Intent
.FLAG_ACTIVITY_CLEAR_TOP
);
108 intent
.putExtra(FileDetailFragment
.EXTRA_FILE
, getIntent().getParcelableExtra(FileDetailFragment
.EXTRA_FILE
));
109 startActivity(intent
);
117 public void onFileStateChanged() {
118 // nothing to do here!