use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.
the class SplashScreen method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(org.horaapps.leafpic.R.layout.activity_splash);
SP = PreferenceUtil.getInstance(getApplicationContext());
((ProgressBar) findViewById(R.id.progress_splash)).getIndeterminateDrawable().setColorFilter(getPrimaryColor(), PorterDuff.Mode.SRC_ATOP);
RelativeLayout RelLay = (RelativeLayout) findViewById(org.horaapps.leafpic.R.id.Splah_Bg);
RelLay.setBackgroundColor(getBackgroundColor());
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
setNavBarColor();
setStatusBarColor();
if (PermissionUtils.isDeviceInfoGranted(this)) {
if (getIntent().getAction().equals(ACTION_OPEN_ALBUM)) {
Bundle data = getIntent().getExtras();
if (data != null) {
String ab = data.getString("albumPath");
if (ab != null) {
File dir = new File(ab);
// TODO: 19/08/16 look for id
album = new Album(getApplicationContext(), dir.getAbsolutePath(), data.getInt("albumId", -1), dir.getName(), -1);
new PrefetchPhotosData().execute();
}
} else
StringUtils.showToast(getApplicationContext(), "Album not found");
} else
new PrefetchAlbumsData().execute();
if (getIntent().getAction().equals(Intent.ACTION_GET_CONTENT) || getIntent().getAction().equals(Intent.ACTION_PICK))
PICK_INTENT = true;
} else {
String[] permissions = new String[] { Manifest.permission.READ_EXTERNAL_STORAGE };
PermissionUtils.requestPermissions(this, READ_EXTERNAL_STORAGE_ID, permissions);
}
}
use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.
the class MediaStoreProvider method getAlbums.
private static ArrayList<Album> getAlbums(Context context) {
ArrayList<Album> list = new ArrayList<Album>();
String[] projection = new String[] { MediaStore.Files.FileColumns.PARENT, MediaStore.Images.Media.BUCKET_DISPLAY_NAME };
String selection, selectionArgs[];
PreferenceUtil SP = PreferenceUtil.getInstance(context);
boolean includeVideo = SP.getBoolean("set_include_video", true);
if (includeVideo) {
selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "=? or " + MediaStore.Files.FileColumns.MEDIA_TYPE + "=?" + " ) GROUP BY ( " + MediaStore.Files.FileColumns.PARENT + " ";
selectionArgs = new String[] { String.valueOf(MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE), String.valueOf(MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO) };
} else {
selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "=? ) GROUP BY ( " + MediaStore.Files.FileColumns.PARENT + " ";
selectionArgs = new String[] { String.valueOf(MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE) };
}
Cursor cur = context.getContentResolver().query(MediaStore.Files.getContentUri("external"), projection, selection, selectionArgs, null);
if (cur != null) {
if (cur.moveToFirst()) {
int idColumn = cur.getColumnIndex(MediaStore.Files.FileColumns.PARENT);
int nameColumn = cur.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);
do {
Media media = getLastMedia(context, cur.getLong(idColumn));
if (media != null && media.getPath() != null) {
String path = StringUtils.getBucketPathByImagePath(media.getPath());
boolean excluded = isExcluded(path);
if (!excluded) {
Album album = new Album(context, path, cur.getLong(idColumn), cur.getString(nameColumn), getAlbumCount(context, cur.getLong(idColumn)));
if (album.addMedia(getLastMedia(context, album.getId())))
list.add(album);
}
}
} while (cur.moveToNext());
}
cur.close();
}
return list;
}
use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.
the class StorageProvider method checkAndAddFolder.
private void checkAndAddFolder(Context context, File dir, ArrayList<Album> albumArrayList) {
File[] files = dir.listFiles(new ImageFileFilter(includeVideo));
if (files != null && files.length > 0) {
//valid folder
Album asd = new Album(context, dir.getAbsolutePath(), -1, dir.getName(), files.length);
long lastMod = Long.MIN_VALUE;
File choice = null;
for (File file : files) {
if (file.lastModified() > lastMod) {
choice = file;
lastMod = file.lastModified();
}
}
if (choice != null)
asd.addMedia(new Media(choice.getAbsolutePath(), choice.lastModified()));
albumArrayList.add(asd);
}
}
use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.
the class SingleMediaActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pager);
SP = PreferenceUtil.getInstance(getApplicationContext());
toolbar = (Toolbar) findViewById(R.id.toolbar);
mViewPager = (HackyViewPager) findViewById(R.id.photos_pager);
securityObj = new SecurityHelper(SingleMediaActivity.this);
if (savedInstanceState != null)
mViewPager.setLocked(savedInstanceState.getBoolean(ISLOCKED_ARG, false));
try {
Album album;
if ((getIntent().getAction().equals(Intent.ACTION_VIEW) || getIntent().getAction().equals(ACTION_REVIEW)) && getIntent().getData() != null) {
String path = ContentHelper.getMediaPath(getApplicationContext(), getIntent().getData());
File file = null;
if (path != null)
file = new File(path);
if (file != null && file.isFile())
//the image is stored in the storage
album = new Album(getApplicationContext(), file);
else {
//try to show with Uri
album = new Album(getApplicationContext(), getIntent().getData());
customUri = true;
}
getAlbums().addAlbum(0, album);
}
initUI();
setupUI();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.horaapps.leafpic.data.Album in project LeafPic by HoraApps.
the class MediaStoreProvider method getHiddenAlbums.
private static ArrayList<Album> getHiddenAlbums(Context context) {
ArrayList<Album> list = new ArrayList<Album>();
String[] projection = new String[] { MediaStore.Files.FileColumns.DATA, MediaStore.Files.FileColumns.PARENT };
String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "=" + MediaStore.Files.FileColumns.MEDIA_TYPE_NONE + " and " + MediaStore.Files.FileColumns.DATA + " LIKE '%.nomedia'";
Cursor cur = context.getContentResolver().query(MediaStore.Files.getContentUri("external"), projection, selection, null, null);
if (cur != null && cur.moveToFirst()) {
do {
File folder = new File(cur.getString(0)).getParentFile();
File[] files = folder.listFiles(new ImageFileFilter(true));
if (files != null && files.length > 0) {
Album album = new Album(context, folder.getAbsolutePath(), -1, folder.getName(), files.length);
// TODO: 21/08/16 sort and find?
long lastMod = Long.MIN_VALUE;
File f = null;
for (File file : files) {
if (file.lastModified() > lastMod) {
f = file;
lastMod = file.lastModified();
}
}
if (f != null && !isExcluded(f.getPath())) {
album.addMedia(new Media(f.getPath(), f.lastModified()));
list.add(album);
}
}
} while (cur.moveToNext());
cur.close();
}
return list;
}
Aggregations