Skip to content
This repository has been archived by the owner on Sep 8, 2019. It is now read-only.

Commit

Permalink
- added support for Api 19 KitKat
Browse files Browse the repository at this point in the history
  • Loading branch information
kollerlukas committed Feb 28, 2017
1 parent 4b79796 commit 8bc0430
Show file tree
Hide file tree
Showing 46 changed files with 830 additions and 390 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "us.koller.cameraroll"
minSdkVersion 21
minSdkVersion 19
targetSdkVersion 25
versionCode 11
versionName "v1.1.1 Beta"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package us.koller.cameraroll.adapter.album;

import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
Expand All @@ -26,6 +24,7 @@
import us.koller.cameraroll.data.Photo;
import us.koller.cameraroll.data.Video;
import us.koller.cameraroll.ui.ItemActivity;
import us.koller.cameraroll.util.Util;

public class RecyclerViewAdapter extends RecyclerView.Adapter {

Expand Down Expand Up @@ -104,20 +103,28 @@ public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position)

((AlbumItemHolder) holder).setAlbumItem(albumItem);

holder.itemView.findViewById(R.id.image)
.setSelected(selected_items[album.getAlbumItems().indexOf(albumItem)]);
//fade selected indicator
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
boolean selected = selected_items[album.getAlbumItems()
.indexOf(((AlbumItemHolder) holder).albumItem)];
boolean selected = selected_items[album.getAlbumItems()
.indexOf(((AlbumItemHolder) holder).albumItem)];

Drawable foreground = holder.itemView.findViewById(R.id.image).getForeground();
final View imageView = holder.itemView.findViewById(R.id.image);

ObjectAnimator
.ofPropertyValuesHolder(foreground,
PropertyValuesHolder.ofInt("alpha",
selected ? 0 : 255,
selected ? 255 : 0)).start();
final Drawable selectorOverlay = Util.getAlbumItemSelectorOverlay(imageView.getContext());
if (selected) {
imageView.post(new Runnable() {
@Override
public void run() {
imageView.getOverlay().clear();
selectorOverlay.setBounds(0, 0, imageView.getWidth(), imageView.getHeight());
imageView.getOverlay().add(selectorOverlay);
}
});
} else {
imageView.post(new Runnable() {
@Override
public void run() {
imageView.getOverlay().clear();
}
});
}

holder.itemView.setTag(albumItem.getPath());
Expand Down Expand Up @@ -202,20 +209,6 @@ private void onItemSelected(AlbumItemHolder holder) {
selected_items[album.getAlbumItems().indexOf(holder.albumItem)]
= !selected_items[album.getAlbumItems().indexOf(holder.albumItem)];
notifyItemChanged(album.getAlbumItems().indexOf(holder.albumItem));
/*holder.itemView.findViewById(R.id.image)
.setSelected(selected_items[album.getAlbumItems().indexOf(holder.albumItem)]);*/

/*//fade selected indicator
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
boolean selected = selected_items[album.getAlbumItems().indexOf(holder.albumItem)];
Drawable foreground = holder.itemView.findViewById(R.id.image).getForeground();
ObjectAnimator
.ofPropertyValuesHolder(foreground,
PropertyValuesHolder.ofInt("alpha",
selected ? 0 : 255,
selected ? 255 : 0)).start();
}*/

callback.onItemSelected(getSelectedItemCount());
checkForNoSelectedItems();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
Expand Down Expand Up @@ -59,8 +60,11 @@ public void setSelected(boolean selected) {
selected ? R.color.grey_900_translucent : R.color.white_translucent1));

ImageView folderIndicator = (ImageView) itemView.findViewById(R.id.folder_indicator);
Drawable d = folderIndicator.getDrawable().mutate();
d.setTint(ContextCompat.getColor(itemView.getContext(),
Drawable d = folderIndicator.getDrawable();
/*d.setTint(ContextCompat.getColor(itemView.getContext(),
selected ? R.color.grey_900_translucent : R.color.white));*/
d = DrawableCompat.wrap(d);
DrawableCompat.setTint(d.mutate(), ContextCompat.getColor(itemView.getContext(),
selected ? R.color.grey_900_translucent : R.color.white));
folderIndicator.setImageDrawable(d);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,32 @@ public Copy(File_POJO[] files) {
}

@Override
public void execute(Activity context, File_POJO target, Callback callback) {
void executeAsync(final Activity context, File_POJO target, final Callback callback) {
if (target == null) {
return;
}

File_POJO[] files = getFiles();
final File_POJO[] files = getFiles();

int success_count = 0;
for (int i = 0; i < files.length; i++) {
boolean result = copyFilesRecursively(context, files[i].getPath(), target.getPath(), true);
success_count += result ? 1 : 0;
}

Toast.makeText(context, context.getString(R.string.successfully_copied)
+ String.valueOf(success_count) + "/"
+ String.valueOf(files.length), Toast.LENGTH_SHORT).show();

if (callback != null) {
callback.done();
}
final int finalSuccess_count = success_count;
context.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, context.getString(R.string.successfully_copied)
+ String.valueOf(finalSuccess_count) + "/"
+ String.valueOf(files.length), Toast.LENGTH_SHORT).show();

if (callback != null) {
callback.done();
}
}
});

