Commit f6157ce2 authored by Gilbert Ndresaj's avatar Gilbert Ndresaj

Merge pull request #1 from DNLDsht/master

Merge Donald
parents ac66ec3f 794ba492
......@@ -17,6 +17,7 @@ import java.util.ArrayList;
/**
* Created by dnld on 1/7/16.
*/
public class PhotosAdapter extends RecyclerView.Adapter<PhotosAdapter.ViewHolder> {
ArrayList<Photo> photos;
......
......@@ -6,7 +6,6 @@ import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.util.Log;
import com.leafpic.app.utils.StringUtils;
......@@ -31,6 +30,7 @@ public class HandlingPhotos implements Parcelable {
return new HandlingPhotos[size];
}
};
public String FolderPath;
public String ID;
public String DisplayName;
......@@ -114,7 +114,7 @@ public class HandlingPhotos implements Parcelable {
}
public String getPreviewAlbumImg() {
Log.wtf("asdfsfd", settings.coverPath);
//Log.wtf("asdfsfd", settings.coverPath);
if (settings.coverPath != null) return settings.coverPath;
return photos.get(0).Path;
}
......
......@@ -67,7 +67,7 @@ public class MadiaStoreHandler {
MediaStore.Images.Media.MIME_TYPE
};
Uri images = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
Uri images = MediaStore.Images.Media.INTERNAL_CONTENT_URI;
Cursor cur = context.getContentResolver().query(
images,
projection,
......
package com.leafpic.app;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.leafpic.app.Adapters.PhotosPagerAdapter;
import com.leafpic.app.Animations.DepthPageTransformer;
import com.leafpic.app.Base.HandlingPhotos;
import com.leafpic.app.Base.Photo;
import com.leafpic.app.utils.StringUtils;
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.Calendar;
/**
......@@ -55,6 +60,28 @@ public class PhotoActivity extends AppCompatActivity {
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mCustomPagerAdapter);
mViewPager.setCurrentItem(photos.getCurrentPhotoIndex());
Photo f = photos.getCurrentPhoto();
String[] projection = new String[]{
MediaStore.Images.Media.DATE_TAKEN,
MediaStore.Images.Media.DATA,
MediaStore.Images.Media.MIME_TYPE
};
Log.wtf("asdasdasd", f.Path);
Cursor cursor = getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection,
MediaStore.Images.Media.DATA + " = ?",
new String[]{f.Path}, "");
if (cursor.moveToFirst()) {
int columnIndex = cursor.getColumnIndex(MediaStore.Images.Media.MIME_TYPE);
StringUtils.showToast(getApplicationContext(), cursor.getString(columnIndex));
}
cursor.close();
mViewPager.setPageTransformer(true, new DepthPageTransformer());
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
......@@ -158,11 +185,35 @@ public class PhotoActivity extends AppCompatActivity {
/****DATA****/
Calendar cl = Calendar.getInstance();
cl.setTimeInMillis(Long.parseLong(StringUtils.getPhotoNamebyPath(photos.getCurrentPhoto().DateTaken))); //here your time in miliseconds
String date = "" + cl.get(Calendar.DAY_OF_MONTH) + "/" + cl.get(Calendar.MONTH) + "/" + cl.get(Calendar.YEAR);
String time = "" + cl.get(Calendar.HOUR_OF_DAY) + ":" + cl.get(Calendar.MINUTE) + ":" + cl.get(Calendar.SECOND);
String date = "", size = "", resolution = "";
SimpleDateFormat s = new SimpleDateFormat("dd/mm/yyyy HH:MM");// //new DateFormat();
date = s.format(new Time(Long.valueOf(photos.getCurrentPhoto().DateTaken)));
Photo f = photos.getCurrentPhoto();
String[] projection = new String[]{
MediaStore.Images.Media.SIZE,
MediaStore.Images.Media.HEIGHT,
MediaStore.Images.Media.WIDTH
};
Cursor cursor = getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection,
MediaStore.Images.Media.DATA + " = ?",
new String[]{f.Path}, "");
if (cursor.moveToFirst()) {
size = StringUtils.humanReadableByteCount(cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media.SIZE)), true);
resolution = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.WIDTH));
resolution += "x" + cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.HEIGHT));
}
cursor.close();
/**GET COLOR**/
/*
SharedPreferences SP;
SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String SColor = SP.getString("PrefColor", "#03A9F4");
......@@ -175,10 +226,10 @@ public class PhotoActivity extends AppCompatActivity {
//.titleColor(color)
.content("Album: " + StringUtils.getPhotoNamebyPath(photos.FolderPath)
+ "\nName: " + StringUtils.getPhotoNamebyPath(photos.getCurrentPhoto().Path)
+ "\nDimensione: " + "DA Implementare"
+ "\nRisoluzione: " + "DA Implementare"
+ "\nDimensione: " + size
+ "\nRisoluzione: " + resolution
+ "\nFormato: " + photos.getCurrentPhoto().MIME
+ "\nData: " + date + " " + time)
+ "\nData: " + date)
.positiveText("OK")
.show();
break;
......
package com.leafpic.app;
import android.content.ContentResolver;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.net.Uri;
......@@ -13,7 +15,6 @@ import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.NavUtils;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.*;
import android.text.Html;
......@@ -83,6 +84,22 @@ public class PhotosActivity extends AppCompatActivity {
});
*/
private long getVideoIdFromFilePath(String filePath,
ContentResolver contentResolver) {
long videoId;
Uri videosUri = MediaStore.Video.Media.getContentUri("internal");
String[] projection = {MediaStore.Images.ImageColumns._ID};
// TODO This will break if we have no matching item in the MediaStore.
Cursor cursor = contentResolver.query(videosUri, projection, MediaStore.Images.ImageColumns.DATA + " LIKE ?", new String[]{filePath}, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(projection[0]);
videoId = cursor.getLong(columnIndex);
cursor.close();
return videoId;
}
public void LoadPhotos() {
try {
......@@ -362,9 +379,8 @@ public class PhotosActivity extends AppCompatActivity {
.onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
StringUtils.showToast(getApplicationContext(), "Not implemented yet!");
//albums.excludeAlbum(photos.FolderPath);
// finish();
customAlbumsHandler.excludeAlbum(photos.ID);
finish();
}
})
.show();
......@@ -379,16 +395,16 @@ public class PhotosActivity extends AppCompatActivity {
ArrayList<Uri> files = new ArrayList<Uri>();
for (Photo f : photos.selectedPhotos) {
File file = new File(f.Path);
files.add(Uri.fromFile(file));
}
for (Photo f : photos.selectedPhotos)
files.add(Uri.fromFile(new File(f.Path)));
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
startActivity(intent);
break;
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
onBackPressed();
//NavUtils.navigateUpFromSameTask(this);
return true;
case R.id.action_camera:
......
......@@ -86,4 +86,12 @@ public class StringUtils {
public static String quoteReverse(String psString) {
return psString.replace("{*~^]", "'");
}
public static String humanReadableByteCount(long bytes, boolean si) {
int unit = si ? 1000 : 1024;
if (bytes < unit) return bytes + " B";
int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
}
}
......@@ -110,14 +110,14 @@
>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/gridPhotos"
android:numColumns="3"
android:verticalSpacing="2dp"
android:horizontalSpacing="2dp"
android:clipToPadding="false"
android:background="@color/md_dark_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/gridPhotos"
android:numColumns="3"
android:verticalSpacing="0dp"
android:horizontalSpacing="0dp"
android:clipToPadding="false"
android:background="@color/md_dark_background"
/>
<!--app:layout_behavior="@StringUtils/appbar_scrolling_view_behavior"-->
</android.support.v7.widget.CardView>
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/selectedPicIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:elevation="10dp"
android:src="@mipmap/ic_check_circle_white_18dp"
android:layout_gravity="top|end"
......@@ -36,7 +37,7 @@
android:id="@+id/pic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:layout_margin="1dp"
android:minHeight="120dp"
android:scaleType="fitXY"
/>
</FrameLayout>
\ No newline at end of file
</FrameLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment