diff --git a/app/src/main/gen/com/horaapps/leafpic/BuildConfig.java b/app/src/main/gen/com/horaapps/leafpic/BuildConfig.java deleted file mode 100644 index 5356a1e61..000000000 --- a/app/src/main/gen/com/horaapps/leafpic/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package com.horaapps.leafpic; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/app/src/main/gen/com/horaapps/leafpic/Manifest.java b/app/src/main/gen/com/horaapps/leafpic/Manifest.java deleted file mode 100644 index 6e0b3c62c..000000000 --- a/app/src/main/gen/com/horaapps/leafpic/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package com.horaapps.leafpic; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/app/src/main/gen/com/horaapps/leafpic/R.java b/app/src/main/gen/com/horaapps/leafpic/R.java deleted file mode 100644 index c7951a330..000000000 --- a/app/src/main/gen/com/horaapps/leafpic/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package com.horaapps.leafpic; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/app/src/main/java/org/horaapps/leafpic/data/provider/CPHelper.java b/app/src/main/java/org/horaapps/leafpic/data/provider/CPHelper.java index 8e58d05b6..630aaefcc 100644 --- a/app/src/main/java/org/horaapps/leafpic/data/provider/CPHelper.java +++ b/app/src/main/java/org/horaapps/leafpic/data/provider/CPHelper.java @@ -2,6 +2,7 @@ import android.content.Context; import android.provider.MediaStore; +import android.util.Log; import org.horaapps.leafpic.data.Album; import org.horaapps.leafpic.data.ContentHelper; @@ -13,6 +14,7 @@ import org.horaapps.leafpic.util.PreferenceUtil; import java.io.File; +import java.util.ArrayList; import java.util.HashSet; import io.reactivex.Observable; @@ -31,9 +33,29 @@ public static Observable getAlbums(Context context, boolean hidden, Sorti return !hidden ? getAlbums(context, excluded, sortingMode, sortingOrder) : getHiddenAlbums(context, excluded); } + private static String getHavingCluause(HashSet excluded){ + if (excluded.size() == 0) return ""; - private static Observable getAlbums(Context context, HashSet excludedAlbums, SortingMode sortingMode, SortingOrder sortingOrder) { + //String[] paths = excluded.toArray(new String[excluded.size()]); + StringBuilder res = new StringBuilder(); + res.append("HAVING ("); + //res.append(MediaStore.Images.Media.DATA).append(" NOT LIKE '").append(pa.).append("%'"); + res.append(MediaStore.Images.Media.DATA).append(" NOT LIKE ?"); + + for (int i = 1; i < excluded.size(); i++) + res.append(" AND ") + .append(MediaStore.Images.Media.DATA) + .append(" NOT LIKE ?"); + + + res.append(")"); + + return res.toString(); + + } + + public static Observable getAlbums(Context context, HashSet excludedAlbums, SortingMode sortingMode, SortingOrder sortingOrder) { Query.Builder query = new Query.Builder() .uri(MediaStore.Files.getContentUri("external")) @@ -41,20 +63,31 @@ private static Observable getAlbums(Context context, HashSet excl .sort(sortingMode.getAlbumsColumn()) .ascending(sortingOrder.isAscending()); + ArrayList args = new ArrayList<>(); + if (PreferenceUtil.getBool(context, "set_include_video", true)) { - query.selection(String.format("%s=? or %s=?) group by ( %s ", + query.selection(String.format("%s=? or %s=?) group by (%s) %s ", MediaStore.Files.FileColumns.MEDIA_TYPE, MediaStore.Files.FileColumns.MEDIA_TYPE, - MediaStore.Files.FileColumns.PARENT)); - - query.args(MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE, - MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO); + MediaStore.Files.FileColumns.PARENT, + getHavingCluause(excludedAlbums))); + args.add(MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE); + args.add(MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO); } else { - query.selection(String.format("%s=?) group by ( %s ", + query.selection(String.format("%s=?) group by (%s) %s ", MediaStore.Files.FileColumns.MEDIA_TYPE, - MediaStore.Files.FileColumns.PARENT)); - query.args(MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE); + MediaStore.Files.FileColumns.PARENT, + getHavingCluause(excludedAlbums))); + args.add(MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE); + //query.args(, excludedAlbums); + } + + Log.wtf("asd", query.selection); + for (String s : excludedAlbums) { + args.add(s+"%"); } + //args.addAll(excludedAlbums); + query.args(args.toArray()); return QueryUtils.query(query.build(), context.getContentResolver(), Album::new); diff --git a/app/src/main/java/org/horaapps/leafpic/fragments/AlbumsFragment.java b/app/src/main/java/org/horaapps/leafpic/fragments/AlbumsFragment.java index 66a1a397a..d283263fd 100644 --- a/app/src/main/java/org/horaapps/leafpic/fragments/AlbumsFragment.java +++ b/app/src/main/java/org/horaapps/leafpic/fragments/AlbumsFragment.java @@ -8,6 +8,7 @@ import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; +import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -32,6 +33,7 @@ import org.horaapps.leafpic.util.ThemeHelper; import org.horaapps.leafpic.views.GridSpacingItemDecoration; +import java.util.HashSet; import java.util.Locale; import butterknife.BindView; @@ -56,10 +58,14 @@ public class AlbumsFragment extends BaseFragment{ private MainActivity act; private boolean hidden = false; + HashSet excuded = new HashSet<>(); + @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + excuded.add("/storage/emulated/0/Pictures"); + excuded.add("/storage/emulated/0/Download/apk"); setHasOptionsMenu(true); } @@ -81,21 +87,37 @@ public void displayAlbums(boolean hidden) { displayAlbums(); } + + private boolean isOk(String path){ + for (String s : excuded) { + if (path.startsWith(s)) return false; + } + return true; + } + private void displayAlbums() { - adapter.clear(); + + adapter.clear(); + long start = System.currentTimeMillis(); SQLiteDatabase db = HandlingAlbums.getInstance(getContext()).getReadableDatabase(); - CPHelper.getAlbums(getContext(), hidden, sortingMode(), sortingOrder()) + CPHelper.getAlbums(getContext(), excuded, sortingMode(), sortingOrder()) .subscribeOn(Schedulers.io()) + //.filter(album -> isOk(album.getPath())) .map(album -> album.withSettings(HandlingAlbums.getSettings(db, album.getPath()))) .observeOn(AndroidSchedulers.mainThread()) .subscribe( - album -> adapter.add(album), + album -> { + adapter.add(album); + Log.wtf("asd", album.getPath()); + }, throwable -> refresh.setRefreshing(false), () -> { db.close(); act.nothingToShow(getCount() == 0); refresh.setRefreshing(false); + long end = System.currentTimeMillis() - start; + Log.wtf("time", end+""); }); } diff --git a/scripts/crowdin.key b/scripts/crowdin.key deleted file mode 100644 index d18b473f9..000000000 --- a/scripts/crowdin.key +++ /dev/null @@ -1 +0,0 @@ -e1bded23fc73ddf03d90cb2201656c96 \ No newline at end of file