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
.fragment
;
20 import eu
.alefzero
.owncloud
.DisplayUtils
;
21 import eu
.alefzero
.owncloud
.R
;
22 import eu
.alefzero
.owncloud
.cp
;
23 import eu
.alefzero
.owncloud
.R
.id
;
24 import eu
.alefzero
.owncloud
.R
.layout
;
25 import eu
.alefzero
.owncloud
.db
.ProviderMeta
.ProviderTableMeta
;
26 import android
.content
.Intent
;
27 import android
.database
.Cursor
;
28 import android
.net
.Uri
;
29 import android
.os
.Bundle
;
30 import android
.support
.v4
.app
.Fragment
;
31 import android
.util
.Log
;
32 import android
.view
.LayoutInflater
;
33 import android
.view
.View
;
34 import android
.view
.ViewGroup
;
35 import android
.widget
.TextView
;
36 import android
.widget
.Toast
;
39 * This Fragment is used to display the details about a file.
40 * @author Bartek Przybylski
43 public class FileDetail
extends Fragment
{
45 public Intent mIntent
;
47 public void setStuff(Intent intent
) {
52 private void setStuff(View view
) {
53 String id
= mIntent
.getStringExtra("FILE_ID");
54 String account_name
= mIntent
.getStringExtra("ACCOUNT_NAME");
55 Cursor c
= getActivity().managedQuery(
56 Uri
.withAppendedPath(ProviderTableMeta
.CONTENT_URI_FILE
, id
),
58 ProviderTableMeta
.FILE_ACCOUNT_OWNER
+"=?",
59 new String
[]{account_name
},
63 String filename
= c
.getString(c
.getColumnIndex(ProviderTableMeta
.FILE_NAME
));
64 setFilename(filename
, view
);
65 String mimetype
= c
.getString(c
.getColumnIndex(ProviderTableMeta
.FILE_CONTENT_TYPE
));
66 setFiletype(DisplayUtils
.convertMIMEtoPrettyPrint(mimetype
), view
);
70 public View
onCreateView(LayoutInflater inflater
, ViewGroup container
,
71 Bundle savedInstanceState
) {
72 View v
= inflater
.inflate(R
.layout
.file_details
, container
, false
);
74 if (getActivity().getIntent() != null
) {
75 mIntent
= getActivity().getIntent();
81 private void setFilename(String filename
, View target_view
) {
82 TextView tv
= (TextView
) target_view
.findViewById(R
.id
.textView1
);
83 if (tv
!= null
) tv
.setText(filename
);
86 private void setFiletype(String mimetype
, View target_view
) {
87 TextView tv
= (TextView
) target_view
.findViewById(R
.id
.textView2
);
88 if (tv
!= null
) tv
.setText(mimetype
);
91 public void setFilename(String filename
) {
92 setFilename(filename
, getView());
95 public void setFiletype(String filename
) {
96 setFiletype(filename
, getView());