Commit e3f65a9f authored by Donald's avatar Donald

clean

parent 0606f8f4
......@@ -18,11 +18,7 @@ import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.support.v7.widget.*;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
......@@ -36,7 +32,7 @@ import com.leafpic.app.Adapters.AlbumsAdapter;
import com.leafpic.app.Base.Album;
import com.leafpic.app.Base.HandlingAlbums;
import com.leafpic.app.Base.HiddenPhotosHandler;
import com.leafpic.app.utils.string;
import com.leafpic.app.utils.StringUtils;
import com.mikepenz.fontawesome_typeface_library.FontAwesome;
import com.mikepenz.iconics.context.IconicsContextWrapper;
import com.mikepenz.materialdrawer.AccountHeader;
......@@ -213,7 +209,7 @@ public class AlbumsActivity extends AppCompatActivity implements FolderChooserDi
@Override
public void onFolderSelection(@NonNull File folder) {
HiddenPhotosHandler h = new HiddenPhotosHandler(getApplicationContext());
string.showToast(getApplicationContext(), folder.getAbsolutePath());
StringUtils.showToast(getApplicationContext(), folder.getAbsolutePath());
h.addImagesFromFolder(folder);
albums.loadPreviewHiddenAlbums();
......@@ -231,7 +227,7 @@ public class AlbumsActivity extends AppCompatActivity implements FolderChooserDi
!= PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(AlbumsActivity.this,
Manifest.permission.INTERNET))
string.showToast(AlbumsActivity.this, "eddai dammi internet");
StringUtils.showToast(AlbumsActivity.this, "eddai dammi internet");
else
ActivityCompat.requestPermissions(AlbumsActivity.this,
new String[]{Manifest.permission.INTERNET}, 1);
......@@ -241,7 +237,7 @@ public class AlbumsActivity extends AppCompatActivity implements FolderChooserDi
Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(AlbumsActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE))
string.showToast(AlbumsActivity.this, "no storage permission");
StringUtils.showToast(AlbumsActivity.this, "no storage permission");
else
ActivityCompat.requestPermissions(AlbumsActivity.this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0);
......@@ -312,7 +308,7 @@ public class AlbumsActivity extends AppCompatActivity implements FolderChooserDi
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
string.showToast(getApplicationContext(), "asdasd");
StringUtils.showToast(getApplicationContext(), "asdasd");
return true;
case R.id.sort_action:
......@@ -434,7 +430,7 @@ public class AlbumsActivity extends AppCompatActivity implements FolderChooserDi
break;
case 1:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
string.showToast(AlbumsActivity.this, "i got NET");
StringUtils.showToast(AlbumsActivity.this, "i got NET");
break;
}
}
......
......@@ -3,7 +3,7 @@ package com.leafpic.app.Base;
import android.os.Parcel;
import android.os.Parcelable;
import com.leafpic.app.R;
import com.leafpic.app.utils.string;
import com.leafpic.app.utils.StringUtils;
import java.util.ArrayList;
......@@ -69,7 +69,7 @@ public class Album implements Parcelable {
public void setPath() {
try {
Path = string.getBucketPathbyImagePath(photos.get(0).Path);
Path = StringUtils.getBucketPathbyImagePath(photos.get(0).Path);
} catch (NullPointerException e) {
e.printStackTrace();
}
......
......@@ -6,7 +6,7 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import com.leafpic.app.utils.string;
import com.leafpic.app.utils.StringUtils;
import java.util.ArrayList;
......@@ -50,7 +50,7 @@ public class CustomAlbumsHandler extends SQLiteOpenHelper {
checkAndCreateAlbum(id);
AlbumSettings s = new AlbumSettings();
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery("SELECT " + ALBUM_COVER + ", " + ALBUM_DEAFAULT_SORTMODE + ", " + ALBUM_DEAFAULT_SORT_ASCENDING + " FROM " + TABLE_ALBUMS + " WHERE " + ALBUM_ID + "='" + string.quoteReplace(id) + "'", null);
Cursor cursor = db.rawQuery("SELECT " + ALBUM_COVER + ", " + ALBUM_DEAFAULT_SORTMODE + ", " + ALBUM_DEAFAULT_SORT_ASCENDING + " FROM " + TABLE_ALBUMS + " WHERE " + ALBUM_ID + "='" + StringUtils.quoteReplace(id) + "'", null);
if (cursor.moveToFirst())
s = new AlbumSettings(cursor.getString(0), cursor.getString(1), Boolean.valueOf(cursor.getString(2)));
cursor.close();
......@@ -66,10 +66,10 @@ public class CustomAlbumsHandler extends SQLiteOpenHelper {
public void checkAndCreateAlbum(String id) {
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery("SELECT " + ALBUM_ID + " FROM " + TABLE_ALBUMS + " WHERE " + ALBUM_ID + "='" + string.quoteReplace(id) + "'", null);
Cursor cursor = db.rawQuery("SELECT " + ALBUM_ID + " FROM " + TABLE_ALBUMS + " WHERE " + ALBUM_ID + "='" + StringUtils.quoteReplace(id) + "'", null);
if (cursor.getCount() == 0) {
ContentValues values = new ContentValues();
values.put(ALBUM_ID, string.quoteReplace(id));
values.put(ALBUM_ID, StringUtils.quoteReplace(id));
db.insert(TABLE_ALBUMS, null, values);
}
cursor.close();
......@@ -79,14 +79,14 @@ public class CustomAlbumsHandler extends SQLiteOpenHelper {
public void excludeAlbum(String id) {
checkAndCreateAlbum(id);
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_ALBUMS + " SET " + ALBUM_EXCLUDED + "='true' WHERE " + ALBUM_ID + "='" + string.quoteReplace(id) + "'");
db.execSQL("UPDATE " + TABLE_ALBUMS + " SET " + ALBUM_EXCLUDED + "='true' WHERE " + ALBUM_ID + "='" + StringUtils.quoteReplace(id) + "'");
db.close();
}
public String getPhotPrevieAlbum(String id) {
String s = null;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery("SELECT " + ALBUM_COVER + " FROM " + TABLE_ALBUMS + " WHERE " + ALBUM_ID + "='" + string.quoteReplace(id)
Cursor cursor = db.rawQuery("SELECT " + ALBUM_COVER + " FROM " + TABLE_ALBUMS + " WHERE " + ALBUM_ID + "='" + StringUtils.quoteReplace(id)
+ "'", null);
if (cursor.moveToFirst())
s = cursor.getString(0);
......@@ -99,7 +99,7 @@ public class CustomAlbumsHandler extends SQLiteOpenHelper {
public void setAlbumPhotPreview(String id, String path) {
checkAndCreateAlbum(id);
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_ALBUMS + " SET " + ALBUM_COVER + "='" + path + "' WHERE " + ALBUM_ID + "='" + string.quoteReplace(id) + "'");
db.execSQL("UPDATE " + TABLE_ALBUMS + " SET " + ALBUM_COVER + "='" + path + "' WHERE " + ALBUM_ID + "='" + StringUtils.quoteReplace(id) + "'");
db.close();
}
......@@ -107,7 +107,7 @@ public class CustomAlbumsHandler extends SQLiteOpenHelper {
checkAndCreateAlbum(id);
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_ALBUMS + " SET " + ALBUM_DEAFAULT_SORTMODE + "='" + column +
"' WHERE " + ALBUM_ID + "='" + string.quoteReplace(id) + "'");
"' WHERE " + ALBUM_ID + "='" + StringUtils.quoteReplace(id) + "'");
db.close();
}
......@@ -115,7 +115,7 @@ public class CustomAlbumsHandler extends SQLiteOpenHelper {
checkAndCreateAlbum(id);
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_ALBUMS + " SET " + ALBUM_DEAFAULT_SORT_ASCENDING + "='" + String.valueOf(asc) +
"' WHERE " + ALBUM_ID + "='" + string.quoteReplace(id) + "'");
"' WHERE " + ALBUM_ID + "='" + StringUtils.quoteReplace(id) + "'");
db.close();
}
......
......@@ -3,8 +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 com.leafpic.app.utils.StringUtils;
import java.io.File;
import java.io.FileOutputStream;
......@@ -248,15 +247,6 @@ public class HandlingAlbums {
db.close();
}
public void LogAlbums() {
for (Album dispAlbum : dispAlbums) {
Log.wtf("asdasd", dispAlbum.Path);
for (Photo photo : dispAlbum.photos) {
Log.d("asdasdasdasd", photo.Path);
}
}
}
/*************
* This Metods doesnt work for the moment
**************/
......@@ -264,9 +254,18 @@ public class HandlingAlbums {
public void renameAlbum(String olderPath, String name) {
try {
File from = new File(olderPath);
File to = new File(string.getAlbumPathRenamed(olderPath, name));
File to = new File(StringUtils.getAlbumPathRenamed(olderPath, name));
from.renameTo(to);
scanFile(new String[]{from.getAbsolutePath(), to.getAbsolutePath()});
//from.list();
//context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(from)));
//context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(to)));
//Log.wtf("asdasdasdasd - from",from.getAbsolutePath());
//Log.wtf("asdasdasdasd - to",to.getAbsolutePath());
//
//scanFile(from.list());
scanFile(to.list());
// scanFile(new String[]{from.list(), to.getAbsolutePath()});
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -6,7 +6,7 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Environment;
import com.leafpic.app.utils.string;
import com.leafpic.app.utils.StringUtils;
import java.io.File;
import java.util.ArrayList;
......@@ -56,7 +56,7 @@ public class HiddenPhotosHandler extends SQLiteOpenHelper {
public void deleteAlbum(String path) {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("DELETE FROM " + TABLE_PHOTOS + " WHERE " + PHOTO_FOLDER_PATH + "='" + string.quoteReplace(path) + "'");
db.execSQL("DELETE FROM " + TABLE_PHOTOS + " WHERE " + PHOTO_FOLDER_PATH + "='" + StringUtils.quoteReplace(path) + "'");
db.close();
}
......@@ -89,7 +89,7 @@ public class HiddenPhotosHandler extends SQLiteOpenHelper {
for (String child : dir.list()) {
File temp = new File(dir, child);
String mime = string.getMimeType(temp.getAbsolutePath());
String mime = StringUtils.getMimeType(temp.getAbsolutePath());
if (mime != null && mime.contains("image"))
addPhoto(new Photo(
temp.getAbsolutePath(),
......@@ -101,8 +101,8 @@ public class HiddenPhotosHandler extends SQLiteOpenHelper {
void addPhoto(Photo contact) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(PHOTO_FOLDER_PATH, string.quoteReplace(contact.FolderPath));
values.put(PHOTO_PATH, string.quoteReplace(contact.Path));
values.put(PHOTO_FOLDER_PATH, StringUtils.quoteReplace(contact.FolderPath));
values.put(PHOTO_PATH, StringUtils.quoteReplace(contact.Path));
values.put(PHOTO_MIME, contact.MIME);
db.insert(TABLE_PHOTOS, null, values);
db.close();
......@@ -117,8 +117,8 @@ public class HiddenPhotosHandler extends SQLiteOpenHelper {
null);
if (cursor.moveToFirst()) {
do contactList.add(new Album(
string.quoteReverse(cursor.getString(0)),
string.getBucketNamebyBucketPath(string.quoteReverse(cursor.getString(0))),
StringUtils.quoteReverse(cursor.getString(0)),
StringUtils.getBucketNamebyBucketPath(StringUtils.quoteReverse(cursor.getString(0))),
true, getHiddenPhotosCountByAlbum(cursor.getString(0))));
while (cursor.moveToNext());
}
......@@ -132,7 +132,7 @@ public class HiddenPhotosHandler extends SQLiteOpenHelper {
PHOTO_MIME + ", " + PHOTO_DATE_TAKEN +
" FROM " + TABLE_PHOTOS + " WHERE " +
PHOTO_FOLDER_PATH + "='" +
string.quoteReplace(path) + "' ORDER BY " + PHOTO_DATE_TAKEN + " DESC";
StringUtils.quoteReplace(path) + "' ORDER BY " + PHOTO_DATE_TAKEN + " DESC";
SQLiteDatabase db = this.getWritableDatabase();
......@@ -141,7 +141,7 @@ public class HiddenPhotosHandler extends SQLiteOpenHelper {
if (cursor.moveToFirst()) {
do {
contactList.add(new Photo(
string.quoteReverse(cursor.getString(0)),
StringUtils.quoteReverse(cursor.getString(0)),
cursor.getString(3),
cursor.getString(2),
cursor.getString(1)));
......@@ -154,7 +154,7 @@ public class HiddenPhotosHandler extends SQLiteOpenHelper {
public ArrayList<Photo> getFirstPhotosByAlbum(String path) {
ArrayList<Photo> contactList = new ArrayList<Photo>();
String selectQuery = "SELECT " + PHOTO_PATH + ", " + PHOTO_DATE_TAKEN + " FROM " + TABLE_PHOTOS + " WHERE " +
PHOTO_FOLDER_PATH + "='" + string.quoteReplace(path) + "' ORDER BY " + PHOTO_DATE_TAKEN + " DESC";
PHOTO_FOLDER_PATH + "='" + StringUtils.quoteReplace(path) + "' ORDER BY " + PHOTO_DATE_TAKEN + " DESC";
SQLiteDatabase db = this.getWritableDatabase();
......@@ -162,7 +162,7 @@ public class HiddenPhotosHandler extends SQLiteOpenHelper {
if (cursor.moveToFirst())
contactList.add(new Photo(
string.quoteReverse(cursor.getString(0)),
StringUtils.quoteReverse(cursor.getString(0)),
cursor.getString(1)));
cursor.close();
......
......@@ -18,7 +18,7 @@ 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.utils.string;
import com.leafpic.app.utils.StringUtils;
/**
* Created by dnld on 12/12/15.
......@@ -88,7 +88,7 @@ public class PhotoActivity extends AppCompatActivity {
case R.id.shareButton:
String file_path = photos.photos.get(mViewPager.getCurrentItem()).Path;
Intent share = new Intent(Intent.ACTION_SEND);
share.setType(string.getMimeType(file_path));
share.setType(StringUtils.getMimeType(file_path));
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file_path));
startActivity(Intent.createChooser(share, "Share Image"));
return true;
......@@ -120,7 +120,7 @@ public class PhotoActivity extends AppCompatActivity {
String file_path_use_as = photos.photos.get(mViewPager.getCurrentItem()).Path;
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(Uri.parse("file://" + file_path_use_as), "image/*");
intent.putExtra("jpg", string.getMimeType(file_path_use_as));
intent.putExtra("jpg", StringUtils.getMimeType(file_path_use_as));
startActivity(Intent.createChooser(intent, "Use As"));
return true;
......
......@@ -27,7 +27,7 @@ import com.afollestad.materialdialogs.MaterialDialog;
import com.bumptech.glide.Glide;
import com.leafpic.app.Adapters.PhotosAdapter;
import com.leafpic.app.Base.*;
import com.leafpic.app.utils.string;
import com.leafpic.app.utils.StringUtils;
import java.io.File;
import java.util.ArrayList;
......@@ -285,7 +285,7 @@ public class PhotosActivity extends AppCompatActivity {
});
popup.show();
} else string.showToast(getApplicationContext(), " In progress");
} else StringUtils.showToast(getApplicationContext(), " In progress");
break;
case R.id.renameAlbum:
......@@ -299,8 +299,9 @@ public class PhotosActivity extends AppCompatActivity {
/* TODO make this better
albums.renameAlbum(photos.FolderPath, input.toString());
finish();
*/
string.showToast(getApplicationContext(), "I have to fix this!");
StringUtils.showToast(getApplicationContext(), "I have to fix this!");
*/
}
}).show();
break;
......@@ -360,7 +361,7 @@ public class PhotosActivity extends AppCompatActivity {
.onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
string.showToast(getApplicationContext(), "Not implemented yet!");
StringUtils.showToast(getApplicationContext(), "Not implemented yet!");
//albums.excludeAlbum(photos.FolderPath);
// finish();
}
......
......@@ -7,7 +7,8 @@ import android.widget.Toast;
/**
* Created by dnld on 1/3/16.
*/
public class string {
public class StringUtils {
public static String getMimeType(String url) {
String type = null;
String extension = MimeTypeMap.getFileExtensionFromUrl(url);
......@@ -52,13 +53,9 @@ public class string {
return quoteReplace(folderPath + "/" + name);
}
public static String getAlbumPathRenamed(String olderPath, String newName) {
String b[] = olderPath.split("/");
String c = "";
for (int x = 0; x < b.length - 1; x++) c += b[x] + "/";
c += newName;
//c = c.substring(0, c.length() - 1);
return c;
return olderPath.substring(0, olderPath.lastIndexOf('/')) + "/" + newName;
}
public static String getPhotoPathRenamed(String olderPath, String newName) {
......@@ -83,10 +80,10 @@ public class string {
}
public static String quoteReplace(String psString) {
return psString.replace("'", "^");
return psString.replace("'", "{*~^]");
}
public static String quoteReverse(String psString) {
return psString.replace("^", "'");
return psString.replace("{*~^]", "'");
}
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:theme="@style/Theme.AppCompat.NoActionBar"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:theme="@style/Theme.AppCompat.NoActionBar"
android:background="@color/background_material_dark">
android:background="@color/background_material_dark">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
......@@ -120,7 +119,7 @@
android:clipToPadding="false"
android:background="@color/md_dark_background"
/>
<!--app:layout_behavior="@string/appbar_scrolling_view_behavior"-->
<!--app:layout_behavior="@StringUtils/appbar_scrolling_view_behavior"-->
</android.support.v7.widget.CardView>
<android.support.design.widget.FloatingActionButton
......
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