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

Commit

Permalink
- update v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kollerlukas committed Oct 3, 2017
1 parent 047a4d0 commit 22b8e63
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 33 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "us.koller.cameraroll"
minSdkVersion 19
targetSdkVersion 26
versionCode 31
versionName "v1.0.1"
versionCode 32
versionName "v1.0.2"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,31 @@
import android.os.Parcelable;
import android.provider.MediaStore;
import android.support.annotation.RequiresApi;
import android.support.media.ExifInterface;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.provider.DocumentFile;
import android.util.Log;
import android.widget.Toast;

import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import us.koller.cameraroll.R;
import us.koller.cameraroll.data.ContentObserver;
import us.koller.cameraroll.data.models.AlbumItem;
import us.koller.cameraroll.data.models.File_POJO;
import us.koller.cameraroll.data.Settings;
import us.koller.cameraroll.data.models.Video;
import us.koller.cameraroll.util.ExifUtil;
import us.koller.cameraroll.util.MediaType;
import us.koller.cameraroll.util.StorageUtil;

Expand Down Expand Up @@ -397,6 +405,7 @@ public static void scanPathsWithToast(final Context context, final String[] path

@SuppressLint("ShowToast")
private static void scanPaths(final Context context, final String[] paths, final MediaScannerCallback callback, final boolean showToast) {
Log.i("FileOperation", "scanPaths(), paths: " + Arrays.toString(paths));
if (paths == null) {
if (callback != null) {
callback.onAllPathsScanned();
Expand Down Expand Up @@ -425,8 +434,11 @@ private static void scanPaths(final Context context, final String[] paths, final
@Override
public void onScanCompleted(String path, Uri uri) {
if (uri == null) {
//Scanning failed --> changing MediaStore manually
Log.i("FileOperation", "MediaScannerConnection.scanFile() !FAILED! path = [" + path + "]");
Uri contentUri = MediaStore.Files.getContentUri("external");
ContentResolver resolver = context.getContentResolver();
if (new File(path).exists()) {
Log.i("FileOperation", "MediaScannerConnection.scanFile() !FAILED! path = [" + path + "]");
AlbumItem albumItem = AlbumItem.getInstance(path);
ContentValues values = new ContentValues();
if (albumItem instanceof Video) {
Expand All @@ -435,10 +447,26 @@ public void onScanCompleted(String path, Uri uri) {
} else {
values.put(MediaStore.Images.Media.DATA, path);
values.put(MediaStore.Images.Media.MIME_TYPE, MediaType.getMimeType(path));
try {
ExifInterface exif = new ExifInterface(path);
Locale locale = us.koller.cameraroll.util.Util.getLocale(context);
String dateString = String.valueOf(ExifUtil.getCastValue(exif, ExifInterface.TAG_DATETIME));
try {
Date date = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", locale).parse(dateString);
long dateTaken = date.getTime();
values.put(MediaStore.Images.Media.DATE_TAKEN, dateTaken);
} catch (ParseException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
Uri contentUri = MediaStore.Files.getContentUri("external");
ContentResolver resolver = context.getContentResolver();
resolver.insert(contentUri, values);
} else {
resolver.delete(contentUri,
MediaStore.MediaColumns.DATA + "='" + path + "'",
null);
}
} else {
Log.i("FileOperation", "MediaScannerConnection.scanFile() path = [" + path + "]");
Expand Down
31 changes: 5 additions & 26 deletions app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.FileUriExposedException;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
Expand Down Expand Up @@ -194,7 +193,7 @@ protected void onCreate(@Nullable final Bundle savedInstanceState) {
}

final ViewGroup rootView = findViewById(R.id.root_view);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
Expand Down Expand Up @@ -446,18 +445,8 @@ public void setPhotoAs() {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
try {
startActivityForResult(Intent.createChooser(intent,
getString(R.string.set_as)), 13);
} catch (FileUriExposedException fuee) {
Toast.makeText(this, "Error (FileUriExposedException)", Toast.LENGTH_SHORT).show();
fuee.printStackTrace();
}
} else {
startActivityForResult(Intent.createChooser(intent,
getString(R.string.set_as)), 13);
}
startActivityForResult(Intent.createChooser(intent,
getString(R.string.set_as)), 13);
} catch (SecurityException se) {
Toast.makeText(this, "Error (SecurityException)", Toast.LENGTH_SHORT).show();
se.printStackTrace();
Expand All @@ -475,18 +464,8 @@ public void openWith() {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
try {
startActivityForResult(Intent.createChooser(intent,
getString(R.string.open_with)), 13);
} catch (FileUriExposedException fuee) {
Toast.makeText(this, "Error (FileUriExposedException)", Toast.LENGTH_SHORT).show();
fuee.printStackTrace();
}
} else {
startActivityForResult(Intent.createChooser(intent,
getString(R.string.open_with)), 13);
}
startActivityForResult(Intent.createChooser(intent,
getString(R.string.open_with)), 13);
} catch (SecurityException se) {
Toast.makeText(this, "Error (SecurityException)", Toast.LENGTH_SHORT).show();
se.printStackTrace();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/us/koller/cameraroll/util/ExifUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public static String[][] getExifValues() {
return exifValues;
}

static Object getCastValue(ExifInterface exif, String tag)
public static Object getCastValue(ExifInterface exif, String tag)
throws NumberFormatException, NullPointerException {
String value = exif.getAttribute(tag);
return castValue(tag, value);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/us/koller/cameraroll/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public static float getAnimatorSpeed(Context context) {
android.provider.Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f);
}

static Locale getLocale(Context context) {
public static Locale getLocale(Context context) {
Locale locale;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
locale = context.getResources().getConfiguration().getLocales().get(0);
Expand Down

0 comments on commit 22b8e63

Please sign in to comment.