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 com
.owncloud
.android
.ui
.activity
;
20 import android
.accounts
.Account
;
21 import android
.app
.Dialog
;
22 import android
.app
.ProgressDialog
;
23 import android
.content
.Intent
;
24 import android
.content
.res
.Configuration
;
25 import android
.os
.Bundle
;
26 import android
.support
.v4
.app
.FragmentTransaction
;
28 import com
.actionbarsherlock
.app
.ActionBar
;
29 import com
.actionbarsherlock
.app
.SherlockFragmentActivity
;
30 import com
.actionbarsherlock
.view
.MenuItem
;
31 import com
.owncloud
.android
.datamodel
.OCFile
;
32 import com
.owncloud
.android
.files
.services
.FileDownloader
;
33 import com
.owncloud
.android
.ui
.fragment
.FileDetailFragment
;
35 import com
.owncloud
.android
.R
;
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 public static final int DIALOG_SHORT_WAIT
= 0;
48 private boolean mConfigurationChangedToLandscape
= false
;
51 protected void onCreate(Bundle savedInstanceState
) {
52 super.onCreate(savedInstanceState
);
54 // check if configuration changed to large-land ; for a tablet being changed from portrait to landscape when in FileDetailActivity
55 Configuration conf
= getResources().getConfiguration();
56 mConfigurationChangedToLandscape
= (conf
.orientation
== Configuration
.ORIENTATION_LANDSCAPE
&&
57 (conf
.screenLayout
& Configuration
.SCREENLAYOUT_SIZE_MASK
) >= Configuration
.SCREENLAYOUT_SIZE_LARGE
60 if (!mConfigurationChangedToLandscape
) {
61 setContentView(R
.layout
.file_activity_details
);
63 ActionBar actionBar
= getSupportActionBar();
64 actionBar
.setDisplayHomeAsUpEnabled(true
);
66 OCFile file
= getIntent().getParcelableExtra(FileDetailFragment
.EXTRA_FILE
);
67 Account account
= getIntent().getParcelableExtra(FileDownloader
.EXTRA_ACCOUNT
);
68 FileDetailFragment mFileDetail
= new FileDetailFragment(file
, account
);
70 FragmentTransaction ft
= getSupportFragmentManager().beginTransaction();
71 ft
.replace(R
.id
.fragment
, mFileDetail
, FileDetailFragment
.FTAG
);
75 backToDisplayActivity(); // the 'back' won't be effective until this.onStart() and this.onResume() are completed;
82 public boolean onOptionsItemSelected(MenuItem item
) {
83 boolean returnValue
= false
;
85 switch(item
.getItemId()){
86 case android
.R
.id
.home
:
87 backToDisplayActivity();
97 protected void onResume() {
100 if (!mConfigurationChangedToLandscape
) {
101 FileDetailFragment fragment
= (FileDetailFragment
) getSupportFragmentManager().findFragmentByTag(FileDetailFragment
.FTAG
);
102 fragment
.updateFileDetails();
107 private void backToDisplayActivity() {
108 Intent intent
= new Intent(this, FileDisplayActivity
.class);
109 intent
.addFlags(Intent
.FLAG_ACTIVITY_CLEAR_TOP
);
110 intent
.putExtra(FileDetailFragment
.EXTRA_FILE
, getIntent().getParcelableExtra(FileDetailFragment
.EXTRA_FILE
));
111 startActivity(intent
);
117 protected Dialog
onCreateDialog(int id
) {
118 Dialog dialog
= null
;
120 case DIALOG_SHORT_WAIT
: {
121 ProgressDialog working_dialog
= new ProgressDialog(this);
122 working_dialog
.setMessage(getResources().getString(
123 R
.string
.wait_a_moment
));
124 working_dialog
.setIndeterminate(true
);
125 working_dialog
.setCancelable(false
);
126 dialog
= working_dialog
;
140 public void onFileStateChanged() {
141 // nothing to do here!