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
;
37 * This activity displays the details of a file like its name, its size and so
40 * @author Bartek Przybylski
43 public class FileDetailActivity
extends SherlockFragmentActivity
{
45 private boolean mConfigurationChangedToLandscape
= false
;
48 protected void onCreate(Bundle savedInstanceState
) {
49 super.onCreate(savedInstanceState
);
51 // check if configuration changed to large-land ; for a tablet being changed from portrait to landscape when in FileDetailActivity
52 Configuration conf
= getResources().getConfiguration();
53 mConfigurationChangedToLandscape
= (conf
.orientation
== Configuration
.ORIENTATION_LANDSCAPE
&&
54 (conf
.screenLayout
& Configuration
.SCREENLAYOUT_SIZE_MASK
) >= Configuration
.SCREENLAYOUT_SIZE_LARGE
57 if (!mConfigurationChangedToLandscape
) {
58 setContentView(R
.layout
.file_activity_details
);
60 ActionBar actionBar
= getSupportActionBar();
61 actionBar
.setDisplayHomeAsUpEnabled(true
);
63 OCFile file
= getIntent().getParcelableExtra(FileDetailFragment
.EXTRA_FILE
);
64 Account account
= getIntent().getParcelableExtra(FileDownloader
.EXTRA_ACCOUNT
);
65 FileDetailFragment mFileDetail
= new FileDetailFragment(file
, account
);
67 FragmentTransaction ft
= getSupportFragmentManager().beginTransaction();
68 ft
.replace(R
.id
.fragment
, mFileDetail
, FileDetailFragment
.FTAG
);
72 backToDisplayActivity(); // the 'back' won't be effective until this.onStart() and this.onResume() are completed;
79 public boolean onOptionsItemSelected(MenuItem item
) {
80 boolean returnValue
= false
;
82 switch(item
.getItemId()){
83 case android
.R
.id
.home
:
84 backToDisplayActivity();
94 protected void onResume() {
97 if (!mConfigurationChangedToLandscape
) {
98 FileDetailFragment fragment
= (FileDetailFragment
) getSupportFragmentManager().findFragmentByTag(FileDetailFragment
.FTAG
);
99 fragment
.updateFileDetails();
104 private void backToDisplayActivity() {
105 Intent intent
= new Intent(this, FileDisplayActivity
.class);
106 intent
.addFlags(Intent
.FLAG_ACTIVITY_CLEAR_TOP
);
107 intent
.putExtra(FileDetailFragment
.EXTRA_FILE
, getIntent().getParcelableExtra(FileDetailFragment
.EXTRA_FILE
));
108 startActivity(intent
);