Ver Fonte

new path style in main window

Bartek Przybylski há 13 anos atrás
pai
commit
769fe95791
2 ficheiros alterados com 18 adições e 26 exclusões
  1. 5 12
      res/layout/main.xml
  2. 13 14
      src/eu/alefzero/owncloud/OwnCloudMainScreen.java

+ 5 - 12
res/layout/main.xml

@@ -3,20 +3,13 @@
 	android:layout_width="fill_parent" android:background="#F7F7F7"
 	android:orientation="vertical" android:layout_height="fill_parent">
 	<LinearLayout android:layout_width="fill_parent"
-		android:id="@+id/linearLayout7" android:orientation="vertical"
-		android:background="#1D2D44" android:gravity="top"
-		android:layout_gravity="center_vertical" android:layout_height="wrap_content" android:paddingTop="2pt" android:paddingBottom="2pt">
+		android:id="@+id/linearLayout7" android:background="@drawable/main_header_bg" android:gravity="top"
+		android:layout_gravity="center_vertical" android:layout_height="wrap_content" android:orientation="horizontal">
 		<ImageView android:layout_height="wrap_content"
-			android:src="@drawable/owncloud_logo_small_white"
-			android:layout_width="wrap_content" android:layout_gravity="center_vertical|center_horizontal"
+			android:src="@drawable/icon"
+			android:layout_width="wrap_content" android:layout_gravity="center_vertical|left"
 			android:id="@+id/main_header_small"></ImageView>
-	</LinearLayout>
-	<LinearLayout android:layout_height="wrap_content"
-		android:id="@+id/linearLayout1" android:layout_width="fill_parent"
-		android:layout_gravity="center_horizontal" android:gravity="center_horizontal">
-		<TextView android:layout_width="wrap_content"
-			android:layout_height="wrap_content" android:id="@+id/directory_name"
-			android:layout_gravity="center" android:gravity="center"></TextView>
+		<eu.alefzero.owncloud.PathLayout android:id="@+id/pathLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical"></eu.alefzero.owncloud.PathLayout>
 	</LinearLayout>
 	<FrameLayout android:layout_height="fill_parent"
     android:layout_width="fill_parent" android:id="@+id/frameLayout1">

+ 13 - 14
src/eu/alefzero/owncloud/OwnCloudMainScreen.java

@@ -34,7 +34,9 @@ import android.graphics.BitmapFactory;
 import android.graphics.Matrix;
 import android.net.Uri;
 import android.os.Bundle;
+import android.text.Html;
 import android.text.TextUtils;
+import android.util.Log;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
@@ -146,9 +148,11 @@ public class OwnCloudMainScreen extends ListActivity {
 
   @Override
   public void onBackPressed() {
+    PathLayout pl = (PathLayout) findViewById(R.id.pathLayout1);
     if (mIsDisplayingFile) {
       mIsDisplayingFile = false;
       setContentView(R.layout.main);
+      pl = (PathLayout) findViewById(R.id.pathLayout1);
       Uri uri;
       if (mParents.empty()) {
         uri = ProviderTableMeta.CONTENT_URI;
@@ -161,8 +165,11 @@ public class OwnCloudMainScreen extends ListActivity {
                              new String[]{mAccount.name}, null);
   
       if (mCursor.moveToFirst()) {
-        TextView tv = (TextView) findViewById(R.id.directory_name);
-        tv.setText(mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_PATH)));
+        String s = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_PATH));
+        for (String str : s.split("/")) {
+          if (!TextUtils.isEmpty(str))
+            pl.push(str.replace("%20", " "));
+        }
       }
       getListView().setAdapter(new FileListListAdapter(mCursor, this));      
       getListView().invalidate();
@@ -173,6 +180,7 @@ public class OwnCloudMainScreen extends ListActivity {
       return;
     } else if (mParents.size() == 1) {
       mParents.pop();
+      pl.pop();
       mCursor = managedQuery(ProviderTableMeta.CONTENT_URI,
           null,
           ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
@@ -180,6 +188,7 @@ public class OwnCloudMainScreen extends ListActivity {
           null);
     } else {
       mParents.pop();
+      pl.pop();
       mCursor = managedQuery(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, mParents.peek()),
           null,
           ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",
@@ -189,19 +198,12 @@ public class OwnCloudMainScreen extends ListActivity {
     
     setListAdapter(new FileListListAdapter(mCursor, this));
     getListView().invalidate();
-
-    TextView tv = (TextView) findViewById(R.id.directory_name);
-    String s = tv.getText().toString();
-    if (s.endsWith("/")) {
-      s = s.substring(0, s.length() - 1);
-    }
-    s = s.substring(0, s.lastIndexOf('/') + 1);
-    tv.setText(s);
   }
 
   @Override
   protected void onListItemClick(ListView l, View v, int position, long id) {
     super.onListItemClick(l, v, position, id);
+    PathLayout pl = (PathLayout) findViewById(R.id.pathLayout1);
     if (!mCursor.moveToPosition(position)) {
       throw new IndexOutOfBoundsException("Incorrect item selected");
     }
@@ -209,8 +211,7 @@ public class OwnCloudMainScreen extends ListActivity {
       if (mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)).equals("DIR")) {
         String id_ = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta._ID));
         String dirname = mCursor.getString(mCursor.getColumnIndex(ProviderTableMeta.FILE_NAME));
-        TextView tv = (TextView) findViewById(R.id.directory_name);
-        tv.setText(tv.getText().toString()+dirname+"/");
+        pl.push(dirname);
         mParents.push(id_);
         mCursor = managedQuery(Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, id_),
                                null,
@@ -265,8 +266,6 @@ public class OwnCloudMainScreen extends ListActivity {
   }
   
   private void populateFileList() {
-    TextView tv = (TextView) findViewById(R.id.directory_name);
-    tv.setText("/");
     mCursor = getContentResolver().query(ProviderTableMeta.CONTENT_URI,
                                          null,
                                          ProviderTableMeta.FILE_ACCOUNT_OWNER+"=?",