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

Commit

Permalink
- Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kollerlukas committed Sep 22, 2017
1 parent 749408a commit 440b964
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 9 deletions.
6 changes: 5 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
}

# will keep line numbers and file name obfuscation
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public boolean onMenuItemClick(MenuItem item) {

intent = new Intent();
intent.setAction(Intent.ACTION_SEND_MULTIPLE)
.setType(MediaType.getMimeType(paths[0]))
.setType(MediaType.getMimeType(getContext(), uris.get(0)))
.putExtra(Intent.EXTRA_STREAM, uris);

intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ public void run() {
}

public static void scanPathsWithToast(final Context context, final String[] paths) {
if (paths == null) {
return;
}
@SuppressLint("ShowToast") final WeakReference<Toast> toastWeakReference = new WeakReference<>(
Toast.makeText(context, R.string.scanning, Toast.LENGTH_SHORT));
MediaScannerConnection.scanFile(context.getApplicationContext(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ public static ArrayList<Album> getAlbumsWithVirtualDirectories(Activity context)

public static void loadAlbum(final Activity context, final String path,
final OnAlbumLoadedCallback callback) {
if (path == null) {
return;
}

if (albums == null) {
Settings s = Settings.getInstance(context);
boolean hiddenFolders = s.getHiddenFolders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ public boolean accept(File file) {
//external Directory
File dir = Environment.getExternalStorageDirectory();
File[] dirs = dir.listFiles(filter);
if (dirs == null) {
dirs = new File[]{};
}

//handle removable storage (e.g. SDCards)
ArrayList<File> temp = new ArrayList<>();
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/us/koller/cameraroll/ui/AlbumActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
uris.add(StorageUtil.getContentUri(this, selected_items_paths[i]));
}

intent = new Intent();
intent.setAction(Intent.ACTION_SEND_MULTIPLE)
.setType(MediaType.getMimeType(selected_items_paths[0]))
intent = new Intent()
.setAction(Intent.ACTION_SEND_MULTIPLE)
.setType(MediaType.getMimeType(this, uris.get(0)))
.putExtra(Intent.EXTRA_STREAM, uris);

intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
Expand Down Expand Up @@ -735,7 +735,7 @@ public void onReceive(Context context, Intent intent) {
private ClipData createClipData(AlbumItem[] items) {
String[] mimeTypes = new String[items.length];
for (int i = 0; i < items.length; i++) {
mimeTypes[i] = MediaType.getMimeType(items[i].getPath());
mimeTypes[i] = MediaType.getMimeType(this, items[i].getUri(this));
}

ClipData clipData =
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/us/koller/cameraroll/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.os.Handler;
import android.provider.MediaStore;
import android.support.annotation.RequiresApi;
import android.support.design.widget.BaseTransientBottomBar;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityOptionsCompat;
Expand All @@ -31,8 +32,10 @@
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.accessibility.AccessibilityManager;
import android.widget.Toast;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,13 @@ public void run() {
});
} catch (Exception | OutOfMemoryError e) {
e.printStackTrace();
onResultListener.onResult(new Result(getImageUri(), null));
CropImageView.this.post(new Runnable() {
@Override
public void run() {
onResultListener.onResult(new Result(getImageUri(), null));
setProgressBarVisibility(GONE);
}
});
}
}
});
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/us/koller/cameraroll/util/ExifUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.net.Uri;
import android.os.Build;
import android.support.media.ExifInterface;
import android.widget.Toast;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -469,8 +470,10 @@ public static ExifInterface getExifInterface(Context context, AlbumItem albumIte
} else {
exif = new ExifInterface(albumItem.getPath());
}
} catch (IOException e) {
} catch (IOException | SecurityException e) {
e.printStackTrace();
Toast.makeText(context, "SecurityException", Toast.LENGTH_SHORT).show();
return null;
}
return exif;
}
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/us/koller/cameraroll/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,25 @@
import android.os.Build;
import android.os.PowerManager;
import android.support.annotation.RequiresApi;
import android.support.design.widget.BaseTransientBottomBar;
import android.support.design.widget.Snackbar;
import android.support.media.ExifInterface;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.content.res.AppCompatResources;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
import android.widget.TextView;
import android.widget.Toast;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.Locale;

import us.koller.cameraroll.R;
Expand Down Expand Up @@ -151,6 +155,20 @@ public static boolean areStatusBarIconsDark(final View v) {

public static void showSnackbar(Snackbar snackbar) {
snackbar.getView().setTag(SNACKBAR);
// fixing SnackBar animation, when AccessibilityManager is enabled
// Solution from: https://stackoverflow.com/a/43811447/8378871
try {
Field mAccessibilityManagerField = BaseTransientBottomBar.class.getDeclaredField("mAccessibilityManager");
mAccessibilityManagerField.setAccessible(true);
AccessibilityManager accessibilityManager = (AccessibilityManager) mAccessibilityManagerField.get(snackbar);
Field mIsEnabledField = AccessibilityManager.class.getDeclaredField("mIsEnabled");
mIsEnabledField.setAccessible(true);
mIsEnabledField.setBoolean(accessibilityManager, false);
mAccessibilityManagerField.set(snackbar, accessibilityManager);
} catch (Exception e) {
Log.d("Snackbar", "Reflection error: " + e.toString());
}

TextView textView = snackbar.getView()
.findViewById(android.support.design.R.id.snackbar_text);
textView.setTypeface(Typeface.create("sans-serif-monospace", Typeface.NORMAL));
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings_not_translatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
Russian: <a href=\"https://github.com/SnowVolf\">Atrem Zhiganov</a><br>
Spanish: Christobal Rojas, Luis Gmz<br>
Bulgarian: psydex<br>
Croatian: Ivan Krušlin<br>
Croatian: <a href=\"https://github.com/krux3r\">Ivan Krušlin</a><br>
Portuguese: <a href=\"https://github.com/marciozomb13\">Marcio Zomb13</a><br>
<br>
]]>
Expand Down

0 comments on commit 440b964

Please sign in to comment.