From fddaea76c391f7e3f418f777ebda396e42ee6913 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 24 Jul 2016 16:34:45 +0200 Subject: [PATCH] calculate the size of directories + adding some initial sorting things --- .../gallery/activities/MainActivity.java | 3 +- .../gallery/models/Directory.java | 48 +++++++++++------- .../gallery/models/Medium.java | 22 ++++---- app/src/main/res/mipmap-hdpi/sort.png | Bin 0 -> 205 bytes app/src/main/res/mipmap-mdpi/sort.png | Bin 0 -> 155 bytes app/src/main/res/mipmap-xhdpi/sort.png | Bin 0 -> 175 bytes app/src/main/res/mipmap-xxhdpi/sort.png | Bin 0 -> 213 bytes app/src/main/res/mipmap-xxxhdpi/sort.png | Bin 0 -> 196 bytes app/src/main/res/values-it/strings.xml | 6 +++ app/src/main/res/values-ja/strings.xml | 6 +++ app/src/main/res/values-sv/strings.xml | 6 +++ app/src/main/res/values/strings.xml | 6 +++ 12 files changed, 66 insertions(+), 31 deletions(-) create mode 100644 app/src/main/res/mipmap-hdpi/sort.png create mode 100644 app/src/main/res/mipmap-mdpi/sort.png create mode 100644 app/src/main/res/mipmap-xhdpi/sort.png create mode 100644 app/src/main/res/mipmap-xxhdpi/sort.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/sort.png diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java index db1a5a90e..17d64ed10 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java @@ -210,9 +210,10 @@ public class MainActivity extends SimpleActivity final Directory directory = directories.get(fileDir); final int newImageCnt = directory.getMediaCnt() + 1; directory.setMediaCnt(newImageCnt); + directory.addSize(file.length()); } else if (!mToBeDeleted.contains(fileDir)) { final String dirName = Utils.getFilename(fileDir); - directories.put(fileDir, new Directory(fileDir, path, dirName, 1, timestamp)); + directories.put(fileDir, new Directory(fileDir, path, dirName, 1, timestamp, file.length())); } } while (cursor.moveToNext()); cursor.close(); diff --git a/app/src/main/java/com/simplemobiletools/gallery/models/Directory.java b/app/src/main/java/com/simplemobiletools/gallery/models/Directory.java index 9f8c155f1..14aafe3de 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/models/Directory.java +++ b/app/src/main/java/com/simplemobiletools/gallery/models/Directory.java @@ -1,50 +1,60 @@ package com.simplemobiletools.gallery.models; public class Directory implements Comparable { - private final String path; - private final String thumbnail; - private final String name; - private final long timestamp; - private int mediaCnt; + private final String mPath; + private final String mThumbnail; + private final String mName; + private final long mTimestamp; + private int mMediaCnt; + private long mBytes; - public Directory(String path, String thumbnail, String name, int mediaCnt, long timestamp) { - this.path = path; - this.thumbnail = thumbnail; - this.name = name; - this.mediaCnt = mediaCnt; - this.timestamp = timestamp; + public Directory(String path, String thumbnail, String name, int mediaCnt, long timestamp, long size) { + mPath = path; + mThumbnail = thumbnail; + mName = name; + mMediaCnt = mediaCnt; + mTimestamp = timestamp; + mBytes = size; } public String getPath() { - return path; + return mPath; } public String getThumbnail() { - return thumbnail; + return mThumbnail; } public String getName() { - return name; + return mName; } public int getMediaCnt() { - return mediaCnt; + return mMediaCnt; } public void setMediaCnt(int cnt) { - mediaCnt = cnt; + mMediaCnt = cnt; } public long getTimestamp() { - return timestamp; + return mTimestamp; + } + + public long getSize() { + return mBytes; + } + + public void addSize(long bytes) { + mBytes += bytes; } @Override public int compareTo(Object object) { final Directory directory = (Directory) object; - if (this.timestamp < directory.getTimestamp()) { + if (mTimestamp < directory.getTimestamp()) { return 1; - } else if (this.timestamp > directory.getTimestamp()) { + } else if (mTimestamp > directory.getTimestamp()) { return -1; } return 0; diff --git a/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java b/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java index d875ce946..c443536ff 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java +++ b/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java @@ -4,26 +4,26 @@ import java.io.Serializable; public class Medium implements Serializable, Comparable { private static final long serialVersionUID = -6543139465975455L; - private final String path; - private final boolean isVideo; - private final long timestamp; + private final String mPath; + private final boolean mIsVideo; + private final long mTimestamp; public Medium(String path, boolean isVideo, long timestamp) { - this.path = path; - this.isVideo = isVideo; - this.timestamp = timestamp; + mPath = path; + mIsVideo = isVideo; + mTimestamp = timestamp; } public String getPath() { - return path; + return mPath; } public boolean getIsVideo() { - return isVideo; + return mIsVideo; } public long getTimestamp() { - return timestamp; + return mTimestamp; } public boolean isGif() { @@ -33,9 +33,9 @@ public class Medium implements Serializable, Comparable { @Override public int compareTo(Object object) { final Medium medium = (Medium) object; - if (this.timestamp < medium.getTimestamp()) { + if (mTimestamp < medium.getTimestamp()) { return 1; - } else if (this.timestamp > medium.getTimestamp()) { + } else if (mTimestamp > medium.getTimestamp()) { return -1; } return 0; diff --git a/app/src/main/res/mipmap-hdpi/sort.png b/app/src/main/res/mipmap-hdpi/sort.png new file mode 100644 index 0000000000000000000000000000000000000000..c62475e1f4b66088d1b0e78d97809a0e27b1517f GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k1|%Oc%$NbBSc;uILpXq-h9ji|$mcBZh%9Dc z;5!1sj8nDwq=AC@o-U3d5v^~pIr23q@UR?M`!W8Pag9{nnXivL4=fP*x?yrbuHur} zOiD^cy(tPi_m&*m`9EUE^wPTWiyuOhC&o?6RI+58A)DoH96furjO7!>lQX3DOaG2B xaAW9pe*5jc(8qwCbv9BjrK0RzT%IhGojc{Z;F|rp8bGTVJYD@<);T3K0RRM%M`8c~ literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-mdpi/sort.png b/app/src/main/res/mipmap-mdpi/sort.png new file mode 100644 index 0000000000000000000000000000000000000000..552bb7c33d97908313da0010deafb5572bbe082d GIT binary patch literal 155 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+95PZ!4!kIv)-3D(68K?gd{{QUp_fBh`SNfbjtMXV8pPn~>gTe~DWM4fQobv8 literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xhdpi/sort.png b/app/src/main/res/mipmap-xhdpi/sort.png new file mode 100644 index 0000000000000000000000000000000000000000..1f9dccfd8fc7849429a72feae55f3d1e3881dc19 GIT binary patch literal 175 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCmSQK*5Dp-y;YjHK@;M7UB8wRq z_>O=u<5X=vX`o=Br;B4qM&sM78#xac@VGi^|9-zlM?je8(6JZmLKnyHHDqA;)pb+R zxcIqpz0#x4*VDf%U*%zV@iw9}JvFwpmL14myXHtJl+Ey9j`;G=JYvWFBTfSiXYh3O Kb6Mw<&;$Uif;U?L literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xxhdpi/sort.png b/app/src/main/res/mipmap-xxhdpi/sort.png new file mode 100644 index 0000000000000000000000000000000000000000..42cf9765fc8af92b08abd33e581d1b0f22846e22 GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@ZgvM!EX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m=s-PZ!6KiaBp@IC3>8h`0v!e%t?egX*6Cj)b|!|4erDRjp+Ns$vNF zdg`LYmdKI;Vst0JUX8{r~^~ literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xxxhdpi/sort.png b/app/src/main/res/mipmap-xxxhdpi/sort.png new file mode 100644 index 0000000000000000000000000000000000000000..f2454f1148b3a09f5b6c8dde4d0825dbbf7f457e GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%xcgn3BBRT^Rni_n+Ah4nJ za0`PlBg3pY5H=O_6O_|yt*RiP5GOFLZO~6jv*Dd-d^9x%b>u);8^&7ZXuJE zZ^*kSX*)9mHlPXyS=X-x872B6TbyGI1K1u`Impostazione sfondo Apri fotocamera Riscontrato un errore sconosciuto + Sort by + Name + Size + Date + Ascending + Descending 1 cartella eliminata diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 9f0df7ada..f21a4df01 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -20,6 +20,12 @@ 壁紙の設定 カメラを開く 不明なエラーが発生しました + Sort by + Name + Size + Date + Ascending + Descending 1 フォルダーを削除しました diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index b72801714..9a23192db 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -20,6 +20,12 @@ Inställningar för bakgrundsbild Starta kameran Ett okänt fel har uppstått + Sort by + Name + Size + Date + Ascending + Descending 1 mapp borttagen diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ba4cd6245..839595de3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -20,6 +20,12 @@ Setting wallpaper Open camera An unknown error occurred + Sort by + Name + Size + Date + Ascending + Descending 1 folder deleted