Commit 37bb17fd authored by Gilbert Ndresaj's avatar Gilbert Ndresaj 💬

Merge remote-tracking branch 'refs/remotes/DNLDsht/master'

# Conflicts:
#	app/src/main/java/com/leafpic/app/AlbumsActivity.java
#	app/src/main/java/com/leafpic/app/PhotosActivity.java
parents 46a077d3 84af677a
......@@ -30,7 +30,6 @@ import com.afollestad.materialdialogs.MaterialDialog;
import com.leafpic.app.Adapters.AlbumsAdapter;
import com.leafpic.app.Base.Album;
import com.leafpic.app.Base.HandlingAlbums;
import com.leafpic.app.Base.MadiaStoreHandler;
import com.leafpic.app.utils.string;
import com.mikepenz.fontawesome_typeface_library.FontAwesome;
import com.mikepenz.materialdrawer.AccountHeader;
......@@ -46,13 +45,12 @@ import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
public class AlbumsActivity extends AppCompatActivity {
HandlingAlbums albums = new HandlingAlbums(AlbumsActivity.this);
boolean editmode = false, hidden = false;
RecyclerView mRecyclerView;
AlbumsAdapter adapt;
Toolbar toolbar;
SharedPreferences SP;
MadiaStoreHandler asd = new MadiaStoreHandler(AlbumsActivity.this);
boolean editmode = false, hidden = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -62,6 +60,7 @@ public class AlbumsActivity extends AppCompatActivity {
initUiTweaks();
checkPermissions();
<<<<<<< HEAD
//APP INTRO STATS HEARE DIO CANE
Thread t = new Thread(new Runnable() {
@Override
......@@ -85,6 +84,10 @@ public class AlbumsActivity extends AppCompatActivity {
//asd.logPhotos();
//asd.logAlbums();
//asd.logDeletedPhotos();
=======
>>>>>>> refs/remotes/DNLDsht/master
}
@Override
......@@ -94,11 +97,10 @@ public class AlbumsActivity extends AppCompatActivity {
@Override
public void onResume() {
checkPermissions();
albums.clearSelectedAlbums();
updateSelectedStuff();
invalidateOptionsMenu();
checkPermissions();
super.onResume();
}
......@@ -161,8 +163,6 @@ public class AlbumsActivity extends AppCompatActivity {
break;
case 2: //hidden
hidden = true;
//albums.loadPreviewHiddenAlbums();
//adapt.notifyDataSetChanged();
checkPermissions();
break;
case 6: //settings
......@@ -403,8 +403,28 @@ public class AlbumsActivity extends AppCompatActivity {
private void loadAlbums() {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
SharedPreferences getPrefs = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
boolean isFirstStart = getPrefs.getBoolean("firstStart", true);
if (isFirstStart) {
//albums.loadPreviewHiddenAlbums();
Intent i = new Intent(AlbumsActivity.this, IntroActivity.class);
startActivity(i);
SharedPreferences.Editor e = getPrefs.edit();
e.putBoolean("firstStart", false);
e.apply();
}
}
});
t.start();
if (hidden) {
albums.loadPreviewHiddenAlbums();
//albums.LogAlbums();
}
else {
// db.updatePhotos();
......@@ -453,5 +473,10 @@ public class AlbumsActivity extends AppCompatActivity {
mRecyclerView.setAdapter(adapt);
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
<<<<<<< HEAD
=======
adapt.notifyDataSetChanged();
>>>>>>> refs/remotes/DNLDsht/master
}
}
......@@ -3,6 +3,7 @@ package com.leafpic.app.Base;
import android.content.Context;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.util.Log;
import com.leafpic.app.utils.string;
import java.io.File;
......@@ -121,8 +122,23 @@ public class HandlingAlbums {
clearSelectedAlbums();
}
public void hideAlbum(Album a) {
public void hideAlbum(final Album a) {
hideAlbum(a.Path);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
HiddenPhotosHandler db = new HiddenPhotosHandler(context);
MadiaStoreHandler mediaStoreHandler = new MadiaStoreHandler(context);
for (Photo photo : mediaStoreHandler.getAlbumPhotos(a)) {
photo.FolderPath = a.Path;
db.addPhoto(photo);
}
db.close();
}
});
t.start();
dispAlbums.remove(a);
}
......@@ -141,6 +157,37 @@ public class HandlingAlbums {
}
}
public void hideAlbum(String path, final ArrayList<Photo> ph) {
final File dirName = new File(path);
File file = new File(dirName, ".nomedia");
if (!file.exists()) {
try {
FileOutputStream out = new FileOutputStream(file);
out.flush();
out.close();
scanFile(new String[]{file.getAbsolutePath()});
Thread t = new Thread(new Runnable() {
@Override
public void run() {
HiddenPhotosHandler db = new HiddenPhotosHandler(context);
for (Photo photo : ph) {
photo.FolderPath = dirName.getAbsolutePath();
db.addPhoto(photo);
}
db.close();
}
});
t.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void renameAlbum(String olderPath, String name) {
try {
File from = new File(olderPath);
......@@ -164,6 +211,18 @@ public class HandlingAlbums {
db.close();
}
public void unHideSelectedAlbums() {
for (Album selectedAlbum : selectedAlbums)
unHideAlbum(selectedAlbum);
clearSelectedAlbums();
}
public void unHideAlbum(Album a) {
unHideAlbum(a.Path);
dispAlbums.remove(a);
}
public void unHideAlbum(String path) {
HiddenPhotosHandler db = new HiddenPhotosHandler(context);
......@@ -179,6 +238,16 @@ public class HandlingAlbums {
}
}
dispAlbums.remove(getAlbum(path));
db.close();
}
public void LogAlbums() {
for (Album dispAlbum : dispAlbums) {
Log.wtf("asdasd", dispAlbum.Path);
for (Photo photo : dispAlbum.photos) {
Log.d("asdasdasdasd", photo.Path);
}
}
}
/*************
......@@ -186,19 +255,6 @@ public class HandlingAlbums {
**************/
public void unHideSelectedAlbums() {
/*for (Album selectedAlbum : selectedAlbums)
unHideAlbum(selectedAlbum);
clearSelectedAlbums();*/
}
public void unHideAlbum(Album a) {
unHideAlbum(a.Path);
dispAlbums.remove(a);
}
public void excludeSelectedAlbums() {
......
......@@ -138,14 +138,6 @@ public class HandlingPhotos implements Parcelable {
return last_position_selecte;
}
public int selectPhoto(Photo a, boolean val) {
Photo x = photos.get(photos.indexOf(a));
x.setSelected(val);
if (val) selectedPhotos.add(x);
else selectedPhotos.remove(x);
return last_position_selecte;
}
public void deleteSelectedPhotos() {
for (Photo photo : selectedPhotos)
deletePhoto(photo);
......
......@@ -121,7 +121,7 @@ public class HiddenPhotosHandler extends SQLiteOpenHelper {
if (cursor.moveToFirst()) {
do contactList.add(new Album(
string.quoteReverse(cursor.getString(0)),
string.getBucketNamebyImagePath(string.quoteReverse(cursor.getString(0))),
string.getBucketNamebyBucketPath(string.quoteReverse(cursor.getString(0))),
true, getHiddenPhotosCountByAlbum(cursor.getString(0))));
while (cursor.moveToNext());
}
......
......@@ -24,12 +24,17 @@ import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.text.InputType;
import android.transition.Slide;
<<<<<<< HEAD
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
=======
import android.util.Log;
import android.view.*;
>>>>>>> refs/remotes/DNLDsht/master
import android.widget.ImageView;
import android.widget.TextView;
......@@ -312,7 +317,8 @@ public class PhotosActivity extends AppCompatActivity {
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
albums.hideAlbum(photos.FolderPath);
Log.wtf("asdasdasdas", photos.FolderPath);
albums.hideAlbum(photos.FolderPath, photos.photos);
finish();
}
})
......
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