operation = EMPTY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.widget.Toast;
Expand All @@ -22,8 +23,8 @@ public Delete(File_POJO[] files) {
}

@Override
public void execute(Activity context, File_POJO target, Callback callback) {
File_POJO[] files = getFiles();
void executeAsync(final Activity context, File_POJO target, final Callback callback) {
final File_POJO[] files = getFiles();

int success_count = 0;
for (int i = 0; i < files.length; i++) {
Expand All @@ -37,20 +38,27 @@ public void execute(Activity context, File_POJO target, Callback callback) {
}
}

Toast.makeText(context, context.getString(R.string.successfully_deleted)
+ String.valueOf(success_count) + "/"
+ String.valueOf(files.length), Toast.LENGTH_SHORT).show();
final int finalSuccess_count = success_count;
context.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, context.getString(R.string.successfully_deleted)
+ String.valueOf(finalSuccess_count) + "/"
+ String.valueOf(files.length), Toast.LENGTH_SHORT).show();

if (callback != null) {
callback.done();
}
if (callback != null) {
callback.done();
}
}
});

operation = EMPTY;
}

private static boolean deleteFile(final Activity context, String path) {
boolean success;
if (Environment.isExternalStorageRemovable(new File(path))) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
&& Environment.isExternalStorageRemovable(new File(path))) {
//not working
try {
success = StorageUtil.delete(context, new File(path));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.content.Context;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.AsyncTask;
import android.provider.MediaStore;

import java.io.File;
Expand Down Expand Up @@ -39,7 +40,16 @@ public File_POJO[] getFiles() {
return files;
}

public abstract void execute(final Activity context, final File_POJO target, final Callback callback);
public void execute(final Activity context, final File_POJO target, final Callback callback) {
AsyncTask.execute(new Runnable() {
@Override
public void run() {
executeAsync(context, target, callback);
}
});
}

abstract void executeAsync(final Activity context, final File_POJO target, final Callback callback);

public static String getModeString(Context context) {
switch (operation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,32 @@ public Move(File_POJO[] files) {
}

@Override
public void execute(Activity context, File_POJO target, Callback callback) {
void executeAsync(final Activity context, File_POJO target, final Callback callback) {
if (target == null) {
return;
}

File_POJO[] files = getFiles();
final File_POJO[] files = getFiles();

int success_count = 0;
for (int i = 0; i < files.length; i++) {
boolean result = moveFile(context, files[i].getPath(), target.getPath());
success_count += result ? 1 : 0;
}

Toast.makeText(context, context.getString(R.string.successfully_moved)
+ String.valueOf(success_count) + "/"
+ String.valueOf(files.length), Toast.LENGTH_SHORT).show();

if (callback != null) {
callback.done();
}
final int finalSuccess_count = success_count;
context.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, context.getString(R.string.successfully_moved)
+ String.valueOf(finalSuccess_count) + "/"
+ String.valueOf(files.length), Toast.LENGTH_SHORT).show();

if (callback != null) {
callback.done();
}
}
});

operation = EMPTY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public NewDirectory(File_POJO[] files) {
}

@Override
public void execute(Activity context, File_POJO target, Callback callback) {
File_POJO[] files = getFiles();
void executeAsync(final Activity context, File_POJO target, final Callback callback) {
final File_POJO[] files = getFiles();
if (files.length > 0) {
File_POJO file = files[0];
boolean result = createNewFolder(file.getPath());
Expand All @@ -26,13 +26,23 @@ public void execute(Activity context, File_POJO target, Callback callback) {
}
}

Toast.makeText(context, context.getString(R.string.successfully_created_new_folder),
Toast.LENGTH_SHORT).show();
context.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, context.getString(R.string.successfully_created_new_folder),
Toast.LENGTH_SHORT).show();
}
});
}

if (callback != null) {
callback.done();
}
context.runOnUiThread(new Runnable() {
@Override
public void run() {
if (callback != null) {
callback.done();
}
}
});

operation = EMPTY;
}
Expand Down
Loading

0 comments on commit 8bc0430

Please sign in to comment.