making icons bit smaller, making upload progressbar less cpu eating
authorBartek Przybylski <bart.p.pl@gmail.com>
Tue, 22 May 2012 20:44:57 +0000 (22:44 +0200)
committerBartek Przybylski <bart.p.pl@gmail.com>
Tue, 22 May 2012 20:44:57 +0000 (22:44 +0200)
res/layout/list_layout.xml
src/eu/alefzero/owncloud/files/services/FileUploader.java
src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java
src/eu/alefzero/owncloud/ui/adapter/FileListListAdapter.java

index 5f2a43f..2a0d48b 100644 (file)
@@ -24,7 +24,7 @@
     android:layout_height="56dp">
 
     <FrameLayout
     android:layout_height="56dp">
 
     <FrameLayout
-        android:layout_width="56dp"
+        android:layout_width="wrap_content"
         android:layout_height="56dp"
         android:focusable="false"
         android:focusableInTouchMode="false">
         android:layout_height="56dp"
         android:focusable="false"
         android:focusableInTouchMode="false">
@@ -37,9 +37,9 @@
 
         <ImageView
             android:id="@+id/imageView1"
 
         <ImageView
             android:id="@+id/imageView1"
-            android:layout_width="wrap_content"
-            android:layout_height="48dp"
-            android:layout_gravity="center_vertical"
+            android:layout_width="16dp"
+            android:layout_height="16dp"
+            android:layout_gravity="center_vertical|center"
             android:layout_margin="4dp"
             android:src="@drawable/ic_menu_archive" />
         
             android:layout_margin="4dp"
             android:src="@drawable/ic_menu_archive" />
         
             android:layout_height="wrap_content"
             android:layout_gravity="center_vertical"
             android:layout_marginLeft="4dp"
             android:layout_height="wrap_content"
             android:layout_gravity="center_vertical"
             android:layout_marginLeft="4dp"
+            android:layout_marginRight="4dp"
+            android:ellipsize="middle"
+            android:singleLine="true"
             android:text="TextView"
             android:textColor="#303030"
             android:text="TextView"
             android:textColor="#303030"
-            android:textSize="20dip" />
+            android:textSize="16dip" />
 
 
-        <TextView
-            android:id="@+id/Extension"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center_vertical"
-            android:text="TextView"
-            android:textColor="#D0D0D0"
-            android:textSize="20dip" />
     </LinearLayout>
 
 </LinearLayout>
     </LinearLayout>
 
 </LinearLayout>
index a814fa8..30d91e1 100644 (file)
@@ -47,7 +47,7 @@ public class FileUploader extends Service implements OnUploadProgressListener {
     private int mUploadType;
     private Notification mNotification;
     private int mTotalDataToSend, mSendData;
     private int mUploadType;
     private Notification mNotification;
     private int mTotalDataToSend, mSendData;
-    private int mCurrentIndexUpload;
+    private int mCurrentIndexUpload, mPreviousPercent;
 
     @Override
     public IBinder onBind(Intent arg0) {
 
     @Override
     public IBinder onBind(Intent arg0) {
@@ -134,7 +134,7 @@ public class FileUploader extends Service implements OnUploadProgressListener {
                 mAccount.name.lastIndexOf('@'));
         String password = mAccountManager.getPassword(mAccount);
         
                 mAccount.name.lastIndexOf('@'));
         String password = mAccountManager.getPassword(mAccount);
         
-        mTotalDataToSend = mSendData = 0;
+        mTotalDataToSend = mSendData = mPreviousPercent = 0;
         
         mNotification = new Notification(
                 eu.alefzero.owncloud.R.drawable.icon, "Uploading...",
         
         mNotification = new Notification(
                 eu.alefzero.owncloud.R.drawable.icon, "Uploading...",
@@ -179,9 +179,12 @@ public class FileUploader extends Service implements OnUploadProgressListener {
     public void OnUploadProgress(long currentProgress) {
         mSendData += currentProgress;
         int percent = (int)(100*mSendData/mTotalDataToSend);
     public void OnUploadProgress(long currentProgress) {
         mSendData += currentProgress;
         int percent = (int)(100*mSendData/mTotalDataToSend);
-        String text = String.format("%d%% Uploading %s file", percent, new File(mLocalPaths[mCurrentIndexUpload]).getName());
-        mNotification.contentView.setProgressBar(R.id.status_progress, 100, percent, false);
-        mNotification.contentView.setTextViewText(R.id.status_text, text);
-        mNotificationManager.notify(42, mNotification);
+        if (percent != mPreviousPercent) {
+            String text = String.format("%d%% Uploading %s file", percent, new File(mLocalPaths[mCurrentIndexUpload]).getName());
+            mNotification.contentView.setProgressBar(R.id.status_progress, 100, percent, false);
+            mNotification.contentView.setTextViewText(R.id.status_text, text);
+            mNotificationManager.notify(42, mNotification);
+        }
+        mPreviousPercent = percent;
     }
 }
     }
 }
index 65f03a3..bdc146c 100644 (file)
@@ -177,7 +177,6 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
         setProgressBarIndeterminateVisibility(false);\r
         // if (getSupportFragmentManager().findFragmentById(R.id.fileList) ==\r
         // null)\r
         setProgressBarIndeterminateVisibility(false);\r
         // if (getSupportFragmentManager().findFragmentById(R.id.fileList) ==\r
         // null)\r
-        Log.e("ASDaaa", "ASDaaa");\r
         setContentView(R.layout.files);\r
 \r
     }\r
         setContentView(R.layout.files);\r
 \r
     }\r
index b170647..a2f7996 100644 (file)
@@ -99,18 +99,9 @@ public class FileListListAdapter implements ListAdapter {
         if (mFiles.size() > position) {\r
             OCFile file = mFiles.get(position);\r
             TextView fileName = (TextView) view.findViewById(R.id.Filename);\r
         if (mFiles.size() > position) {\r
             OCFile file = mFiles.get(position);\r
             TextView fileName = (TextView) view.findViewById(R.id.Filename);\r
-            TextView ext_text = (TextView) view.findViewById(R.id.Extension);\r
             String name = file.getFileName();\r
             String name = file.getFileName();\r
-            String ext = file.getFileName();\r
-            if (name.lastIndexOf('.') != -1) {\r
-                name = name.substring(0, name.lastIndexOf('.'));\r
-                ext = ext.substring(ext.lastIndexOf('.'));\r
-            } else {\r
-                ext = "";\r
-            }\r
 \r
             fileName.setText(DisplayUtils.HtmlDecode(name));\r
 \r
             fileName.setText(DisplayUtils.HtmlDecode(name));\r
-            ext_text.setText(ext);\r
             ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1);\r
             if (!file.getMimetype().equals("DIR")) {\r
                 fileIcon.setImageResource(R.drawable.file);\r
             ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1);\r
             if (!file.getMimetype().equals("DIR")) {\r
                 fileIcon.setImageResource(R.drawable.file);\r