Intermediate commit: Work on new FileDetailFragment layout, simplified

it's code a bit and renamed a color. Layout is WIP
This commit is contained in:
Lennart Rosam 2012-05-18 08:09:31 +02:00
parent 548fc80ea1
commit 3727806652
8 changed files with 158 additions and 112 deletions

View file

@ -17,7 +17,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:drawable="@color/filelist_backgorund" android:state_window_focused="false"/>
<item android:drawable="@color/owncloud_white" android:state_window_focused="false"/>
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:drawable="@android:color/holo_blue_bright" android:state_enabled="false" android:state_focused="true" android:state_pressed="true"/>

View file

@ -17,7 +17,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:drawable="@color/filelist_backgorund" android:state_window_focused="false"/>
<item android:drawable="@color/owncloud_white" android:state_window_focused="false"/>
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:drawable="@android:color/holo_blue_bright" android:state_enabled="false" android:state_focused="true" android:state_pressed="true"/>

View file

@ -15,97 +15,146 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#F7F7F7"
android:background="@color/owncloud_white"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout1"
<ScrollView
android:id="@+id/fdScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/fdIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="16dp"
android:src="@drawable/file" />
<TextView
android:id="@+id/fdFilename"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/fdIcon"
android:layout_centerHorizontal="true"
android:text="file.name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/linearLayout2"
<TextView
android:id="@+id/fdType"
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
android:layout_height="wrap_content"
android:layout_above="@+id/fdCreatedLabel"
android:layout_alignLeft="@+id/fdFilename"
android:text="JPG Image"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/fdSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/fdSizeLabel"
android:layout_alignLeft="@+id/fdFilename"
android:text="389 KB"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/fdCreated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/fdModifiedLabel"
android:layout_alignLeft="@+id/fdFilename"
android:text="2012/05/18 12:23 PM"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/fdModified"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/fdModifiedLabel"
android:layout_alignBottom="@+id/fdModifiedLabel"
android:layout_alignLeft="@+id/fdCreated"
android:text="2012/05/19 02:56 PM"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="@+id/imageView1"
android:id="@+id/fdPreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon" >
</ImageView>
</LinearLayout>
android:layout_below="@+id/fdModified"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:src="@drawable/owncloud_logo" />
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" >
</TextView>
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<TextView
android:id="@+id/textView2"
android:id="@+id/fdTypeLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" >
</TextView>
android:layout_alignLeft="@+id/fdIcon"
android:layout_below="@+id/fdIcon"
android:layout_marginTop="24dp"
android:text="@string/filedetails_type"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView3"
android:id="@+id/fdSizeLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" >
</TextView>
android:layout_alignLeft="@+id/fdIcon"
android:layout_below="@+id/fdTypeLabel"
android:layout_marginTop="12dp"
android:text="@string/filedetails_size"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView4"
android:id="@+id/fdCreatedLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" >
</TextView>
android:layout_alignLeft="@+id/fdIcon"
android:layout_below="@+id/fdSizeLabel"
android:layout_marginTop="12dp"
android:text="@string/filedetails_created"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView5"
android:id="@+id/fdModifiedLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" >
</TextView>
android:layout_alignLeft="@+id/fdIcon"
android:layout_below="@+id/fdCreatedLabel"
android:layout_marginTop="12dp"
android:text="@string/filedetails_modified"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/imageView2"
<Button
android:id="@+id/fdDownloadBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/action_item_btn" />
<VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="@drawable/uploader_list_separator"
android:dividerHeight="1dip" >
</ListView>
</LinearLayout>
android:layout_below="@+id/fdScrollView"
android:layout_centerHorizontal="true"
android:text="@string/filedetails_download" />
</LinearLayout>

View file

@ -19,6 +19,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/owncloud_white"
android:orientation="vertical" >
<fragment

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="filelist_icon_backgorund">#DDDDDD</color>
<color name="filelist_backgorund">#F7F7F7</color>
<color name="owncloud_white">#F7F7F7</color>
</resources>

View file

@ -49,6 +49,11 @@
<string name="uploader_info_uploading">Uploading</string>
<string name="uploader_btn_create_dir_text">Create dir for upload</string>
<string name="filedetails_select_file">Tap on a file to display additional information.</string>
<string name="filedetails_size">Size:</string>
<string name="filedetails_type">Type:</string>
<string name="filedetails_created">Created:</string>
<string name="filedetails_modified">Modified:</string>
<string name="filedetails_download">Download</string>
<string name="common_yes">Yes</string>
<string name="common_no">No</string>
<string name="common_ok">OK</string>

View file

@ -35,7 +35,7 @@ public class DisplayUtils {
attachedsuff++;
}
result = ((int) (result * 100)) / 100.;
return result + suffixes[attachedsuff];
return result + " " + suffixes[attachedsuff];
}
public static String HtmlDecode(String s) {

View file

@ -29,10 +29,10 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;
import com.actionbarsherlock.app.SherlockFragment;
@ -123,27 +123,19 @@ public class FileDetailFragment extends SherlockFragment implements
.getMimetype()));
setFilesize(mFile.getFileLength());
// set file preview if available and possible
VideoView videoView = (VideoView) getView()
.findViewById(R.id.videoView1);
videoView.setVisibility(View.INVISIBLE);
if (mFile.getStoragePath() == null) {
ImageView imageView = (ImageView) getView().findViewById(
R.id.imageView2);
imageView.setImageResource(R.drawable.download);
imageView.setOnClickListener(this);
} else {
// Update preview
if (mFile.getStoragePath() != null) {
if (mFile.getMimetype().startsWith("image/")) {
ImageView imageView = (ImageView) getView()
.findViewById(R.id.imageView2);
ImageView preview = (ImageView) getView().findViewById(
R.id.fdPreview);
Bitmap bmp = BitmapFactory.decodeFile(mFile.getStoragePath());
imageView.setImageBitmap(bmp);
} else if (mFile.getMimetype().startsWith("video/")) {
videoView.setVisibility(View.VISIBLE);
videoView.setVideoPath(mFile.getStoragePath());
videoView.start();
preview.setImageBitmap(bmp);
}
}
// Make download button effective
Button downloadButton = (Button) getView().findViewById(R.id.fdDownloadBtn);
downloadButton.setOnClickListener(this);
}
}
@ -172,19 +164,19 @@ public class FileDetailFragment extends SherlockFragment implements
}
private void setFilename(String filename) {
TextView tv = (TextView) getView().findViewById(R.id.textView1);
TextView tv = (TextView) getView().findViewById(R.id.fdFilename);
if (tv != null)
tv.setText(filename);
}
private void setFiletype(String mimetype) {
TextView tv = (TextView) getView().findViewById(R.id.textView2);
TextView tv = (TextView) getView().findViewById(R.id.fdType);
if (tv != null)
tv.setText(mimetype);
}
private void setFilesize(long filesize) {
TextView tv = (TextView) getView().findViewById(R.id.textView3);
TextView tv = (TextView) getView().findViewById(R.id.fdSize);
if (tv != null)
tv.setText(DisplayUtils.bitsToHumanReadable(filesize));
}
@ -211,8 +203,7 @@ public class FileDetailFragment extends SherlockFragment implements
Intent i = new Intent(getActivity(), FileDownloader.class);
i.putExtra(FileDownloader.EXTRA_ACCOUNT,
mIntent.getParcelableExtra(FileDownloader.EXTRA_ACCOUNT));
i.putExtra(FileDownloader.EXTRA_FILE_PATH,
mIntent.getStringExtra(FileDownloader.EXTRA_FILE_PATH));
i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getPath());
getActivity().startService(i);
}