diff --git a/README.md b/README.md
index f417b6198..4d55a5678 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,16 @@
-# LeafPic [![Crowdin](https://d322cqt584bo4o.cloudfront.net/leafpic/localized.svg)](https://crowdin.com/project/leafpic)
-
-
-
-LeafPic is a fluid, material-designed alternative gallery. LeafPic is ad-free, open sourced under GPL v3. It is smaller than other apps but it doesn't miss any of the main features.
-
-LeafPic is available on F-Droid.
-
-[![F-Droid](https://f-droid.org/wiki/images/0/06/F-Droid-button_get-it-on.png)](https://f-droid.org/repository/browse/?fdid=com.horaapps.leafpic)
-
-
-## Screenshot
+[![GitHub release](https://img.shields.io/github/release/HoraApps/LeafPic.svg)](https://github.com/HoraApps/LeafPic/releases)
+[![Crowdin](https://d322cqt584bo4o.cloudfront.net/leafpic/localized.svg)](https://crowdin.com/project/leafpic)
+[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg)](https://www.paypal.me/HoraApps)
+# LeafPic
+
+LeafPic is a fluid, material-designed alternative gallery, it also is ad-free and open source under GPLv3 license. It doesn't miss any of the main features of a stock gallery, we also have in plan to add some useful feature.
+
+
+
+
+
+## Screenshots
@@ -23,19 +24,15 @@ LeafPic is available on F-Droid.
###### Code & Issues
If you are a developer and you wish to contribute to the app please fork the project
-and submit a pull request.
+and submit a pull request if possible make it on the [develop branch](https://github.com/HoraApps/LeafPic/tree/develop).
If you have any questions, feel free to ask [me](mailto:dnld.sht@gmail.com) about whatever you want.
[Here](https://github.com/HoraApps/LeafPic/issues) is the list of known issues.
If you want to report new bugs please add helpful description or screenshots.
###### Translations
If you are able to contribute with a new translation of a missing language or if you want to improve an existing one, we greatly appreciate any suggestion!
-[The project uses Crowdin](https://crowdin.com/project/leafpic), a platform that allows anybody to contribute to translating the app
+The project uses [Crowdin](https://crowdin.com/project/leafpic), a platform that allows anybody to contribute to translating the app
#### Licensing
-Leafpic is licensed under the [GNU v3 Public License](https://github.com/HoraApps/LeafPic/blob/master/LICENSE).
-
+LeafPic is licensed under the [GNU v3 Public License](https://github.com/HoraApps/LeafPic/blob/master/LICENSE).
In addition to the terms set by the GNU v3 Public License, we ask that if you use any code from this repository that you send us a message to let us know.
-
-
-
diff --git a/app/build.gradle b/app/build.gradle
index 6731b8cf4..1b2b39ec9 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.0'
+ classpath 'com.android.tools.build:gradle:2.1.2'
}
}
@@ -22,8 +22,8 @@ android {
applicationId "com.horaapps.leafpic"
minSdkVersion 19
targetSdkVersion 23
- versionCode 6
- versionName "v0.3.5"
+ versionCode 7
+ versionName "v0.4"
}
lintOptions {
@@ -47,7 +47,7 @@ android {
}
dependencies {
- compile fileTree(include: ['*.jar'], dir: 'libs')
+ compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
@@ -62,11 +62,14 @@ dependencies {
compile 'com.mikepenz:fontawesome-typeface:4.6.0.1@aar'
compile 'com.github.paolorotolo:appintro:3.4.0'
compile 'com.yalantis:ucrop:1.5.0'
- compile(group: 'uz.shift', name: 'colorpicker', version: '0.5', ext: 'aar')
+ compile 'uz.shift:colorpicker:0.5@aar'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.commit451:PhotoView:1.2.5'
compile 'com.google.android.exoplayer:exoplayer:r1.5.7'
- compile('de.psdev.licensesdialog:licensesdialog:1.8.0')
+ compile 'de.psdev.licensesdialog:licensesdialog:1.8.0'
compile 'com.android.support:customtabs:23.4.0'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.5.0'
+ compile 'de.hdodenhof:circleimageview:2.0.0'
+ compile 'com.drewnoakes:metadata-extractor:2.9.1'
+ compile 'org.jetbrains:annotations-java5:15.0'
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c232f8a42..212daea98 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -112,7 +112,7 @@
diff --git a/app/src/main/assets/fonts/Hipstelvetica Bold.ttf b/app/src/main/assets/fonts/Hipstelvetica Bold.ttf
deleted file mode 100644
index 2bc607d0b..000000000
Binary files a/app/src/main/assets/fonts/Hipstelvetica Bold.ttf and /dev/null differ
diff --git a/app/src/main/assets/fonts/Hipstelvetica Light.ttf b/app/src/main/assets/fonts/Hipstelvetica Light.ttf
deleted file mode 100644
index 9dd0f586b..000000000
Binary files a/app/src/main/assets/fonts/Hipstelvetica Light.ttf and /dev/null differ
diff --git a/app/src/main/assets/fonts/Hipstelvetica UltraLight.ttf b/app/src/main/assets/fonts/Hipstelvetica UltraLight.ttf
deleted file mode 100644
index 55870ecd2..000000000
Binary files a/app/src/main/assets/fonts/Hipstelvetica UltraLight.ttf and /dev/null differ
diff --git a/app/src/main/assets/fonts/Margot-BoldItalic.ttf b/app/src/main/assets/fonts/Margot-BoldItalic.ttf
deleted file mode 100644
index a1cd5d263..000000000
Binary files a/app/src/main/assets/fonts/Margot-BoldItalic.ttf and /dev/null differ
diff --git a/app/src/main/assets/fonts/Metrica-Regular.otf b/app/src/main/assets/fonts/Metrica-Regular.otf
deleted file mode 100644
index 336a55e04..000000000
Binary files a/app/src/main/assets/fonts/Metrica-Regular.otf and /dev/null differ
diff --git a/app/src/main/java/com/horaapps/leafpic/AboutActivity.java b/app/src/main/java/com/horaapps/leafpic/AboutActivity.java
index 532de3f60..a4986318d 100644
--- a/app/src/main/java/com/horaapps/leafpic/AboutActivity.java
+++ b/app/src/main/java/com/horaapps/leafpic/AboutActivity.java
@@ -1,20 +1,26 @@
package com.horaapps.leafpic;
+import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.widget.CardView;
import android.support.v7.widget.Toolbar;
+import android.text.method.LinkMovementMethod;
import android.view.View;
-import android.widget.LinearLayout;
+import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
+import android.widget.Toast;
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.Priority;
import com.horaapps.leafpic.Views.ThemedActivity;
import com.horaapps.leafpic.utils.CustomTabService;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.iconics.view.IconicsImageView;
+import de.hdodenhof.circleimageview.CircleImageView;
import de.psdev.licensesdialog.LicensesDialog;
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
import de.psdev.licensesdialog.licenses.MITLicense;
@@ -26,31 +32,21 @@
*/
public class AboutActivity extends ThemedActivity {
- Toolbar toolbar;
-
- /**** Title Cards ***/
- TextView txtLP;
- TextView txtAT;
- TextView txtSU;
- TextView txtLI;
+ private Toolbar toolbar;
+ int color;
/**** CustomTabService*/
- CustomTabService cts;
-
- /**** Buttons ***/
+ private CustomTabService cts;
/**** Scroll View*/
- ScrollView scr;
+ private ScrollView scr;
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
setContentView(R.layout.activity_about);
toolbar = (Toolbar) findViewById(R.id.toolbar);
- txtLP = (TextView) findViewById(R.id.about_app_title);
- txtAT = (TextView) findViewById(R.id.about_authors_title);
- txtSU = (TextView) findViewById(R.id.about_support_title);
- txtLI = (TextView) findViewById(R.id.about_license_title);
+
setNavBarColor();
cts = new CustomTabService(AboutActivity.this,getPrimaryColor());
scr = (ScrollView)findViewById(R.id.aboutAct_scrollView);
@@ -62,7 +58,7 @@ public void onPostResume() {
setTheme();
}
- public void setTheme(){
+ private void setTheme(){
/**** ToolBar *****/
toolbar.setBackgroundColor(getPrimaryColor());
setSupportActionBar(toolbar);
@@ -89,38 +85,98 @@ public void onClick(View v) {
setRecentApp(getString(R.string.about));
/**** Title Cards ***/
- txtAT.setTextColor(getAccentColor());
- txtLP.setTextColor(getAccentColor());
- txtSU.setTextColor(getAccentColor());
- txtLI.setTextColor(getAccentColor());
-
- /***** Buttons *****/
-
- /***** Views *****/
- View authorDivider = findViewById(R.id.author_view_divider);
- authorDivider.setBackgroundColor(getSubTextColor());
+ color=getAccentColor();
+ ((TextView) findViewById(R.id.about_app_title)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_special_thanks_title)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_support_title)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_license_title)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_special_thanks_title)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_author_donald_mail_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_author_gilbert_mail_item)).setTextColor(color);
+ /***** LeafPic Header *****/
+ /*
+ Glide.with(this)
+ .load("https://lh5.googleusercontent.com/-aX4YeN8Cvdc/VizLlektHNI/AAAAAAAATE0/c8NUmcEs46QTVf-HITTbvo3e5dja6JwoQCL0B/w958-h539-no/flat_landscape_wallpaper_by_othrod-d8crs50.png")
+ .priority(Priority.HIGH)
+ .animate(R.anim.fade_in)
+ .into((ImageView) findViewById(R.id.leafpic_header));
+ */
+ /***** Donald Card *****/
+ /***** Images *****/
+ Glide.with(this)
+ .load("https://lh3.googleusercontent.com/-4lGmk-K4r4U/Vw1Vj8yERrI/AAAAAAAANww/FIsb58PcO-U-9AfD8FXfruK1c75SZ184QCL0B/w958-h539-no/asd.png")
+ .placeholder(getPlaceHolder())
+ .priority(Priority.HIGH)
+ .error(R.drawable.ic_error)
+ .animate(R.anim.fade_in)
+ .into((ImageView) findViewById(R.id.donald_header_img));
+ Glide.with(this)
+ .load("https://lh5.googleusercontent.com/-kp20brbsTS0/VLQv60zDLQI/AAAAAAAAD9s/Wu-g8p-OvdISYmyEC9aCQXNaxxUJYfD0QCL0B/w776-h779-no/IMG_20150112_164721.jpg")
+ //.placeholder(new IconicsDrawable(this, "gmd-person").sizeDp(90).color(getIconColor()))
+ .priority(Priority.HIGH)
+ .error(R.drawable.ic_error)
+ .animate(R.anim.fade_in)
+ .into((CircleImageView) findViewById(R.id.donald_profile_img));
+ ((CircleImageView) findViewById(R.id.donald_profile_img)).setBorderColor(getInvertedBackgroundColor());
+ /***** Object *****/
+ ((CardView) findViewById(R.id.about_donald_card)).setCardBackgroundColor(getCardBackgroundColor());
+ ((TextView) findViewById(R.id.donald_shtjefni)).setTextColor(getTextColor());
+ ((TextView) findViewById(R.id.donald_description)).setTextColor(getSubTextColor());
+ color=getAccentColor();
+ ((TextView) findViewById(R.id.about_author_donald_mail_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_author_donald_googleplus_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_author_donald_github_item)).setTextColor(color);
+
+ /***** Gilbert Card *****/
+ /***** Images *****/
+ Glide.with(this)
+ .load("https://lh6.googleusercontent.com/-CQSWRHA3PMU/U1giCTxx3LI/AAAAAAAAAZU/YVnUYwwnNOEE7ob0LyHmRnbUtEtC5znIQCL0B/w958-h639-no/1397233014-game-over-samus.jpg")
+ .placeholder(getPlaceHolder())
+ .priority(Priority.HIGH)
+ .error(R.drawable.ic_error)
+ .animate(R.anim.fade_in)
+ .into((ImageView) findViewById(R.id.gilbert_header_img));
+ Glide.with(this)
+ .load("https://lh6.googleusercontent.com/-gucGwwJrFMg/U4IErjai3SI/AAAAAAAAANI/YGGxrdWO88cIsIpYrYxaq2KjSDfinLTmACL0B/s779-no/PicsArt_1387801769612.jpg")
+ //.placeholder(new IconicsDrawable(this, "gmd-person").sizeDp(90).color(getIconColor()))
+ .priority(Priority.HIGH)
+ .error(R.drawable.ic_error)
+ .animate(R.anim.fade_in)
+ .into((CircleImageView) findViewById(R.id.gilbert_profile_img));
+ ((CircleImageView) findViewById(R.id.gilbert_profile_img)).setBorderColor(getInvertedBackgroundColor());
+ /***** Object *****/
+ ((CardView) findViewById(R.id.about_gilbert_card)).setCardBackgroundColor(getCardBackgroundColor());
+ ((TextView) findViewById(R.id.gilbert_ndresaj)).setTextColor(getTextColor());
+ ((TextView) findViewById(R.id.gilbert_description)).setTextColor(getSubTextColor());
+ color=getAccentColor();
+ ((TextView) findViewById(R.id.about_author_gilbert_mail_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_author_gilbert_googleplus_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_author_gilbert_github_item)).setTextColor(color);
/***** ScrolView *****/
setScrollViewColor(scr);
setThemeOnChangeListener();
- ClickListeners();
+ setUpActions();
}
- public void ClickListeners(){
+ private void setUpActions(){
- ///GitHub
+ //GitHub
findViewById(R.id.ll_about_support_github).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- //Intent i = new Intent(Intent.ACTION_VIEW);
- //i.setData(Uri.parse("https://github.com/HoraApps/LeafPic"));
- //startActivity(i);
cts.launchUrl("https://github.com/HoraApps/LeafPic");
-
}
});
+ ///Report bug
+ findViewById(R.id.ll_about_report_bug).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ cts.launchUrl("https://github.com/HoraApps/LeafPic/issues");
+ }
+ });
//Crowdin
findViewById(R.id.ll_about_support_translate).setOnClickListener(new View.OnClickListener() {
@Override
@@ -129,28 +185,69 @@ public void onClick(View v) {
/*** Donald Shtjefni ***/
//G+
- findViewById(R.id.ll_donald_googleplus).setOnClickListener(new View.OnClickListener() {
+ findViewById(R.id.about_author_donald_googleplus_item).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { cts.launchUrl("https://plus.google.com/103359244653769120543/about");}
});
//Github
- findViewById(R.id.ll_donald_github).setOnClickListener(new View.OnClickListener() {
+ findViewById(R.id.about_author_donald_github_item).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { cts.launchUrl("https://github.com/DNLDsht");}
});
+ //Send Mail
+ findViewById(R.id.about_author_donald_mail_item).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent i = new Intent(Intent.ACTION_SEND);
+ i.setType("message/rfc822");
+ i.putExtra(Intent.EXTRA_EMAIL, new String[]{"dnld.sht@gmail.com"});
+ try {
+ startActivity(Intent.createChooser(i, getString(R.string.send_via)));
+ } catch (android.content.ActivityNotFoundException ex) {
+ Toast.makeText(AboutActivity.this, getString(R.string.send_mail_error), Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
/*** Gilbert Ndresaj ***/
//Github
- findViewById(R.id.ll_gilbert_googleplus).setOnClickListener(new View.OnClickListener() {
+ findViewById(R.id.about_author_gilbert_googleplus_item).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { cts.launchUrl("https://plus.google.com/118430643662868782426/about");}
});
//Github
- findViewById(R.id.ll_gilbert_github).setOnClickListener(new View.OnClickListener() {
+ findViewById(R.id.about_author_gilbert_github_item).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { cts.launchUrl("https://github.com/Mow3l");}
});
+ //Send Mail
+ findViewById(R.id.about_author_gilbert_mail_item).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent i = new Intent(Intent.ACTION_SEND);
+ i.setType("message/rfc822");
+ i.putExtra(Intent.EXTRA_EMAIL , new String[]{"jibo95@gmail.com"});
+ try {
+ startActivity(Intent.createChooser(i, getString(R.string.send_via)));
+ } catch (android.content.ActivityNotFoundException ex) {
+ Toast.makeText(AboutActivity.this, getString(R.string.send_mail_error), Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+
+ /*** SPECIAL THANKS ***/
+ /*** Patryk Goworowski ***/
+ //G+
+ //((TextView) findViewById(R.id.about_patryk_goworowski_googleplus_item)).setTextColor(getAccentColor());
+ /*findViewById(R.id.about_patryk_goworowski_googleplus_item).setOnClickListener(new View
+ .OnClickListener() {
+ @Override
+ public void onClick(View v) { cts.launchUrl("https://plus.google.com/109304801957014561872/about");}
+ });*/
+ ((TextView) findViewById(R.id.about_patryk_goworowski_item_sub)).setMovementMethod(LinkMovementMethod.getInstance());
+ ((TextView) findViewById(R.id.about_patryk_goworowski_item_sub)).setLinkTextColor(getAccentColor());
+ //((TextView) findViewById(R.id.about_comunity_members_sub)).setMovementMethod(LinkMovementMethod.getInstance());
//License
findViewById(R.id.ll_about_license).setOnClickListener(new View.OnClickListener() {
@Override
@@ -165,96 +262,58 @@ public void onClick(View v) {
}
- public void setThemeOnChangeListener(){
+ private void setThemeOnChangeListener(){
/** BackGround **/
- LinearLayout bg = (LinearLayout) findViewById(R.id.about_background);
- bg.setBackgroundColor(getBackgroundColor());
+ findViewById(R.id.about_background).setBackgroundColor(getBackgroundColor());
/** Cards **/
- CardView cvApp = (CardView) findViewById(R.id.about_app_card);
- CardView cvAuthor = (CardView) findViewById(R.id.about_authors_card);
- CardView cvSupport = (CardView) findViewById(R.id.about_support_card);
- CardView cvLicense = (CardView) findViewById(R.id.about_license_card);
-
- int color = getCardBackgroundColor();
- cvApp.setCardBackgroundColor(color);
- cvAuthor.setCardBackgroundColor(color);
- cvSupport.setCardBackgroundColor(color);
- cvLicense.setCardBackgroundColor(color);
+ color = getCardBackgroundColor();
+ ((CardView) findViewById(R.id.about_app_card)).setCardBackgroundColor(color);
+ ((CardView) findViewById(R.id.about_special_thanks_card)).setCardBackgroundColor(color);
+ ((CardView) findViewById(R.id.about_support_card)).setCardBackgroundColor(color);
+ ((CardView) findViewById(R.id.about_license_card)).setCardBackgroundColor(color);
+ //cvSpecialThanks.setBackgroundColor(color);
/** Icons **/
//ABOUT APP
- //IconicsImageView imgAAV = (IconicsImageView) findViewById(R.id.about_version_icon);
- IconicsImageView imgAALL = (IconicsImageView) findViewById(R.id.about_libs_icon);
- IconicsImageView imgALicense = (IconicsImageView) findViewById(R.id.about_license_icon);
-
- //ABOUT AUTHOR
- IconicsImageView imgDonald = (IconicsImageView) findViewById(R.id.about_author_donald_icon);
- IconicsImageView imgGilbert = (IconicsImageView) findViewById(R.id.about_author_gilbert_icon);
+ color = getIconColor();
+ ((IconicsImageView) findViewById(R.id.about_libs_icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.about_license_icon)).setColor(color);
//ABOUT SUPPORT
- IconicsImageView imgSRate = (IconicsImageView) findViewById(R.id.about_support_translate_icon);
- IconicsImageView imgSTranslate = (IconicsImageView) findViewById(R.id.about_support_rate_icon);
- IconicsImageView imgSGitHub = (IconicsImageView) findViewById(R.id.about_support_github_icon);
-
- color = getIconColor();
- //imgAAV.setColor(color);
- imgAALL.setColor(color);
- imgDonald.setColor(color);
- imgGilbert.setColor(color);
- imgSRate.setColor(color);
- imgSTranslate.setColor(color);
- imgSGitHub.setColor(color);
- imgALicense.setColor(color);
+ ((IconicsImageView) findViewById(R.id.about_support_translate_icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.about_support_rate_icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.about_support_github_icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.about_support_report_bug_icon)).setColor(color);
/** TextViews **/
- //TextView txtAV = (TextView) findViewById(R.id.about_version_item);
- TextView txtAL = (TextView) findViewById(R.id.about_libs_item);
- TextView txtLDesc = (TextView) findViewById(R.id.about_app_light_description);
- TextView txtDName = (TextView) findViewById(R.id.about_author_donald_item);
- TextView txtGName = (TextView) findViewById(R.id.about_author_gilbert_item);
- TextView txtSRate = (TextView) findViewById(R.id.about_support_rate_item);
- TextView txtSTranslate = (TextView) findViewById(R.id.about_support_translate_item);
- TextView txtSGitHub = (TextView) findViewById(R.id.about_support_github_item);
- TextView txtALicense = (TextView) findViewById(R.id.about_license_item);
- TextView txtALicense_Sub = (TextView) findViewById(R.id.about_license_item_sub);
-
- color=getTextColor();
- //txtAV.setTextColor(color);
- txtLDesc.setTextColor(color);
- txtAL.setTextColor(color);
- txtDName.setTextColor(color);
- txtGName.setTextColor(color);
- txtSRate.setTextColor(color);
- txtSTranslate.setTextColor(color);
- txtSGitHub.setTextColor(color);
- txtALicense.setTextColor(color);
+ color = getTextColor();
+ ((TextView) findViewById(R.id.about_libs_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_app_light_description)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_support_rate_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_support_translate_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_support_github_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_license_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_support_report_bug_item)).setTextColor(color);
/** Sub Text Views**/
- TextView txtAV_Sub = (TextView) findViewById(R.id.about_version_item_sub);
- TextView txtAL_Sub = (TextView) findViewById(R.id.about_libs_item_sub);
- TextView txtDName_Sub = (TextView) findViewById(R.id.about_author_donald_item_sub);
- TextView txtGName_Sub = (TextView) findViewById(R.id.about_author_gilbert_item_sub);
- TextView txtSRate_Sub = (TextView) findViewById(R.id.about_support_rate_item_sub);
- TextView txtSTranslate_Sub = (TextView) findViewById(R.id.about_support_translate_item_sub);
- TextView txtSGitHub_Sub = (TextView) findViewById(R.id.about_support_github_item_sub);
-
- txtAV_Sub.setText(BuildConfig.VERSION_NAME);
-
- color=getSubTextColor();
- txtAV_Sub.setTextColor(color);
- txtAL_Sub.setTextColor(color);
- txtDName_Sub.setTextColor(color);
- txtGName_Sub.setTextColor(color);
- txtSRate_Sub.setTextColor(color);
- txtSTranslate_Sub.setTextColor(color);
- txtSGitHub_Sub.setTextColor(color);
- txtALicense_Sub.setTextColor(color);
-
+ color = getSubTextColor();
+ ((TextView) findViewById(R.id.about_version_item_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_version_item_sub)).setText(BuildConfig.VERSION_NAME);
+ ((TextView) findViewById(R.id.about_libs_item_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_patryk_goworowski_item_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_comunity_members_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_comunity_you_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_support_rate_item_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_support_translate_item_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_support_github_item_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_license_item_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.about_support_report_bug_sub)).setTextColor(color);
}
- public void licenseDialog(){
+ private void licenseDialog() {
+ //TODO I HATE THIS redo please.
final Notices notices = new Notices();
notices.addNotice(new Notice("Glide", "http://github.com/bumptech/glide", "Copyright 2014 Google, Inc. All rights reserved.", new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("Ion", "http://github.com/koush/ion", "Copyright 2013 Koushik Dutta (2013)", new ApacheSoftwareLicense20()));
@@ -265,6 +324,7 @@ public void licenseDialog(){
notices.addNotice(new Notice("ShiftColorPicker", "http://github.com/DASAR/ShiftColorPicker", "Copyright (c) 2015 Bogdasarov Bogdan", new MITLicense()));
notices.addNotice(new Notice("material-ripple", "http://github.com/balysv/material-ripple", "Copyright 2015 Balys Valentukevicius", new ApacheSoftwareLicense20()));
notices.addNotice(new Notice("PhotoView", "http://github.com/chrisbanes/PhotoView", "Copyright 2011, 2012 Chris Banes.", new ApacheSoftwareLicense20()));
+ notices.addNotice(new Notice("CircleImageView", "https://github.com/hdodenhof/CircleImageView", "Copyright 2014 - 2015 Henning Dodenhof", new ApacheSoftwareLicense20()));
new LicensesDialog.Builder(this)
.setNotices(notices)
diff --git a/app/src/main/java/com/horaapps/leafpic/Adapters/AlbumsAdapter.java b/app/src/main/java/com/horaapps/leafpic/Adapters/AlbumsAdapter.java
index 7b492f23f..07fbd2d9c 100644
--- a/app/src/main/java/com/horaapps/leafpic/Adapters/AlbumsAdapter.java
+++ b/app/src/main/java/com/horaapps/leafpic/Adapters/AlbumsAdapter.java
@@ -4,6 +4,7 @@
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.PorterDuff;
+import android.graphics.drawable.BitmapDrawable;
import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.CardView;
@@ -24,6 +25,7 @@
import com.horaapps.leafpic.Base.Album;
import com.horaapps.leafpic.Base.Media;
import com.horaapps.leafpic.R;
+import com.horaapps.leafpic.Views.ThemedActivity;
import java.util.ArrayList;
@@ -32,19 +34,38 @@
*/
public class AlbumsAdapter extends RecyclerView.Adapter {
- ArrayList albums;
- SharedPreferences SP;
+ private ArrayList albums;
+ private SharedPreferences SP;
private View.OnClickListener mOnClickListener;
private View.OnLongClickListener mOnLongClickListener;
- public AlbumsAdapter(ArrayList ph, Context ctx) {
+ private int theme_code = 1;
+ private BitmapDrawable placeholder;
+
+ public AlbumsAdapter(ArrayList ph, Context context) {
albums = ph;
- SP = PreferenceManager.getDefaultSharedPreferences(ctx);
+ SP = PreferenceManager.getDefaultSharedPreferences(context);
+ updateTheme(context, SP.getInt("basic_theme", ThemedActivity.LIGHT_THEME));
+ }
+
+ public void updateTheme(Context context, int theme) {
+ theme_code = theme;
+ switch (theme){
+ case ThemedActivity.DARK_THEME:
+ placeholder = ((BitmapDrawable) ContextCompat.getDrawable(context, R.drawable.ic_empty));
+ break;
+ case ThemedActivity.AMOLED_THEME:
+ placeholder = ((BitmapDrawable) ContextCompat.getDrawable(context, R.drawable.ic_empty_amoled));;
+ break;
+ case ThemedActivity.LIGHT_THEME: default:
+ placeholder = ((BitmapDrawable) ContextCompat.getDrawable(context, R.drawable.ic_empty_white));
+ break;
+ }
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.album_card, parent, false);
+ View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_album, parent, false);
v.setOnClickListener(mOnClickListener);
v.setOnLongClickListener(mOnLongClickListener);
@@ -73,11 +94,7 @@ public void onBindViewHolder(final AlbumsAdapter.ViewHolder holder, int position
.signature(new StringSignature(f.getPath() +"-"+ f.getDateModified()))
.centerCrop()
.error(R.drawable.ic_error)
- .placeholder(SP.getInt("basic_theme", 1)==1
- ? R.drawable.ic_empty_white
- : (SP.getInt("basic_theme", 1)==2
- ? R.drawable.ic_empty
- : R.drawable.ic_empty_amoled))
+ .placeholder(placeholder)
.animate(R.anim.fade_in)
.into(holder.picture);
@@ -95,20 +112,20 @@ public void onBindViewHolder(final AlbumsAdapter.ViewHolder holder, int position
hexAccentColor= String.format("#%06X", (0xFFFFFF & color));
}
- String textColor = SP.getInt("basic_theme", 1)!=1 ? "#FAFAFA" : "#2b2b2b";
+ String textColor = theme_code != ThemedActivity.LIGHT_THEME ? "#FAFAFA" : "#2b2b2b";
if (a.isSelected()) {
holder.card_layout.setBackgroundColor(Color.parseColor(hexPrimaryColor));
holder.picture.setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP);
holder.selectHolder.setVisibility(View.VISIBLE);
- if (SP.getInt("basic_theme", 1)==1 ) textColor ="#FAFAFA";
+ if (theme_code == ThemedActivity.LIGHT_THEME ) textColor ="#FAFAFA";
} else {
holder.picture.clearColorFilter();
holder.selectHolder.setVisibility(View.GONE);
- if (SP.getInt("basic_theme", 1)==1)
+ if (theme_code == ThemedActivity.LIGHT_THEME)
holder.card_layout.setBackgroundColor(ContextCompat.getColor(c, R.color.md_light_cards));
- else if (SP.getInt("basic_theme", 1)==2)
+ else if (theme_code == ThemedActivity.DARK_THEME)
holder.card_layout.setBackgroundColor(ContextCompat.getColor(c, R.color.md_dark_cards));
else holder.card_layout.setBackgroundColor(ContextCompat.getColor(c, R.color.md_black_1000));
}
@@ -126,19 +143,17 @@ public void setOnLongClickListener(View.OnLongClickListener lis) {
mOnLongClickListener = lis;
}
- public void updateDataset(ArrayList asd) {
+ public void updateDataSet(ArrayList asd) {
albums = asd;
notifyDataSetChanged();
}
-
-
@Override
public int getItemCount() {
return albums.size();
}
- public static class ViewHolder extends RecyclerView.ViewHolder {
+ static class ViewHolder extends RecyclerView.ViewHolder {
LinearLayout card_layout;
ImageView picture;
ImageView selectHolder;
@@ -146,7 +161,7 @@ public static class ViewHolder extends RecyclerView.ViewHolder {
TextView nPhotos;
CardView cv;
- public ViewHolder(View itemView) {
+ ViewHolder(View itemView) {
super(itemView);
picture = (ImageView) itemView.findViewById(R.id.album_preview);
selectHolder = (ImageView) itemView.findViewById(R.id.selected_icon);
diff --git a/app/src/main/java/com/horaapps/leafpic/Adapters/MediaPagerAdapter.java b/app/src/main/java/com/horaapps/leafpic/Adapters/MediaPagerAdapter.java
index 1c86bac6b..fd947e2dd 100644
--- a/app/src/main/java/com/horaapps/leafpic/Adapters/MediaPagerAdapter.java
+++ b/app/src/main/java/com/horaapps/leafpic/Adapters/MediaPagerAdapter.java
@@ -21,14 +21,14 @@
public class MediaPagerAdapter extends FragmentStatePagerAdapter {
- ArrayList medias;
- View.OnClickListener videoOnClickListener;
- SparseArray registeredFragments = new SparseArray();
+ private ArrayList media;
+ private View.OnClickListener videoOnClickListener;
+ private SparseArray registeredFragments = new SparseArray();
- public MediaPagerAdapter(FragmentManager fm, ArrayList medias) {
+ public MediaPagerAdapter(FragmentManager fm, ArrayList media) {
super(fm);
- this.medias = medias;
+ this.media = media;
}
public void setVideoOnClickListener(View.OnClickListener videoOnClickListener) {
@@ -37,15 +37,14 @@ public void setVideoOnClickListener(View.OnClickListener videoOnClickListener) {
@Override
public Fragment getItem(int pos) {
- Media p = medias.get(pos);
- if (p.isImage()) {
- if (p.isGif()) return GifFragment.newInstance(p.getPath());
- else return ImageFragment.newInstance(p);
- } else {
+ Media p = media.get(pos);
+ if (p.isVideo()) {
VideoFragment fragment = VideoFragment.newInstance(p.getPath());
fragment.setOnClickListener(videoOnClickListener);
return fragment;
}
+ if (p.isGif()) return GifFragment.newInstance(p.getPath());
+ else return ImageFragment.newInstance(p);
}
@Override
@@ -65,6 +64,11 @@ public Fragment getRegisteredFragment(int position) {
return registeredFragments.get(position);
}
+ public void swapDataSet(ArrayList media) {
+ this.media = media;
+ notifyDataSetChanged();
+ }
+
@Override
public int getItemPosition(Object object) {
return PagerAdapter.POSITION_NONE;
@@ -72,6 +76,6 @@ public int getItemPosition(Object object) {
@Override
public int getCount() {
- return medias.size();
+ return media.size();
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/horaapps/leafpic/Adapters/PhotosAdapter.java b/app/src/main/java/com/horaapps/leafpic/Adapters/PhotosAdapter.java
index 8f9e5e057..51e639720 100644
--- a/app/src/main/java/com/horaapps/leafpic/Adapters/PhotosAdapter.java
+++ b/app/src/main/java/com/horaapps/leafpic/Adapters/PhotosAdapter.java
@@ -15,9 +15,9 @@
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
-import com.bumptech.glide.signature.MediaStoreSignature;
import com.bumptech.glide.signature.StringSignature;
import com.horaapps.leafpic.Base.Media;
+import com.horaapps.leafpic.Views.ThemedActivity;
import com.koushikdutta.ion.Ion;
import com.horaapps.leafpic.R;
@@ -30,34 +30,33 @@
public class PhotosAdapter extends RecyclerView.Adapter {
- ArrayList medias;
- SharedPreferences SP;
+ private ArrayList medias;
- BitmapDrawable drawable;
+ private BitmapDrawable drawable;
private View.OnClickListener mOnClickListener;
private View.OnLongClickListener mOnLongClickListener;
public PhotosAdapter(ArrayList ph , Context context) {
medias = ph;
- SP = PreferenceManager.getDefaultSharedPreferences(context);
- updatePlaceholder(context, SP.getInt("basic_theme", 1));
+ SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(context);
+ updatePlaceholder(context, SP.getInt("basic_theme", ThemedActivity.LIGHT_THEME));
}
public void updatePlaceholder(Context context, int theme) {
switch (theme){
- case 2: drawable = ((BitmapDrawable) ContextCompat.getDrawable(context, R.drawable.ic_empty));break;
- case 3: drawable = null ;break;
- case 1: default: drawable = ((BitmapDrawable) ContextCompat.getDrawable(context, R.drawable.ic_empty_white));break;
+ case ThemedActivity.DARK_THEME:
+ drawable = ((BitmapDrawable) ContextCompat.getDrawable(context, R.drawable.ic_empty));
+ break;
+ case ThemedActivity.AMOLED_THEME: drawable = null; break;
+ case ThemedActivity.LIGHT_THEME: default:
+ drawable = ((BitmapDrawable) ContextCompat.getDrawable(context, R.drawable.ic_empty_white));
+ break;
}
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.photo_card, parent, false);
-
- //int width=v.getLayoutParams().width;
- //v.setLayoutParams(new FrameLayout.LayoutParams(v.getWidth(), v.getWidth()));//width , width
-
+ View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_photo, parent, false);
v.setOnClickListener(mOnClickListener);
v.setOnLongClickListener(mOnLongClickListener);
/*return new ViewHolder(
@@ -78,11 +77,11 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
public void onBindViewHolder(final PhotosAdapter.ViewHolder holder, int position) {
Media f = medias.get(position);
- byte[] thumnail = f.getThumnail();
+ byte[] thumbnail = f.getThumbnail();
- if (thumnail != null) {
+ if (thumbnail != null) {
Glide.with(holder.imageView.getContext())
- .load(thumnail)
+ .load(thumbnail)
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.placeholder(drawable)
@@ -98,11 +97,10 @@ public void onBindViewHolder(final PhotosAdapter.ViewHolder holder, int position
Glide.with(holder.imageView.getContext())
.load(f.getPath())
.asBitmap()
- .signature(new StringSignature(f.getPath() +"-"+ f.getDateModified()))
+ .signature(new StringSignature(f.getPath() + "-" + f.getDateModified()))
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.placeholder(drawable)
- //.placeholder(SP.getBoolean("set_dark_theme", true) ? R.drawable.ic_empty : R.drawable.ic_empty_white)
.animate(R.anim.fade_in)
.into(holder.imageView);
holder.gifIcon.setVisibility(View.GONE);
@@ -142,11 +140,11 @@ public void updateDataSet(ArrayList asd) {
}
- public static class ViewHolder extends RecyclerView.ViewHolder {
+ static class ViewHolder extends RecyclerView.ViewHolder {
ImageView imageView, selectHolder, gifIcon, videoIcon;
TextView path;
- public ViewHolder(View itemView) {
+ ViewHolder(View itemView) {
super(itemView);
imageView = (ImageView) itemView.findViewById(R.id.photo_preview);
selectHolder = (ImageView) itemView.findViewById(R.id.selected_icon);
diff --git a/app/src/main/java/com/horaapps/leafpic/Base/Album.java b/app/src/main/java/com/horaapps/leafpic/Base/Album.java
index 1fb01e0b9..f20cff94f 100644
--- a/app/src/main/java/com/horaapps/leafpic/Base/Album.java
+++ b/app/src/main/java/com/horaapps/leafpic/Base/Album.java
@@ -5,20 +5,18 @@
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.preference.PreferenceManager;
-import android.util.Log;
import com.horaapps.leafpic.Adapters.PhotosAdapter;
-import com.horaapps.leafpic.MyApplication;
import com.horaapps.leafpic.R;
+import com.horaapps.leafpic.utils.ContentHelper;
import com.horaapps.leafpic.utils.StringUtils;
+import org.jetbrains.annotations.NotNull;
+
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
/**
* Created by dnld on 26/04/16.
@@ -26,77 +24,86 @@
public class Album {
String name = null;
- String path = null;
- int count = -1;
- boolean selected = false;
- private int filter_photos;
+ private String path = null;
+ private int count = -1;
+ private boolean selected = false;
+ private int filter;
public AlbumSettings settings = new AlbumSettings();
- SharedPreferences SP;
- MediaComparators mediaComparators;
- int current = -1;
+ private int currentMediaIndex = 0;
+
+ private String storageRootPath;
public ArrayList media = new ArrayList();
public ArrayList selectedMedias = new ArrayList();
- public Album() {
- media = new ArrayList();
- selectedMedias = new ArrayList();
- }
+ public Album() { }
- public Album(String path, String name, int count) {
+ public Album(String path, String name) {
media = new ArrayList();
selectedMedias = new ArrayList();
this.path = path;
this.name = name;
+ }
+
+ public Album(String path, String name, int count, String storageRootPath) {
+ this(path, name, count);
+ this.storageRootPath = storageRootPath;
+ }
+
+ public Album(String path, String name, int count) {
+ this(path, name);
this.count = count;
}
- public Album(Context context, String mediaPath) {
- File folder = new File(mediaPath).getParentFile();
+ public Album(Context context, @NotNull File mediaPath) {
+ File folder = mediaPath.getParentFile();
media = new ArrayList();
selectedMedias = new ArrayList();
this.path = folder.getPath();
this.name = folder.getName();
updatePhotos(context);
- setCurrentPhoto(mediaPath);
+ setCurrentPhoto(mediaPath.getAbsolutePath());
}
- public Album(String path, String name) {
+ public Album(Context context, Uri mediaUri) {
media = new ArrayList();
selectedMedias = new ArrayList();
- this.path = path;
- this.name = name;
- //updatePhotos();
+ media.add(0, new Media(context, mediaUri));
+ setCurrentPhotoIndex(0);
}
public void updatePhotos(Context context) {
- SP = PreferenceManager.getDefaultSharedPreferences(context);
+ SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(context);
ArrayList mediaArrayList = new ArrayList();
- File[] images = new File(getPath()).listFiles(new ImageFileFilter(filter_photos, SP.getBoolean("set_include_video",true)));
+ File[] images = new File(getPath()).listFiles(new ImageFileFilter(filter, SP.getBoolean("set_include_video",true)));
for (File image : images)
- mediaArrayList.add(0, new Media(image.getAbsolutePath(), image.lastModified(), image.length()));
+ mediaArrayList.add(0, new Media(image));
media = mediaArrayList;
sortPhotos();
setCount(media.size());
}
- /* public void updatePhotos(PhotosAdapter adapter) {
- media = new ArrayList();
- File[] images = new File(getPath()).listFiles(new ImageFileFilter(filter_photos));
- for (int i = 0; i < images.length; i++) {
- media.add(0, new Media(images[i].getAbsolutePath(), images[i].lastModified(), images[i].length()));
- adapter.notifyItemInserted(i);
- }
- sortPhotos();
- adapter.notifyDataSetChanged();
- }*/
+ public ArrayList getParentsFolders() {
+ ArrayList result = new ArrayList();
+ String[] asd = getPath().split("/");
+ String[] asdroot = storageRootPath.split("/");
- public boolean areFiltersActive() {
- return filter_photos != ImageFileFilter.FILTER_ALL;
+ String conc = storageRootPath;
+ result.add(conc);
+ for (int i = asdroot.length; i < asd.length; i++)
+ result.add(conc += "/" + asd[i]);
+
+ Collections.sort(result, new Comparator() {
+ @Override
+ public int compare(String lhs, String rhs) {
+ return Integer.compare(rhs.length(), lhs.length());
+ }
+ });
+ return result;
}
public void filterMedias(Context context, int filter) {
- filter_photos = filter;
+ this.filter = filter;
updatePhotos(context);
}
@@ -109,7 +116,7 @@ public boolean hasCustomCover() {
return settings.coverPath != null;
}
- public void setSelected(boolean selected) {
+ void setSelected(boolean selected) {
this.selected = selected;
}
@@ -119,11 +126,11 @@ public boolean isSelected() {
public Media getMedia(int index) { return media.get(index); }
- public void setCurrentPhotoIndex(int index){ current = index; }
+ public void setCurrentPhotoIndex(int index){ currentMediaIndex = index; }
- public Media getCurrentMedia() { return getMedia(current); }
+ public Media getCurrentMedia() { return getMedia(currentMediaIndex); }
- public int getCurrentMediaIndex() { return current; }
+ public int getCurrentMediaIndex() { return currentMediaIndex; }
public String getContentDescription(Context c) {
return c.getString(R.string.media);
@@ -137,7 +144,7 @@ public String getPath() {
return path;
}
- public void setCount(int count) {
+ private void setCount(int count) {
this.count = count;
}
@@ -145,7 +152,7 @@ public int getCount() {
return count;
}
- public void setCoverPath(String path) {
+ void setCoverPath(String path) {
settings.coverPath = path;
}
@@ -169,21 +176,24 @@ public void setSelectedPhotoAsPreview(Context context) {
}
}
- public void setCurrentPhoto(String path) {
+ private void setCurrentPhoto(String path) {
for (int i = 0; i < media.size(); i++)
- if (media.get(i).getPath().equals(path)) current = i;
+ if (media.get(i).getPath().equals(path)) currentMediaIndex = i;
}
public int getSelectedCount() {
return selectedMedias.size();
}
+ public boolean areMediaSelected() { return getSelectedCount() != 0;}
+
public void selectAllPhotos() {
- for (int i = 0; i < media.size(); i++)
+ for (int i = 0; i < media.size(); i++) {
if (!media.get(i).isSelected()) {
media.get(i).setSelected(true);
selectedMedias.add(media.get(i));
}
+ }
}
public int toggleSelectPhoto(int index) {
@@ -203,31 +213,32 @@ public void setDefaultSortingMode(Context context, int column) {
settings.columnSortingMode = column;
}
- public void renameCurrentMedia(Context context, String newName) {
+ public boolean renameCurrentMedia(Context context, String newName) {
+ boolean success = false;
try {
File from = new File(getCurrentMedia().getPath());
File to = new File(StringUtils.getPhotoPathRenamed(getCurrentMedia().getPath(), newName));
- if (from.renameTo(to)) {
+ if (success = ContentHelper.moveFile(context, from, to)) {
scanFile(context, new String[]{ to.getAbsolutePath(), from.getAbsolutePath() });
getCurrentMedia().path = to.getAbsolutePath();
}
- } catch (Exception e) {
- e.printStackTrace();
- }
+ } catch (Exception e) { e.printStackTrace(); }
+ return success;
}
- public int moveCurrentPhoto(Context context, String newName) {
+ public boolean moveCurrentPhoto(Context context, String newName) {
+ boolean success = false;
try {
File from = new File(getCurrentMedia().getPath());
File to = new File(StringUtils.getPhotoPathMoved(getCurrentMedia().getPath(), newName));
- if (from.renameTo(to)) {
+ if (success = ContentHelper.moveFile(context, from, to)) {
scanFile(context, new String[]{ to.getAbsolutePath(), from.getAbsolutePath() });
getCurrentMedia().path = to.getAbsolutePath();
media.remove(getCurrentMediaIndex());
setCount(media.size());
}
} catch (Exception e) { e.printStackTrace(); }
- return getCurrentMediaIndex();
+ return success;
}
public void setDefaultSortingAscending(Context context, Boolean ascending) {
@@ -273,14 +284,13 @@ public void selectAllPhotosUpTo(int targetIndex, PhotosAdapter adapter) {
}
public void clearSelectedPhotos() {
- for (Media m : media) {
+ for (Media m : media)
m.setSelected(false);
- }
selectedMedias.clear();
}
public void sortPhotos() {
- mediaComparators = new MediaComparators(settings.ascending);
+ MediaComparators mediaComparators = new MediaComparators(settings.ascending);
switch (settings.columnSortingMode) {
case AlbumSettings.SORT_BY_NAME:
Collections.sort(media, mediaComparators.getNameComparator());
@@ -288,6 +298,9 @@ public void sortPhotos() {
case AlbumSettings.SORT_BY_SIZE:
Collections.sort(media, mediaComparators.getSizeComparator());
break;
+ case AlbumSettings.SORT_BY_TYPE:
+ Collections.sort(media, mediaComparators.getTypeComparator());
+ break;
case AlbumSettings.SORT_BY_DATE:
default:
Collections.sort(media, mediaComparators.getDateComparator());
@@ -300,36 +313,30 @@ public void copySelectedPhotos(Context context, String folderPath) {
copyPhoto(context, media.getPath(), folderPath);
}
- public void copyPhoto(Context context, String olderPath, String folderPath) {
+ public boolean copyPhoto(Context context, String olderPath, String folderPath) {
+ boolean success = false;
try {
File from = new File(olderPath);
File to = new File(StringUtils.getPhotoPathMoved(olderPath, folderPath));
+ if (success = ContentHelper.copyFile(context, from, to))
+ scanFile(context, new String[]{ to.getAbsolutePath() });
- InputStream in = new FileInputStream(from);
- OutputStream out = new FileOutputStream(to);
-
- byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0)
- out.write(buf, 0, len);
-
- in.close();
- out.close();
-
- scanFile(context, new String[]{to.getAbsolutePath()});
} catch (Exception e) { e.printStackTrace(); }
+ return success;
}
public void deleteCurrentMedia(Context context) {
- deleteMedia(context, media.get(getCurrentMediaIndex()));
+ deleteMedia(context, getCurrentMedia());
media.remove(getCurrentMediaIndex());
setCount(media.size());
}
- public void deleteMedia(Context context, Media media) {
+ private boolean deleteMedia(Context context, Media media) {
+ boolean success;
File file = new File(media.getPath());
- if (file.delete())
+ if (success = ContentHelper.deleteFile(context, file))
scanFile(context, new String[]{ file.getAbsolutePath() });
+ return success;
}
public void deleteSelectedMedia(Context context) {
@@ -343,13 +350,13 @@ public void deleteSelectedMedia(Context context) {
public void renameAlbum(Context context, String newName) {
File dir = new File(StringUtils.getAlbumPathRenamed(getPath(), newName));
- if (dir.mkdir() || dir.exists()) {
+ if (ContentHelper.mkdir(context, dir)) {
path = dir.getAbsolutePath();
name = newName;
for (int i = 0; i < media.size(); i++) {
File from = new File(media.get(i).getPath());
File to = new File(StringUtils.getPhotoPathRenamedAlbumChange(media.get(i).getPath(), newName));
- if (from.renameTo(to)) {
+ if (ContentHelper.moveFile(context, from, to)) {
MediaScannerConnection.scanFile(context,
new String[]{from.getAbsolutePath(), to.getAbsolutePath()}, null, null);
media.get(i).path = to.getAbsolutePath();
@@ -358,6 +365,9 @@ public void renameAlbum(Context context, String newName) {
}
}
- public void scanFile(Context context, String[] path) { MediaScannerConnection.scanFile(context, path, null, null); }
+ public void scanFile(Context context, String[] path) { MediaScannerConnection.scanFile(context, path, null, null); }
+ public boolean areFiltersActive() {
+ return filter != ImageFileFilter.FILTER_ALL;
+ }
}
diff --git a/app/src/main/java/com/horaapps/leafpic/Base/AlbumSettings.java b/app/src/main/java/com/horaapps/leafpic/Base/AlbumSettings.java
index f3711cc73..29d3467bf 100644
--- a/app/src/main/java/com/horaapps/leafpic/Base/AlbumSettings.java
+++ b/app/src/main/java/com/horaapps/leafpic/Base/AlbumSettings.java
@@ -9,33 +9,24 @@
*/
public class AlbumSettings {
- /*public final static String SORT_BY_NAME = "sortByName";
- public final static String SORT_BY_DATE = "sortByDate";
- public final static String SORT_BY_SIZE = "sortBySize";*/
-
public final static int SORT_BY_NAME = 3;
public final static int SORT_BY_DATE = 0;
public final static int SORT_BY_SIZE = 1;
+ public final static int SORT_BY_TYPE = 2;
- public String coverPath;
+ String coverPath;
public int columnSortingMode;
public boolean ascending;
- public AlbumSettings(String cover, int SortingMode, boolean asce) {
+ AlbumSettings(String cover, int SortingMode, boolean asce) {
coverPath = cover;
columnSortingMode = SortingMode;
ascending = asce;
}
- public AlbumSettings() {
+ AlbumSettings() {
coverPath = null;
columnSortingMode = 0;
ascending = false;
}
-
- /*public String getSQLSortingMode() {
- columnSortingMode = columnSortingMode != null ? columnSortingMode : MediaStore.Images.ImageColumns.DATE_TAKEN;
- return columnSortingMode + (ascending ? " ASC" : " DESC");
- }*/
-
}
\ No newline at end of file
diff --git a/app/src/main/java/com/horaapps/leafpic/Base/AlbumsComparators.java b/app/src/main/java/com/horaapps/leafpic/Base/AlbumsComparators.java
index 768164a6e..a9e6107e5 100644
--- a/app/src/main/java/com/horaapps/leafpic/Base/AlbumsComparators.java
+++ b/app/src/main/java/com/horaapps/leafpic/Base/AlbumsComparators.java
@@ -5,14 +5,14 @@
/**
* Created by dnld on 26/04/16.
*/
-public class AlbumsComparators {
+class AlbumsComparators {
boolean ascending = true;
- public AlbumsComparators(boolean ascending){
+ AlbumsComparators(boolean ascending){
this.ascending = ascending;
}
- public Comparator getDateComparator(){
+ Comparator getDateComparator(){
return new Comparator(){
public int compare(Album f1, Album f2) {
return ascending
@@ -23,7 +23,7 @@ public int compare(Album f1, Album f2) {
};
}
- public Comparator getNameComparator() {
+ Comparator getNameComparator() {
return new Comparator() {
public int compare(Album f1, Album f2) {
return ascending
@@ -33,7 +33,7 @@ public int compare(Album f1, Album f2) {
};
}
- public Comparator getSizeComparator() {
+ Comparator getSizeComparator() {
return new Comparator() {
public int compare(Album f1, Album f2) {
return ascending
diff --git a/app/src/main/java/com/horaapps/leafpic/Base/CustomAlbumsHandler.java b/app/src/main/java/com/horaapps/leafpic/Base/CustomAlbumsHandler.java
index 0618cbe97..963c71617 100644
--- a/app/src/main/java/com/horaapps/leafpic/Base/CustomAlbumsHandler.java
+++ b/app/src/main/java/com/horaapps/leafpic/Base/CustomAlbumsHandler.java
@@ -54,21 +54,21 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
onCreate(db);
}
- public ArrayList getExcludedFolders() {
+ ArrayList getExcludedFolders() {
ArrayList list = new ArrayList();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cur = db.query(TABLE_ALBUMS, new String[]{ ALBUM_PATH }, ALBUM_EXCLUDED + "=1", null, null, null, null);
- if (cur.moveToFirst())
+ if (cur.moveToFirst()) {
do list.add(new File(cur.getString(0)));
while (cur.moveToNext());
-
+ }
cur.close();
db.close();
return list;
}
- public void clearAlbumExclude(String id) {
+ void clearAlbumExclude(String id) {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_ALBUMS + " SET " + ALBUM_EXCLUDED + "=0 WHERE " + ALBUM_PATH + "='" + StringUtils.quoteReplace(id) + "'");
db.close();
@@ -81,7 +81,7 @@ public void excludeAlbum(String path) {
db.close();
}
- public AlbumSettings getSettings(String id) {
+ AlbumSettings getSettings(String id) {
checkAndCreateAlbum(id);
AlbumSettings s = new AlbumSettings();
SQLiteDatabase db = this.getWritableDatabase();
@@ -93,7 +93,7 @@ public AlbumSettings getSettings(String id) {
return s;
}
- public void checkAndCreateAlbum(String path) {
+ private void checkAndCreateAlbum(String path) {
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery("SELECT " + ALBUM_PATH + " FROM " + TABLE_ALBUMS + " WHERE " + ALBUM_PATH + "='" + StringUtils.quoteReplace(path) + "'", null);
if (cursor.getCount() == 0) {
@@ -106,10 +106,10 @@ public void checkAndCreateAlbum(String path) {
db.close();
}
- public String getPhotPrevieAlbum(String id) {
+ String getCoverPathAlbum(String path) {
String s = null;
SQLiteDatabase db = this.getWritableDatabase();
- Cursor cursor = db.rawQuery("SELECT " + ALBUM_COVER + " FROM " + TABLE_ALBUMS + " WHERE " + ALBUM_PATH + "='" + StringUtils.quoteReplace(id)
+ Cursor cursor = db.rawQuery("SELECT " + ALBUM_COVER + " FROM " + TABLE_ALBUMS + " WHERE " + ALBUM_PATH + "='" + StringUtils.quoteReplace(path)
+ "'", null);
if (cursor.moveToFirst())
s = cursor.getString(0);
@@ -119,7 +119,7 @@ public String getPhotPrevieAlbum(String id) {
return s;
}
- public void setAlbumPhotPreview(String id, String path) {
+ void setAlbumPhotPreview(String id, String path) {
checkAndCreateAlbum(id);
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_ALBUMS + " SET " + ALBUM_COVER + "='" + path + "' WHERE " + ALBUM_PATH + "='" + StringUtils.quoteReplace(id) + "'");
@@ -133,7 +133,7 @@ public void clearAlbumPreview(String id) {
db.close();
}
- public void setAlbumSortingMode(String id, int column) {
+ void setAlbumSortingMode(String id, int column) {
checkAndCreateAlbum(id);
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_ALBUMS + " SET " + ALBUM_DEAFAULT_SORTMODE + "=" + column +
@@ -141,7 +141,7 @@ public void setAlbumSortingMode(String id, int column) {
db.close();
}
- public void setAlbumSortingAscending(String id, boolean asc) {
+ void setAlbumSortingAscending(String id, boolean asc) {
checkAndCreateAlbum(id);
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_ALBUMS + " SET " + ALBUM_DEAFAULT_SORT_ASCENDING + "=" + (asc ? 1 : 0) +
diff --git a/app/src/main/java/com/horaapps/leafpic/Base/ExternalStorage.java b/app/src/main/java/com/horaapps/leafpic/Base/ExternalStorage.java
deleted file mode 100644
index 4c1a79d9d..000000000
--- a/app/src/main/java/com/horaapps/leafpic/Base/ExternalStorage.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package com.horaapps.leafpic.Base;
-
-import android.os.Build;
-import android.os.Environment;
-import android.util.Log;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Scanner;
-
-/**
- * Created by dnld on 09/05/16.
- */
-public class ExternalStorage {
- public static final String SD_CARD = "sdCard";
- public static final String EXTERNAL_SD_CARD = "externalSdCard";
-
- /**
- * @return True if the external storage is available. False otherwise.
- */
- public static boolean isAvailable() {
- String state = Environment.getExternalStorageState();
- if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
- return true;
- }
- return false;
- }
-
- public static String getSdCardPath() {
- return Environment.getExternalStorageDirectory().getPath() + "/";
- }
-
- /**
- * @return True if the external storage is writable. False otherwise.
- */
- public static boolean isWritable() {
- String state = Environment.getExternalStorageState();
- if (Environment.MEDIA_MOUNTED.equals(state)) {
- return true;
- }
- return false;
-
- }
-
- /**
- * @return A map of all storage locations available
- */
- public static ArrayList getAllStorageLocations() {
- //Map map = new HashMap(10);
- ArrayList roots = new ArrayList();
-
- List mMounts = new ArrayList(10);
- List mVold = new ArrayList(10);
- mMounts.add("/mnt/sdcard");
- mVold.add("/mnt/sdcard");
-
- try {
- File mountFile = new File("/proc/mounts");
- if(mountFile.exists()){
- Scanner scanner = new Scanner(mountFile);
- while (scanner.hasNext()) {
- String line = scanner.nextLine();
- if (line.startsWith("/dev/block/vold/")) {
- String[] lineElements = line.split(" ");
- String element = lineElements[1];
-
- // don't add the default mount path
- // it's already in the list.
- if (!element.equals("/mnt/sdcard"))
- mMounts.add(element);
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- try {
- File voldFile = new File("/system/etc/vold.fstab");
- if(voldFile.exists()){
- Scanner scanner = new Scanner(voldFile);
- while (scanner.hasNext()) {
- String line = scanner.nextLine();
- if (line.startsWith("dev_mount")) {
- String[] lineElements = line.split(" ");
- String element = lineElements[2];
-
- if (element.contains(":"))
- element = element.substring(0, element.indexOf(":"));
- if (!element.equals("/mnt/sdcard"))
- mVold.add(element);
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- for (int i = 0; i < mMounts.size(); i++) {
- String mount = mMounts.get(i);
- if (!mVold.contains(mount))
- mMounts.remove(i--);
- }
- mVold.clear();
-
- List mountHash = new ArrayList(10);
-
- for(String mount : mMounts){
- File root = new File(mount);
- if (root.exists() && root.isDirectory() && root.canWrite()) {
- File[] list = root.listFiles();
- String hash = "[";
- if(list!=null){
- for(File f : list){
- hash += f.getName().hashCode()+":"+f.length()+", ";
- }
- }
- hash += "]";
- if(!mountHash.contains(hash)){
- /*String key = SD_CARD + "_" + map.size();
- if (map.size() == 0) {
- key = SD_CARD;
- } else if (map.size() == 1) {
- key = EXTERNAL_SD_CARD;
- }*/
- mountHash.add(hash);
- roots.add(root);
- //map.put(key, root);
- }
- }
- }
-
- mMounts.clear();
-
- /*if(map.isEmpty()){
- map.put(SD_CARD, Environment.getExternalStorageDirectory());
- }*/
- return roots;
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/horaapps/leafpic/Base/HandlingAlbums.java b/app/src/main/java/com/horaapps/leafpic/Base/HandlingAlbums.java
index dc0e11bf3..21d859779 100644
--- a/app/src/main/java/com/horaapps/leafpic/Base/HandlingAlbums.java
+++ b/app/src/main/java/com/horaapps/leafpic/Base/HandlingAlbums.java
@@ -12,10 +12,10 @@
import android.os.Environment;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
-import android.util.Log;
import com.horaapps.leafpic.R;
import com.horaapps.leafpic.SplashScreen;
+import com.horaapps.leafpic.utils.ContentHelper;
import com.horaapps.leafpic.utils.StringUtils;
import java.io.File;
@@ -34,21 +34,21 @@
public class HandlingAlbums {
public final static String TAG = "HandlingAlbums";
- Pattern CAMERA_FOLDER_PATTERN = Pattern.compile("\\b/DCIM/Camera/?$");
+ private Pattern CAMERA_FOLDER_PATTERN = Pattern.compile("\\b/DCIM/Camera/?$");
public ArrayList dispAlbums;
private ArrayList selectedAlbums;
- boolean includeVideo = true;
+ private boolean includeVideo = true;
- CustomAlbumsHandler customAlbumsHandler;
+ private CustomAlbumsHandler customAlbumsHandler;
private SharedPreferences SP;
- int indexCamera = -1;
- int current = -1;
- boolean hidden;
+ private int indexCamera = -1;
+ private int current = -1;
+ private boolean hidden;
- ArrayList excludedfolders;
- AlbumsComparators albumsComparators;
+ private ArrayList excludedfolders;
+ private AlbumsComparators albumsComparators;
public HandlingAlbums(Context context) {
SP = PreferenceManager.getDefaultSharedPreferences(context);
@@ -78,13 +78,13 @@ public void loadPreviewAlbums(Context context, boolean hidden) {
clearCameraIndex();
includeVideo = SP.getBoolean("set_include_video", true);
ArrayList albumArrayList = new ArrayList();
- HashSet roots = listStorages();
+ HashSet roots = listStorages(context);
if (hidden)
for (File storage : roots)
- fetchRecursivelyHiddenFolder(storage, albumArrayList);
+ fetchRecursivelyHiddenFolder(storage, albumArrayList, storage.getAbsolutePath());
else
for (File storage : roots)
- fetchRecursivelyFolder(storage, albumArrayList);
+ fetchRecursivelyFolder(storage, albumArrayList, storage.getAbsolutePath());
dispAlbums = albumArrayList;
sortAlbums(context);
@@ -98,74 +98,39 @@ public Album getCurrentAlbum() {
return dispAlbums.get(current);
}
- public void clearCameraIndex() {
+ private void clearCameraIndex() {
indexCamera = -1;
}
- public HashSet listStorages() {
+ private HashSet listStorages(Context context) {
HashSet roots = new HashSet();
roots.add(Environment.getExternalStorageDirectory());
- //Log.wtf(TAG, Environment.getExternalStorageDirectory().getAbsolutePath());
- /*for (String mount : getExternalMounts()) {
- File mas = new File(mount);
+ String[] extSdCardPaths = ContentHelper.getExtSdCardPaths(context);
+ for (String extSdCardPath : extSdCardPaths) {
+ File mas = new File(extSdCardPath);
if (mas.canRead())
roots.add(mas);
- }*/
+ }
String sdCard = System.getenv("SECONDARY_STORAGE");
if (sdCard != null) roots.add(new File(sdCard));
return roots;
}
- public static HashSet getExternalMounts() {
- final HashSet out = new HashSet();
- String reg = "(?i).*vold.*(vfat|ntfs|exfat|fat32|ext3|ext4).*rw.*";
- String s = "";
- try {
- final Process process = new ProcessBuilder().command("mount")
- .redirectErrorStream(true).start();
- process.waitFor();
- final InputStream is = process.getInputStream();
- final byte[] buffer = new byte[1024];
- while (is.read(buffer) != -1) {
- s = s + new String(buffer);
- }
- is.close();
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- // parse output
- final String[] lines = s.split("\n");
- for (String line : lines) {
- if (!line.toLowerCase(Locale.US).contains("asec")) {
- if (line.matches(reg)) {
- String[] parts = line.split(" ");
- for (String part : parts) {
- if (part.startsWith("/"))
- if (!part.toLowerCase(Locale.US).contains("vold"))
- out.add(part);
- }
- }
- }
- }
- return out;
- }
-
- public ArrayList getValidFolders(boolean hidden) {
+ public ArrayList getValidFolders(Context context,boolean hidden) {
ArrayList folders = new ArrayList();
if (hidden)
- for (File storage : listStorages())
- fetchRecursivelyHiddenFolder(storage, folders, false);
+ for (File storage : listStorages(context))
+ fetchRecursivelyHiddenFolder(storage, folders);
else
- for (File storage : listStorages())
- fetchRecursivelyFolder(storage, folders, false);
+ for (File storage : listStorages(context))
+ fetchRecursivelyFolder(storage, folders);
return folders;
}
- private void fetchRecursivelyFolder(File dir, ArrayList folders, boolean asd) {
+ private void fetchRecursivelyFolder(File dir, ArrayList folders) {
if (!excludedfolders.contains(dir)) {
File[] listFiles = dir.listFiles(new ImageFileFilter());
if (listFiles != null && listFiles.length > 0)
@@ -176,14 +141,14 @@ private void fetchRecursivelyFolder(File dir, ArrayList folders, boolean
for (File temp : children) {
File nomedia = new File(temp, ".nomedia");
if (!excludedfolders.contains(temp) && !temp.isHidden() && !nomedia.exists()) {
- fetchRecursivelyFolder(temp, folders, asd);
+ fetchRecursivelyFolder(temp, folders);
}
}
}
}
}
- private void fetchRecursivelyHiddenFolder(File dir, ArrayList folders, boolean asd) {
+ private void fetchRecursivelyHiddenFolder(File dir, ArrayList folders) {
if (!excludedfolders.contains(dir)) {
File[] asdf = dir.listFiles(new FoldersFileFilter());
if (asdf !=null) {
@@ -194,48 +159,63 @@ private void fetchRecursivelyHiddenFolder(File dir, ArrayList folders, bo
if (files != null && files.length > 0)
folders.add(new Album(temp.getAbsolutePath(), temp.getName(), files.length));
}
- fetchRecursivelyHiddenFolder(temp, folders, asd);
+ fetchRecursivelyHiddenFolder(temp, folders);
}
}
}
}
- private void fetchRecursivelyFolder(File dir, ArrayList albumArrayList) {
+
+ public static ArrayList getSubFolders(File dir) {
+ ArrayList array = new ArrayList();
+ //File[] children = dir.listFiles(new FoldersFileFilter());
+ File[] children = dir.listFiles();
+ if (children != null)
+ for (File child : children)
+ array.add(child.getName());
+ return array;
+ }
+
+ private void fetchRecursivelyFolder(File dir, ArrayList albumArrayList, String rootExternalStorage) {
if (!excludedfolders.contains(dir)) {
- checkAndAddAlbum(dir, albumArrayList);
+ checkAndAddAlbum(dir, albumArrayList, rootExternalStorage);
File[] children = dir.listFiles(new FoldersFileFilter());
if (children != null) {
for (File temp : children) {
File nomedia = new File(temp, ".nomedia");
if (!excludedfolders.contains(temp) && !temp.isHidden() && !nomedia.exists()) {
//not excluded/hidden folder
- fetchRecursivelyFolder(temp, albumArrayList);
+ fetchRecursivelyFolder(temp, albumArrayList, rootExternalStorage);
}
}
}
}
}
- private void fetchRecursivelyHiddenFolder(File dir, ArrayList albumArrayList) {
+ private void fetchRecursivelyHiddenFolder(File dir, ArrayList albumArrayList, String rootExternalStorage) {
if (!excludedfolders.contains(dir)) {
File[] folders = dir.listFiles(new FoldersFileFilter());
if (folders != null) {
for (File temp : folders) {
File nomedia = new File(temp, ".nomedia");
if (!excludedfolders.contains(temp) && nomedia.exists()) {
- checkAndAddAlbum(temp, albumArrayList);
+ checkAndAddAlbum(temp, albumArrayList, rootExternalStorage);
}
- fetchRecursivelyHiddenFolder(temp, albumArrayList);
+ fetchRecursivelyHiddenFolder(temp, albumArrayList, rootExternalStorage);
}
}
}
}
- public void checkAndAddAlbum(File temp, ArrayList albumArrayList) {
+ public ArrayList getExcludedFolders() {
+ return excludedfolders;
+ }
+
+ private void checkAndAddAlbum(File temp, ArrayList albumArrayList, String rootExternalStorage) {
File[] files = temp.listFiles(new ImageFileFilter(includeVideo));
if (files != null && files.length > 0) {
//valid folder
- Album asd = new Album(temp.getAbsolutePath(), temp.getName(), files.length);
- asd.setCoverPath(customAlbumsHandler.getPhotPrevieAlbum(asd.getPath()));
+ Album asd = new Album(temp.getAbsolutePath(), temp.getName(), files.length, rootExternalStorage);
+ asd.setCoverPath(customAlbumsHandler.getCoverPathAlbum(asd.getPath()));
long lastMod = Long.MIN_VALUE;
File choice = null;
@@ -348,7 +328,8 @@ private Bitmap getCropedBitmap(Bitmap srcBmp){
}
return dstBmp;
}
- public void scanFile(Context context, String[] path) { MediaScannerConnection.scanFile(context, path, null, null); }
+
+ private void scanFile(Context context, String[] path) { MediaScannerConnection.scanFile(context, path, null, null); }
public void hideAlbum(String path, Context context) {
File dirName = new File(path);
@@ -370,7 +351,7 @@ public void hideSelectedAlbums(Context context) {
clearSelectedAlbums();
}
- public void hideAlbum(final Album a, Context context) {
+ private void hideAlbum(final Album a, Context context) {
hideAlbum(a.getPath(), context);
dispAlbums.remove(a);
}
@@ -389,7 +370,7 @@ public void unHideSelectedAlbums(Context context) {
clearSelectedAlbums();
}
- public void unHideAlbum(final Album a, Context context) {
+ private void unHideAlbum(final Album a, Context context) {
unHideAlbum(a.getPath(), context);
dispAlbums.remove(a);
}
@@ -418,12 +399,18 @@ public void excludeSelectedAlbums(Context context) {
clearSelectedAlbums();
}
- public void excludeAlbum(Context context, Album a) {
+ private void excludeAlbum(Context context, Album a) {
CustomAlbumsHandler h = new CustomAlbumsHandler(context);
h.excludeAlbum(a.getPath());
+ excludedfolders.add(new File(a.getPath()));
dispAlbums.remove(a);
}
+ public void unExcludeAlbum(Context c, File dirPath) {
+ customAlbumsHandler.clearAlbumExclude(dirPath.getAbsolutePath());
+ excludedfolders.remove(dirPath);
+ }
+
public int getColumnSortingMode() {
return SP.getInt("column_sort", AlbumSettings.SORT_BY_DATE);
}
diff --git a/app/src/main/java/com/horaapps/leafpic/Base/ImageFileFilter.java b/app/src/main/java/com/horaapps/leafpic/Base/ImageFileFilter.java
index 3cd37c8f1..d5f50e569 100644
--- a/app/src/main/java/com/horaapps/leafpic/Base/ImageFileFilter.java
+++ b/app/src/main/java/com/horaapps/leafpic/Base/ImageFileFilter.java
@@ -17,17 +17,17 @@ public class ImageFileFilter implements FilenameFilter
public final static int FILTER_IMAGES = 1;
public final static int FILTER_GIFS = 2;
public final static int FILTER_VIDEO = 3;
- public final static int FILTER_NO_VIDEO = 4;
+ private final static int FILTER_NO_VIDEO = 4;
- HashSet extensions;
- public static String[] imagesExtensions =
+ private HashSet extensions;
+ private static String[] imagesExtensions =
new String[] { "jpg", "png", "jpe", "jpeg", "bmp", "webp" };
- public static String[] videoExtensions = new String[] { "mp4", "mkv", "webm", "avi" };
- public static String[] gifsExtensions = new String[] { "gif"} ;
+ private static String[] videoExtensions = new String[] { "mp4", "mkv", "webm", "avi" };
+ private static String[] gifsExtensions = new String[] { "gif"} ;
//private String[] okFileExtensions = allExtensions;
- public ImageFileFilter(int filter) {
+ private ImageFileFilter(int filter) {
extensions = new HashSet();
switch (filter) {
case FILTER_IMAGES:
@@ -51,7 +51,8 @@ public ImageFileFilter(int filter) {
break;
}
}
- public ImageFileFilter(int filter, boolean includeVideo) {
+
+ ImageFileFilter(int filter, boolean includeVideo) {
extensions = new HashSet();
switch (filter) {
case FILTER_IMAGES:
@@ -77,17 +78,18 @@ public ImageFileFilter(int filter, boolean includeVideo) {
}
}
- public ImageFileFilter(boolean includeVideo) {
+ ImageFileFilter(boolean includeVideo) {
this(includeVideo ? FILTER_ALL : FILTER_NO_VIDEO);
}
- public ImageFileFilter() {
+
+ ImageFileFilter() {
this(FILTER_ALL);
}
@Override
public boolean accept(File dir, String filename) {
for (String extension : extensions)
- if (filename.endsWith(extension))
+ if (filename.toLowerCase().endsWith(extension))
return true;
return false;
}
diff --git a/app/src/main/java/com/horaapps/leafpic/Base/Media.java b/app/src/main/java/com/horaapps/leafpic/Base/Media.java
index 7c2a7c4b7..48c84daf2 100644
--- a/app/src/main/java/com/horaapps/leafpic/Base/Media.java
+++ b/app/src/main/java/com/horaapps/leafpic/Base/Media.java
@@ -1,48 +1,79 @@
package com.horaapps.leafpic.Base;
+import android.content.ContentResolver;
+import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
-import android.text.format.Time;
-import android.util.Log;
import android.webkit.MimeTypeMap;
+import com.drew.imaging.ImageMetadataReader;
+import com.drew.lang.GeoLocation;
+import com.drew.lang.Rational;
+import com.drew.metadata.Directory;
+import com.drew.metadata.Metadata;
+import com.drew.metadata.Tag;
+import com.drew.metadata.exif.GpsDirectory;
import com.horaapps.leafpic.utils.StringUtils;
import java.io.File;
import java.io.IOException;
+import java.math.RoundingMode;
+import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.util.HashMap;
import java.util.Locale;
+import java.util.Map;
/**
* Created by dnld on 26/04/16.
*/
public class Media implements Parcelable {
+ private static final String TAG_WIDTH = "Image Width";
+ private static final String TAG_HEIGHT = "Image Height";
+ private static final String TAG_DATE_TAKEN = "Date/Time Original";
+ private static final String TAG_MAKE = "Make";
+ private static final String TAG_MODEL = "Model";
+ private static final String TAG_F_NUMBER = "F-Number";
+ private static final String TAG_ISO = "ISO Speed Ratings";
+ private static final String TAG_EXPOSURE = "Exposure Time";
+ private static final String TAG_ORIENTATION = "Orientation";
+
+ //region ORIENTATION VALUES
+ private static final int ORIENTATION_NORMAL = 1;
+ private static final int ORIENTATION_ROTATE_180 = 3;
+ private static final int ORIENTATION_ROTATE_90 = 6; // rotate 90 cw to right it
+ private static final int ORIENTATION_ROTATE_270 = 8; // rotate 270 to right it
+ //endregion
+
+ private final Map metadataMap = new HashMap();
+
String path = null;
- long dateModified = -1;
- String mime = null;
+ private long dateModified = -1;
+ private String mime = null;
+ private Uri uri = null;
- long size = 0;
- boolean selected = false;
+ private long size = 0;
+ private boolean selected = false;
public Media() { }
public Media(String path, long dateModified) {
- this.path=path;
- this.dateModified=dateModified;
+ this.path = path;
+ this.dateModified = dateModified;
setMIME();
}
- public Media(String path, long dateModified, long size) {
- this.path = path;
- this.dateModified = dateModified;
- this.size = size;
+ public Media(File file) {
+ this.path = file.getAbsolutePath();
+ this.dateModified = file.lastModified();
+ this.size = file.length();
setMIME();
}
@@ -51,62 +82,101 @@ public Media(String path) {
setMIME();
}
+ public Media(Context context, Uri mediaUri) {
+ this.uri = mediaUri;
+ this.path = null;
+ ContentResolver cR = context.getContentResolver();
+ mime = MimeTypeMap.getSingleton().getExtensionFromMimeType(cR.getType(uri));
+ if(mime == null) mime = "unknown";
+ }
+
public String getMIME() {
return mime;
}
- public void setMIME() {
+ private void setMIME() {
String extension = path.substring(path.lastIndexOf('.')+1);
- mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
+ mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.toLowerCase());
+ if(mime == null) mime= "unknown";
}
- public void setSelected(boolean selected) {
+ void setSelected(boolean selected) {
this.selected = selected;
}
- public boolean isGif() { return getPath().endsWith("gif"); }
+ public boolean isGif() { return getMIME().endsWith("gif"); }
public boolean isImage() { return getMIME().startsWith("image"); }
public boolean isVideo() { return getMIME().startsWith("video"); }
public Uri getUri() {
- return Uri.fromFile(new File(path));
+ return isMediainStorage() ? Uri.fromFile(new File(path)) : uri;
}
- public byte[] getThumnail() {
+ public byte[] getThumbnail() {
+
ExifInterface exif;
- try { exif = new ExifInterface(getPath()); }
- catch (IOException e) { return null; }
+ try {
+ exif = new ExifInterface(getPath());
+ } catch (IOException e) {
+ return null;
+ }
byte[] imageData = exif.getThumbnail();
if (imageData != null)
return imageData;
return null;
+
+ // NOTE: ExifInterface is faster than metadata-extractor to get the thumbnail data
+ /*try {
+ Metadata metadata = ImageMetadataReader.readMetadata(new File(getPath()));
+ ExifThumbnailDirectory thumbnailDirectory = metadata.getFirstDirectoryOfType(ExifThumbnailDirectory.class);
+ if (thumbnailDirectory.hasThumbnailData())
+ return thumbnailDirectory.getThumbnailData();
+ } catch (Exception e) { return null; }*/
}
+
+ public GeoLocation getGeoLocation() {
+ try {
+ Metadata metadata = ImageMetadataReader.readMetadata(new File(getPath()));
+ GpsDirectory thumbnailDirectory = metadata.getFirstDirectoryOfType(GpsDirectory.class);
+ return thumbnailDirectory.getGeoLocation();
+ } catch (Exception e) { return null; }
+ }
+
+ private void loadMetadata() {
+ if (metadataMap.isEmpty()) {
+ try {
+ Metadata metadata = ImageMetadataReader.readMetadata(new File(getPath()));
+ for (Directory directory : metadata.getDirectories())
+ for (Tag tag : directory.getTags()) {
+ metadataMap.put(tag.getTagName(), directory.getObject(tag.getTagType()));
+ //Log.wtf("asd", tag.getTagName());
+ }
+ } catch (Exception e){ e.printStackTrace(); }
+ }
+ }
public long getSize() {
return size;
}
public int getOrientation() {
- ExifInterface exif;
- try { exif = new ExifInterface(getPath()); }
- catch (IOException ex) { return 0; }
- if (exif != null) {
- int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
- if (orientation != -1) {
- switch (orientation) {
- case ExifInterface.ORIENTATION_ROTATE_90: return 90;
- case ExifInterface.ORIENTATION_ROTATE_180: return 180;
- case ExifInterface.ORIENTATION_ROTATE_270: return 270;
- }
+ loadMetadata();
+ if (metadataMap.containsKey(TAG_ORIENTATION)) {
+ switch (Integer.parseInt(metadataMap.get(TAG_ORIENTATION).toString())) {
+ case ORIENTATION_NORMAL: return 0;
+ case ORIENTATION_ROTATE_90: return 90;
+ case ORIENTATION_ROTATE_180: return 180;
+ case ORIENTATION_ROTATE_270: return 270;
+ default: return -1;
}
}
- return 0;
+ return -1;
}
public boolean setOrientation(int orientation){
- int asd;
+ /*int asd;
ExifInterface exif;
try { exif = new ExifInterface(getPath()); }
catch (IOException ex) { return false; }
@@ -117,41 +187,115 @@ public boolean setOrientation(int orientation){
case 0: asd = 1; break;
default: return false;
}
- exif.setAttribute(ExifInterface.TAG_ORIENTATION,asd+"");
+ exif.setAttribute(ExifInterface.TAG_ORIENTATION, asd+"");
try { exif.saveAttributes(); }
catch (IOException e) { return false;}
- return true;
+ return true;*/
+ return false;
}
- public int getWidth() { //TODO improve
- ExifInterface exif;
- try { exif = new ExifInterface(getPath()); }
- catch (IOException e) { return 0; }
- return Integer.parseInt(exif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH));
+ public boolean isMediainStorage() {
+ return path != null;
}
- public int getHeight() { //TODO improve
- ExifInterface exif;
- try { exif = new ExifInterface(getPath()); }
- catch (IOException e) { return 0; }
- return Integer.parseInt(exif.getAttribute(ExifInterface.TAG_IMAGE_LENGTH));
+ public String getExifInfo() {
+ return String.format("%s %s %s", getFNumber(), getExposureTime(), getISO());
}
- public long getDateEXIF() {
- ExifInterface exif;
- Date date;
- try { exif = new ExifInterface(getPath()); }
- catch (IOException e) { return -1; }
- try {
- date = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss").parse(exif.getAttribute(ExifInterface.TAG_DATETIME));
+ private Rational getRational(Object o)
+ {
+ if (o == null)
+ return null;
+
+ if (o instanceof Rational)
+ return (Rational)o;
+ if (o instanceof Integer)
+ return new Rational((Integer)o, 1);
+ if (o instanceof Long)
+ return new Rational((Long)o, 1);
+
+ // NOTE not doing conversions for real number types
+
+ return null;
+ }
+
+ private String getFNumber() {
+ loadMetadata();
+ if (metadataMap.containsKey(TAG_F_NUMBER)) {
+ DecimalFormat format = new DecimalFormat("0.0");
+ format.setRoundingMode(RoundingMode.HALF_UP);
+ Rational f = getRational(metadataMap.get(TAG_F_NUMBER));
+
+ return "f/" + format.format(f.doubleValue());
}
- catch (ParseException e) { return -1; }
- catch (NullPointerException e) { return -1; }
- return date.getTime();
+ return null;
+ }
+
+ private String getExposureTime() {
+ loadMetadata();
+ if (metadataMap.containsKey(TAG_EXPOSURE)){
+ DecimalFormat format = new DecimalFormat("0.000");
+ format.setRoundingMode(RoundingMode.HALF_UP);
+ Rational f = getRational(metadataMap.get(TAG_EXPOSURE));
+ return format.format(f.doubleValue())+"s";
+ }
+ return null;
+ }
+
+ private String getISO() {
+ loadMetadata();
+ if (metadataMap.containsKey(TAG_ISO))
+ return "ISO-"+metadataMap.get(TAG_ISO).toString();
+ return null;
+ }
+
+ public String getCameraInfo() {
+ String make;
+ if ((make = getMake()) != null)
+ return String.format("%s %s", make, getModel());
+ return null;
+ }
+
+ private String getMake() {
+ loadMetadata();
+ if (metadataMap.containsKey(TAG_MAKE))
+ return metadataMap.get(TAG_MAKE).toString();
+ return null;
+ }
+
+ private String getModel() {
+ loadMetadata();
+ if (metadataMap.containsKey(TAG_MODEL))
+ return metadataMap.get(TAG_MODEL).toString();
+ return null;
+ }
+
+
+ private int getWidth() {
+ loadMetadata();
+ if (metadataMap.containsKey(TAG_WIDTH))
+ return Integer.parseInt(metadataMap.get(TAG_WIDTH).toString());
+ return -1;
+ }
+
+ private int getHeight() {
+ loadMetadata();
+ if (metadataMap.containsKey(TAG_HEIGHT))
+ return Integer.parseInt(metadataMap.get(TAG_HEIGHT).toString());
+ return -1;
+ }
+
+ public long getDateTaken() {
+ loadMetadata();
+ if (metadataMap.containsKey(TAG_DATE_TAKEN))
+ try { return new SimpleDateFormat("yyyy:MM:dd HH:mm:ss").parse(metadataMap.get(TAG_DATE_TAKEN).toString()).getTime(); }
+ catch (ParseException e) { return -1; }
+ catch (NullPointerException e) { return -1; }
+ return -1;
}
public boolean fixDate(){
- long newDate = getDateEXIF();
+ long newDate = getDateTaken();
if (newDate != -1){
File f = new File(getPath());
if (f.setLastModified(newDate)) {
@@ -175,7 +319,7 @@ public String getPath() {
}
public long getDate() {
- long exifDate = getDateEXIF();
+ long exifDate = getDateTaken();
return exifDate != -1 ? exifDate : dateModified;
}
diff --git a/app/src/main/java/com/horaapps/leafpic/Base/MediaComparators.java b/app/src/main/java/com/horaapps/leafpic/Base/MediaComparators.java
index 2f2ac47b4..7f5ab9596 100644
--- a/app/src/main/java/com/horaapps/leafpic/Base/MediaComparators.java
+++ b/app/src/main/java/com/horaapps/leafpic/Base/MediaComparators.java
@@ -5,14 +5,15 @@
/**
* Created by dnld on 26/04/16.
*/
-public class MediaComparators {
- boolean ascending = true;
- public MediaComparators(boolean ascending){
+class MediaComparators {
+ private boolean ascending = true;
+
+ MediaComparators(boolean ascending){
this.ascending = ascending;
}
- public Comparator getDateComparator(){
+ Comparator getDateComparator(){
return new Comparator(){
public int compare(Media f1, Media f2) {
return ascending
@@ -23,7 +24,7 @@ public int compare(Media f1, Media f2) {
};
}
- public Comparator getNameComparator() {
+ Comparator getNameComparator() {
return new Comparator() {
public int compare(Media f1, Media f2) {
return ascending
@@ -33,12 +34,22 @@ public int compare(Media f1, Media f2) {
};
}
- public Comparator getSizeComparator() {
+ Comparator getSizeComparator() {
+ return new Comparator() {
+ public int compare(Media f1, Media f2) {
+ return ascending
+ ? Long.compare(f1.getSize(), f2.getSize())
+ : Long.compare(f2.getSize(), f1.getSize());
+ }
+ };
+ }
+
+ Comparator getTypeComparator() {
return new Comparator() {
public int compare(Media f1, Media f2) {
return ascending
- ? Long.compare(f1.getSize(), f2.getSize())
- : Long.compare(f2.getSize(), f1.getSize());
+ ? f1.getMIME().compareTo(f2.getMIME())
+ : f2.getMIME().compareTo(f1.getMIME());
}
};
}
diff --git a/app/src/main/java/com/horaapps/leafpic/DonateActivity.java b/app/src/main/java/com/horaapps/leafpic/DonateActivity.java
index 147002df4..f00a5a85d 100644
--- a/app/src/main/java/com/horaapps/leafpic/DonateActivity.java
+++ b/app/src/main/java/com/horaapps/leafpic/DonateActivity.java
@@ -7,7 +7,7 @@
import android.support.v7.widget.CardView;
import android.support.v7.widget.Toolbar;
import android.view.View;
-import android.widget.LinearLayout;
+import android.widget.ScrollView;
import android.widget.TextView;
import com.horaapps.leafpic.Views.ThemedActivity;
@@ -22,33 +22,23 @@
*/
public class DonateActivity extends ThemedActivity {
- Toolbar toolbar;
+ private Toolbar toolbar;
/**** Title Cards ***/
- TextView txtHoraApps;
- TextView txtDonateHead;
- TextView txtGP;
- TextView txtPP;
- TextView txtBT;
- IconicsImageView imageViewGift;
- CustomTabService cts;
+ private CustomTabService cts;
- /**** Buttons ***/
+ /**** Scroll View*/
+ private ScrollView scr;
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
setContentView(R.layout.activity_donate);
toolbar = (Toolbar) findViewById(R.id.toolbar);
- txtHoraApps = (TextView) findViewById(R.id.team_name);
- txtDonateHead = (TextView) findViewById(R.id.donate_header_item);
- imageViewGift = (IconicsImageView) findViewById(R.id.donate_header_icon);
- txtGP = (TextView) findViewById(R.id.donate_googleplay_item_title);
- txtPP = (TextView) findViewById(R.id.donate_paypal_item_title);
- txtBT = (TextView) findViewById(R.id.donate_bitcoin_item_title);
setNavBarColor();
cts = new CustomTabService(DonateActivity.this, getPrimaryColor());
+ scr = (ScrollView)findViewById(R.id.donateAct_scrollView);
}
@Override
@@ -57,7 +47,7 @@ public void onPostResume() {
setTheme();
}
- public void setTheme(){
+ private void setTheme(){
/**** ToolBar *****/
toolbar.setBackgroundColor(getPrimaryColor());
@@ -75,70 +65,45 @@ public void onClick(View v) {
});
toolbar.setTitle(getString(R.string.donate));
- /**** Status Bar ****/
setStatusBarColor();
-
- /**** Nav Bar *******/
setNavBarColor();
-
- /**** Recent App ****/
setRecentApp(getString(R.string.donate));
/**** Title Cards ***/
- txtHoraApps.setTextColor(getAccentColor());
- txtGP.setTextColor(getAccentColor());
- txtPP.setTextColor(getAccentColor());
- txtBT.setTextColor(getAccentColor());
-
- /***** Buttons *****/
- setThemeOnChangeListener();
- }
-
- public void setThemeOnChangeListener(){
+ ((TextView) findViewById(R.id.team_name)).setTextColor(getAccentColor());
+ ((TextView) findViewById(R.id.donate_googleplay_item_title)).setTextColor(getAccentColor());
+ ((TextView) findViewById(R.id.donate_paypal_item_title)).setTextColor(getAccentColor());
+ ((TextView) findViewById(R.id.donate_bitcoin_item_title)).setTextColor(getAccentColor());
/** BackGround **/
- LinearLayout bg = (LinearLayout) findViewById(R.id.donate_background);
- bg.setBackgroundColor(getBackgroundColor());
+ findViewById(R.id.donate_background).setBackgroundColor(getBackgroundColor());
/** Cards **/
- CardView cvGP = (CardView) findViewById(R.id.donate_googleplay_card);
- CardView cvPP = (CardView) findViewById(R.id.donate_paypal_card);
- CardView cvBT = (CardView) findViewById(R.id.donate_bitcoin_card);
- CardView cvHD = (CardView) findViewById(R.id.donate_header_card);
-
-
int color = getCardBackgroundColor();
- cvGP.setCardBackgroundColor(color);
- cvPP.setCardBackgroundColor(color);
- cvBT.setCardBackgroundColor(color);
- cvHD.setCardBackgroundColor(color);
- /** Icons **/
- //ABOUT APP
- IconicsImageView imgGP = (IconicsImageView) findViewById(R.id.donate_googleplay_icon_title);
- IconicsImageView imgPP = (IconicsImageView) findViewById(R.id.donate_paypal_icon_title);
- IconicsImageView imgBT = (IconicsImageView) findViewById(R.id.donate_bitcoin_icon_title);
+ ((CardView) findViewById(R.id.donate_googleplay_card)).setCardBackgroundColor(color);
+ ((CardView) findViewById(R.id.donate_paypal_card)).setCardBackgroundColor(color);
+ ((CardView) findViewById(R.id.donate_bitcoin_card)).setCardBackgroundColor(color);
+ ((CardView) findViewById(R.id.donate_header_card)).setCardBackgroundColor(color);
+ /** Icons **/
color = getIconColor();
- imgGP.setColor(color);
- imgPP.setColor(color);
- imgBT.setColor(color);
- imageViewGift.setColor(color);
+ ((IconicsImageView) findViewById(R.id.donate_googleplay_icon_title)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.donate_paypal_icon_title)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.donate_bitcoin_icon_title)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.donate_header_icon)).setColor(color);
/** TextViews **/
- TextView txtGP_CS = (TextView) findViewById(R.id.donate_googleplay_item);
- TextView txtPP_CS = (TextView) findViewById(R.id.donate_paypal_item);
- TextView txtBT_CS = (TextView) findViewById(R.id.donate_bitcoin_item);
- TextView txtHD_CS = (TextView) findViewById(R.id.donate_header_item);
-
color = getTextColor();
- txtGP_CS.setTextColor(color);
- txtPP_CS.setTextColor(color);
- txtBT_CS.setTextColor(color);
- txtHD_CS.setTextColor(color);
- txtDonateHead.setTextColor(color);
+ ((TextView) findViewById(R.id.donate_googleplay_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.donate_paypal_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.donate_bitcoin_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.donate_header_item)).setTextColor(color);
+
+ /***** ScrolView *****/
+ setScrollViewColor(scr);
/** ACTIONS **/
findViewById(R.id.button_donate_paypal).setOnClickListener(new View.OnClickListener() {
@@ -148,7 +113,7 @@ public void onClick(View v) {
}
});
- txtBT_CS.setOnLongClickListener(new View.OnLongClickListener() {
+ findViewById(R.id.donate_bitcoin_item).setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
diff --git a/app/src/main/java/com/horaapps/leafpic/ExcludedAlbumsActivity.java b/app/src/main/java/com/horaapps/leafpic/ExcludedAlbumsActivity.java
index c68b71aab..143d47d1b 100644
--- a/app/src/main/java/com/horaapps/leafpic/ExcludedAlbumsActivity.java
+++ b/app/src/main/java/com/horaapps/leafpic/ExcludedAlbumsActivity.java
@@ -9,11 +9,10 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
import android.widget.TextView;
import com.balysv.materialripple.MaterialRippleLayout;
-import com.horaapps.leafpic.Base.CustomAlbumsHandler;
+import com.horaapps.leafpic.Base.HandlingAlbums;
import com.horaapps.leafpic.Views.ThemedActivity;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.view.IconicsImageView;
@@ -26,29 +25,30 @@
*/
public class ExcludedAlbumsActivity extends ThemedActivity {
- CustomAlbumsHandler h = new CustomAlbumsHandler(ExcludedAlbumsActivity.this);
- ArrayList albums = new ArrayList();
+ private ArrayList excludedFolders = new ArrayList();
+ private HandlingAlbums handlingAlbums;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_excluded);
- albums = h.getExcludedFolders();
- checkNothing(albums);
+ handlingAlbums = ((MyApplication) getApplicationContext()).getAlbums();
+ excludedFolders = handlingAlbums.getExcludedFolders();
+
+ checkNothing(excludedFolders);
initUI();
}
- public void checkNothing(ArrayList asd){
+ private void checkNothing(ArrayList asd){
TextView a = (TextView) findViewById(R.id.nothing_to_show);
a.setTextColor(getTextColor());
a.setVisibility(asd.size() == 0 ? View.VISIBLE : View.GONE);
}
- public void initUI(){
+ private void initUI(){
RecyclerView mRecyclerView;
- RelativeLayout rl_ea;
Toolbar toolbar;
/** TOOLBAR **/
@@ -77,8 +77,8 @@ public void onClick(View v) {
setStatusBarColor();
setNavBarColor();
setRecentApp(getString(R.string.excluded_albums));
- rl_ea = (RelativeLayout) findViewById(R.id.rl_ea);
- rl_ea.setBackgroundColor(getBackgroundColor());
+
+ findViewById(R.id.rl_ea).setBackgroundColor(getBackgroundColor());
}
private class ExcludedAlbumsAdapter extends RecyclerView.Adapter {
@@ -89,16 +89,21 @@ public void onClick(View v) {
String ID = v.getTag().toString();
int pos;
if((pos = getIndex(ID)) !=-1) {
- h.clearAlbumExclude(ID);
- albums.remove(pos);
+ handlingAlbums.unExcludeAlbum(getApplicationContext(), excludedFolders.remove(pos));
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ handlingAlbums.loadPreviewAlbums(getApplicationContext());
+ }
+ });
notifyItemRemoved(pos);
- checkNothing(albums);
+ checkNothing(excludedFolders);
}
}
};
public ExcludedAlbumsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.excluded_card, parent, false);
+ View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_excluded_album, parent, false);
v.findViewById(R.id.UnExclude_icon).setOnClickListener(listener);
return new ViewHolder(
MaterialRippleLayout.on(v)
@@ -113,7 +118,7 @@ public ExcludedAlbumsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int
@Override
public void onBindViewHolder(final ExcludedAlbumsAdapter.ViewHolder holder, final int position) {
- File a = albums.get(position);
+ File a = excludedFolders.get(position);
holder.album_path.setText(a.getAbsolutePath());
holder.album_name.setText(a.getName());
@@ -128,24 +133,24 @@ public void onBindViewHolder(final ExcludedAlbumsAdapter.ViewHolder holder, fina
}
public int getItemCount() {
- return albums.size();
+ return excludedFolders.size();
}
- public int getIndex(String id) {
- for (int i = 0; i < albums.size(); i++)
- if (albums.get(i).getAbsolutePath().equals(id)) return i;
+ int getIndex(String id) {
+ for (int i = 0; i < excludedFolders.size(); i++)
+ if (excludedFolders.get(i).getAbsolutePath().equals(id)) return i;
return -1;
}
- public class ViewHolder extends RecyclerView.ViewHolder {
+ class ViewHolder extends RecyclerView.ViewHolder {
LinearLayout card_layout;
IconicsImageView imgUnExclude;
IconicsImageView imgFolder;
TextView album_name;
TextView album_path;
- public ViewHolder(View itemView) {
+ ViewHolder(View itemView) {
super(itemView);
card_layout = (LinearLayout) itemView.findViewById(R.id.linear_card_excluded);
imgUnExclude = (IconicsImageView) itemView.findViewById(R.id.UnExclude_icon);
diff --git a/app/src/main/java/com/horaapps/leafpic/Fragments/ImageFragment.java b/app/src/main/java/com/horaapps/leafpic/Fragments/ImageFragment.java
index 9ea53a311..2acf522fc 100644
--- a/app/src/main/java/com/horaapps/leafpic/Fragments/ImageFragment.java
+++ b/app/src/main/java/com/horaapps/leafpic/Fragments/ImageFragment.java
@@ -73,9 +73,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getContext());
PhotoView photoView = new PhotoView(getContext());
final SubsamplingScaleImageView imageView = new SubsamplingScaleImageView(getContext());
- final ImageView imag = new ImageView(getContext());
- if (SP.getBoolean("set_delay_full_image", true)) {
+ if (SP.getBoolean("set_delay_full_image", true) && img.isMediainStorage()) {
Ion.with(getContext())
.load(img.getPath())
.withBitmap()
@@ -96,11 +95,11 @@ public void onOutsidePhotoTap() {
photoView.setZoomTransitionDuration(375);
photoView.setScaleLevels(1.0F, 4.5F, 10.0F);//TODO improve
- Ion.with(getContext())
- .load(img.getPath())
- .withBitmap()
- .deepZoom()
- .intoImageView(photoView);
+ /*Ion.with(getContext())
+ .load(img.getPath())
+ .withBitmap()
+ .deepZoom()
+ .intoImageView(photoView);*/
return photoView;
@@ -116,6 +115,7 @@ public void onClick(View v) {
});
return imageView;
}
+
}
@Override
@@ -141,7 +141,6 @@ public void rotatePicture(int rotation) {
if(img.setOrientation(orienatation))
((SubsamplingScaleImageView) view).setOrientation(orienatation);
} else {
-
int orienatation = Measure.rotateBy(img.getOrientation(),rotation);
//((ImageView) view).setRotation(orienatation);
((PhotoView) view).setRotationBy(rotation);
diff --git a/app/src/main/java/com/horaapps/leafpic/Fragments/VideoFragment.java b/app/src/main/java/com/horaapps/leafpic/Fragments/VideoFragment.java
index 7c32db88c..c0e2b4c99 100644
--- a/app/src/main/java/com/horaapps/leafpic/Fragments/VideoFragment.java
+++ b/app/src/main/java/com/horaapps/leafpic/Fragments/VideoFragment.java
@@ -47,7 +47,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.video_fragment, container, false);
+ View view = inflater.inflate(R.layout.fragment_video, container, false);
ImageView picture = (ImageView) view.findViewById(R.id.media_view);
IconicsImageView videoInd = (IconicsImageView) view.findViewById(R.id.video_indicator);
diff --git a/app/src/main/java/com/horaapps/leafpic/IntroActivity.java b/app/src/main/java/com/horaapps/leafpic/IntroActivity.java
index bcd1a070c..572ea8a8c 100644
--- a/app/src/main/java/com/horaapps/leafpic/IntroActivity.java
+++ b/app/src/main/java/com/horaapps/leafpic/IntroActivity.java
@@ -21,7 +21,7 @@ public class IntroActivity extends AppIntro {
public void init(Bundle savedInstanceState) {
addSlide(AppIntroFragment.newInstance(this.getString(R.string.welcome_slide_title), this.getString(R.string.welcome_slide_sub),
- R.drawable.leafpic_big, ContextCompat.getColor(this, R.color.accent_teal)));
+ R.drawable.leaf_pic, ContextCompat.getColor(this, R.color.accent_teal)));
/* addSlide(AppIntroFragment.newInstance(this.getString(R.string.storage_slide_title), this.getString(R.string.storage_slide_sub),
R.drawable.storage_permission, ContextCompat.getColor(this, R.color.accent_brown)));//Color.parseColor("#607D8B")*/
@@ -73,7 +73,7 @@ public void onSlideChanged() {
}
setSeparatorColor(ContextCompat.getColor(this, R.color.accent_teal));
setBarColor(ContextCompat.getColor(this, R.color.accent_teal));
- drawable = ((BitmapDrawable) getDrawable(R.mipmap.ic_launcher));
+ //drawable = ((BitmapDrawable) ContextCompat.getDrawable(R.mipmap.ic_launcher));
} else{
diff --git a/app/src/main/java/com/horaapps/leafpic/MainActivity.java b/app/src/main/java/com/horaapps/leafpic/MainActivity.java
index b9d69a517..ed50e0462 100644
--- a/app/src/main/java/com/horaapps/leafpic/MainActivity.java
+++ b/app/src/main/java/com/horaapps/leafpic/MainActivity.java
@@ -1,6 +1,7 @@
package com.horaapps.leafpic;
-import android.content.ContentResolver;
+import android.annotation.TargetApi;
+import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -17,11 +18,11 @@
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
+import android.os.Environment;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
-import android.support.v4.provider.DocumentFile;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
@@ -42,16 +43,21 @@
import android.view.MenuItem;
import android.view.Surface;
import android.view.View;
+import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.DecelerateInterpolator;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
+import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.SeekBar;
+import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
@@ -78,50 +84,46 @@
import com.mikepenz.iconics.view.IconicsImageView;
import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.Arrays;
import java.util.Locale;
public class MainActivity extends ThemedActivity {
- public static String TAG = "AlbumsAct";
+ private static String TAG = "AlbumsAct";
+ private int REQUEST_CODE_SD_CARD_PERMISSIONS = 42;
- CustomAlbumsHandler customAlbumsHandler = new CustomAlbumsHandler(MainActivity.this);
- SharedPreferences SP;
- SecurityHelper securityObj;
+ private CustomAlbumsHandler customAlbumsHandler = new CustomAlbumsHandler(MainActivity.this);
+ private SharedPreferences SP;
+ private SecurityHelper securityObj;
- HandlingAlbums albums;
- RecyclerView recyclerViewAlbums;
- AlbumsAdapter albumsAdapter;
- GridSpacingItemDecoration albumsDecoration;
+ private HandlingAlbums albums;
+ private RecyclerView recyclerViewAlbums;
+ private AlbumsAdapter albumsAdapter;
+ private GridSpacingItemDecoration albumsDecoration;
- Album album;
- RecyclerView recyclerViewMedia;
- PhotosAdapter mediaAdapter;
- GridSpacingItemDecoration photosDecoration;
+ private Album album;
+ private RecyclerView recyclerViewMedia;
+ private PhotosAdapter mediaAdapter;
+ private GridSpacingItemDecoration photosDecoration;
- FloatingActionButton fabCamera;
- DrawerLayout mDrawerLayout;
- Toolbar toolbar;
- SelectAlbumBottomSheet bottomSheetDialogFragment;
- SwipeRefreshLayout swipeRefreshLayout;
+ private FloatingActionButton fabCamera;
+ private DrawerLayout mDrawerLayout;
+ private Toolbar toolbar;
+ private SelectAlbumBottomSheet bottomSheetDialogFragment;
+ private SwipeRefreshLayout swipeRefreshLayout;
- ScrollView drawerScr;
- Drawable drawableScrollBar;
+ private boolean hidden = false, pickMode = false, editMode = false, albumsMode = true, firstLaunch = true;
- boolean hidden = false, pickmode = false, editmode = false, albumsMode = true, firstLaunch = true;
-
- View.OnLongClickListener photosOnLongClickListener = new View.OnLongClickListener() {
+ private View.OnLongClickListener photosOnLongClickListener = new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
int index = Integer.parseInt(v.findViewById(R.id.photo_path).getTag().toString());
- if (!editmode) {
+ if (!editMode) {
// If it is the first long press
mediaAdapter.notifyItemChanged(album.toggleSelectPhoto(index));
- editmode = true;
+ editMode = true;
} else
album.selectAllPhotosUpTo(index, mediaAdapter);
@@ -130,12 +132,12 @@ public boolean onLongClick(View v) {
}
};
- View.OnClickListener photosOnClickListener = new View.OnClickListener() {
+ private View.OnClickListener photosOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
int index = Integer.parseInt(v.findViewById(R.id.photo_path).getTag().toString());
- if (!pickmode) {
- if (editmode) {
+ if (!pickMode) {
+ if (editMode) {
mediaAdapter.notifyItemChanged(album.toggleSelectPhoto(index));
invalidateOptionsMenu();
} else {
@@ -157,7 +159,7 @@ public void onClick(View v) {
public boolean onLongClick(View v) {
int index = Integer.parseInt(v.findViewById(R.id.album_name).getTag().toString());
albumsAdapter.notifyItemChanged(albums.toggleSelectAlbum(index));
- editmode = true;
+ editMode = true;
invalidateOptionsMenu();
return true;
}
@@ -167,7 +169,7 @@ public boolean onLongClick(View v) {
@Override
public void onClick(View v) {
int index = Integer.parseInt(v.findViewById(R.id.album_name).getTag().toString());
- if (editmode) {
+ if (editMode) {
albumsAdapter.notifyItemChanged(albums.toggleSelectAlbum(index));
invalidateOptionsMenu();
} else {
@@ -178,42 +180,6 @@ public void onClick(View v) {
}
};
-
- public static HashSet getExternalMounts() {
- final HashSet out = new HashSet();
- String reg = "(?i).*vold.*(vfat|ntfs|exfat|fat32|ext3|ext4).*rw.*";
- String s = "";
- try {
- final Process process = new ProcessBuilder().command("mount")
- .redirectErrorStream(true).start();
- process.waitFor();
- final InputStream is = process.getInputStream();
- final byte[] buffer = new byte[1024];
- while (is.read(buffer) != -1) {
- s = s + new String(buffer);
- }
- is.close();
- } catch (final Exception e) {
- e.printStackTrace();
- }
-
- // parse output
- final String[] lines = s.split("\n");
- for (String line : lines) {
- if (!line.toLowerCase(Locale.US).contains("asec")) {
- if (line.matches(reg)) {
- String[] parts = line.split(" ");
- for (String part : parts) {
- if (part.startsWith("/"))
- if (!part.toLowerCase(Locale.US).contains("vold"))
- out.add(part);
- }
- }
- }
- }
- return out;
- }
-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -223,8 +189,8 @@ public void onCreate(Bundle savedInstanceState) {
albums = new HandlingAlbums(getApplicationContext());
album = new Album();
albumsMode = true;
- editmode = false;
- securityObj= new SecurityHelper(MainActivity.this);
+ editMode = false;
+ securityObj = new SecurityHelper(MainActivity.this);
initUI();
setupUI();
@@ -235,6 +201,7 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public void onResume() {
super.onResume();
+ securityObj.updateSecuritySetting();
setupUI();
albums.clearSelectedAlbums();
album.clearSelectedPhotos();
@@ -251,7 +218,7 @@ public void onResume() {
- public void displayCurrentAlbumMedia(boolean reload) {
+ private void displayCurrentAlbumMedia(boolean reload) {
album = ((MyApplication) getApplicationContext()).getCurrentAlbum();
album.setSettings(getApplicationContext());
toolbar.setTitle(album.getName());
@@ -268,21 +235,21 @@ public void onClick(View v) {
displayAlbums();
}
});
- albumsMode = editmode = false;
+ albumsMode = editMode = false;
invalidateOptionsMenu();
}
- public void displayAlbums() {
+ private void displayAlbums() {
if (SP.getBoolean("auto_update_media", false))
displayAlbums(true);
else {
displayAlbums(false);
- albumsAdapter.updateDataset(albums.dispAlbums);
+ albumsAdapter.updateDataSet(albums.dispAlbums);
toggleRecyclersVisibilty(true);
}
}
- public void displayAlbums(boolean reload) {
+ private void displayAlbums(boolean reload) {
toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_menu));
toolbar.setTitle(getString(R.string.app_name));
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
@@ -295,7 +262,7 @@ public void displayAlbums(boolean reload) {
});
albumsMode = true;
- editmode = false;
+ editMode = false;
invalidateOptionsMenu();
mediaAdapter.updateDataSet(new ArrayList());
recyclerViewMedia.scrollToPosition(0);
@@ -305,21 +272,20 @@ public void displayAlbums(boolean reload) {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- int nSpan;
- if (albumsMode) {
- nSpan = Measure.getAlbumsColumns(MainActivity.this);
- recyclerViewAlbums.setLayoutManager(new GridLayoutManager(this, nSpan));
- recyclerViewAlbums.removeItemDecoration(albumsDecoration);
- albumsDecoration = new GridSpacingItemDecoration(nSpan, Measure.pxToDp(3, getApplicationContext()), true);
- recyclerViewAlbums.addItemDecoration(albumsDecoration);
- } else {
- nSpan = Measure.getPhotosColumns(MainActivity.this);
- recyclerViewMedia.setLayoutManager(new GridLayoutManager(this, nSpan));
- recyclerViewMedia.removeItemDecoration(photosDecoration);
- photosDecoration = new GridSpacingItemDecoration(nSpan, Measure.pxToDp(3, getApplicationContext()), true);
- recyclerViewMedia.addItemDecoration(photosDecoration);
- }
+ // rearrange column number
+ int nSpan = Measure.getAlbumsColumns(MainActivity.this);
+ recyclerViewAlbums.setLayoutManager(new GridLayoutManager(this, nSpan));
+ recyclerViewAlbums.removeItemDecoration(albumsDecoration);
+ albumsDecoration = new GridSpacingItemDecoration(nSpan, Measure.pxToDp(3, getApplicationContext()), true);
+ recyclerViewAlbums.addItemDecoration(albumsDecoration);
+
+ nSpan = Measure.getPhotosColumns(MainActivity.this);
+ recyclerViewMedia.setLayoutManager(new GridLayoutManager(this, nSpan));
+ recyclerViewMedia.removeItemDecoration(photosDecoration);
+ photosDecoration = new GridSpacingItemDecoration(nSpan, Measure.pxToDp(3, getApplicationContext()), true);
+ recyclerViewMedia.addItemDecoration(photosDecoration);
+
int status_height = Measure.getStatusBarHeight(getResources()),
navBarHeight = Measure.getNavBarHeight(MainActivity.this);
@@ -346,15 +312,15 @@ public void onConfigurationChanged(Configuration newConfig) {
}
}
- public void displayPreFetchedData(Bundle data){
+ private void displayPreFetchedData(Bundle data){
try {
if (data!=null) {
int content = data.getInt(SplashScreen.CONTENT);
if (content == SplashScreen.ALBUMS_PREFETCHED) {
albums = ((MyApplication) getApplicationContext()).getAlbums();
displayAlbums(false);
- pickmode = data.getBoolean(SplashScreen.PICK_MODE);
- albumsAdapter.updateDataset(albums.dispAlbums);
+ pickMode = data.getBoolean(SplashScreen.PICK_MODE);
+ albumsAdapter.updateDataSet(albums.dispAlbums);
toggleRecyclersVisibilty(true);
} else if (content == SplashScreen.PHOTS_PREFETCHED) {
albums = ((MyApplication) getApplicationContext()).getAlbums();
@@ -379,7 +345,7 @@ public void run() {
}
- public void initUI() {
+ private void initUI() {
/**** TOOLBAR ****/
toolbar = (Toolbar) findViewById(R.id.toolbar);
@@ -429,8 +395,6 @@ public void onRefresh() {
}
});
-
-
/**** DRAWER ****/
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLayout.addDrawerListener(new ActionBarDrawerToggle(this,
@@ -446,8 +410,7 @@ public void onDrawerOpened(View drawerView) {
}
});
- TextView logo = (TextView) findViewById(R.id.txtLogo);
- logo.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Figa.ttf"));
+ ((TextView) findViewById(R.id.txtLogo)).setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Figa.ttf"));
/**** FAB ***/
fabCamera = (FloatingActionButton) findViewById(R.id.fab_camera);
@@ -456,27 +419,35 @@ public void onDrawerOpened(View drawerView) {
fabCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- /*if (!albumsMode && album.areFiltersActive()) {
- album.filterMedias(ImageFileFilter.FILTER_ALL);
+ if (!albumsMode && album.areFiltersActive()) {
+ album.filterMedias(getApplicationContext(), ImageFileFilter.FILTER_ALL);
mediaAdapter.updateDataSet(album.media);
checkNothing();
toolbar.getMenu().findItem(R.id.all_media_filter).setChecked(true);
fabCamera.setImageDrawable(new IconicsDrawable(MainActivity.this).icon(GoogleMaterial.Icon.gmd_camera_alt).color(Color.WHITE));
- } else startActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));*/
+ } else startActivity(new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA));
+ }
+ });
+ //region TESTING
+ fabCamera.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ //newFolderDialog();
+ // NOTE: this is used to acquire write permission on sd with api 21
+ // TODO call this one when unable to write on sd
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
- startActivityForResult(new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE), 42);
+ startActivityForResult(new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE), REQUEST_CODE_SD_CARD_PERMISSIONS);
}
-
+ return false;
}
});
+ //endregion
- drawerScr = (ScrollView) findViewById(R.id.drawer_scrollbar);
- drawableScrollBar = ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_scrollbar);
int statusBarHeight = Measure.getStatusBarHeight(getResources()),
- navBarHeight = Measure.getNavBarHeight(MainActivity.this);
+ navBarHeight = Measure.getNavBarHeight(MainActivity.this);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
toolbar.animate().translationY(statusBarHeight).setInterpolator(new DecelerateInterpolator()).start();
@@ -495,30 +466,159 @@ public void onClick(View v) {
}
}
- public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
- if (resultCode == RESULT_OK) {
- Uri treeUri = resultData.getData();
- //ContentResolver.getPersistedUriPermissions()
- getContentResolver().takePersistableUriPermission(treeUri,
- Intent.FLAG_GRANT_READ_URI_PERMISSION |
- Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
- DocumentFile pickedDir = DocumentFile.fromTreeUri(this, treeUri);
- String path = ContentHelper.getPath(getApplicationContext(),pickedDir.getUri());
- StringUtils.showToast(getApplicationContext(), path+"");
- //Log.wtf(TAG,path);
- // List all existing files inside picked directory
- for (DocumentFile file : pickedDir.listFiles()) {
- StringUtils.showToast(getApplicationContext(),file.getName());
- Log.d(TAG, "Found file " + file.getName() + " with size " + file.length());
+ //region TESTING
+ private ArrayAdapter directoryList;
+ private void newFolderDialog(final int value) {
+ final File curFolder = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
+ directoryList = new ArrayAdapter(getApplicationContext(), android.R.layout
+ .simple_list_item_1, Arrays.asList(curFolder.list())) {
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View view = super.getView(position, convertView, parent);
+ if (view!=null){
+ TextView text = (TextView) view.findViewById(android.R.id.text1);
+ text.setTextColor(getTextColor());
+ }
+ return view;
}
+ };
- // Create a new file and write into it
- /*DocumentFile newFile = pickedDir.createFile("text/plain", "My Novel");
- OutputStream out = getContentResolver().openOutputStream(newFile.getUri());
- out.write("A long time ago...".getBytes());
- out.close();*/
+ final AlertDialog.Builder dialogExplorer = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
+ View dialogExplorerLayout = getLayoutInflater().inflate(R.layout.dialog_explorer, null);
+
+ final ListView dialogExplorerListView = (ListView) dialogExplorerLayout.findViewById(R.id.folder_list);
+ dialogExplorerListView.setAdapter(directoryList);
+
+ final TextView textViewCurrentPath = (TextView) dialogExplorerLayout.findViewById(R.id.current_path);
+ textViewCurrentPath.setText(curFolder.getAbsolutePath());
+
+ final RelativeLayout relativeLayoutTitle = (RelativeLayout) dialogExplorerLayout.findViewById(R.id.ll_explorer_dialog_title);
+ relativeLayoutTitle.setBackgroundColor(getPrimaryColor());
+
+ final LinearLayout linearCreateNewFolder = (LinearLayout) dialogExplorerLayout.findViewById(R.id.new_folder_layout);
+ ((TextView) dialogExplorerLayout.findViewById(R.id.txt_new_folder_description)).setTextColor(getSubTextColor());
+ ((IconicsImageView) dialogExplorerLayout.findViewById(R.id.folder)).setColor(getIconColor());
+
+ final EditText editTextFolderName = (EditText) dialogExplorerLayout.findViewById(R.id.folder_name_edit_text);
+ editTextFolderName.getBackground().mutate().setColorFilter(getTextColor(), PorterDuff.Mode.SRC_IN);
+ editTextFolderName.setTextColor(getTextColor());
+
+ /**** Scrollbar ****/
+ Drawable drawableScrollBar = ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_scrollbar);
+ drawableScrollBar.setColorFilter(new PorterDuffColorFilter(getPrimaryColor(), PorterDuff.Mode.SRC_ATOP));
+
+ /**** New Folder ****/
+ IconicsImageView newFolder = (IconicsImageView) dialogExplorerLayout.findViewById(R.id.toggle_create_new_folder_icon);
+ newFolder.setOnClickListener(new View.OnClickListener(){
+ @Override
+ public void onClick(View v){
+ linearCreateNewFolder.setVisibility(linearCreateNewFolder.getVisibility()==View.GONE ? View.VISIBLE : View.GONE);
+ dialogExplorerListView.setVisibility(dialogExplorerListView.getVisibility()==View.GONE ? View.VISIBLE : View.GONE);
+ }
+ });
+
+ /**** Btn UP ****/
+ IconicsImageView btnUP = (IconicsImageView) dialogExplorerLayout.findViewById(R.id.directory_up);
+ btnUP.setOnClickListener(new View.OnClickListener(){
+ @Override
+ public void onClick(View v){
+ File current = new File(textViewCurrentPath.getText().toString());
+ Log.wtf(TAG,current.getAbsolutePath());
+ if(current.isDirectory() && !(textViewCurrentPath.getText().toString().equals("/")) ) {
+ directoryList = new ArrayAdapter(getApplicationContext(), android.R.layout
+ .simple_list_item_1, HandlingAlbums.getSubFolders(current.getParentFile())){
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View view = super.getView(position, convertView, parent);
+ if (view!=null){
+ TextView text = (TextView) view.findViewById(android.R.id.text1);
+ text.setTextColor(getTextColor());
+ }
+ return view;
+ }
+ };
+ textViewCurrentPath.setText(current.getParentFile().getAbsolutePath());
+ dialogExplorerListView.setAdapter(directoryList);
+ }
+ }
+ });
+
+ /**** OK Dialog ****/
+ dialogExplorer.setPositiveButton(R.string.ok_action, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if(linearCreateNewFolder.getVisibility()==View.VISIBLE && !editTextFolderName.getText().toString().equals("")) {
+ String path = textViewCurrentPath.getText().toString();
+ File folder = new File(path + File.separator + editTextFolderName.getText().toString());
+ boolean success = true;
+ if (!folder.exists())
+ success = folder.mkdir();
+ if (success) {
+ if(value==1){
+ album.copySelectedPhotos(getApplicationContext(), path + File.separator + editTextFolderName.getText().toString() + File.separator);
+ finishEditMode();
+ } else { new MovePhotos().execute(path + File.separator + editTextFolderName.getText().toString() + File.separator);}
+ } else {
+ Toast.makeText(MainActivity.this, "Folder Already Exist!", Toast.LENGTH_SHORT).show();
+ }
+ }
+ }
+ });
+ /**** CANCEL Dialog ****/
+ dialogExplorer.setNegativeButton(R.string.cancel, null);
+ /**** Set View ****/
+ dialogExplorer.setView(dialogExplorerLayout);
+
+ /**** ListView Click Listener ****/
+ dialogExplorerListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
+ @Override
+ public void onItemClick(AdapterView> parent, final View view, int position, long id) {
+ File selected = new File(textViewCurrentPath.getText()+"/"+ directoryList.getItem(position));
+
+ if(selected.isDirectory()){
+ directoryList = new ArrayAdapter(getApplicationContext(), android.R.layout
+ .simple_list_item_1, HandlingAlbums.getSubFolders(selected)) {
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View view = super.getView(position, convertView, parent);
+ if (view!=null){
+ TextView text = (TextView) view.findViewById(android.R.id.text1);
+ text.setTextColor(getTextColor());
+ }
+ return view;
+ }
+ };
+ textViewCurrentPath.setText(selected.getAbsolutePath());
+ dialogExplorerListView.setAdapter(directoryList);
+ } else {
+ Toast.makeText(getApplicationContext(), selected.toString() + "selected ", Toast.LENGTH_SHORT).show();
+ //dialog.dismiss();
+ }
+ }
+ });
+ dialogExplorer.show();
+ }
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ @Override
+ public final void onActivityResult(final int requestCode, final int resultCode, final Intent resultData) {
+ if (resultCode == Activity.RESULT_OK) {
+ if (requestCode == REQUEST_CODE_SD_CARD_PERMISSIONS) {
+ // Get Uri from Storage Access Framework.
+ Uri treeUri = resultData.getData();
+
+ // Persist URI in shared preference so that you can use it later.
+ // Use your own framework here instead of PreferenceUtil.
+ ContentHelper.setSharedPreferenceUri(R.string.key_internal_uri_extsdcard_photos, treeUri);
+
+ // Persist access permissions.
+ final int takeFlags = resultData.getFlags()
+ & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
+ getContentResolver().takePersistableUriPermission(treeUri, takeFlags);
+ }
}
}
+ //endregion
@Override
public void setNavBarColor() {
@@ -532,8 +632,8 @@ public void setNavBarColor() {
}
//region UI/GRAPHIC
- public void setupUI() {
- //TODO: MUST BE FIXXED
+ private void setupUI() {
+ //TODO: MUST BE FIXED
toolbar.setPopupTheme(getPopupToolbarStyle());
toolbar.setBackgroundColor(getPrimaryColor());
@@ -548,19 +648,18 @@ public void setupUI() {
setDrawerTheme();
recyclerViewAlbums.setBackgroundColor(getBackgroundColor());
recyclerViewMedia.setBackgroundColor(getBackgroundColor());
- mediaAdapter.updatePlaceholder(getApplicationContext(), getBasicTheme());
+ mediaAdapter.updatePlaceholder(getApplicationContext(), getBaseTheme());
+ albumsAdapter.updateTheme(getApplicationContext(), getBaseTheme());
/**** DRAWER ****/
- setScrollViewColor(drawerScr);
+ setScrollViewColor((ScrollView) findViewById(R.id.drawer_scrollbar));
/**** recyclers drawable *****/
- //drawableScrollBar = getResources().getDrawable( R.drawable.ic_scrollbar);
+ Drawable drawableScrollBar = ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_scrollbar);
drawableScrollBar.setColorFilter(new PorterDuffColorFilter(getPrimaryColor(), PorterDuff.Mode.SRC_ATOP));
- securityObj.updateSecuritySetting();
-
}
- public void setDrawerTheme() {
+ private void setDrawerTheme() {
RelativeLayout DrawerHeader = (RelativeLayout) findViewById(R.id.Drawer_Header);
DrawerHeader.setBackgroundColor(getPrimaryColor());
@@ -625,7 +724,7 @@ public void onClick(View v) {
findViewById(R.id.ll_drawer_Setting).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- Intent intent = new Intent(MainActivity.this, SettingActivity.class);
+ Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
startActivity(intent);
}
});
@@ -656,9 +755,7 @@ public void onClick(View v) {
final EditText editTextPassword = securityObj.getInsertPasswordDialog(MainActivity.this, passwordDialogBuilder);
passwordDialogBuilder.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
-
- }
+ public void onClick(DialogInterface dialog, int which) {}
});
passwordDialogBuilder.setNegativeButton(getString(R.string.cancel), null);
@@ -694,35 +791,35 @@ public void onClick(View v) {
findViewById(R.id.ll_drawer_Moments).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- ComingSoonDialog("Moments");
+ comingSoonDialog("Moments");
}
});
findViewById(R.id.ll_drawer_Tags).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- ComingSoonDialog("Tags");
+ comingSoonDialog("Tags");
}
});
*/
findViewById(R.id.ll_drawer_Wallpapers).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- ComingSoonDialog("Wallpapers");
+ comingSoonDialog("Wallpapers");
}
});
}
//endregion
- void ComingSoonDialog(String title) {
+ private void comingSoonDialog(String title) {
AlertDialog.Builder comingSoonDialog = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
AlertDialogsHelper.getTextDialog(this, comingSoonDialog, title, getString(R.string.coming_soon));
comingSoonDialog.setPositiveButton(this.getString(R.string.ok_action), null);
comingSoonDialog.show();
}
- void updateSelectedStuff() {
+ private void updateSelectedStuff() {
int c;
try {
if (albumsMode) {
@@ -732,7 +829,7 @@ void updateSelectedStuff() {
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- editmode = false;
+ editMode = false;
albums.clearSelectedAlbums();
albumsAdapter.notifyDataSetChanged();
invalidateOptionsMenu();
@@ -798,7 +895,7 @@ public void onClick(View v) {
}
private void finishEditMode() {
- editmode = false;
+ editMode = false;
if (albumsMode) {
albums.clearSelectedAlbums();
albumsAdapter.notifyDataSetChanged();
@@ -809,7 +906,7 @@ private void finishEditMode() {
invalidateOptionsMenu();
}
- public void checkNothing() {
+ private void checkNothing() {
TextView a = (TextView) findViewById(R.id.nothing_to_show);
a.setTextColor(getTextColor());
a.setVisibility((albumsMode && albums.dispAlbums.size() == 0) || (!albumsMode && album.media.size() == 0) ? View.VISIBLE : View.GONE);
@@ -870,32 +967,33 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
if (albumsMode) {
- editmode = albums.getSelectedCount() != 0;
- menu.setGroupVisible(R.id.album_options_menu, editmode);
+ editMode = albums.getSelectedCount() != 0;
+ menu.setGroupVisible(R.id.album_options_menu, editMode);
menu.setGroupVisible(R.id.photos_option_men, false);
} else {
- editmode = album.getSelectedCount() != 0;
- menu.setGroupVisible(R.id.photos_option_men, editmode);
- menu.setGroupVisible(R.id.album_options_menu, !editmode);
+ editMode = album.areMediaSelected();
+ menu.setGroupVisible(R.id.photos_option_men, editMode);
+ menu.setGroupVisible(R.id.album_options_menu, !editMode);
}
togglePrimaryToolbarOptions(menu);
updateSelectedStuff();
- menu.findItem(R.id.select_all).setVisible(editmode);
- menu.findItem(R.id.installShortcut).setVisible(albumsMode && editmode);
- menu.findItem(R.id.delete_action).setVisible((albumsMode && editmode) || (!albumsMode));
+ menu.findItem(R.id.select_all).setVisible(editMode);
+ menu.findItem(R.id.installShortcut).setVisible(albumsMode && editMode);
+ menu.findItem(R.id.type_sort_action).setVisible(!albumsMode);
+ menu.findItem(R.id.delete_action).setVisible(!albumsMode || editMode);
menu.findItem(R.id.setAsAlbumPreview).setVisible(!albumsMode && album.getSelectedCount() == 1);
menu.findItem(R.id.clear_album_preview).setVisible(!albumsMode && album.hasCustomCover());
- menu.findItem(R.id.renameAlbum).setVisible((albumsMode && albums.getSelectedCount() == 1) || (!albumsMode && !editmode));
+ menu.findItem(R.id.renameAlbum).setVisible((albumsMode && albums.getSelectedCount() == 1) || (!albumsMode && !editMode));
menu.findItem(R.id.affixPhoto).setVisible(!albumsMode && album.getSelectedCount() > 1);
return super.onPrepareOptionsMenu(menu);
}
private void togglePrimaryToolbarOptions(final Menu menu) {
- menu.setGroupVisible(R.id.general_action, !editmode);
+ menu.setGroupVisible(R.id.general_action, !editMode);
- if (!editmode) {
+ if (!editMode) {
menu.findItem(R.id.filter_menu).setVisible(!albumsMode);
menu.findItem(R.id.search_action).setVisible(albumsMode);
}
@@ -909,13 +1007,13 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.select_all:
if (albumsMode) {
if (albums.getSelectedCount() == albumsAdapter.getItemCount()) {
- editmode = false;
+ editMode = false;
albums.clearSelectedAlbums();
} else albums.selectAllAlbums();
albumsAdapter.notifyDataSetChanged();
} else {
if (album.getSelectedCount() == mediaAdapter.getItemCount()) {
- editmode = false;
+ editMode = false;
album.clearSelectedPhotos();
} else album.selectAllPhotos();
mediaAdapter.notifyDataSetChanged();
@@ -924,7 +1022,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
case R.id.settings:
- startActivity(new Intent(MainActivity.this, SettingActivity.class));
+ startActivity(new Intent(MainActivity.this, SettingsActivity.class));
return true;
case R.id.installShortcut:
@@ -933,39 +1031,28 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
case R.id.hideAlbumButton:
- final AlertDialog.Builder hideDialog = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
- final View dialogLayout = getLayoutInflater().inflate(R.layout.text_dialog, null);
- final TextView textViewTitle = (TextView) dialogLayout.findViewById(R.id.text_dialog_title);
- final TextView textViewMessage = (TextView) dialogLayout.findViewById(R.id.text_dialog_message);
- CardView cardView = (CardView) dialogLayout.findViewById(R.id.message_card);
-
- cardView.setCardBackgroundColor(getCardBackgroundColor());
- textViewTitle.setBackgroundColor(getPrimaryColor());
- textViewTitle.setText(getString(hidden ? R.string.unhide : R.string.hide));
- textViewMessage.setText(hidden ? R.string.unhide_album_message : R.string.hide_album_message);
- textViewMessage.setTextColor(getTextColor());
- hideDialog.setView(dialogLayout);
- hideDialog.setPositiveButton(getString(hidden ? R.string.unhide : R.string.hide), new DialogInterface.OnClickListener() {
+ final AlertDialog.Builder hideDialogBuilder = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
+
+ AlertDialogsHelper.getTextDialog(MainActivity.this,hideDialogBuilder,
+ getString(hidden ? R.string.unhide : R.string.hide),
+ getString(hidden ? R.string.unhide_album_message : R.string.hide_album_message));
+
+ hideDialogBuilder.setPositiveButton(getString(hidden ? R.string.unhide : R.string.hide), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if (albumsMode) {
- if (hidden)
- albums.unHideSelectedAlbums(getApplicationContext());
- else
- albums.hideSelectedAlbums(getApplicationContext());
-
+ if (hidden) albums.unHideSelectedAlbums(getApplicationContext());
+ else albums.hideSelectedAlbums(getApplicationContext());
albumsAdapter.notifyDataSetChanged();
invalidateOptionsMenu();
} else {
- if(hidden)
- albums.unHideAlbum(album.getPath(), getApplicationContext());
- else
- albums.hideAlbum(album.getPath(), getApplicationContext());
+ if(hidden) albums.unHideAlbum(album.getPath(), getApplicationContext());
+ else albums.hideAlbum(album.getPath(), getApplicationContext());
displayAlbums(true);
}
}
});
if (!hidden) {
- hideDialog.setNeutralButton(this.getString(R.string.exclude), new DialogInterface.OnClickListener() {
+ hideDialogBuilder.setNeutralButton(this.getString(R.string.exclude), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (albumsMode) {
@@ -979,11 +1066,8 @@ public void onClick(DialogInterface dialog, int which) {
}
});
}
- hideDialog.setNegativeButton(this.getString(R.string.cancel), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- }
- });
- hideDialog.show();
+ hideDialogBuilder.setNegativeButton(this.getString(R.string.cancel), null);
+ hideDialogBuilder.show();
return true;
case R.id.delete_action:
@@ -996,12 +1080,12 @@ protected void onPreExecute() {
@Override
protected Void doInBackground(String... arg0) {
- if (albumsMode) {
+ if (albumsMode)
albums.deleteSelectedAlbums(MainActivity.this);
- } else {
- if (editmode) {
+ else {
+ if (editMode)
album.deleteSelectedMedia(getApplicationContext());
- } else {
+ else {
albums.deleteAlbum(album, getApplicationContext());
album.media.clear();
}
@@ -1030,27 +1114,40 @@ protected void onPostExecute(Void result) {
}
AlertDialog.Builder deleteDialog = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
- AlertDialogsHelper.getTextDialog(this, deleteDialog, getString(R.string.delete), getString(albumsMode || (!albumsMode && !editmode) ? R.string.delete_album_message : R.string.delete_photos_message));
-
- deleteDialog.setNegativeButton(this.getString(R.string.cancel), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {}});
+ AlertDialogsHelper.getTextDialog(this, deleteDialog, getString(R.string.delete), getString(albumsMode || (!albumsMode && !editMode) ? R.string.delete_album_message : R.string.delete_photos_message));
+ deleteDialog.setNegativeButton(this.getString(R.string.cancel), null);
deleteDialog.setPositiveButton(this.getString(R.string.delete), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
- if (securityObj.isActiveSecurity()&&securityObj.isPasswordOnDelete()) {
- final AlertDialog.Builder passwordDialogBuilder = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
-
+ if (securityObj.isActiveSecurity() && securityObj.isPasswordOnDelete()) {
+ AlertDialog.Builder passwordDialogBuilder = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
+ final EditText editTextPassword = securityObj.getInsertPasswordDialog(MainActivity.this,passwordDialogBuilder);
+ passwordDialogBuilder.setNegativeButton(getString(R.string.cancel), null);
- final EditText editTextPassword = securityObj.getInsertPasswordDialog(MainActivity.this,passwordDialogBuilder);
passwordDialogBuilder.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
+ @Override
public void onClick(DialogInterface dialog, int which) {
-
+ //This should br empty it will be overwrite later
+ //to avoid dismiss of the dialog on wrong password
}
});
- passwordDialogBuilder.setNegativeButton(getString(R.string.cancel),null);
- AlertDialog passwordDialog = passwordDialogBuilder.create();
+
+ final AlertDialog passwordDialog = passwordDialogBuilder.create();
passwordDialog.show();
-
+
+ passwordDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (securityObj.checkPassword(editTextPassword.getText().toString())) {
+ passwordDialog.dismiss();
+ new DeletePhotos().execute();
+ } else {
+ Toast.makeText(getApplicationContext(), R.string.wrong_password, Toast.LENGTH_SHORT).show();
+ editTextPassword.getText().clear();
+ editTextPassword.requestFocus();
+ }
+ }
+ });
} else new DeletePhotos().execute();
}
});
@@ -1059,37 +1156,49 @@ public void onClick(DialogInterface dialog, int which) {
return true;
case R.id.excludeAlbumButton:
- final AlertDialog.Builder excludeDialog = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
- final View excludeDialogLayout = getLayoutInflater().inflate(R.layout.text_dialog, null);
- final TextView textViewExcludeTitle = (TextView) excludeDialogLayout.findViewById(R.id.text_dialog_title);
- final TextView textViewExcludeMessage = (TextView) excludeDialogLayout.findViewById(R.id.text_dialog_message);
- CardView cardViewExclude = (CardView) excludeDialogLayout.findViewById(R.id.message_card);
+ final AlertDialog.Builder excludeDialogBuilder = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
+ /*AlertDialogsHelper.getTextDialog(MainActivity.this, excludeDialogBuilder,
+ getString(R.string.exclude),getString(R.string.exclude_album_message));*/
+
+ final View excludeDialogLayout = getLayoutInflater().inflate(R.layout.dialog_exclude, null);
+ TextView textViewExcludeTitle = (TextView) excludeDialogLayout.findViewById(R.id.text_dialog_title);
+ TextView textViewExcludeMessage = (TextView) excludeDialogLayout.findViewById(R.id.text_dialog_message);
+ final Spinner spinnerParents = (Spinner) excludeDialogLayout.findViewById(R.id.parents_folder);
- cardViewExclude.setCardBackgroundColor(getCardBackgroundColor());
+ spinnerParents.getBackground().setColorFilter(getIconColor(), PorterDuff.Mode.SRC_ATOP);
+
+ ((CardView) excludeDialogLayout.findViewById(R.id.message_card)).setCardBackgroundColor(getCardBackgroundColor());
textViewExcludeTitle.setBackgroundColor(getPrimaryColor());
textViewExcludeTitle.setText(getString(R.string.exclude));
- textViewExcludeMessage.setText(R.string.exclude_album_message);
- textViewExcludeMessage.setTextColor(getTextColor());
- excludeDialog.setView(excludeDialogLayout);
+ if(albumsMode && albums.getSelectedCount() > 1) {
+ textViewExcludeMessage.setText(R.string.exclude_albums_message);
+ spinnerParents.setVisibility(View.GONE);
+ } else {
+
+ textViewExcludeMessage.setText(R.string.exclude_album_message);
+ spinnerParents.setAdapter(getSpinnerAdapter(albumsMode ? albums.getSelectedAlbum(0).getParentsFolders() : album.getParentsFolders()));
+ }
- excludeDialog.setPositiveButton(this.getString(R.string.exclude), new DialogInterface.OnClickListener() {
+ textViewExcludeMessage.setTextColor(getTextColor());
+ excludeDialogBuilder.setView(excludeDialogLayout);
+
+ excludeDialogBuilder.setPositiveButton(this.getString(R.string.exclude), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
- if (albumsMode) {
+ if (albumsMode && albums.getSelectedCount() > 1) {
albums.excludeSelectedAlbums(getApplicationContext());
albumsAdapter.notifyDataSetChanged();
invalidateOptionsMenu();
} else {
- customAlbumsHandler.excludeAlbum(album.getPath());
- displayAlbums();
+ StringUtils.showToast(getApplicationContext(), spinnerParents.getSelectedItem().toString());
+ customAlbumsHandler.excludeAlbum(spinnerParents.getSelectedItem().toString());
+ albums.loadExcludedFolders(getApplicationContext());
+ displayAlbums(true);
}
}
});
- excludeDialog.setNegativeButton(this.getString(R.string.cancel), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- }
- });
- excludeDialog.show();
+ excludeDialogBuilder.setNegativeButton(this.getString(R.string.cancel), null);
+ excludeDialogBuilder.show();
return true;
case R.id.sharePhotos:
@@ -1105,7 +1214,7 @@ public void onClick(DialogInterface dialog, int id) {
intent.setType(StringUtils.getGenericMIME(album.selectedMedias.get(0).getMIME()));
finishEditMode();
startActivity(intent);
- return true;
+ return true;
case R.id.all_media_filter:
if (!albumsMode) {
@@ -1148,29 +1257,11 @@ public void onClick(DialogInterface dialog, int id) {
}
return true;
- case R.id.action_copy:
- bottomSheetDialogFragment = new SelectAlbumBottomSheet();
- bottomSheetDialogFragment.setCurrentPath(album.getPath());
- bottomSheetDialogFragment.setTitle(getString(R.string.copy_to));
- bottomSheetDialogFragment.setAlbumArrayList(albums.dispAlbums);
- bottomSheetDialogFragment.setHidden(hidden);
- bottomSheetDialogFragment.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String path = v.findViewById(R.id.title_bottom_sheet_item).getTag().toString();
- album.copySelectedPhotos(getApplicationContext(), path);
- finishEditMode();
- bottomSheetDialogFragment.dismiss();
- }
- });
- bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
- return true;
-
case R.id.name_sort_action:
if (albumsMode) {
albums.setDefaultSortingMode(AlbumSettings.SORT_BY_NAME);
albums.sortAlbums(getApplicationContext());
- albumsAdapter.updateDataset(albums.dispAlbums);
+ albumsAdapter.updateDataSet(albums.dispAlbums);
} else {
album.setDefaultSortingMode(getApplicationContext(), AlbumSettings.SORT_BY_NAME);
album.sortPhotos();
@@ -1183,7 +1274,7 @@ public void onClick(View v) {
if (albumsMode) {
albums.setDefaultSortingMode(AlbumSettings.SORT_BY_DATE);
albums.sortAlbums(getApplicationContext());
- albumsAdapter.updateDataset(albums.dispAlbums);
+ albumsAdapter.updateDataSet(albums.dispAlbums);
} else {
album.setDefaultSortingMode(getApplicationContext(), AlbumSettings.SORT_BY_DATE);
album.sortPhotos();
@@ -1196,8 +1287,7 @@ public void onClick(View v) {
if (albumsMode) {
albums.setDefaultSortingMode(AlbumSettings.SORT_BY_SIZE);
albums.sortAlbums(getApplicationContext());
- albumsAdapter.updateDataset(albums.dispAlbums);
-
+ albumsAdapter.updateDataSet(albums.dispAlbums);
} else {
album.setDefaultSortingMode(getApplicationContext(),AlbumSettings.SORT_BY_SIZE);
album.sortPhotos();
@@ -1206,11 +1296,21 @@ public void onClick(View v) {
item.setChecked(true);
return true;
+ case R.id.type_sort_action:
+ if (!albumsMode) {
+ album.setDefaultSortingMode(getApplicationContext(), AlbumSettings.SORT_BY_TYPE);
+ album.sortPhotos();
+ mediaAdapter.updateDataSet(album.media);
+ item.setChecked(true);
+ }
+
+ return true;
+
case R.id.ascending_sort_action:
if (albumsMode) {
albums.setDefaultSortingAscending(!item.isChecked());
albums.sortAlbums(getApplicationContext());
- albumsAdapter.updateDataset(albums.dispAlbums);
+ albumsAdapter.updateDataSet(albums.dispAlbums);
} else {
album.setDefaultSortingAscending(getApplicationContext(), !item.isChecked());
album.sortPhotos();
@@ -1222,50 +1322,47 @@ public void onClick(View v) {
//region Affix
case R.id.affixPhoto:
- final AlertDialog.Builder AffixDialog = new AlertDialog.Builder(MainActivity.this,getDialogStyle());
- final View Affix_dialogLayout = getLayoutInflater().inflate(R.layout.affix_dialog, null);
- final TextView Affix_title = (TextView) Affix_dialogLayout.findViewById(R.id.affix_title);
- CardView cv_Affix_Dialog = (CardView) Affix_dialogLayout.findViewById(R.id.affix_card);
+ final AlertDialog.Builder AffixDialog = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
+ final View dialogLayout = getLayoutInflater().inflate(R.layout.dialog_affix, null);
- Affix_title.setBackgroundColor(getPrimaryColor());
- cv_Affix_Dialog.setCardBackgroundColor(getCardBackgroundColor());
+ dialogLayout.findViewById(R.id.affix_title).setBackgroundColor(getPrimaryColor());
+ ((CardView) dialogLayout.findViewById(R.id.affix_card)).setCardBackgroundColor(getCardBackgroundColor());
//ITEMS
- final TextView txt_Affix_Vertical_title = (TextView) Affix_dialogLayout.findViewById(R.id.affix_vertical_title);
- final TextView txt_Affix_Vertical_sub = (TextView) Affix_dialogLayout.findViewById(R.id.affix_vertical_sub);
- final SwitchCompat swVertical = (SwitchCompat) Affix_dialogLayout.findViewById(R.id.affix_vertical_switch);
- final IconicsImageView imgAffix = (IconicsImageView) Affix_dialogLayout.findViewById(R.id.affix_vertical_icon);
- final IconicsImageView imgQuality = (IconicsImageView) Affix_dialogLayout.findViewById(R.id.affix_quality_icon);
-
- final TextView labelSaveHere = (TextView) Affix_dialogLayout.findViewById(R.id.save_here_title);
- final TextView subLabelSaveHere = (TextView) Affix_dialogLayout.findViewById(R.id.save_here_sub);
-
- final SwitchCompat swSaveHere = (SwitchCompat) Affix_dialogLayout.findViewById(R.id.save_here_switch);
- final IconicsImageView imgSaveHere = (IconicsImageView) Affix_dialogLayout.findViewById(R.id.save_here_icon);
-
- final TextView txtCompressionTitle = (TextView) Affix_dialogLayout.findViewById(R.id.compression_settings_title);
- final TextView txtFormat = (TextView) Affix_dialogLayout.findViewById(R.id.affix_format_sub);
- final TextView txtQuality = (TextView) Affix_dialogLayout.findViewById(R.id.affix_quality_title);
- final SeekBar seekQuality = (SeekBar) Affix_dialogLayout.findViewById(R.id.seek_bar_quality);
-
- final RadioGroup radioFormatGroup = (RadioGroup) Affix_dialogLayout.findViewById(R.id.radio_format);
- final RadioButton radio_jpg = (RadioButton) Affix_dialogLayout.findViewById(R.id.radio_jpeg);
- final RadioButton radio_png = (RadioButton) Affix_dialogLayout.findViewById(R.id.radio_png);
- final IconicsImageView imgFormat = (IconicsImageView) Affix_dialogLayout.findViewById(R.id.affix_format_icon);
- final RadioButton radio_webp = (RadioButton) Affix_dialogLayout.findViewById(R.id.radio_webp);
- txt_Affix_Vertical_title .setTextColor(getTextColor());
- subLabelSaveHere.setTextColor(getSubTextColor());
- imgSaveHere.setColor(getIconColor());
-
- labelSaveHere.setTextColor(getTextColor());
- txt_Affix_Vertical_sub.setTextColor(getSubTextColor());
- txtFormat.setTextColor(getSubTextColor());
- txtCompressionTitle.setTextColor(getTextColor());
- txtQuality.setTextColor(getSubTextColor());
-
- imgQuality.setColor(getIconColor());
- imgFormat.setColor(getIconColor());
- imgAffix.setColor(getIconColor());
+ final SwitchCompat swVertical = (SwitchCompat) dialogLayout.findViewById(R.id.affix_vertical_switch);
+ final SwitchCompat swSaveHere = (SwitchCompat) dialogLayout.findViewById(R.id.save_here_switch);
+
+ final RadioGroup radioFormatGroup = (RadioGroup) dialogLayout.findViewById(R.id.radio_format);
+ final RadioButton radio_jpg = (RadioButton) dialogLayout.findViewById(R.id.radio_jpeg);
+ final RadioButton radio_png = (RadioButton) dialogLayout.findViewById(R.id.radio_png);
+ final RadioButton radio_webp = (RadioButton) dialogLayout.findViewById(R.id.radio_webp);
+
+ final TextView txtQuality = (TextView) dialogLayout.findViewById(R.id.affix_quality_title);
+ final SeekBar seekQuality = (SeekBar) dialogLayout.findViewById(R.id.seek_bar_quality);
+
+ final ScrollView scrollView = (ScrollView) dialogLayout.findViewById(R.id.affix_scrollView);
+ setScrollViewColor(scrollView);
+
+ /** TextViews **/
+ int color = getTextColor();
+ ((TextView) dialogLayout.findViewById(R.id.affix_vertical_title)).setTextColor(color);
+ ((TextView) dialogLayout.findViewById(R.id.compression_settings_title)).setTextColor(color);
+ ((TextView) dialogLayout.findViewById(R.id.save_here_title)).setTextColor(color);
+
+ /** Sub TextViews **/
+ color = getTextColor();
+ ((TextView) dialogLayout.findViewById(R.id.save_here_sub)).setTextColor(color);
+ ((TextView) dialogLayout.findViewById(R.id.affix_vertical_sub)).setTextColor(color);
+ ((TextView) dialogLayout.findViewById(R.id.affix_format_sub)).setTextColor(color);
+ txtQuality.setTextColor(color);
+
+ /** Icons **/
+ color = getIconColor();
+ ((IconicsImageView) dialogLayout.findViewById(R.id.affix_quality_icon)).setColor(color);
+ ((IconicsImageView) dialogLayout.findViewById(R.id.affix_format_icon)).setColor(color);
+ ((IconicsImageView) dialogLayout.findViewById(R.id.affix_vertical_icon)).setColor(color);
+ ((IconicsImageView) dialogLayout.findViewById(R.id.save_here_icon)).setColor(color);
+
seekQuality.getProgressDrawable().setColorFilter(new PorterDuffColorFilter(getAccentColor(), PorterDuff.Mode.SRC_IN));
seekQuality.getThumb().setColorFilter(new PorterDuffColorFilter(getAccentColor(),PorterDuff.Mode.SRC_IN));
@@ -1275,35 +1372,24 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
txtQuality.setText(Html.fromHtml(
String.format(Locale.getDefault(), "%s %d", getString(R.string.quality), progress)));
}
-
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
-
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
-
seekQuality.setProgress(90); //DEFAULT
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- radio_jpg.setButtonTintList(getRadioButtonColor());
- radio_png.setButtonTintList(getRadioButtonColor());
- radio_webp.setButtonTintList(getRadioButtonColor());
- radio_jpg.setTextColor(getTextColor());
- radio_png.setTextColor(getTextColor());
- radio_webp.setTextColor(getTextColor());
- }
+ updateRadioButtonColor(radio_jpg);
+ updateRadioButtonColor(radio_png);
+ updateRadioButtonColor(radio_webp);
//SWITCH
- swVertical.setChecked(false);
- updateSwitchColor(swVertical,getAccentColor());
- swSaveHere.setChecked(false);
- updateSwitchColor(swSaveHere,getAccentColor());
+ updateSwitchColor(swVertical, getAccentColor());
+ updateSwitchColor(swSaveHere, getAccentColor());
swVertical.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@@ -1321,7 +1407,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//Affixing On Background//
class affixMedia extends AsyncTask {
- AlertDialog dialog;
+ private AlertDialog dialog;
@Override
protected void onPreExecute() {
dialog = ProgressDialog(getString(R.string.affix), getString(R.string.affix_text));
@@ -1338,7 +1424,7 @@ protected Void doInBackground(String... arg0) {
}
if (bitmapArray.size()>1) {
-
+ //TODO: MUST FIX
Bitmap.CompressFormat compressFormat;
switch (radioFormatGroup.getCheckedRadioButtonId()) {
case R.id.radio_jpeg: default:
@@ -1367,7 +1453,7 @@ protected Void doInBackground(String... arg0) {
}
@Override
protected void onPostExecute(Void result) {
- editmode = false;
+ editMode = false;
album.clearSelectedPhotos();
dialog.dismiss();
invalidateOptionsMenu();
@@ -1376,7 +1462,7 @@ protected void onPostExecute(Void result) {
}
}
//Dialog Buttons
- AffixDialog.setView(Affix_dialogLayout);
+ AffixDialog.setView(dialogLayout);
AffixDialog.setPositiveButton(this.getString(R.string.ok_action), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {new affixMedia().execute();}});
AffixDialog.setNegativeButton(this.getString(R.string.cancel), new DialogInterface.OnClickListener() {
@@ -1386,74 +1472,77 @@ protected void onPostExecute(Void result) {
//endregion
case R.id.action_move:
- class MovePhotos extends AsyncTask {
-
- @Override
- protected void onPreExecute() {
- swipeRefreshLayout.setRefreshing(true);
- super.onPreExecute();
- }
-
+ bottomSheetDialogFragment = new SelectAlbumBottomSheet();
+ bottomSheetDialogFragment.setCurrentPath(album.getPath());
+ bottomSheetDialogFragment.setTitle(getString(R.string.move_to));
+ bottomSheetDialogFragment.setHidden(hidden);
+ bottomSheetDialogFragment.setAlbumArrayList(albums.dispAlbums);
+ bottomSheetDialogFragment.setOnClickListenerNewFolder(new View.OnClickListener(){
@Override
- protected Void doInBackground(String... arg0) {
- try {
- for (int i = 0; i < album.selectedMedias.size(); i++) {
- File from = new File(album.selectedMedias.get(i).getPath());
- File to = new File(StringUtils.getPhotoPathMoved(album.selectedMedias.get(i).getPath(), arg0[0]));
-
- if (from.renameTo(to)) {
- MediaScannerConnection.scanFile(getApplicationContext(),
- new String[]{ to.getAbsolutePath(), from.getAbsolutePath() }, null, null);
- album.media.remove(album.selectedMedias.get(i));
- }
- }
- } catch (Exception e) { e.printStackTrace(); }
- return null;
+ public void onClick(View v) {
+ bottomSheetDialogFragment.dismiss();
+ newFolderDialog(2);
}
-
+ });
+ bottomSheetDialogFragment.setOnClickListener(new View.OnClickListener() {
@Override
- protected void onPostExecute(Void result) {
- if (album.media.size() == 0) {
- albums.removeCurrentAlbum();
- albumsAdapter.notifyDataSetChanged();
- displayAlbums();
- }
-
- mediaAdapter.updateDataSet(album.media);
- finishEditMode();
- invalidateOptionsMenu();
- swipeRefreshLayout.setRefreshing(false);
+ public void onClick(View v) {
+ String path = v.findViewById(R.id.title_bottom_sheet_item).getTag().toString();
+ new MovePhotos().execute(path);
+ bottomSheetDialogFragment.dismiss();
}
- }
+ });
+ bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
+ return true;
+ case R.id.action_copy:
bottomSheetDialogFragment = new SelectAlbumBottomSheet();
bottomSheetDialogFragment.setCurrentPath(album.getPath());
- bottomSheetDialogFragment.setTitle(getString(R.string.move_to));
- bottomSheetDialogFragment.setHidden(hidden);
+ bottomSheetDialogFragment.setTitle(getString(R.string.copy_to));
bottomSheetDialogFragment.setAlbumArrayList(albums.dispAlbums);
+ bottomSheetDialogFragment.setHidden(hidden);
+ bottomSheetDialogFragment.setOnClickListenerNewFolder(new View.OnClickListener(){
+ @Override
+ public void onClick(View v) {
+ bottomSheetDialogFragment.dismiss();
+ newFolderDialog(1);
+ }
+ });
bottomSheetDialogFragment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String path = v.findViewById(R.id.title_bottom_sheet_item).getTag().toString();
- new MovePhotos().execute(path);
+ album.copySelectedPhotos(getApplicationContext(), path);
+ finishEditMode();
bottomSheetDialogFragment.dismiss();
}
});
bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
- return true;
+ return true;
case R.id.renameAlbum:
AlertDialog.Builder renameDialogBuilder = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
final EditText editTextNewName = new EditText(getApplicationContext());
editTextNewName.setText(albumsMode ? albums.getSelectedAlbum(0).getName() : album.getName());
- AlertDialog renameDialog =
- AlertDialogsHelper.getInsertTextDialog(
- this,renameDialogBuilder, editTextNewName, getString(R.string.rename_album));
+ AlertDialogsHelper.getInsertTextDialog(MainActivity.this, renameDialogBuilder,
+ editTextNewName, getString(R.string.rename_album));
+
+ renameDialogBuilder.setNegativeButton(getString(R.string.cancel), null);
- renameDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok_action), new DialogInterface.OnClickListener() {
+ renameDialogBuilder.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
+ //This should br empty it will be overwrite later
+ //to avoid dismiss of the dialog on wrong password
+ }
+ });
+ final AlertDialog renameDialog = renameDialogBuilder.create();
+ renameDialog.show();
+
+ renameDialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener( new View.OnClickListener() {
+ @Override
+ public void onClick(View dialog) {
if (editTextNewName.length() != 0) {
if (albumsMode){
int index = albums.dispAlbums.indexOf(albums.getSelectedAlbum(0));
@@ -1465,13 +1554,12 @@ public void onClick(DialogInterface dialog, int which) {
toolbar.setTitle(album.getName());
mediaAdapter.notifyDataSetChanged();
}
- } else
- StringUtils.showToast(getApplicationContext(), getString(R.string.nothing_changed));
+ renameDialog.dismiss();
+ } else {
+ StringUtils.showToast(getApplicationContext(), getString(R.string.insert_something));
+ editTextNewName.requestFocus();
+ }
}});
- renameDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) { } });
- renameDialog.show();
return true;
case R.id.clear_album_preview:
@@ -1493,7 +1581,6 @@ public void onClick(DialogInterface dialog, int which) {
// If we got here, the user's action was not recognized.
// Invoke the superclass to handle it.
return super.onOptionsItemSelected(item);
-
}
}
@@ -1504,7 +1591,7 @@ private void toggleRecyclersVisibilty(boolean albumsMode){
@Override
public void onBackPressed() {
- if (editmode) finishEditMode();
+ if (editMode) finishEditMode();
else {
if (albumsMode) {
if (mDrawerLayout.isDrawerOpen(GravityCompat.START))
@@ -1517,13 +1604,12 @@ public void onBackPressed() {
}
}
- public AlertDialog.Builder progressDialog;
- public AlertDialog ProgressDialog(String dialogTitle, String dialogText){
- progressDialog = new AlertDialog.Builder(MainActivity.this,getDialogStyle());
+ private AlertDialog ProgressDialog(String dialogTitle, String dialogText){
+ AlertDialog.Builder progressDialog = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
return AlertDialogsHelper.getProgressDialog(this, progressDialog, dialogTitle, dialogText);
}
- public class PrepareAlbumTask extends AsyncTask {
+ private class PrepareAlbumTask extends AsyncTask {
@Override
protected void onPreExecute() {
@@ -1540,13 +1626,13 @@ protected Void doInBackground(Void... arg0) {
@Override
protected void onPostExecute(Void result) {
- albumsAdapter.updateDataset(albums.dispAlbums);
+ albumsAdapter.updateDataSet(albums.dispAlbums);
checkNothing();
swipeRefreshLayout.setRefreshing(false);
}
}
- public class PreparePhotosTask extends AsyncTask {
+ private class PreparePhotosTask extends AsyncTask {
@Override
protected void onPreExecute() {
@@ -1568,4 +1654,45 @@ protected void onPostExecute(Void result) {
swipeRefreshLayout.setRefreshing(false);
}
}
+
+ //MOVE SELECTED MEDIA ASYNCTASK
+ private class MovePhotos extends AsyncTask {
+
+ @Override
+ protected void onPreExecute() {
+ swipeRefreshLayout.setRefreshing(true);
+ super.onPreExecute();
+ }
+
+ @Override
+ protected Void doInBackground(String... arg0) {
+ try {
+ for (int i = 0; i < album.selectedMedias.size(); i++) {
+ File from = new File(album.selectedMedias.get(i).getPath());
+ File to = new File(StringUtils.getPhotoPathMoved(album.selectedMedias.get(i).getPath(), arg0[0]));
+
+ if (ContentHelper.moveFile(getApplicationContext(), from, to)) {
+ MediaScannerConnection.scanFile(getApplicationContext(),
+ new String[]{ to.getAbsolutePath(), from.getAbsolutePath() }, null, null);
+ album.media.remove(album.selectedMedias.get(i));
+ }
+ }
+ } catch (Exception e) { e.printStackTrace(); }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void result) {
+ if (album.media.size() == 0) {
+ albums.removeCurrentAlbum();
+ albumsAdapter.notifyDataSetChanged();
+ displayAlbums();
+ }
+
+ mediaAdapter.updateDataSet(album.media);
+ finishEditMode();
+ invalidateOptionsMenu();
+ swipeRefreshLayout.setRefreshing(false);
+ }
+ }
}
diff --git a/app/src/main/java/com/horaapps/leafpic/MyApplication.java b/app/src/main/java/com/horaapps/leafpic/MyApplication.java
index e67645c30..4ef29fa2b 100644
--- a/app/src/main/java/com/horaapps/leafpic/MyApplication.java
+++ b/app/src/main/java/com/horaapps/leafpic/MyApplication.java
@@ -1,9 +1,10 @@
package com.horaapps.leafpic;
import android.app.Application;
+import android.content.Context;
-import com.horaapps.leafpic.Base.HandlingAlbums;
import com.horaapps.leafpic.Base.Album;
+import com.horaapps.leafpic.Base.HandlingAlbums;
/**
* Created by dnld on 28/04/16.
@@ -11,12 +12,21 @@
public class MyApplication extends Application {
private HandlingAlbums albums;
+ static Context context;
+
+ public static Context getContext() { return context; }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ context = getApplicationContext();
+ }
- public Album getCurrentAlbum() {
+ Album getCurrentAlbum() {
return albums.getCurrentAlbum();
}
- public void removeCurrentAlbum() { albums.removeCurrentAlbum(); }
+ void removeCurrentAlbum() { albums.removeCurrentAlbum(); }
public HandlingAlbums getAlbums() {
return albums;
@@ -26,7 +36,7 @@ public void setAlbums(HandlingAlbums albums) {
this.albums = albums;
}
- public void updateAlbums() {
+ void updateAlbums() {
albums.loadPreviewAlbums(getApplicationContext());
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/horaapps/leafpic/PhotoPagerActivity.java b/app/src/main/java/com/horaapps/leafpic/PhotoPagerActivity.java
index 088f06ce7..14362cc2a 100644
--- a/app/src/main/java/com/horaapps/leafpic/PhotoPagerActivity.java
+++ b/app/src/main/java/com/horaapps/leafpic/PhotoPagerActivity.java
@@ -37,6 +37,7 @@
import com.horaapps.leafpic.Adapters.MediaPagerAdapter;
import com.horaapps.leafpic.Animations.DepthPageTransformer;
import com.horaapps.leafpic.Base.Album;
+import com.horaapps.leafpic.Base.AlbumSettings;
import com.horaapps.leafpic.Fragments.ImageFragment;
import com.horaapps.leafpic.Views.HackyViewPager;
import com.horaapps.leafpic.Views.ThemedActivity;
@@ -61,18 +62,18 @@
public class PhotoPagerActivity extends ThemedActivity {
private static final String ISLOCKED_ARG = "isLocked";
- public static final String ACTION_OPEN_ALBUM = "android.intent.action.pagerAlbumMedia";
- public static final String ACTION_REVIEW = "com.android.camera.action.REVIEW";
-
- HackyViewPager mViewPager;
- MediaPagerAdapter adapter;
- SharedPreferences SP;
- RelativeLayout ActivityBackgorund;
- Album album;
- SelectAlbumBottomSheet bottomSheetDialogFragment;
- SecurityHelper securityObj;
- Toolbar toolbar;
- boolean fullscreenmode;
+ static final String ACTION_OPEN_ALBUM = "android.intent.action.pagerAlbumMedia";
+ private static final String ACTION_REVIEW = "com.android.camera.action.REVIEW";
+
+ private HackyViewPager mViewPager;
+ private MediaPagerAdapter adapter;
+ private SharedPreferences SP;
+ private RelativeLayout ActivityBackgorund;
+ private Album album;
+ private SelectAlbumBottomSheet bottomSheetDialogFragment;
+ private SecurityHelper securityObj;
+ private Toolbar toolbar;
+ private boolean fullscreenmode;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -92,7 +93,16 @@ public void onCreate(Bundle savedInstanceState) {
album = ((MyApplication) getApplicationContext()).getCurrentAlbum();
else if ((getIntent().getAction().equals(Intent.ACTION_VIEW) || getIntent().getAction().equals(ACTION_REVIEW))
&& getIntent().getData() != null) {
- album = new Album(getApplicationContext(), ContentHelper.getPath(getApplicationContext(), getIntent().getData()));
+ File folderPath = new File( ContentHelper.getPath(getApplicationContext(),
+ getIntent().getData()));
+
+ if (folderPath.isFile())
+ //the image is stored in the storage
+ album = new Album(getApplicationContext(), folderPath);
+ else
+ //try to show with Uri
+ album = new Album(getApplicationContext(), getIntent().getData());
+
}
initUI();
@@ -100,7 +110,7 @@ && getIntent().getData() != null) {
} catch (Exception e) { e.printStackTrace(); }
}
- public void initUI() {
+ private void initUI() {
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(new IconicsDrawable(this)
@@ -189,7 +199,7 @@ public void onPageScrollStateChanged(int state) {
}
- public void setupUI() {
+ private void setupUI() {
/**** Theme ****/
toolbar = (Toolbar) findViewById(R.id.toolbar);
@@ -293,7 +303,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
} else
StringUtils.showToast(getApplicationContext(), "errori random");
break;
-
default:
break;
}
@@ -311,7 +320,7 @@ private void copyFileToDownloads(Uri croppedFileUri) throws Exception {
album.scanFile(getApplicationContext(), new String[]{album.getCurrentMedia().getPath()});
}
- public void displayAlbums(boolean reload) {
+ private void displayAlbums(boolean reload) {
Intent i = new Intent(PhotoPagerActivity.this, MainActivity.class);
Bundle b = new Bundle();
b.putInt(SplashScreen.CONTENT, SplashScreen.ALBUMS_PREFETCHED);
@@ -363,6 +372,42 @@ public void onClick(View v) {
break;
+ case R.id.name_sort_action:
+ album.setDefaultSortingMode(getApplicationContext(), AlbumSettings.SORT_BY_NAME);
+ album.sortPhotos();
+ adapter.swapDataSet(album.media);
+ item.setChecked(true);
+ return true;
+
+ case R.id.date_taken_sort_action:
+ album.setDefaultSortingMode(getApplicationContext(), AlbumSettings.SORT_BY_DATE);
+ album.sortPhotos();
+ adapter.swapDataSet(album.media);
+ item.setChecked(true);
+ return true;
+
+ case R.id.size_sort_action:
+ album.setDefaultSortingMode(getApplicationContext(),AlbumSettings.SORT_BY_SIZE);
+ album.sortPhotos();
+ adapter.swapDataSet(album.media);
+ item.setChecked(true);
+ return true;
+
+ case R.id.type_sort_action:
+ album.setDefaultSortingMode(getApplicationContext(), AlbumSettings.SORT_BY_TYPE);
+ album.sortPhotos();
+ adapter.swapDataSet(album.media);
+ item.setChecked(true);
+ return true;
+
+ case R.id.ascending_sort_action:
+ album.setDefaultSortingAscending(getApplicationContext(), !item.isChecked());
+ album.sortPhotos();
+ adapter.swapDataSet(album.media);
+
+ item.setChecked(!item.isChecked());
+ return true;
+
case R.id.action_share:
Intent share = new Intent(Intent.ACTION_SEND);
@@ -399,23 +444,7 @@ public void onClick(View v) {
AlertDialogsHelper.getTextDialog(PhotoPagerActivity.this,deleteDialog,
getString(R.string.delete), getString(R.string.delete_photo_message));
- /* final View Delete_dialogLayout = getLayoutInflater().inflate(R.layout
- .text_dialog, null);
- final TextView txt_Delete_title = (TextView) Delete_dialogLayout.findViewById(R.id.text_dialog_title);
- final TextView txt_Delete_message = (TextView) Delete_dialogLayout.findViewById(R.id.text_dialog_message);
- CardView cv_Delete_Dialog = (CardView) Delete_dialogLayout.findViewById(R.id.message_card);
-
- cv_Delete_Dialog.setBackgroundColor(getCardBackgroundColor());
- txt_Delete_title.setBackgroundColor(getPrimaryColor());
- txt_Delete_title.setText(getString(R.string.delete));
- txt_Delete_message.setText(R.string.delete_photo_message);
- txt_Delete_message.setTextColor(getTextColor());
- DeleteDialog.setView(Delete_dialogLayout);*/
-
- deleteDialog.setNegativeButton(this.getString(R.string.cancel), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- }
- });
+ deleteDialog.setNegativeButton(this.getString(R.string.cancel), null);
deleteDialog.setPositiveButton(this.getString(R.string.delete), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if (securityObj.isActiveSecurity()&&securityObj.isPasswordOnDelete()) {
@@ -434,9 +463,9 @@ public void onClick(DialogInterface dialog, int which) {
}
adapter.notifyDataSetChanged();
toolbar.setTitle((mViewPager.getCurrentItem() + 1) + " " + getString(R.string.of) + " " + album.media.size());
- } else {
+ } else
Toast.makeText(passwordDialogBuilder.getContext(), R.string.wrong_password, Toast.LENGTH_SHORT).show();
- }
+
}
});
passwordDialogBuilder.setNegativeButton(getString(R.string.cancel), null);
@@ -536,7 +565,7 @@ public void onClick(DialogInterface dialog, int which) {
break;
case R.id.action_settings:
- startActivity(new Intent(getApplicationContext(), SettingActivity.class));
+ startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
break;
default:
@@ -554,21 +583,20 @@ private void updateBrightness(float level) {
getWindow().setAttributes(lp);
}
- public UCrop.Options getUcropOptions() {
+ private UCrop.Options getUcropOptions() {
UCrop.Options options = new UCrop.Options();
options.setCompressionFormat(Bitmap.CompressFormat.PNG);
options.setCompressionQuality(90);
options.setActiveWidgetColor(getAccentColor());
options.setToolbarColor(getPrimaryColor());
- options.setStatusBarColor(isTraslucentStatusBar() ? ColorPalette.getOscuredColor(getPrimaryColor()) : getPrimaryColor());
+ options.setStatusBarColor(isTranslucentStatusBar() ? ColorPalette.getOscuredColor(getPrimaryColor()) : getPrimaryColor());
options.setCropFrameColor(getAccentColor());
options.setFreeStyleCropEnabled(true);
return options;
}
-
@Override
public void setNavBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@@ -582,18 +610,17 @@ public void setNavBarColor() {
}
}
-
@Override
protected void setStatusBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (isApplyThemeOnImgAct())
- if (isTraslucentStatusBar() && isTransparencyZero())
+ if (isTranslucentStatusBar() && isTransparencyZero())
getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
else
getWindow().setStatusBarColor(ColorPalette.getTransparentColor(getPrimaryColor(), getTransparency()));
else
getWindow().setStatusBarColor(ColorPalette.getTransparentColor(
- ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000), 175));//TODO ;UST BE BETER FIXXED
+ ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000), 175));
}
}
@@ -654,7 +681,7 @@ public void run() {
});
}
- public void changeBackGroundColor() {
+ private void changeBackGroundColor() {
int colorTo;
int colorFrom;
if (fullscreenmode) {
diff --git a/app/src/main/java/com/horaapps/leafpic/PlayerActivity.java b/app/src/main/java/com/horaapps/leafpic/PlayerActivity.java
index 79db7cbfc..4e7724d04 100644
--- a/app/src/main/java/com/horaapps/leafpic/PlayerActivity.java
+++ b/app/src/main/java/com/horaapps/leafpic/PlayerActivity.java
@@ -24,6 +24,7 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
+import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
@@ -79,7 +80,7 @@ public class PlayerActivity extends ThemedActivity implements SurfaceHolder.Call
DemoPlayer.Listener, DemoPlayer.Id3MetadataListener, AudioCapabilitiesReceiver.Listener {
// For use within demo app code.
- public static final String CONTENT_TYPE_EXTRA = "content_type";
+ private static final String CONTENT_TYPE_EXTRA = "content_type";
// For use when launching the demo app using adb.
private static final String CONTENT_EXT_EXTRA = "type";
@@ -93,7 +94,7 @@ public class PlayerActivity extends ThemedActivity implements SurfaceHolder.Call
}
private MediaController mediaController;
- View mediController_anchor;
+ private View mediController_anchor;
private View shutterView;
private AspectRatioFrameLayout videoFrame;
private SurfaceView surfaceView;
@@ -106,13 +107,13 @@ public class PlayerActivity extends ThemedActivity implements SurfaceHolder.Call
private int contentType;
private AudioCapabilitiesReceiver audioCapabilitiesReceiver;
- Toolbar toolbar;
+ private Toolbar toolbar;
- boolean fullscreen = false;
+ private boolean fullscreen = false;
// Activity lifecycle
- public void initUI(){
+ private void initUI(){
toolbar.setBackgroundColor(
isApplyThemeOnImgAct()
@@ -183,7 +184,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
case R.id.action_settings:
- startActivity(new Intent(getApplicationContext(), SettingActivity.class));
+ startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
return true;
case R.id.rotate_layout:
@@ -213,7 +214,7 @@ public void setNavBarColor() {
@Override
protected void setStatusBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- if (isTraslucentStatusBar() && isTransparencyZero())
+ if (isTranslucentStatusBar() && isTransparencyZero())
getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
else
getWindow().setStatusBarColor(ColorPalette.getTransparentColor(getPrimaryColor(), getTransparency()));
@@ -323,8 +324,7 @@ public void onAudioCapabilitiesChanged(AudioCapabilities audioCapabilities) {
// Permission request listener method
@Override
- public void onRequestPermissionsResult(int requestCode, String[] permissions,
- int[] grantResults) {
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
preparePlayer(true);
} else {
@@ -436,7 +436,7 @@ public void onStateChanged(boolean playWhenReady, int playbackState) {
text += "unknown";
break;
}
- //Log.d(TAG, "onStateChanged: "+text);
+ Log.d(TAG, "onStateChanged: "+text);
//updateButtonVisibilities();
}
diff --git a/app/src/main/java/com/horaapps/leafpic/SecurityActivity.java b/app/src/main/java/com/horaapps/leafpic/SecurityActivity.java
index dc317d1c2..5ffa1bb17 100644
--- a/app/src/main/java/com/horaapps/leafpic/SecurityActivity.java
+++ b/app/src/main/java/com/horaapps/leafpic/SecurityActivity.java
@@ -27,14 +27,16 @@
* Created by dnld on 22/05/16.
*/
public class SecurityActivity extends ThemedActivity {
- Toolbar toolbar;
- LinearLayout llbody;
- LinearLayout llroot;
- SharedPreferences SP;
- SecurityHelper securityObj;
- SwitchCompat swActiveSecurity;
- SwitchCompat swApplySecurityDelete;
- SwitchCompat swApplySecurityHidden;
+
+ private Toolbar toolbar;
+ private LinearLayout llbody;
+ private LinearLayout llroot;
+ private SharedPreferences SP;
+ private SecurityHelper securityObj;
+ private SwitchCompat swActiveSecurity;
+ private SwitchCompat swApplySecurityDelete;
+ private SwitchCompat swApplySecurityHidden;
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -45,7 +47,6 @@ public void onCreate(Bundle savedInstanceState) {
llbody = (LinearLayout) findViewById(R.id.ll_security_dialog_body);
llroot = (LinearLayout) findViewById(R.id.root);
-
swApplySecurityDelete = (SwitchCompat) findViewById(R.id.security_body_apply_delete_switch);
swActiveSecurity = (SwitchCompat) findViewById(R.id.active_security_switch);
swApplySecurityHidden = (SwitchCompat) findViewById(R.id.security_body_apply_hidden_switch);
@@ -57,9 +58,6 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences.Editor editor = SP.edit();
- /*editor.putBoolean("active_security", isChecked);
- editor.apply();*/
-
securityObj.updateSecuritySetting();
updateSwitchColor(swActiveSecurity, getAccentColor());
@@ -67,17 +65,15 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked)
setPasswordDialog();
else {
- editor.putString("password_value","");
- editor.putBoolean("active_security", false);
+ editor.putString(getString(R.string.preference_password_value),"");
+ editor.putBoolean(getString(R.string.preference_use_password), false);
editor.apply();
toggleEnabledChild(false);
}
- //llbody.setVisibility(isChecked ? View.VISIBLE : View.GONE);
}
});
updateSwitchColor(swActiveSecurity, getAccentColor());
llbody.setEnabled(swActiveSecurity.isChecked());
- //llbody.setVisibility(swActiveSecurity.isChecked() ? View.VISIBLE : View.GONE);
/** - ACTIVE SECURITY ON HIDDEN FOLDER - **/
swApplySecurityHidden.setChecked(securityObj.isPasswordOnHidden());
@@ -85,7 +81,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences.Editor editor = SP.edit();
- editor.putBoolean("password_on_hidden", isChecked);
+ editor.putBoolean(getString(R.string.preference_use_password_on_hidden), isChecked);
editor.apply();
securityObj.updateSecuritySetting();
@@ -100,7 +96,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences.Editor editor = SP.edit();
- editor.putBoolean("password_on_delete", isChecked);
+ editor.putBoolean(getString(R.string.preference_use_password_on_delete), isChecked);
editor.apply();
securityObj.updateSecuritySetting();
@@ -111,10 +107,10 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
setupUI();
}
- public void setPasswordDialog() {
- final AlertDialog.Builder passwordDialog = new AlertDialog.Builder(SecurityActivity.this,
- getDialogStyle());
- final View PasswordDialogLayout = getLayoutInflater().inflate(R.layout.set_password_dialog, null);
+ private void setPasswordDialog() {
+
+ final AlertDialog.Builder passwordDialog = new AlertDialog.Builder(SecurityActivity.this, getDialogStyle());
+ final View PasswordDialogLayout = getLayoutInflater().inflate(R.layout.dialog_set_password, null);
final TextView passwordDialogTitle = (TextView) PasswordDialogLayout.findViewById(R.id.password_dialog_title);
final CardView passwordDialogCard = (CardView) PasswordDialogLayout.findViewById(R.id.password_dialog_card);
final EditText editTextPassword = (EditText) PasswordDialogLayout.findViewById(R.id.password_edittxt);
@@ -135,13 +131,14 @@ public void setPasswordDialog() {
passwordDialog.setView(PasswordDialogLayout);
AlertDialog dialog = passwordDialog.create();
+ dialog.setCancelable(false);
dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
SharedPreferences.Editor editor = SP.edit();
swActiveSecurity.setChecked(false);
- editor.putBoolean("active_security", false);
+ editor.putBoolean(getString(R.string.preference_use_password), false);
editor.apply();
}
});
@@ -149,26 +146,22 @@ public void onClick(DialogInterface dialog, int which) {
dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.ok_action), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- boolean changed;
+ boolean changed = false;
SharedPreferences.Editor editor = SP.edit();
if (editTextPassword.length() > 3) {
if (editTextPassword.getText().toString().equals(editTextConfirmPassword.getText().toString())) {
-
- editor.putString("password_value", editTextPassword.getText().toString());
+ editor.putString(getString(R.string.preference_password_value), editTextPassword.getText().toString());
editor.apply();
securityObj.updateSecuritySetting();
Toast.makeText(getApplicationContext(), R.string.remember_password_message, Toast.LENGTH_SHORT).show();
changed = true;
- } else {
- Toast.makeText(SecurityActivity.this, "password doesn't match", Toast.LENGTH_SHORT).show();
- changed = false;
- }
- } else {
+ } else
+ Toast.makeText(getApplicationContext(), R.string.password_dont_match, Toast.LENGTH_SHORT).show();
+ } else
Toast.makeText(getApplicationContext(), R.string.error_password_length, Toast.LENGTH_SHORT).show();
- changed = false;
- }
+
swActiveSecurity.setChecked(changed);
- editor.putBoolean("active_security", changed);
+ editor.putBoolean(getString(R.string.preference_use_password), changed);
editor.apply();
toggleEnabledChild(changed);
}
@@ -182,7 +175,7 @@ private void toggleEnabledChild(boolean enable) {
swApplySecurityHidden.setEnabled(enable);
}
- public void setupUI() {
+ private void setupUI() {
setStatusBarColor();
setNavBarColor();
toolbar.setBackgroundColor(getPrimaryColor());
diff --git a/app/src/main/java/com/horaapps/leafpic/SelectAlbumBottomSheet.java b/app/src/main/java/com/horaapps/leafpic/SelectAlbumBottomSheet.java
index 2b723b523..ff5b2d9ef 100644
--- a/app/src/main/java/com/horaapps/leafpic/SelectAlbumBottomSheet.java
+++ b/app/src/main/java/com/horaapps/leafpic/SelectAlbumBottomSheet.java
@@ -6,33 +6,33 @@
import android.app.Dialog;
import android.content.SharedPreferences;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffColorFilter;
+import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
-import android.os.Environment;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialogFragment;
import android.support.design.widget.CoordinatorLayout;
import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AlertDialog;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
-import android.widget.Toast;
import com.balysv.materialripple.MaterialRippleLayout;
import com.horaapps.leafpic.Base.Album;
import com.horaapps.leafpic.Base.HandlingAlbums;
+import com.horaapps.leafpic.Views.ThemedActivity;
import com.mikepenz.iconics.view.IconicsImageView;
import java.io.File;
@@ -42,45 +42,45 @@
public class SelectAlbumBottomSheet extends BottomSheetDialogFragment {
- RecyclerView mRecyclerView;
- TextView textViewTitle;
- TextView txtNewFolder;
- IconicsImageView imgHiddenDefault;
- ProgressBar progressBar;
+ private IconicsImageView imgHiddenDefault;
+ private ProgressBar progressBar;
public void setHidden(boolean hidden) {
this.hidden = hidden;
}
- boolean hidden = false;
- HandlingAlbums albums;
+ private boolean hidden = false;
+ private HandlingAlbums albums;
- IconicsImageView imgNewFolder;
- LinearLayout background;
- LinearLayout llNewFolder;
- ArrayList albumArrayList = null;
- SharedPreferences SP;
- View.OnClickListener onClickListener;
+ private LinearLayout llNewFolder;
+ private ArrayList albumArrayList = null;
+ private SharedPreferences SP;
+ private View.OnClickListener onClickListener;
+ private View.OnClickListener onClickListenerNewFolder;
- public void setCurrentPath(String currentPath) {
+ void setCurrentPath(String currentPath) {
this.currentPath = currentPath;
}
- public void setAlbumArrayList(ArrayList albumArrayList){ this.albumArrayList = albumArrayList; }
+ void setAlbumArrayList(ArrayList albumArrayList){ this.albumArrayList = albumArrayList; }
- String currentPath;
- BottomSheetAlbumsAdapter adapter;
+ private String currentPath;
+ private BottomSheetAlbumsAdapter adapter;
public void setTitle(String title) {
this.title = title;
}
- String title;
+ private String title;
public void setOnClickListener(View.OnClickListener onClickListener) {
this.onClickListener = onClickListener;
}
+ void setOnClickListenerNewFolder(View.OnClickListener onClickListenerNF){
+ onClickListenerNewFolder = onClickListenerNF;
+ }
+
private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
@@ -98,7 +98,7 @@ public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style);
albums = new HandlingAlbums(getContext());
View contentView = View.inflate(getContext(), R.layout.copy_move_bottom_sheet, null);
- mRecyclerView = (RecyclerView) contentView.findViewById(R.id.rv_modal_dialog_albums);
+ RecyclerView mRecyclerView = (RecyclerView) contentView.findViewById(R.id.rv_modal_dialog_albums);
adapter = new BottomSheetAlbumsAdapter(onClickListener);
mRecyclerView.setAdapter(adapter);
mRecyclerView.setLayoutManager(new GridLayoutManager(dialog.getContext(), 1));
@@ -106,10 +106,15 @@ public void setupDialog(Dialog dialog, int style) {
/**SET UP DIALOG THEME**/
SP = PreferenceManager.getDefaultSharedPreferences(dialog.getContext());
- contentView.findViewById(R.id.ll_bottom_sheet_title).setBackgroundColor(SP.getInt("accent_color",
- ContextCompat.getColor(dialog.getContext(), R.color.md_light_blue_500)));
+ /**** Scrollbar *****/
+ Drawable drawableScrollBar = ContextCompat.getDrawable(dialog.getContext(), R.drawable.ic_scrollbar);
+ drawableScrollBar.setColorFilter(new PorterDuffColorFilter(SP.getInt("primary_color",
+ ContextCompat.getColor(dialog.getContext(), R.color.md_indigo_500)), PorterDuff.Mode.SRC_ATOP));
- textViewTitle = (TextView) contentView.findViewById(R.id.bottom_sheet_title);
+ contentView.findViewById(R.id.ll_bottom_sheet_title).setBackgroundColor(SP.getInt("primary_color",
+ ContextCompat.getColor(dialog.getContext(), R.color.md_indigo_500)));
+
+ TextView textViewTitle = (TextView) contentView.findViewById(R.id.bottom_sheet_title);
progressBar = (ProgressBar) contentView.findViewById(R.id.spinner_loading);
textViewTitle.setText(title);
textViewTitle.setTextColor(ContextCompat.getColor(dialog.getContext(),R.color.md_white_1000));
@@ -126,33 +131,30 @@ public void onClick(View v) {
}
});
- txtNewFolder = (TextView) contentView.findViewById(R.id.Create_New_Folder_Item);
- txtNewFolder.setTextColor(
- ContextCompat.getColor(getDialog().getContext(), SP.getInt("basic_theme", 1)==1
- ? R.color.md_grey_800
- : R.color.md_grey_200));
-
- imgNewFolder = (IconicsImageView) contentView.findViewById(R.id.Create_New_Folder_Icon);
- imgNewFolder.setColor(
- ContextCompat.getColor(getDialog().getContext(), SP.getInt("basic_theme", 1)==1
- ? R.color.md_light_primary_icon
- : R.color.md_dark_primary_icon));
+ TextView txtNewFolder = (TextView) contentView.findViewById(R.id.Create_New_Folder_Item);
+ IconicsImageView imgNewFolder = (IconicsImageView) contentView.findViewById(R.id.Create_New_Folder_Icon);
llNewFolder = (LinearLayout) contentView.findViewById(R.id.ll_create_new_folder);
- llNewFolder.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- //newFolderDialog();
- }
- });
-
- background = (LinearLayout) contentView.findViewById(R.id.ll_album_modal_dialog);
- background.setBackgroundColor(ContextCompat.getColor(dialog.getContext(),
- SP.getInt("basic_theme", 1)==1
- ? R.color.md_light_cards
- : (SP.getInt("basic_theme", 1)==2
- ? R.color.md_dark_cards
- : R.color.md_black_1000))
- );
+ llNewFolder.setOnClickListener(onClickListenerNewFolder);
+
+ LinearLayout background = (LinearLayout) contentView.findViewById(R.id.ll_album_modal_dialog);
+ switch (SP.getInt(getContext().getString(R.string.preference_base_theme), ThemedActivity.LIGHT_THEME)) {
+ case ThemedActivity.LIGHT_THEME:
+ default:
+ background.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.md_light_cards));
+ imgNewFolder.setColor(ContextCompat.getColor(getContext(), R.color.md_light_primary_icon));
+ txtNewFolder.setTextColor(ContextCompat.getColor(getDialog().getContext(),R.color.md_grey_800));
+ break;
+ case ThemedActivity.DARK_THEME:
+ background.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.md_dark_cards));
+ imgNewFolder.setColor(ContextCompat.getColor(getContext(), R.color.md_dark_primary_icon));
+ txtNewFolder.setTextColor(ContextCompat.getColor(getDialog().getContext(),R.color.md_grey_200));
+ break;
+ case ThemedActivity.AMOLED_THEME:
+ background.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.md_black_1000));
+ imgNewFolder.setColor(ContextCompat.getColor(getContext(), R.color.md_dark_primary_icon));
+ txtNewFolder.setTextColor(ContextCompat.getColor(getDialog().getContext(),R.color.md_grey_200));
+ break;
+ }
dialog.setContentView(contentView);
CoordinatorLayout.LayoutParams layoutParams =
@@ -182,72 +184,90 @@ public void onClick(View v) {
File curFolder;
private List fileList = new ArrayList();
+ ArrayAdapter directoryList;
+
private void newFolderDialog() {
- Toast.makeText(getContext(),"New Folder",Toast.LENGTH_SHORT).show();
+ //Toast.makeText(getContext(),"New Folder",Toast.LENGTH_SHORT).show();
- root = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
- curFolder=root;
- ListDir(curFolder);
+ /*final File curFolder = new File(Environment.getExternalStorageDirectory()
+ .getAbsolutePath());
- final AlertDialog.Builder deleteDialog = new AlertDialog.Builder(getContext(),
- R.style.AlertDialog_Light);
+ directoryList = new ArrayAdapter(getApplicationContext(), android.R.layout
+ .simple_list_item_1, Arrays.asList(curFolder.list()));
- Dialog dialog = new Dialog(getContext());
- dialog.setContentView(R.layout.dialog_explorer);
- dialog.setTitle("Dialog Explorer");
+ final AlertDialog.Builder deleteDialog = new AlertDialog.Builder(MainActivity.this, getDialogStyle());
- textFolder = (TextView) dialog.findViewById(R.id.folder);
- btnUP = (Button) dialog.findViewById(R.id.up);
+ IconicsImageView btnUP;
+ final ListView dialog_ListView;
+
+ View dialogLayout = getLayoutInflater().inflate(R.layout.dialog_explorer, null);
+
+ final TextView textViewCurrentPath = (TextView) dialogLayout.findViewById(R.id.current_path);
+ btnUP = (IconicsImageView) dialogLayout.findViewById(R.id.directory_up);
+ btnUP.setColor(getIconColor());
+ ((IconicsImageView) dialogLayout.findViewById(R.id.folder_icon)).setColor(getIconColor());
+ dialog_ListView = (ListView) dialogLayout.findViewById(R.id.folder_list);
btnUP.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
- ListDir(curFolder.getParentFile());
+ File current = new File(textViewCurrentPath.getText().toString());
+ Log.wtf(TAG,current.getAbsolutePath());
+ if(current.isDirectory()) {
+ directoryList = new ArrayAdapter(getApplicationContext(), android.R.layout
+ .simple_list_item_1, HandlingAlbums.getSubFolders(current.getParentFile()));
+ textViewCurrentPath.setText(current.getParentFile().getAbsolutePath());
+ dialog_ListView.setAdapter(directoryList);
+ }
}
});
+ deleteDialog.setPositiveButton(R.string.ok_action, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ String path = textViewCurrentPath.getText().toString();
+ Toast.makeText(getContext(),"asd", Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ /*deleteDialog.setNeutralButton(R.string.new_folder, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ String path = textViewCurrentPath.getText().toString();
+ Toast.makeText(MainActivity.this, "new folder", Toast.LENGTH_SHORT).show();
+ }
+ });*/
- dialog_ListView = (ListView) dialog.findViewById(R.id.folder_list);
+
+ /*dialog_ListView.setAdapter(directoryList);
+ textViewCurrentPath.setText(curFolder.getAbsolutePath());
+ deleteDialog.setView(dialogLayout);
dialog_ListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
- File selected=new File(fileList.get(position));
+ File selected = new File(textViewCurrentPath.getText()+"/"+ directoryList.getItem(position));
+
+ Log.wtf("asd",selected.isDirectory()+ " - " + selected.getAbsolutePath());
if(selected.isDirectory()){
- ListDir(selected);
+ directoryList = new ArrayAdapter(getContext(), android.R.layout
+ .simple_list_item_1, HandlingAlbums.getSubFolders(selected));
+ textViewCurrentPath.setText(selected.getAbsolutePath());
+ dialog_ListView.setAdapter(directoryList);
} else {
- Toast.makeText(getContext(), selected.toString() + "selected ", Toast.LENGTH_SHORT).show();
- //dialog.dismiss();
+ Toast.makeText(getContext(), selected.toString() + "selected ", Toast.LENGTH_SHORT)
+ .show();
}
}
});
- }
-
- void ListDir(File f){
-
- if(f.equals(root)){
- btnUP.setEnabled(false);
- } else {
- btnUP.setEnabled(true);
- }
-
- curFolder=f;
- textFolder.setText(f.getPath());
-
- File[] files = f.listFiles();
- fileList.clear();
+ deleteDialog.show();*/
- for (File file : files)
- fileList.add(file.getPath());
- ArrayAdapter directoryList = new ArrayAdapter(getContext(),
- android.R.layout.simple_list_item_1, fileList);
- dialog_ListView.setAdapter(directoryList);
}
- class ToggleAlbumsTask extends AsyncTask {
+ private class ToggleAlbumsTask extends AsyncTask {
@Override
protected void onPreExecute() {
@@ -257,7 +277,7 @@ protected void onPreExecute() {
@Override
protected Void doInBackground(Boolean... arg0) {
- albumArrayList = albums.getValidFolders(arg0[0]);
+ albumArrayList = albums.getValidFolders(getContext(), arg0[0]);
return null;
}
@@ -273,7 +293,7 @@ protected void onPostExecute(Void result) {
class BottomSheetAlbumsAdapter extends RecyclerView.Adapter {
private View.OnClickListener listener;
- public BottomSheetAlbumsAdapter( View.OnClickListener lis){
+ BottomSheetAlbumsAdapter(View.OnClickListener lis){
listener=lis;
}
@@ -330,11 +350,11 @@ public int getItemCount() {
return albumArrayList.size();
}
- public class ViewHolder extends RecyclerView.ViewHolder {
+ class ViewHolder extends RecyclerView.ViewHolder {
TextView album_name;
TextView album_media_count;
IconicsImageView imgFolder;
- public ViewHolder(View itemView) {
+ ViewHolder(View itemView) {
super(itemView);
album_name = (TextView) itemView.findViewById(R.id.title_bottom_sheet_item);
album_media_count = (TextView) itemView.findViewById(R.id.count_bottom_sheet_item);
diff --git a/app/src/main/java/com/horaapps/leafpic/SettingActivity.java b/app/src/main/java/com/horaapps/leafpic/SettingActivity.java
deleted file mode 100644
index 3a20e0701..000000000
--- a/app/src/main/java/com/horaapps/leafpic/SettingActivity.java
+++ /dev/null
@@ -1,820 +0,0 @@
-package com.horaapps.leafpic;
-
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.res.ColorStateList;
-import android.graphics.Color;
-import android.os.Build;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.design.widget.FloatingActionButton;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.widget.CardView;
-import android.support.v7.widget.SwitchCompat;
-import android.support.v7.widget.Toolbar;
-import android.view.View;
-import android.widget.CompoundButton;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-import android.widget.ScrollView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.horaapps.leafpic.Views.ThemedActivity;
-import com.horaapps.leafpic.utils.ColorPalette;
-import com.horaapps.leafpic.utils.SecurityHelper;
-import com.horaapps.leafpic.utils.StringUtils;
-import com.mikepenz.fontawesome_typeface_library.FontAwesome;
-import com.mikepenz.google_material_typeface_library.GoogleMaterial;
-import com.mikepenz.iconics.IconicsDrawable;
-import com.mikepenz.iconics.view.IconicsImageView;
-
-import uz.shift.colorpicker.LineColorPicker;
-import uz.shift.colorpicker.OnColorChangedListener;
-
-/**
- * Created by Jibo on 02/03/2016.
- */
-public class SettingActivity extends ThemedActivity {
-
- Toolbar toolbar;
- SharedPreferences SP;
- int BasicThemeValue;
-
- TextView txtGT;
- TextView txtTT;
- TextView txtPT;
- TextView txtVT;
- SecurityHelper securityObj;
-
- SwitchCompat swNavBar;
- SwitchCompat swStatusBar;
- SwitchCompat swMaxLuminosita;
- SwitchCompat swPictureOrientation;
- SwitchCompat swDelayFullImage;
- SwitchCompat swInternalBrowser;
- SwitchCompat swAutoUpdate;
- SwitchCompat swIncludeVideo;
-
- boolean maxLuminosita, pictureOrientation, delayfullimage, internalPlayer, includeVideo;
-
- ScrollView scr;
-
- FloatingActionButton fabMoreThemeOptions;
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- setContentView(R.layout.activity_settings);
- toolbar = (Toolbar) findViewById(R.id.toolbar);
- SP = PreferenceManager.getDefaultSharedPreferences(this);
-
- fabMoreThemeOptions = (FloatingActionButton) findViewById(R.id.fab_more_theme_options);
-
- fabMoreThemeOptions.setBackgroundTintList(ColorStateList.valueOf(getSubTextColor()));
- fabMoreThemeOptions.setImageDrawable(new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_arrow_drop_down).color(Color.WHITE));
- fabMoreThemeOptions.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- //StringUtils.showToast(getApplicationContext(),"yo!");
- LinearLayout llMoreOptions = (LinearLayout) findViewById(R.id.ll_more_options_theme);
- boolean visible = llMoreOptions.getVisibility() == View.VISIBLE;
- llMoreOptions.setVisibility(visible ? View.GONE : View.VISIBLE);
- fabMoreThemeOptions.setImageDrawable(new IconicsDrawable(SettingActivity.this).icon
- (FontAwesome.Icon.faw_arrow_down).color(Color.WHITE));
-
- }
- });
- securityObj = new SecurityHelper(SettingActivity.this);
-
- txtTT = (TextView) findViewById(R.id.theme_setting_title);
- txtGT = (TextView) findViewById(R.id.general_setting_title);
- txtPT = (TextView) findViewById(R.id.picture_setting_title);
- txtVT = (TextView) findViewById(R.id.video_setting_title);
-
- scr = (ScrollView)findViewById(R.id.settingAct_scrollView);
-
-
- setNavBarColor();
- maxLuminosita = SP.getBoolean("set_max_luminosita", false);
- pictureOrientation = SP.getBoolean("set_picture_orientation", false);
- delayfullimage = SP.getBoolean("set_delay_full_image", true);
- internalPlayer = SP.getBoolean("set_internal_player", false);
- includeVideo = SP.getBoolean("set_include_video", true);
-
-
- //EXCLUDED ALBUMS INTENT*****************************************
- LinearLayout ll_BT = (LinearLayout) findViewById(R.id.ll_basic_theme);
- ll_BT.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- BasicThemeDialog();
- }
- });
-
- //SECURITY*****************************************
- LinearLayout ll_SR = (LinearLayout) findViewById(R.id.ll_security);
- ll_SR.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if(!securityObj.isActiveSecurity())
- startActivity(new Intent(getApplicationContext(), SecurityActivity.class));
- else
- askPasswordDialog();
-
- }
- });
-
- //PRIMARY COLOR PIKER*****************************************
- LinearLayout ll_PC = (LinearLayout) findViewById(R.id.ll_primaryColor);
- ll_PC.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- PrimaryColorPikerDialogShow();
- }
- });
-
- //ACCENT COLOR PIKER*****************************************
- LinearLayout ll_AC = (LinearLayout) findViewById(R.id.ll_accentColor);
- ll_AC.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- AccentColorPikerDialogShow();
- }
- });
-
- //EXCLUDED ALBUMS INTENT*****************************************
- LinearLayout ll_EA = (LinearLayout) findViewById(R.id.ll_excluded_album);
- ll_EA.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- startActivity(new Intent(SettingActivity.this, ExcludedAlbumsActivity.class));
- }
- });
-
- //CUSTOMIZE PICTURE VIEWER DIALOG*****************************************
- LinearLayout ll_CPV = (LinearLayout) findViewById(R.id.ll_custom_thirdAct);
- ll_CPV.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- CustomizePictureViewerDialog();
- }
- });
-
-
- /*********** SW Internal Player ************/
- swInternalBrowser = (SwitchCompat) findViewById(R.id.set_internal_player);
- swInternalBrowser.setChecked(internalPlayer);
- swInternalBrowser.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- SharedPreferences.Editor editor = SP.edit();
- editor.putBoolean("set_internal_player", isChecked);
- editor.apply();
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- ((MyApplication) getApplicationContext()).updateAlbums();
- }
- }).start();
-
- updateSwitchColor(swInternalBrowser, getAccentColor());
- }
- });
- updateSwitchColor(swInternalBrowser, getAccentColor());
-
- /*********** SW INCLUDE VIDEO ************/
- swIncludeVideo = (SwitchCompat) findViewById(R.id.set_include_video);
- swIncludeVideo.setChecked(includeVideo);
- swIncludeVideo.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- SharedPreferences.Editor editor = SP.edit();
- editor.putBoolean("set_include_video", isChecked);
- editor.apply();
- updateSwitchColor(swIncludeVideo, getAccentColor());
- }
- });
- updateSwitchColor(swIncludeVideo, getAccentColor());
- /**** Switches ****/
-
- /*********** SW AUTO UPDATE MEDIA ************/
- swAutoUpdate = (SwitchCompat) findViewById(R.id.SetAutoUpdateMedia);
- swAutoUpdate.setChecked(SP.getBoolean("auto_update_media", false));
- swAutoUpdate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- SharedPreferences.Editor editor = SP.edit();
- editor.putBoolean("auto_update_media", isChecked);
- editor.apply();
- updateSwitchColor(swAutoUpdate, getAccentColor());
- }
- });
- updateSwitchColor(swAutoUpdate, getAccentColor());
-
- /*********** SW Delay Full Image ************/
- swDelayFullImage = (SwitchCompat) findViewById(R.id.set_full_resolution);
- swDelayFullImage.setChecked(delayfullimage);
- swDelayFullImage.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- SharedPreferences.Editor editor = SP.edit();
- editor.putBoolean("set_delay_full_image", isChecked);
- editor.apply();
- updateSwitchColor(swDelayFullImage, getAccentColor());
- }
- });
- updateSwitchColor(swDelayFullImage, getAccentColor());
-
- /*********** SW Picture_orientation ************/
- swPictureOrientation = (SwitchCompat) findViewById(R.id.set_picture_orientation);
- swPictureOrientation.setChecked(pictureOrientation);
- swPictureOrientation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- SharedPreferences.Editor editor = SP.edit();
- editor.putBoolean("set_picture_orientation", isChecked);
- editor.apply();
- updateSwitchColor(swPictureOrientation, getAccentColor());
- }
- });
- updateSwitchColor(swPictureOrientation, getAccentColor());
-
- /*********** SW MAX LUMINOSITA ************/
- swMaxLuminosita = (SwitchCompat) findViewById(R.id.set_max_luminosita);
- swMaxLuminosita.setChecked(maxLuminosita);
- swMaxLuminosita.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- SharedPreferences.Editor editor = SP.edit();
- editor.putBoolean("set_max_luminosita", isChecked);
- editor.apply();
- updateSwitchColor(swMaxLuminosita, getAccentColor());
- }
- });
- updateSwitchColor(swMaxLuminosita, getAccentColor());
-
- /*********** SW TRASLUCENT STATUS BAR ****************/
- swStatusBar=(SwitchCompat) findViewById(R.id.SetTraslucentStatusBar);
- swStatusBar.setChecked(isTraslucentStatusBar());
- swStatusBar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- SharedPreferences.Editor editor = SP.edit();
- editor.putBoolean("set_traslucent_statusbar", !isTraslucentStatusBar());
- editor.apply();
- updateTheme();
- setStatusBarColor();
- updateSwitchColor(swStatusBar, getAccentColor());
- }
- });
- updateSwitchColor(swStatusBar, getAccentColor());
-
- /*********** SW COLORED NAV BAR ****************/
- swNavBar=(SwitchCompat) findViewById(R.id.SetColoredNavBar);
- swNavBar.setChecked(isNavigationBarColored());
- swNavBar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- SharedPreferences.Editor editor = SP.edit();
- editor.putBoolean("nav_bar", !isNavigationBarColored());
- editor.apply();
- updateTheme();
- updateSwitchColor(swNavBar, getAccentColor());
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- if (isNavigationBarColored())
- getWindow().setNavigationBarColor(getPrimaryColor());
- else
- getWindow().setNavigationBarColor(ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
- }
- }
- });
- updateSwitchColor(swNavBar, getAccentColor());
- }
-
- public void askPasswordDialog() {
- final AlertDialog.Builder passwordDialogBuilder = new AlertDialog.Builder(SettingActivity.this, getDialogStyle());
- final EditText editTextPassword = securityObj.getInsertPasswordDialog(SettingActivity.this,passwordDialogBuilder);
- passwordDialogBuilder.setNegativeButton(getString(R.string.cancel), null);
- passwordDialogBuilder.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
-
- }
- });
-
- AlertDialog passwordDialog = passwordDialogBuilder.create();
- passwordDialog.show();
-
- passwordDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View
- .OnClickListener() {
- @Override
- public void onClick(View v) {
- if (securityObj.checkPassword(editTextPassword.getText().toString()))
- startActivity(new Intent(getApplicationContext(),SecurityActivity.class));
- else {
- Toast.makeText(passwordDialogBuilder.getContext(), R.string.wrong_password, Toast.LENGTH_SHORT).show();
- editTextPassword.getText().clear();
- editTextPassword.requestFocus();
- }
- }
- });
- }
-
- public void BasicThemeDialog(){
- final AlertDialog.Builder BasicThemeDialog = new AlertDialog.Builder(SettingActivity.this, getDialogStyle());
- SP = PreferenceManager.getDefaultSharedPreferences(SettingActivity.this);
-
- final View BasicTheme_dialogLayout = getLayoutInflater().inflate(R.layout.basic_theme_dialog, null);
- final TextView BasicTheme_Dialog_Title = (TextView) BasicTheme_dialogLayout.findViewById(R.id.basic_theme_title);
- final CardView BasicTheme_CV = (CardView) BasicTheme_dialogLayout.findViewById(R.id.basic_theme_card);
-
- final LinearLayout ll_white = (LinearLayout) BasicTheme_dialogLayout.findViewById(R.id.ll_white_basic_theme);
- final LinearLayout ll_dark = (LinearLayout) BasicTheme_dialogLayout.findViewById(R.id.ll_dark_basic_theme);
- final LinearLayout ll_darkAMOLED = (LinearLayout) BasicTheme_dialogLayout.findViewById(R.id.ll_dark_amoled_basic_theme);
-
- final IconicsImageView whiteSelect = (IconicsImageView) BasicTheme_dialogLayout.findViewById(R.id.white_basic_theme_select);
- final IconicsImageView darkSelect = (IconicsImageView) BasicTheme_dialogLayout.findViewById(R.id.dark_basic_theme_select);
- final IconicsImageView darkAmoledSelect = (IconicsImageView) BasicTheme_dialogLayout.findViewById(R.id.dark_amoled_basic_theme_select);
-
- whiteSelect.setVisibility(View.INVISIBLE);
- darkSelect.setVisibility(View.INVISIBLE);
- darkAmoledSelect.setVisibility(View.VISIBLE);
- switch (getBasicTheme()){
- case 1:
- whiteSelect.setVisibility(View.VISIBLE);
- darkSelect.setVisibility(View.INVISIBLE);
- darkAmoledSelect.setVisibility(View.INVISIBLE);
- break;
- case 2:
- whiteSelect.setVisibility(View.INVISIBLE);
- darkSelect.setVisibility(View.VISIBLE);
- darkAmoledSelect.setVisibility(View.INVISIBLE);
- break;
- case 3:
- whiteSelect.setVisibility(View.INVISIBLE);
- darkSelect.setVisibility(View.INVISIBLE);
- darkAmoledSelect.setVisibility(View.VISIBLE);
- break;
- }
-
- /**SET OBJ THEME**/
- BasicTheme_Dialog_Title.setBackgroundColor(getPrimaryColor());
- BasicTheme_CV.setCardBackgroundColor(getCardBackgroundColor());
-
- ll_white.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- whiteSelect.setVisibility(View.VISIBLE);
- darkSelect.setVisibility(View.INVISIBLE);
- darkAmoledSelect.setVisibility(View.INVISIBLE);
- BasicThemeValue=1;
- }
- });
- ll_dark.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- whiteSelect.setVisibility(View.INVISIBLE);
- darkSelect.setVisibility(View.VISIBLE);
- darkAmoledSelect.setVisibility(View.INVISIBLE);
- BasicThemeValue=2;
- }
- });
- ll_darkAMOLED.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- whiteSelect.setVisibility(View.INVISIBLE);
- darkSelect.setVisibility(View.INVISIBLE);
- darkAmoledSelect.setVisibility(View.VISIBLE);
- BasicThemeValue=3;
- }
- });
- BasicThemeDialog.setView(BasicTheme_dialogLayout);
- BasicThemeDialog.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- SharedPreferences.Editor editor = SP.edit();
- editor.putInt("basic_theme", BasicThemeValue);
- editor.apply();
- dialog.cancel();
- Intent intent = getIntent();
- finish();
- startActivity(intent);
- }
- });
- BasicThemeDialog.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- BasicThemeValue=getBasicTheme();
- }
- });
- BasicThemeDialog.show();
- }
-
- public void PrimaryColorPikerDialogShow(){
- final AlertDialog.Builder PrimaryPikerDialog = new AlertDialog.Builder(SettingActivity.this, getDialogStyle());
- SP = PreferenceManager.getDefaultSharedPreferences(SettingActivity.this);
-
- final View Accent_dialogLayout = getLayoutInflater().inflate(R.layout.color_piker_primary, null);
- final LineColorPicker colorPicker = (LineColorPicker) Accent_dialogLayout.findViewById(R.id.pickerPrimary);
- final LineColorPicker colorPicker2 = (LineColorPicker) Accent_dialogLayout.findViewById(R.id.pickerPrimary2);
- final TextView title = (TextView) Accent_dialogLayout.findViewById(R.id.cp_primary_title);
- CardView cv = (CardView) Accent_dialogLayout.findViewById(R.id.cp_primary_card);
- cv.setCardBackgroundColor(getCardBackgroundColor());
-
- colorPicker.setColors(ColorPalette.getBaseColors(getApplicationContext()));
- for (int i : colorPicker.getColors())
- for (int i2 : ColorPalette.getColors(getBaseContext(), i))
- if (i2 == getPrimaryColor()) {
- colorPicker.setSelectedColor(i);
- colorPicker2.setColors(ColorPalette.getColors(getBaseContext(), i));
- colorPicker2.setSelectedColor(i2);
- break;}
-
- title.setBackgroundColor(getPrimaryColor());
-
- colorPicker.setOnColorChangedListener(new OnColorChangedListener() {
- @Override
- public void onColorChanged(int c) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- if (isTraslucentStatusBar()) {
- getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
- } else getWindow().setStatusBarColor(c);
- }
-
- toolbar.setBackgroundColor(c);
- title.setBackgroundColor(c);
- colorPicker2.setColors(ColorPalette.getColors(getApplicationContext(), colorPicker.getColor()));
- colorPicker2.setSelectedColor(colorPicker.getColor());
- }
- });
- colorPicker2.setOnColorChangedListener(new OnColorChangedListener() {
- @Override
- public void onColorChanged(int c) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- if (isTraslucentStatusBar()) {
- getWindow().setStatusBarColor(ColorPalette.getOscuredColor(c));
- } else getWindow().setStatusBarColor(c);
- if (isNavigationBarColored())
- getWindow().setNavigationBarColor(c);
- else
- getWindow().setNavigationBarColor(ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
- }
- toolbar.setBackgroundColor(c);
- title.setBackgroundColor(c);
- }
- });
-
- PrimaryPikerDialog.setView(Accent_dialogLayout);
- PrimaryPikerDialog.setNeutralButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- if (isTraslucentStatusBar()) {
- getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
- } else getWindow().setStatusBarColor(getPrimaryColor());
- }
- toolbar.setBackgroundColor(getPrimaryColor());
- dialog.cancel();
- }
- });
- PrimaryPikerDialog.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- SharedPreferences.Editor editor = SP.edit();
- editor.putInt("primary_color", colorPicker2.getColor());
- editor.apply();
- updateTheme();
- setNavBarColor();
- setScrollViewColor(scr);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- if (isTraslucentStatusBar()) {
- getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
- } else {
- getWindow().setStatusBarColor(getPrimaryColor());
- }
- }
- }
- });
- PrimaryPikerDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialog) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- if (isTraslucentStatusBar()) {
- getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
- } else getWindow().setStatusBarColor(getPrimaryColor());
- if (isNavigationBarColored())
- getWindow().setNavigationBarColor(getPrimaryColor());
- else getWindow().setNavigationBarColor(ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
- }
- toolbar.setBackgroundColor(getPrimaryColor());
-
- }
- });
- PrimaryPikerDialog.show();
- }
-
- public void AccentColorPikerDialogShow(){
-
- final AlertDialog.Builder AccentPikerDialog = new AlertDialog.Builder(SettingActivity.this, getDialogStyle());
- SP = PreferenceManager.getDefaultSharedPreferences(SettingActivity.this);
-
- final View Accent_dialogLayout = getLayoutInflater().inflate(R.layout.color_piker_accent, null);
- final LineColorPicker colorPicker = (LineColorPicker) Accent_dialogLayout.findViewById(R.id.pickerAccent);
- final TextView title = (TextView) Accent_dialogLayout.findViewById(R.id.cp_accent_title);
- CardView cv = (CardView) Accent_dialogLayout.findViewById(R.id.cp_accent_card);
- cv.setCardBackgroundColor(getCardBackgroundColor());
-
- colorPicker.setColors(ColorPalette.getAccentColors(getApplicationContext()));
- colorPicker.setSelectedColor(getAccentColor());
- title.setBackgroundColor(getAccentColor());
-
- colorPicker.setOnColorChangedListener(new OnColorChangedListener() {
- @Override
- public void onColorChanged(int c) {
- title.setBackgroundColor(c);
- updateAccentViewsColor(colorPicker.getColor());
-
- }
- });
- AccentPikerDialog.setView(Accent_dialogLayout);
-
- AccentPikerDialog.setNeutralButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- updateAccentViewsColor(getAccentColor());
- }
- });
- AccentPikerDialog.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- SharedPreferences.Editor editor = SP.edit();
- editor.putInt("accent_color", colorPicker.getColor());
- editor.apply();
- updateTheme();
- updateAccentViewsColor(getAccentColor());
- }
- });
- AccentPikerDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialog) {
- updateAccentViewsColor(getAccentColor());
- }
- });
- AccentPikerDialog.show();
- }
-
- public void CustomizePictureViewerDialog(){
-
- final AlertDialog.Builder CustomizeViewer = new AlertDialog.Builder(SettingActivity.this, getDialogStyle());
- SP = PreferenceManager.getDefaultSharedPreferences(SettingActivity.this);
-
- final View CustomizeThird_dialogLayout = getLayoutInflater().inflate(R.layout.third_act_theme_dialog, null);
- final TextView txtTitle = (TextView) CustomizeThird_dialogLayout.findViewById(R.id.third_act_theme_title);
- final TextView txtAT3A = (TextView) CustomizeThird_dialogLayout.findViewById(R.id.apply_theme_3thAct_title);
- final TextView txtAT3A_Sub = (TextView) CustomizeThird_dialogLayout.findViewById(R.id.apply_theme_3thAct_title_Sub);
- final IconicsImageView imgAT3A = (IconicsImageView) CustomizeThird_dialogLayout.findViewById(R.id.ll_apply_theme_3thAct_icon);
- final SwitchCompat swApplyTheme_Viewer = (SwitchCompat) CustomizeThird_dialogLayout.findViewById(R.id.apply_theme_3th_act_enabled);
-
- CardView cv = (CardView) CustomizeThird_dialogLayout.findViewById(R.id.third_act_theme_card);
- cv.setCardBackgroundColor(getCardBackgroundColor());
- txtTitle.setBackgroundColor(getPrimaryColor());//or Getprimary
- txtAT3A.setTextColor(getTextColor());
- txtAT3A_Sub.setTextColor(getSubTextColor());
- imgAT3A.setColor(getIconColor());
-
- /**SWITCH**/
- swApplyTheme_Viewer.setChecked(isApplyThemeOnImgAct());
- swApplyTheme_Viewer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- updateSwitchColor(swApplyTheme_Viewer, getAccentColor());
- }
- });
- updateSwitchColor(swApplyTheme_Viewer, getAccentColor());
-
- /**COLOR PICK**/
- final LineColorPicker TrasparentCP = (LineColorPicker) CustomizeThird_dialogLayout.findViewById(R.id.pickerTransparent);
- int[] colors = new int[10];
- for (int i=0; i<10;i++){
- colors[i]=(ColorPalette.getTransparentColor(getPrimaryColor(), ((100-(i*10))*255)/100));
- }
- TrasparentCP.setColors(colors);
- int transColor = ColorPalette.getTransparentColor(getPrimaryColor(), getTransparency());
- TrasparentCP.setSelectedColor(transColor);
-
- /**TEXT VIEWS**/
- final TextView txtTrasparencyTit = (TextView) CustomizeThird_dialogLayout.findViewById(R.id.seek_bar_alpha_title);
- final TextView txtTrasparency_Sub = (TextView) CustomizeThird_dialogLayout.findViewById(R.id.seek_bar_alpha_title_Sub);
- txtTrasparencyTit.setTextColor(getTextColor());
- txtTrasparency_Sub.setTextColor(getSubTextColor());
-
- CustomizeViewer.setView(CustomizeThird_dialogLayout);
- CustomizeViewer.setNeutralButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- CustomizeViewer.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- SharedPreferences.Editor editor = SP.edit();
- editor.putBoolean("apply_theme_img_act", swApplyTheme_Viewer.isChecked());
- int c = Color.alpha(TrasparentCP.getColor());
- editor.putInt("set_alpha", 255 - c);
- editor.apply();
- updateTheme();
- }
- });
- CustomizeViewer.setOnDismissListener(new DialogInterface.OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialog) {
- }
- });
- CustomizeViewer.show();
- }
-
- public void updateAccentViewsColor(int color){
- txtGT.setTextColor(color);
- txtTT.setTextColor(color);
- txtPT.setTextColor(color);
- txtVT.setTextColor(color);
-
- updateSwitchColor(swDelayFullImage, color);
- updateSwitchColor(swNavBar, color);
- updateSwitchColor(swStatusBar, color);
- updateSwitchColor(swMaxLuminosita, color);
- updateSwitchColor(swPictureOrientation, color);
- updateSwitchColor(swInternalBrowser, color);
- updateSwitchColor(swAutoUpdate, color);
- }
-
- @Override
- public void onPostResume() {
- super.onPostResume();
- setTheme();
- securityObj.updateSecuritySetting();
- }
-
- public void setTheme(){
-
- /**** ToolBar *****/
- toolbar.setBackgroundColor(getPrimaryColor());
- setSupportActionBar(toolbar);
- toolbar.setNavigationIcon(
- new IconicsDrawable(this)
- .icon(GoogleMaterial.Icon.gmd_arrow_back)
- .color(Color.WHITE)
- .sizeDp(19));
- toolbar.setNavigationOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onBackPressed();
- }
- });
- toolbar.setTitle(getString(R.string.settings));
-
- /**** Status Bar */
- setStatusBarColor();
-
- /**** Nav Bar ****/
- setNavBarColor();
-
- /**** Recent App */
- setRecentApp(getString(R.string.settings));
-
- txtGT.setTextColor(getAccentColor());
- txtTT.setTextColor(getAccentColor());
- txtPT.setTextColor(getAccentColor());
- txtVT.setTextColor(getAccentColor());
-
-
- setScrollViewColor(scr);
-
- setThemeOnChangeListener();
- }
-
- public void setThemeOnChangeListener(){
-
- setScrollViewColor(scr);
-
- /** BackGround **/
- LinearLayout bg = (LinearLayout) findViewById(R.id.setting_background);
- bg.setBackgroundColor(getBackgroundColor());
-
- /** Cards **/
- CardView cvGeneral = (CardView) findViewById(R.id.general_setting_card);
- CardView cvTheme = (CardView) findViewById(R.id.theme_setting_card);
- CardView cvPicture = (CardView) findViewById(R.id.preview_picture_setting_card);
- CardView cvVideo= (CardView) findViewById(R.id.video_setting_card);
-
- int color = getCardBackgroundColor();
- cvGeneral.setCardBackgroundColor(color);
- cvTheme.setCardBackgroundColor(color);
- cvPicture.setCardBackgroundColor(color);
- cvVideo.setCardBackgroundColor(color);
-
- /** Icons **/
- IconicsImageView imgOrient = (IconicsImageView) findViewById(R.id.ll_switch_picture_orientation_icon);
- IconicsImageView imgMax = (IconicsImageView) findViewById(R.id.ll_switch_max_luminosita_icon);
- IconicsImageView imgDelay = (IconicsImageView) findViewById(R.id.ll_switch_full_resolution_icon);
-
- IconicsImageView imgTSB = (IconicsImageView) findViewById(R.id.Traslucent_StatusBar_Icon);
- IconicsImageView imgC3A = (IconicsImageView) findViewById(R.id.custom_3thAct_icon);
- IconicsImageView imgPC = (IconicsImageView) findViewById(R.id.PrimaryColor_Icon);
- IconicsImageView imgAC = (IconicsImageView) findViewById(R.id.accentColor_Icon);
- IconicsImageView imgBT = (IconicsImageView) findViewById(R.id.basic_theme_icon);
- IconicsImageView imgNB = (IconicsImageView) findViewById(R.id.NavBar_Icon);
- IconicsImageView imgEA = (IconicsImageView) findViewById(R.id.Excluded_Album_Icon);
- IconicsImageView imgIN = (IconicsImageView) findViewById(R.id.internal_player_Icon);
- IconicsImageView imgIV = (IconicsImageView) findViewById(R.id.internal_include_video);
- IconicsImageView imgAUM = (IconicsImageView) findViewById(R.id.auto_update_media_Icon);
- IconicsImageView imgSR = (IconicsImageView) findViewById(R.id.security_icon);
-
-
- color = getIconColor();
- imgMax.setColor(color);
- imgIN.setColor(color);
- imgDelay.setColor(color);
- imgC3A.setColor(color);
- imgTSB.setColor(color);
- imgPC.setColor(color);
- imgAC.setColor(color);
- imgBT.setColor(color);
- imgNB.setColor(color);
- imgOrient.setColor(color);
- imgEA.setColor(color);
- imgAUM.setColor(color);
- imgSR.setColor(color);
- imgIV.setColor(color);
-
- /** TextViews **/
- TextView txtMax = (TextView) findViewById(R.id.max_luminosita_Item);
- TextView txtDelay = (TextView) findViewById(R.id.full_resolution_Item);
- TextView txtOrient = (TextView) findViewById(R.id.picture_orientation_Item);
- TextView txtC3AT = (TextView) findViewById(R.id.custom_3thAct_title);
- TextView txtTSB = (TextView) findViewById(R.id.Traslucent_StatusBar_Item);
- TextView txtPC = (TextView) findViewById(R.id.PrimaryColor_Item);
- TextView txtAC = (TextView) findViewById(R.id.accentColor_Item);
- TextView txtBTI = (TextView) findViewById(R.id.basic_theme_item);
- TextView txtNB = (TextView) findViewById(R.id.NavBar_Item);
- TextView txtEAT = (TextView) findViewById(R.id.Excluded_Album_Item_Title);
- TextView txtInt = (TextView) findViewById(R.id.internal_player_Item);
- TextView txtIV = (TextView) findViewById(R.id.include_video_Item);
-
- TextView txtAUM = (TextView) findViewById(R.id.auto_update_media_Item);
- TextView txtSR = (TextView) findViewById(R.id.security_item_title);
-
- color=getTextColor();
- txtInt.setTextColor(color);
- txtMax.setTextColor(color);
- txtOrient.setTextColor(color);
- txtC3AT.setTextColor(color);
- txtTSB.setTextColor(color);
- txtPC.setTextColor(color);
- txtAC.setTextColor(color);
- txtBTI.setTextColor(color);
- txtNB.setTextColor(color);
- txtEAT.setTextColor(color);
- txtDelay.setTextColor(color);
- txtAUM.setTextColor(color);
- txtSR.setTextColor(color);
- txtIV.setTextColor(color);
-
- /** Sub Text Views**/
- TextView txtMax_Sub = (TextView) findViewById(R.id.max_luminosita_Item_Sub);
- TextView txtDelay_Sub = (TextView) findViewById(R.id.full_resolution_Item_Sub);
- TextView txtOrient_Sub = (TextView) findViewById(R.id.picture_orientation_Item_Sub);
- TextView txtC3A_Sub = (TextView) findViewById(R.id.custom_3thAct_Sub);
- TextView txtTSB_Sub = (TextView) findViewById(R.id.Traslucent_StatusBar_Item_Sub);
- TextView txtPC_Sub = (TextView) findViewById(R.id.PrimaryColor_Item_Sub);
- TextView txtAC_Sub = (TextView) findViewById(R.id.accentColor_Item_Sub);
- TextView txtBTI_Sub = (TextView) findViewById(R.id.basic_theme_item_sub);
- TextView txtNB_Sub = (TextView) findViewById(R.id.NavBar_Item_Sub);
- TextView txtEAT_Sub = (TextView) findViewById(R.id.Excluded_Album_Item_Title_Sub);
- TextView txtInt_Sub = (TextView) findViewById(R.id.internal_player_Item_Sub);
- TextView txtIV_Sub = (TextView) findViewById(R.id.include_video_Item_Sub);
-
- TextView txtAUM_Sub = (TextView) findViewById(R.id.auto_update_media_Item_sub);
- TextView txtSR_Sub = (TextView) findViewById(R.id.security_item_sub);
-
-
- color = getSubTextColor();
- txtInt_Sub.setTextColor(color);
- txtDelay_Sub.setTextColor(color);
- txtMax_Sub.setTextColor(color);
- txtOrient_Sub.setTextColor(color);
- txtC3A_Sub.setTextColor(color);
- txtTSB_Sub.setTextColor(color);
- txtPC_Sub.setTextColor(color);
- txtAC_Sub.setTextColor(color);
- txtBTI_Sub.setTextColor(color);
- txtNB_Sub.setTextColor(color);
- txtEAT_Sub.setTextColor(color);
- txtAUM_Sub.setTextColor(color);
- txtSR_Sub.setTextColor(color);
- txtIV_Sub.setTextColor(color);
-
- }
-}
diff --git a/app/src/main/java/com/horaapps/leafpic/SettingsActivity.java b/app/src/main/java/com/horaapps/leafpic/SettingsActivity.java
new file mode 100644
index 000000000..609be4e30
--- /dev/null
+++ b/app/src/main/java/com/horaapps/leafpic/SettingsActivity.java
@@ -0,0 +1,824 @@
+package com.horaapps.leafpic;
+
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.res.ColorStateList;
+import android.graphics.Color;
+import android.os.Build;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.support.design.widget.FloatingActionButton;
+import android.support.v4.content.ContextCompat;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.CardView;
+import android.support.v7.widget.SwitchCompat;
+import android.support.v7.widget.Toolbar;
+import android.view.View;
+import android.widget.CompoundButton;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+import android.widget.ScrollView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.horaapps.leafpic.Views.ThemedActivity;
+import com.horaapps.leafpic.utils.ColorPalette;
+import com.horaapps.leafpic.utils.SecurityHelper;
+import com.mikepenz.google_material_typeface_library.GoogleMaterial;
+import com.mikepenz.iconics.IconicsDrawable;
+import com.mikepenz.iconics.view.IconicsImageView;
+
+import uz.shift.colorpicker.LineColorPicker;
+import uz.shift.colorpicker.OnColorChangedListener;
+
+/**
+ * Created by Jibo on 02/03/2016.
+ */
+public class SettingsActivity extends ThemedActivity {
+
+ public static final int GOOGLE_MAPS_PROVIDER = 0;
+ public static final int OSM_DE_PROVIDER = 1;
+ public static final int OSM_TYLER_PROVIDER = 2;
+
+ private SharedPreferences SP;
+ private SecurityHelper securityObj;
+
+ private Toolbar toolbar;
+ private ScrollView scr;
+
+ private TextView txtGT;
+ private TextView txtTT;
+ private TextView txtPT;
+ private TextView txtVT;
+
+ private SwitchCompat swNavBar;
+ private SwitchCompat swStatusBar;
+ private SwitchCompat swMaxLuminosita;
+ private SwitchCompat swPictureOrientation;
+ private SwitchCompat swDelayFullImage;
+ private SwitchCompat swInternalBrowser;
+ private SwitchCompat swAutoUpdate;
+ private SwitchCompat swIncludeVideo;
+ private SwitchCompat swSwipeDirection;
+
+ private int baseThemeValue;
+
+ //TESTING STUFF
+ private FloatingActionButton fabMoreThemeOptions;
+ private FloatingActionButton fabMoreGeneralOptions;
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ setContentView(R.layout.activity_settings);
+ toolbar = (Toolbar) findViewById(R.id.toolbar);
+ SP = PreferenceManager.getDefaultSharedPreferences(this);
+
+ //region TESTING
+ fabMoreThemeOptions = (FloatingActionButton) findViewById(R.id.fab_more_theme_options);
+ fabMoreGeneralOptions = (FloatingActionButton) findViewById(R.id.fab_more_general_options);
+
+ fabMoreGeneralOptions.setBackgroundTintList(ColorStateList.valueOf(getSubTextColor()));
+ fabMoreGeneralOptions.setImageDrawable(new IconicsDrawable(this)
+ .icon(GoogleMaterial.Icon.gmd_keyboard_arrow_up)
+ .sizeDp(16).color(getCardBackgroundColor()));
+
+ fabMoreGeneralOptions.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ LinearLayout llMoreOptions = (LinearLayout) findViewById(R.id.ll_more_options_general);
+ boolean visible = llMoreOptions.getVisibility() == View.VISIBLE;
+ llMoreOptions.setVisibility(visible ? View.GONE : View.VISIBLE);
+ fabMoreGeneralOptions.setImageDrawable(new IconicsDrawable(SettingsActivity.this)
+ .icon(visible ? GoogleMaterial.Icon.gmd_keyboard_arrow_up : GoogleMaterial.Icon.gmd_keyboard_arrow_down)
+ .sizeDp(16).color(getCardBackgroundColor()));
+ }
+ });
+
+ fabMoreThemeOptions.setBackgroundTintList(ColorStateList.valueOf(getSubTextColor()));
+ fabMoreThemeOptions.setImageDrawable(new IconicsDrawable(this)
+ .icon(GoogleMaterial.Icon.gmd_keyboard_arrow_up)
+ .sizeDp(16).color(getCardBackgroundColor()));
+ fabMoreThemeOptions.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ LinearLayout llMoreOptions = (LinearLayout) findViewById(R.id.ll_more_options_theme);
+ boolean visible = llMoreOptions.getVisibility() == View.VISIBLE;
+ llMoreOptions.setVisibility(visible ? View.GONE : View.VISIBLE);
+ fabMoreThemeOptions.setImageDrawable(new IconicsDrawable(SettingsActivity.this)
+ .icon(visible ? GoogleMaterial.Icon.gmd_keyboard_arrow_up : GoogleMaterial.Icon.gmd_keyboard_arrow_down)
+ .sizeDp(16).color(getCardBackgroundColor()));
+ }
+ });
+ //endregion
+
+ securityObj = new SecurityHelper(SettingsActivity.this);
+
+ txtTT = (TextView) findViewById(R.id.theme_setting_title);
+ txtGT = (TextView) findViewById(R.id.general_setting_title);
+ txtPT = (TextView) findViewById(R.id.picture_setting_title);
+ txtVT = (TextView) findViewById(R.id.video_setting_title);
+
+ scr = (ScrollView)findViewById(R.id.settingAct_scrollView);
+
+
+ /*** EXCLUDED ALBUMS ***/
+ findViewById(R.id.ll_basic_theme).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ baseThemeDialog();
+ }
+ });
+
+ /*** SECURITY ***/
+ findViewById(R.id.ll_security).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if(!securityObj.isActiveSecurity())
+ startActivity(new Intent(getApplicationContext(), SecurityActivity.class));
+ else
+ askPasswordDialog();
+
+ }
+ });
+
+ /*** PRIMARY COLOR PIKER ***/
+ findViewById(R.id.ll_primaryColor).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ primaryColorPiker();
+ }
+ });
+
+ /*** ACCENT COLOR PIKER ***/
+ findViewById(R.id.ll_accentColor).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ accentColorPiker();
+ }
+ });
+
+ /*** EXCLUDED ALBUMS INTENT ***/
+ findViewById(R.id.ll_excluded_album).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ startActivity(new Intent(SettingsActivity.this, ExcludedAlbumsActivity.class));
+ }
+ });
+
+ /*** CUSTOMIZE PICTURE VIEWER DIALOG ***/
+ findViewById(R.id.ll_custom_thirdAct).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ customizePictureViewer();
+ }
+ });
+
+ /*** MAP PROVIDER DIALOG ***/
+ findViewById(R.id.ll_map_provider).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mapProviderDialog();
+ }
+ });
+
+ /*** SW Internal Player ***/
+ swInternalBrowser = (SwitchCompat) findViewById(R.id.set_internal_player);
+ swInternalBrowser.setChecked(SP.getBoolean(getString(R.string.preference_internal_player), false));
+ swInternalBrowser.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putBoolean(getString(R.string.preference_internal_player), isChecked);
+ editor.apply();
+
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ ((MyApplication) getApplicationContext()).updateAlbums();
+ }
+ }).start();
+
+ updateSwitchColor(swInternalBrowser, getAccentColor());
+ }
+ });
+ updateSwitchColor(swInternalBrowser, getAccentColor());
+
+ /*** SW INCLUDE VIDEO ***/
+ swIncludeVideo = (SwitchCompat) findViewById(R.id.set_include_video);
+ swIncludeVideo.setChecked(SP.getBoolean(getString(R.string.preference_include_video), true));
+ swIncludeVideo.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putBoolean(getString(R.string.preference_include_video), isChecked);
+ editor.apply();
+ updateSwitchColor(swIncludeVideo, getAccentColor());
+ }
+ });
+ updateSwitchColor(swIncludeVideo, getAccentColor());
+
+ /*** SW SWIPE DIRECTION ***/
+ swSwipeDirection = (SwitchCompat) findViewById(R.id.Set_media_viewer_swipe_direction);
+ swSwipeDirection.setChecked(SP.getBoolean(getString(R.string.preference_swipe_direction_inverted), false));
+ swSwipeDirection.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putBoolean(getString(R.string.preference_swipe_direction_inverted), isChecked);
+ editor.apply();
+ updateSwitchColor(swSwipeDirection, getAccentColor());
+ }
+ });
+ updateSwitchColor(swSwipeDirection, getAccentColor());
+
+ /*** SW AUTO UPDATE MEDIA ***/
+ swAutoUpdate = (SwitchCompat) findViewById(R.id.SetAutoUpdateMedia);
+ swAutoUpdate.setChecked(SP.getBoolean(getString(R.string.preference_auto_update_media), false));
+ swAutoUpdate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putBoolean(getString(R.string.preference_auto_update_media), isChecked);
+ editor.apply();
+ updateSwitchColor(swAutoUpdate, getAccentColor());
+ }
+ });
+ updateSwitchColor(swAutoUpdate, getAccentColor());
+
+ /*** SW DELAY FULL-SIZE IMAGE ***/
+ swDelayFullImage = (SwitchCompat) findViewById(R.id.set_full_resolution);
+ swDelayFullImage.setChecked(SP.getBoolean(getString(R.string.preference_delay_full_image), true));
+ swDelayFullImage.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putBoolean(getString(R.string.preference_delay_full_image), isChecked);
+ editor.apply();
+ updateSwitchColor(swDelayFullImage, getAccentColor());
+ }
+ });
+ updateSwitchColor(swDelayFullImage, getAccentColor());
+
+ /*** SW PICTURE ORIENTATION ***/
+ swPictureOrientation = (SwitchCompat) findViewById(R.id.set_picture_orientation);
+ swPictureOrientation.setChecked(SP.getBoolean(getString(R.string.preference_auto_rotate), false));
+ swPictureOrientation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putBoolean(getString(R.string.preference_auto_rotate), isChecked);
+ editor.apply();
+ updateSwitchColor(swPictureOrientation, getAccentColor());
+ }
+ });
+ updateSwitchColor(swPictureOrientation, getAccentColor());
+
+ /*** SW MAX LUMINOSITA ***/
+ swMaxLuminosita = (SwitchCompat) findViewById(R.id.set_max_luminosita);
+ swMaxLuminosita.setChecked(SP.getBoolean(getString(R.string.preference_max_brightness), false));
+ swMaxLuminosita.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putBoolean(getString(R.string.preference_max_brightness), isChecked);
+ editor.apply();
+ updateSwitchColor(swMaxLuminosita, getAccentColor());
+ }
+ });
+ updateSwitchColor(swMaxLuminosita, getAccentColor());
+
+ /*** SW TRANSLUCENT STATUS BAR ***/
+ swStatusBar = (SwitchCompat) findViewById(R.id.SetTraslucentStatusBar);
+ swStatusBar.setChecked(isTranslucentStatusBar());
+ swStatusBar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putBoolean(getString(R.string.preference_translucent_status_bar), isChecked);
+ editor.apply();
+ updateTheme();
+ setStatusBarColor();
+ updateSwitchColor(swStatusBar, getAccentColor());
+ }
+ });
+ updateSwitchColor(swStatusBar, getAccentColor());
+
+ /*** SW COLORED NAV BAR ***/
+ swNavBar = (SwitchCompat) findViewById(R.id.SetColoredNavBar);
+ swNavBar.setChecked(isNavigationBarColored());
+ swNavBar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putBoolean(getString(R.string.preference_colored_nav_bar), isChecked);
+ editor.apply();
+ updateTheme();
+ updateSwitchColor(swNavBar, getAccentColor());
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
+ getWindow().setNavigationBarColor(
+ isNavigationBarColored() ? getPrimaryColor() : ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
+
+ }
+ });
+ updateSwitchColor(swNavBar, getAccentColor());
+ }
+
+ private void askPasswordDialog() {
+ AlertDialog.Builder passwordDialogBuilder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
+ final EditText editTextPassword = securityObj.getInsertPasswordDialog(SettingsActivity.this,passwordDialogBuilder);
+ passwordDialogBuilder.setNegativeButton(getString(R.string.cancel), null);
+
+ passwordDialogBuilder.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ //This should br empty it will be overwrite later
+ //to avoid dismiss of the dialog on wrong password
+ }
+ });
+
+ final AlertDialog passwordDialog = passwordDialogBuilder.create();
+ passwordDialog.show();
+
+ passwordDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (securityObj.checkPassword(editTextPassword.getText().toString())) {
+ passwordDialog.dismiss();
+ startActivity(new Intent(getApplicationContext(), SecurityActivity.class));
+ } else {
+ Toast.makeText(getApplicationContext(), R.string.wrong_password, Toast.LENGTH_SHORT).show();
+ editTextPassword.getText().clear();
+ editTextPassword.requestFocus();
+ }
+ }
+ });
+ }
+
+ private void mapProviderDialog() {
+
+ final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
+ View dialogLayout = getLayoutInflater().inflate(R.layout.dialog_map_provider, null);
+ TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.title);
+ ((CardView) dialogLayout.findViewById(R.id.rename_card)).setCardBackgroundColor(getCardBackgroundColor());
+ dialogTitle.setBackgroundColor(getPrimaryColor());
+
+ final RadioGroup mapProvider = (RadioGroup) dialogLayout.findViewById(R.id.radio_group_maps_provider);
+ RadioButton radioGoogleMaps = (RadioButton) dialogLayout.findViewById(R.id.radio_google_maps);
+ RadioButton radioOsmDe = (RadioButton) dialogLayout.findViewById(R.id.radio_osm_de);
+ RadioButton radioTyler = (RadioButton) dialogLayout.findViewById(R.id.radio_osm_tyler);
+ setRadioTextButtonColor(radioGoogleMaps, getSubTextColor());
+ setRadioTextButtonColor(radioOsmDe, getSubTextColor());
+ setRadioTextButtonColor(radioTyler, getSubTextColor());
+
+ ((TextView) dialogLayout.findViewById(R.id.header_proprietary_maps)).setTextColor(getTextColor());
+ ((TextView) dialogLayout.findViewById(R.id.header_free_maps)).setTextColor(getTextColor());
+ switch (SP.getInt(getString(R.string.preference_map_provider), GOOGLE_MAPS_PROVIDER)) {
+ case GOOGLE_MAPS_PROVIDER:
+ default:
+ radioGoogleMaps.setChecked(true);
+ break;
+ case OSM_DE_PROVIDER:
+ radioOsmDe.setChecked(true);
+ break;
+ case OSM_TYLER_PROVIDER:
+ radioTyler.setChecked(true);
+ break;
+ }
+
+ dialogBuilder.setNegativeButton(R.string.cancel, null);
+ dialogBuilder.setPositiveButton(R.string.ok_action, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putInt(getString(R.string.preference_map_provider), baseThemeValue);
+ editor.apply();
+
+ switch (mapProvider.getCheckedRadioButtonId()) {
+ case R.id.radio_google_maps:
+ default:
+ editor.putInt(getString(R.string.preference_map_provider), GOOGLE_MAPS_PROVIDER);
+ break;
+ case R.id.radio_osm_de:
+ editor.putInt(getString(R.string.preference_map_provider), OSM_DE_PROVIDER);
+ break;
+ case R.id.radio_osm_tyler:
+ editor.putInt(getString(R.string.preference_map_provider), OSM_TYLER_PROVIDER);
+ break;
+ }
+ editor.apply();
+
+ }
+ });
+ dialogBuilder.setView(dialogLayout);
+ dialogBuilder.show();
+ }
+
+ private void baseThemeDialog(){
+ final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
+
+ final View dialogLayout = getLayoutInflater().inflate(R.layout.dialog_basic_theme, null);
+ final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.basic_theme_title);
+ final CardView dialogCardView = (CardView) dialogLayout.findViewById(R.id.basic_theme_card);
+
+ final IconicsImageView whiteSelect = (IconicsImageView) dialogLayout.findViewById(R.id.white_basic_theme_select);
+ final IconicsImageView darkSelect = (IconicsImageView) dialogLayout.findViewById(R.id.dark_basic_theme_select);
+ final IconicsImageView darkAmoledSelect = (IconicsImageView) dialogLayout.findViewById(R.id.dark_amoled_basic_theme_select);
+
+ switch (getBaseTheme()){
+ case LIGHT_THEME:
+ whiteSelect.setVisibility(View.VISIBLE);
+ darkSelect.setVisibility(View.GONE);
+ darkAmoledSelect.setVisibility(View.GONE);
+ break;
+ case DARK_THEME:
+ whiteSelect.setVisibility(View.GONE);
+ darkSelect.setVisibility(View.VISIBLE);
+ darkAmoledSelect.setVisibility(View.GONE);
+ break;
+ case AMOLED_THEME:
+ whiteSelect.setVisibility(View.GONE);
+ darkSelect.setVisibility(View.GONE);
+ darkAmoledSelect.setVisibility(View.VISIBLE);
+ break;
+ }
+
+ /** SET OBJ THEME **/
+ dialogTitle.setBackgroundColor(getPrimaryColor());
+ dialogCardView.setCardBackgroundColor(getCardBackgroundColor());
+
+ dialogLayout.findViewById(R.id.ll_white_basic_theme).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ whiteSelect.setVisibility(View.VISIBLE);
+ darkSelect.setVisibility(View.GONE);
+ darkAmoledSelect.setVisibility(View.GONE);
+ baseThemeValue = LIGHT_THEME;
+ }
+ });
+ dialogLayout.findViewById(R.id.ll_dark_basic_theme).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ whiteSelect.setVisibility(View.GONE);
+ darkSelect.setVisibility(View.VISIBLE);
+ darkAmoledSelect.setVisibility(View.GONE);
+ baseThemeValue = DARK_THEME;
+ }
+ });
+ dialogLayout.findViewById(R.id.ll_dark_amoled_basic_theme).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ whiteSelect.setVisibility(View.GONE);
+ darkSelect.setVisibility(View.GONE);
+ darkAmoledSelect.setVisibility(View.VISIBLE);
+ baseThemeValue = AMOLED_THEME;
+ }
+ });
+ dialogBuilder.setView(dialogLayout);
+ dialogBuilder.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putInt(getString(R.string.preference_base_theme), baseThemeValue);
+ editor.apply();
+ startActivity(getIntent());
+ finish();
+ }
+ });
+ dialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ baseThemeValue = getBaseTheme();
+ }
+ });
+ dialogBuilder.show();
+ }
+
+ private void primaryColorPiker(){
+ final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
+
+ final View dialogLayout = getLayoutInflater().inflate(R.layout.color_piker_primary, null);
+ final LineColorPicker colorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_primary);
+ final LineColorPicker colorPicker2 = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_primary_2);
+ final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.cp_primary_title);
+ CardView dialogCardView = (CardView) dialogLayout.findViewById(R.id.cp_primary_card);
+ dialogCardView.setCardBackgroundColor(getCardBackgroundColor());
+
+ colorPicker.setColors(ColorPalette.getBaseColors(getApplicationContext()));
+ for (int i : colorPicker.getColors())
+ for (int i2 : ColorPalette.getColors(getBaseContext(), i))
+ if (i2 == getPrimaryColor()) {
+ colorPicker.setSelectedColor(i);
+ colorPicker2.setColors(ColorPalette.getColors(getBaseContext(), i));
+ colorPicker2.setSelectedColor(i2);
+ break;}
+
+ dialogTitle.setBackgroundColor(getPrimaryColor());
+
+ colorPicker.setOnColorChangedListener(new OnColorChangedListener() {
+ @Override
+ public void onColorChanged(int c) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ if (isTranslucentStatusBar()) {
+ getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
+ } else getWindow().setStatusBarColor(c);
+ }
+
+ toolbar.setBackgroundColor(c);
+ dialogTitle.setBackgroundColor(c);
+ colorPicker2.setColors(ColorPalette.getColors(getApplicationContext(), colorPicker.getColor()));
+ colorPicker2.setSelectedColor(colorPicker.getColor());
+ }
+ });
+ colorPicker2.setOnColorChangedListener(new OnColorChangedListener() {
+ @Override
+ public void onColorChanged(int c) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ if (isTranslucentStatusBar()) {
+ getWindow().setStatusBarColor(ColorPalette.getOscuredColor(c));
+ } else getWindow().setStatusBarColor(c);
+ if (isNavigationBarColored())
+ getWindow().setNavigationBarColor(c);
+ else
+ getWindow().setNavigationBarColor(ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
+ }
+ toolbar.setBackgroundColor(c);
+ dialogTitle.setBackgroundColor(c);
+ }
+ });
+ dialogBuilder.setView(dialogLayout);
+
+ dialogBuilder.setNeutralButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ if (isTranslucentStatusBar()) {
+ getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
+ } else getWindow().setStatusBarColor(getPrimaryColor());
+ }
+ toolbar.setBackgroundColor(getPrimaryColor());
+ dialog.cancel();
+ }
+ });
+
+ dialogBuilder.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putInt(getString(R.string.preference_primary_color), colorPicker2.getColor());
+ editor.apply();
+ updateTheme();
+ setNavBarColor();
+ setScrollViewColor(scr);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ if (isTranslucentStatusBar()) {
+ getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
+ } else {
+ getWindow().setStatusBarColor(getPrimaryColor());
+ }
+ }
+ }
+ });
+
+ dialogBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ if (isTranslucentStatusBar()) {
+ getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
+ } else getWindow().setStatusBarColor(getPrimaryColor());
+ if (isNavigationBarColored())
+ getWindow().setNavigationBarColor(getPrimaryColor());
+ else getWindow().setNavigationBarColor(ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
+ }
+ toolbar.setBackgroundColor(getPrimaryColor());
+
+ }
+ });
+ dialogBuilder.show();
+ }
+
+ private void accentColorPiker(){
+ final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
+
+ final View dialogLayout = getLayoutInflater().inflate(R.layout.color_piker_accent, null);
+ final LineColorPicker colorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_accent);
+ final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.cp_accent_title);
+ CardView cv = (CardView) dialogLayout.findViewById(R.id.cp_accent_card);
+ cv.setCardBackgroundColor(getCardBackgroundColor());
+
+ colorPicker.setColors(ColorPalette.getAccentColors(getApplicationContext()));
+ colorPicker.setSelectedColor(getAccentColor());
+ dialogTitle.setBackgroundColor(getAccentColor());
+
+ colorPicker.setOnColorChangedListener(new OnColorChangedListener() {
+ @Override
+ public void onColorChanged(int c) {
+ dialogTitle.setBackgroundColor(c);
+ updateAccentViewsColor(colorPicker.getColor());
+
+ }
+ });
+ dialogBuilder.setView(dialogLayout);
+
+ dialogBuilder.setNeutralButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ updateAccentViewsColor(getAccentColor());
+ }
+ });
+ dialogBuilder.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putInt(getString(R.string.preference_accent_color), colorPicker.getColor());
+ editor.apply();
+ updateTheme();
+ updateAccentViewsColor(getAccentColor());
+ }
+ });
+ dialogBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ updateAccentViewsColor(getAccentColor());
+ }
+ });
+ dialogBuilder.show();
+ }
+
+ private void customizePictureViewer(){
+
+ final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(SettingsActivity.this, getDialogStyle());
+
+ View dialogLayout = getLayoutInflater().inflate(R.layout.dialog_media_viewer_theme, null);
+ final SwitchCompat swApplyTheme_Viewer = (SwitchCompat) dialogLayout.findViewById(R.id.apply_theme_3th_act_enabled);
+
+ ((CardView) dialogLayout.findViewById(R.id.third_act_theme_card)).setCardBackgroundColor(getCardBackgroundColor());
+ dialogLayout.findViewById(R.id.third_act_theme_title).setBackgroundColor(getPrimaryColor());//or Getprimary
+ ((TextView) dialogLayout.findViewById(R.id.apply_theme_3thAct_title)).setTextColor(getTextColor());
+ ((TextView) dialogLayout.findViewById(R.id.apply_theme_3thAct_title_Sub)).setTextColor(getSubTextColor());
+ ((IconicsImageView) dialogLayout.findViewById(R.id.ll_apply_theme_3thAct_icon)).setColor(getIconColor());
+
+ swApplyTheme_Viewer.setChecked(isApplyThemeOnImgAct());
+ swApplyTheme_Viewer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ updateSwitchColor(swApplyTheme_Viewer, getAccentColor());
+ }
+ });
+ updateSwitchColor(swApplyTheme_Viewer, getAccentColor());
+
+
+ final LineColorPicker transparencyColorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.pickerTransparent);
+ transparencyColorPicker.setColors(ColorPalette.getTransparencyShadows(getPrimaryColor()));
+ transparencyColorPicker.setSelectedColor(ColorPalette.getTransparentColor(getPrimaryColor(), getTransparency()));
+
+ /**TEXT VIEWS**/
+ ((TextView) dialogLayout.findViewById(R.id.seek_bar_alpha_title)).setTextColor(getTextColor());
+ ((TextView) dialogLayout.findViewById(R.id.seek_bar_alpha_title_Sub)).setTextColor(getSubTextColor());
+
+ dialogBuilder.setView(dialogLayout);
+ dialogBuilder.setNeutralButton(getString(R.string.cancel), null);
+ dialogBuilder.setPositiveButton(getString(R.string.ok_action), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ SharedPreferences.Editor editor = SP.edit();
+ editor.putBoolean(getString(R.string.preference_apply_theme_pager), swApplyTheme_Viewer.isChecked
+ ());
+ int c = Color.alpha(transparencyColorPicker.getColor());
+ editor.putInt(getString(R.string.preference_transparency), 255 - c);
+ editor.apply();
+ updateTheme();
+ }
+ });
+
+ dialogBuilder.show();
+ }
+
+ private void updateAccentViewsColor(int color){
+ txtGT.setTextColor(color);
+ txtTT.setTextColor(color);
+ txtPT.setTextColor(color);
+ txtVT.setTextColor(color);
+
+ updateSwitchColor(swDelayFullImage, color);
+ updateSwitchColor(swNavBar, color);
+ updateSwitchColor(swStatusBar, color);
+ updateSwitchColor(swMaxLuminosita, color);
+ updateSwitchColor(swPictureOrientation, color);
+ updateSwitchColor(swInternalBrowser, color);
+ updateSwitchColor(swAutoUpdate, color);
+ updateSwitchColor(swIncludeVideo, color);
+ updateSwitchColor(swSwipeDirection, color);
+ }
+
+ @Override
+ public void onPostResume() {
+ super.onPostResume();
+ setTheme();
+ securityObj.updateSecuritySetting();
+ }
+
+ private void setTheme(){
+ toolbar.setBackgroundColor(getPrimaryColor());
+ setSupportActionBar(toolbar);
+ toolbar.setNavigationIcon(
+ new IconicsDrawable(this)
+ .icon(GoogleMaterial.Icon.gmd_arrow_back)
+ .color(Color.WHITE)
+ .sizeDp(19));
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ onBackPressed();
+ }
+ });
+
+ setStatusBarColor();
+ setNavBarColor();
+ setRecentApp(getString(R.string.settings));
+
+ txtGT.setTextColor(getAccentColor());
+ txtTT.setTextColor(getAccentColor());
+ txtPT.setTextColor(getAccentColor());
+ txtVT.setTextColor(getAccentColor());
+
+ setScrollViewColor(scr);
+ setThemeOnChangeListener();
+ }
+
+ private void setThemeOnChangeListener(){
+ setScrollViewColor(scr);
+
+ /** BackGround **/
+ findViewById(R.id.setting_background).setBackgroundColor(getBackgroundColor());
+
+ /** Cards **/
+ int color = getCardBackgroundColor();
+ ((CardView) findViewById(R.id.general_setting_card)).setCardBackgroundColor(color);
+ ((CardView) findViewById(R.id.theme_setting_card)).setCardBackgroundColor(color);
+ ((CardView) findViewById(R.id.preview_picture_setting_card)).setCardBackgroundColor(color);
+ ((CardView) findViewById(R.id.video_setting_card)).setCardBackgroundColor(color);
+
+ /** Icons **/
+ color = getIconColor();
+ ((IconicsImageView) findViewById(R.id.ll_switch_picture_orientation_icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.ll_switch_max_luminosita_icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.ll_switch_full_resolution_icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.Traslucent_StatusBar_Icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.custom_3thAct_icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.PrimaryColor_Icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.accentColor_Icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.basic_theme_icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.NavBar_Icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.Excluded_Album_Icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.internal_player_Icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.internal_include_video)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.auto_update_media_Icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.security_icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.fab_options_icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.map_provider_icon)).setColor(color);
+ ((IconicsImageView) findViewById(R.id.media_viewer_swipe_direction_Icon)).setColor(color);
+
+ /** TextViews **/
+ color = getTextColor();
+ ((TextView) findViewById(R.id.max_luminosita_Item)).setTextColor(color);
+ ((TextView) findViewById(R.id.full_resolution_Item)).setTextColor(color);
+ ((TextView) findViewById(R.id.picture_orientation_Item)).setTextColor(color);
+ ((TextView) findViewById(R.id.custom_3thAct_title)).setTextColor(color);
+ ((TextView) findViewById(R.id.Traslucent_StatusBar_Item)).setTextColor(color);
+ ((TextView) findViewById(R.id.PrimaryColor_Item)).setTextColor(color);
+ ((TextView) findViewById(R.id.accentColor_Item)).setTextColor(color);
+ ((TextView) findViewById(R.id.basic_theme_item)).setTextColor(color);
+ ((TextView) findViewById(R.id.NavBar_Item)).setTextColor(color);
+ ((TextView) findViewById(R.id.Excluded_Album_Item_Title)).setTextColor(color);
+ ((TextView) findViewById(R.id.internal_player_Item)).setTextColor(color);
+ ((TextView) findViewById(R.id.include_video_Item)).setTextColor(color);
+ ((TextView) findViewById(R.id.auto_update_media_Item)).setTextColor(color);
+ ((TextView) findViewById(R.id.security_item_title)).setTextColor(color);
+ ((TextView) findViewById(R.id.fab_options_item_title)).setTextColor(color);
+ ((TextView) findViewById(R.id.map_provider_item_title)).setTextColor(color);
+ ((TextView) findViewById(R.id.media_viewer_swipe_direction_Item)).setTextColor(color);
+
+ /** Sub Text Views**/
+ color = getSubTextColor();
+ ((TextView) findViewById(R.id.max_luminosita_Item_Sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.full_resolution_Item_Sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.custom_3thAct_Sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.picture_orientation_Item_Sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.Traslucent_StatusBar_Item_Sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.PrimaryColor_Item_Sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.accentColor_Item_Sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.basic_theme_item_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.NavBar_Item_Sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.Excluded_Album_Item_Title_Sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.internal_player_Item_Sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.include_video_Item_Sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.auto_update_media_Item_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.security_item_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.fab_options_item_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.map_provider_item_sub)).setTextColor(color);
+ ((TextView) findViewById(R.id.media_viewer_swipe_direction_sub)).setTextColor(color);
+ }
+}
diff --git a/app/src/main/java/com/horaapps/leafpic/SplashScreen.java b/app/src/main/java/com/horaapps/leafpic/SplashScreen.java
index c1b78b191..fa585aa97 100644
--- a/app/src/main/java/com/horaapps/leafpic/SplashScreen.java
+++ b/app/src/main/java/com/horaapps/leafpic/SplashScreen.java
@@ -9,10 +9,7 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
-import android.support.v4.view.ViewPager;
-import android.util.Log;
import android.view.View;
-import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -21,7 +18,6 @@
import com.horaapps.leafpic.Base.HandlingAlbums;
import com.horaapps.leafpic.Views.ThemedActivity;
import com.horaapps.leafpic.utils.ColorPalette;
-import com.horaapps.leafpic.utils.Measure;
import com.horaapps.leafpic.utils.PermissionUtils;
import com.horaapps.leafpic.utils.StringUtils;
@@ -32,19 +28,19 @@
*/
public class SplashScreen extends ThemedActivity {
- public final int READ_EXTERNAL_STORAGE_ID = 12;
- static final int PICK_MEDIA_REQUEST = 44;
+ private final int READ_EXTERNAL_STORAGE_ID = 12;
+ private static final int PICK_MEDIA_REQUEST = 44;
- public final static String CONTENT = "content";
- public final static String PICK_MODE = "pick_mode";
+ final static String CONTENT = "content";
+ final static String PICK_MODE = "pick_mode";
- public final static int ALBUMS_PREFETCHED = 23;
- public final static int PHOTS_PREFETCHED = 2;
- public boolean PICK_INTENT = false;
+ final static int ALBUMS_PREFETCHED = 23;
+ final static int PHOTS_PREFETCHED = 2;
+ private boolean PICK_INTENT = false;
public final static String ACTION_OPEN_ALBUM = "com.horaapps.leafpic.OPEN_ALBUM";
- HandlingAlbums albums;
- Album album;
+ private HandlingAlbums albums;
+ private Album album;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -70,18 +66,17 @@ public void run() {
albums = new HandlingAlbums(getApplicationContext());
TextView logo = (TextView) findViewById(R.id.txtLogo);
-// logo.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Metrica-Regular.otf"));
logo.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Figa.ttf"));
//logo.setPadding(0,0,0,25+ Measure.getNavBarHeight(getApplicationContext()));
//logo.animate().translationY(-Measure.getNavBarHeight(getApplicationContext())).start();
- logo.setTextColor(getTextColor());
+ logo.setTextColor(getSubTextColor());
+ //logo.setLetterSpacing((float)0.2);
+
- //ImageView imgLogo = (ImageView) findViewById(R.id.imgLogo);
- //imgLogo.setImageResource(R.drawable.leafpic_big);
RelativeLayout RelLay = (RelativeLayout) findViewById(R.id.Splah_Bg);
RelLay.setBackgroundColor(getBackgroundColor());
- //logo.setTextColor(getInvertedBackgroundColor());
+
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
diff --git a/app/src/main/java/com/horaapps/leafpic/Views/FabScroll.java b/app/src/main/java/com/horaapps/leafpic/Views/FabScrollBehaviour.java
similarity index 83%
rename from app/src/main/java/com/horaapps/leafpic/Views/FabScroll.java
rename to app/src/main/java/com/horaapps/leafpic/Views/FabScrollBehaviour.java
index 3e98e7792..63d444e3b 100644
--- a/app/src/main/java/com/horaapps/leafpic/Views/FabScroll.java
+++ b/app/src/main/java/com/horaapps/leafpic/Views/FabScrollBehaviour.java
@@ -1,7 +1,6 @@
package com.horaapps.leafpic.Views;
import android.content.Context;
-import android.content.res.Resources;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.view.ViewCompat;
@@ -15,18 +14,18 @@
/**
* Created by dnld on 06/03/16.
*/
-public class FabScroll extends FloatingActionButton.Behavior {
+public class FabScrollBehaviour extends FloatingActionButton.Behavior {
- public FabScroll(Context context, AttributeSet attributeSet) {
- super();
+ public FabScrollBehaviour(Context context, AttributeSet attributeSet) {
+ super();
}
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
- if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE)
+ if (dyConsumed > 0)
child.animate().translationY(child.getHeight()*2).setInterpolator(new AccelerateInterpolator(2)).start();
- else
+ else
child.animate().translationY(-Measure.getNavigationBarSize(coordinatorLayout.getContext()).y).setInterpolator(new DecelerateInterpolator(2)).start();
}
diff --git a/app/src/main/java/com/horaapps/leafpic/Views/SquareRelativeLayout.java b/app/src/main/java/com/horaapps/leafpic/Views/SquareRelativeLayout.java
index d2980e7f8..6f9b72a1a 100644
--- a/app/src/main/java/com/horaapps/leafpic/Views/SquareRelativeLayout.java
+++ b/app/src/main/java/com/horaapps/leafpic/Views/SquareRelativeLayout.java
@@ -24,7 +24,7 @@ public SquareRelativeLayout(Context context, AttributeSet attrs, int defStyleAtt
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
- public SquareRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ public SquareRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
diff --git a/app/src/main/java/com/horaapps/leafpic/Views/ThemedActivity.java b/app/src/main/java/com/horaapps/leafpic/Views/ThemedActivity.java
index 238fcbba7..e84884690 100644
--- a/app/src/main/java/com/horaapps/leafpic/Views/ThemedActivity.java
+++ b/app/src/main/java/com/horaapps/leafpic/Views/ThemedActivity.java
@@ -1,5 +1,6 @@
package com.horaapps.leafpic.Views;
+import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
@@ -13,10 +14,11 @@
import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.AppCompatCheckBox;
import android.support.v7.widget.SwitchCompat;
import android.view.View;
+import android.widget.ArrayAdapter;
import android.widget.EditText;
+import android.widget.RadioButton;
import android.widget.ScrollView;
import android.widget.TextView;
@@ -27,6 +29,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.util.ArrayList;
/**
* Created by dnld on 23/02/16.
@@ -37,34 +40,34 @@ public class ThemedActivity extends AppCompatActivity {
public static final int LIGHT_THEME = 1;
public static final int AMOLED_THEME = 3;
- SharedPreferences SP;
+ private SharedPreferences SP;
private int primaryColor;
private int accentColor;
private int basicTheme;
private boolean coloredNavBar;
private boolean oscuredStatusBar;
- private boolean applyThemeImgAct; //TASPARENCY
+ private boolean applyThemeImgAct;
public boolean isNavigationBarColored() {
return coloredNavBar;
}
- public boolean isTraslucentStatusBar() {
+ public boolean isTranslucentStatusBar() {
return oscuredStatusBar;
}
- public boolean isApplyThemeOnImgAct() {
+ protected boolean isApplyThemeOnImgAct() {
return applyThemeImgAct;
}
- public boolean isTransparencyZero() {
- return 255 - SP.getInt("set_alpha", 0) == 255;
+ protected boolean isTransparencyZero() {
+ return 255 - SP.getInt(getString(R.string.preference_transparency), 0) == 255;
}
public int getTransparency() {
- return 255 - SP.getInt("set_alpha", 0);
+ return 255 - SP.getInt(getString(R.string.preference_transparency), 0);
}
public int getPrimaryColor() {
@@ -75,10 +78,9 @@ public int getAccentColor() {
return accentColor;
}
- public int getBasicTheme(){ return basicTheme; }
+ public int getBaseTheme(){ return basicTheme; }
- //METHOD
- public int getBackgroundColor(){
+ protected int getBackgroundColor(){
int color;
switch (basicTheme){
case DARK_THEME:color = ContextCompat.getColor(getApplicationContext(), R.color.md_dark_background);break;
@@ -89,12 +91,20 @@ public int getBackgroundColor(){
return color;
}
- public int getInvertedBackgroundColor(){
+ protected Drawable getPlaceHolder(){
+ switch (basicTheme){
+ case DARK_THEME : return ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_empty);
+ case AMOLED_THEME : return ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_empty_amoled);
+ case LIGHT_THEME: return ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_empty_white);
+ }
+ return null;
+ }
+
+ protected int getInvertedBackgroundColor(){
int color;
switch (basicTheme){
case DARK_THEME:color = ContextCompat.getColor(getApplicationContext(), R.color.md_light_background);break;
- case AMOLED_THEME:color = ContextCompat.getColor(getApplicationContext(), R.color
- .md_light_background);break;
+ case AMOLED_THEME:color = ContextCompat.getColor(getApplicationContext(), R.color.md_light_background);break;
case LIGHT_THEME:
default:color = ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000);
}
@@ -116,8 +126,7 @@ public int getSubTextColor(){
int color;
switch (basicTheme){
case DARK_THEME:color = ContextCompat.getColor(getApplicationContext(), R.color.md_grey_400);break;
- case AMOLED_THEME:color = ContextCompat.getColor(getApplicationContext(), R.color.md_grey_400);
- break;
+ case AMOLED_THEME:color = ContextCompat.getColor(getApplicationContext(), R.color.md_grey_400);break;
case LIGHT_THEME:
default:color = ContextCompat.getColor(getApplicationContext(), R.color.md_grey_600);
}
@@ -137,13 +146,13 @@ public int getCardBackgroundColor(){
public int getIconColor(){
int color;
switch (basicTheme){
- case DARK_THEME:case AMOLED_THEME:color = ContextCompat.getColor(getApplicationContext(), R.color.md_white_1000);break;
- case LIGHT_THEME:default:color = ContextCompat.getColor(getApplicationContext(), R.color.md_light_primary_icon);
+ case DARK_THEME: case AMOLED_THEME: color = ContextCompat.getColor(getApplicationContext(), R.color.md_white_1000);break;
+ case LIGHT_THEME: default: color = ContextCompat.getColor(getApplicationContext(), R.color.md_light_primary_icon);
}
return color;
}
- public int getDrawerBackground(){
+ protected int getDrawerBackground(){
int color;
switch (basicTheme){
case DARK_THEME:color = ContextCompat.getColor(getApplicationContext(), R.color.md_dark_cards);break;
@@ -156,7 +165,7 @@ public int getDrawerBackground(){
public int getDialogStyle(){
int style;
- switch (getBasicTheme()){
+ switch (getBaseTheme()){
case DARK_THEME: style = R.style.AlertDialog_Dark;break;
case AMOLED_THEME: style = R.style.AlertDialog_Dark_Amoled;break;
case LIGHT_THEME: default: style = R.style.AlertDialog_Light;
@@ -164,9 +173,9 @@ public int getDialogStyle(){
return style;
}
- public int getPopupToolbarStyle(){
+ protected int getPopupToolbarStyle(){
int style;
- switch (getBasicTheme()){
+ switch (getBaseTheme()){
case DARK_THEME: style = R.style.DarkActionBarMenu;break;
case AMOLED_THEME: style = R.style.AmoledDarkActionBarMenu;break;
case LIGHT_THEME: default: style = R.style.LightActionBarMenu;
@@ -174,9 +183,15 @@ public int getPopupToolbarStyle(){
return style;
}
+ protected ArrayAdapter getSpinnerAdapter(ArrayList items) {
+ switch (getBaseTheme()){
+ case AMOLED_THEME:
+ case DARK_THEME: return new ArrayAdapter(this, R.layout.spinner_item_light, items);
+ case LIGHT_THEME: default: return new ArrayAdapter(this, R.layout.spinner_item_dark, items);
+ }
+ }
-
- public int getDefaultThemeToolbarColor3th(){
+ protected int getDefaultThemeToolbarColor3th(){
int color;
switch (basicTheme){
case DARK_THEME:color = ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000); break;
@@ -186,7 +201,7 @@ public int getDefaultThemeToolbarColor3th(){
return color;
}
- public ColorStateList getRadioButtonColor(){
+ private ColorStateList getRadioButtonColor(){
return new ColorStateList(
new int[][]{
new int[]{ -android.R.attr.state_enabled }, //disabled
@@ -194,6 +209,20 @@ public ColorStateList getRadioButtonColor(){
}, new int[] { getTextColor(), getAccentColor() });
}
+ protected void updateRadioButtonColor(RadioButton radioButton) {
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ radioButton.setButtonTintList(getRadioButtonColor());
+ radioButton.setTextColor(getTextColor());
+ }
+ }
+ protected void setRadioTextButtonColor(RadioButton radioButton, int color) {
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ radioButton.setButtonTintList(getRadioButtonColor());
+ radioButton.setTextColor(color);
+ }
+ }
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setNavBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (isNavigationBarColored()) getWindow().setNavigationBarColor(getPrimaryColor());
@@ -207,20 +236,6 @@ public void updateSwitchColor(SwitchCompat sw, int color){
sw.getTrackDrawable().setColorFilter(sw.isChecked() ? ColorPalette.getTransparentColor(color,100): getBackgroundColor(), PorterDuff.Mode.MULTIPLY);
}
- public void updateCheckBoxColor(AppCompatCheckBox sw, int color){
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- sw.getButtonDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
- }
- /* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- if(sw.isChecked())
- sw.getButtonDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
- else
- sw.getButtonDrawable().setColorFilter(getTextColor(), PorterDuff.Mode.SRC_IN);
- if(getBasicTheme()!=3)sw.getButtonDrawable().setColorFilter(getBackgroundColor(), PorterDuff.Mode.SRC_IN);
- else sw.getButtonDrawable().setColorFilter(getSubTextColor(), PorterDuff.Mode.SRC_IN);
- }*/
- }
-
@Override
public void onResume(){
super.onResume();
@@ -238,9 +253,10 @@ public void onCreate(Bundle savedInstanceState) {
updateTheme();
}
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected void setStatusBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- if (isTraslucentStatusBar())
+ if (isTranslucentStatusBar())
getWindow().setStatusBarColor(ColorPalette.getOscuredColor(getPrimaryColor()));
else
getWindow().setStatusBarColor(getPrimaryColor());
@@ -261,15 +277,9 @@ protected void setScrollViewColor(ScrollView scr){
Method method = scrollBar.getClass().getDeclaredMethod("setVerticalThumbDrawable", Drawable.class);
method.setAccessible(true);
- // Set your drawable here.
- //Bitmap myBitmap = Bitmap.createBitmap(5, 5, Bitmap.Config.ARGB_8888);
- //myBitmap.setPixel(0, 0, getPrimaryColor());
-
ColorDrawable ColorDraw = new ColorDrawable(getPrimaryColor());
method.invoke(scrollBar, ColorDraw);
- }
- catch(Exception e)
- {
+ } catch(Exception e) {
e.printStackTrace();
}
}
@@ -297,19 +307,21 @@ public static void setCursorDrawableColor(EditText editText, int color) {
}
public void updateTheme(){
- this.primaryColor = SP.getInt("primary_color", ContextCompat.getColor(getApplicationContext(),R.color.md_indigo_500));//DEFAULT;
- this.accentColor = SP.getInt("accent_color", ContextCompat.getColor(getApplicationContext(), R.color.md_light_blue_500));//COLOR DEFAULT
- basicTheme = SP.getInt("basic_theme", 1);//WHITE DEFAULT
- coloredNavBar = SP. getBoolean("nav_bar", false);
- oscuredStatusBar = SP.getBoolean("set_traslucent_statusbar",true);
- applyThemeImgAct = SP.getBoolean("apply_theme_img_act", true);
+ this.primaryColor = SP.getInt(getString(R.string.preference_primary_color),
+ ContextCompat.getColor(getApplicationContext(), R.color.md_indigo_500));
+ this.accentColor = SP.getInt(getString(R.string.preference_accent_color),
+ ContextCompat.getColor(getApplicationContext(), R.color.md_light_blue_500));
+ basicTheme = SP.getInt(getString(R.string.preference_base_theme), LIGHT_THEME);
+ coloredNavBar = SP. getBoolean(getString(R.string.preference_colored_nav_bar), false);
+ oscuredStatusBar = SP.getBoolean(getString(R.string.preference_translucent_status_bar),true);
+ applyThemeImgAct = SP.getBoolean(getString(R.string.preference_apply_theme_pager), true);
}
-
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setRecentApp(String text){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
BitmapDrawable drawable = ((BitmapDrawable) getDrawable(R.mipmap.ic_launcher));
setTaskDescription(new ActivityManager.TaskDescription(text, drawable.getBitmap(), getPrimaryColor()));
}
}
-}
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/horaapps/leafpic/utils/AffixMedia.java b/app/src/main/java/com/horaapps/leafpic/utils/AffixMedia.java
index 3919c9972..96d4341ee 100644
--- a/app/src/main/java/com/horaapps/leafpic/utils/AffixMedia.java
+++ b/app/src/main/java/com/horaapps/leafpic/utils/AffixMedia.java
@@ -18,7 +18,7 @@
*/
public class AffixMedia {
- public static final String DIRECTORY_NAME = "AffixedPictures";
+ private static final String DIRECTORY_NAME = "AffixedPictures";
/* public static void AffixBitmapList(Context ctx, ArrayList bitmapArray, boolean
vertical, String folderPath, String format){
@@ -45,7 +45,7 @@ public static void AffixBitmapList(Context ctx, ArrayList bitmapArray, A
saveFile(ctx, unionBitmap, options);
}
- public static Canvas combineBitmap(Canvas cs, ArrayList bpmList, boolean vertical){
+ private static Canvas combineBitmap(Canvas cs, ArrayList bpmList, boolean vertical){
if (vertical){
int height = bpmList.get(0).getHeight();
cs.drawBitmap(bpmList.get(0), 0f, 0f, null);
@@ -67,9 +67,7 @@ public static Canvas combineBitmap(Canvas cs, ArrayList bpmList, boolean
}
}
- public static void saveFile(Context context, Bitmap bmp, AffixOptions options){
- Log .wtf("asd",String.format("%s/%d.%s",options.getFolderPath(),System.currentTimeMillis
- (),options.getExtensionFormat()));
+ private static void saveFile(Context context, Bitmap bmp, AffixOptions options){
try {
File file = new File(options.getFolderPath()+'/'+(System.currentTimeMillis()) + "." +
options.getExtensionFormat());
@@ -84,7 +82,7 @@ public static void saveFile(Context context, Bitmap bmp, AffixOptions options){
}
}
- public static int getMaxBitmapWidth(ArrayList bpmHeightArray){
+ private static int getMaxBitmapWidth(ArrayList bpmHeightArray){
int width = bpmHeightArray.get(0).getWidth();
for (int i=1;i bpmHeightArray){
return width;
}
- public static int getBitmapsWidth(ArrayList bpmHeightArray){
+ private static int getBitmapsWidth(ArrayList bpmHeightArray){
int width=0;
for (int i=0;i bpmHeightArray){
return width;
}
- public static int getMaxBitmapHeight(ArrayList bpmHeightArray){
+ private static int getMaxBitmapHeight(ArrayList bpmHeightArray){
int height = bpmHeightArray.get(0).getHeight();
for (int i=1;i bpmHeightArray){
return height;
}
- public static int getBitmapsHeight(ArrayList bpmHeightArray){
+ private static int getBitmapsHeight(ArrayList bpmHeightArray){
int height=0;
for (int i=0;i= Build.VERSION_CODES.LOLLIPOP) {
+ DocumentFile document = getDocumentFile(context, file, true, true);
+ // getDocumentFile implicitly creates the directory.
+ return document != null && document.exists();
+ }
+
+ return file.exists();
+ }
+
+ public static boolean copyFile(Context context, @NonNull final File source, @NonNull final File target) {
+ java.io.FileInputStream inStream = null;
+ java.io.OutputStream outStream = null;
+ java.nio.channels.FileChannel inChannel = null;
+ FileChannel outChannel = null;
+ try {
+ inStream = new FileInputStream(source);
+
+ // First try the normal way
+ if (isWritable(target)) {
+ // standard way
+ outStream = new java.io.FileOutputStream(target);
+ inChannel = inStream.getChannel();
+ outChannel = ((FileOutputStream) outStream).getChannel();
+ inChannel.transferTo(0, inChannel.size(), outChannel);
+ } else {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ // Storage Access Framework
+ DocumentFile targetDocument = getDocumentFile(context,target, false, true);
+ if (targetDocument != null) {
+ outStream = context.getContentResolver().openOutputStream(targetDocument.getUri());
+ }
+ }
+ else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
+ // Workaround for Kitkat ext SD card
+ Uri uri = getUriFromFile(context,target.getAbsolutePath());
+ if (uri != null) {
+ outStream = context.getContentResolver().openOutputStream(uri);
+ }
+ }
+ else {
+ return false;
+ }
+
+ if (outStream != null) {
+ // Both for SAF and for Kitkat, write to output stream.
+ byte[] buffer = new byte[4096]; // MAGIC_NUMBER
+ int bytesRead;
+ while ((bytesRead = inStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, bytesRead);
+ }
+ }
+
+ }
+ }
+ catch (Exception e) {
+ Log.e(TAG, "Error when copying file from " + source.getAbsolutePath() + " to " + target.getAbsolutePath(), e);
+ return false;
+ }
+ finally {
+ try {
+ inStream.close();
+ }
+ catch (Exception e) {
+ // ignore exception
+ }
+ try {
+ outStream.close();
+ }
+ catch (Exception e) {
+ // ignore exception
+ }
+ try {
+ inChannel.close();
+ }
+ catch (Exception e) {
+ // ignore exception
+ }
+ try {
+ outChannel.close();
+ }
+ catch (Exception e) {
+ // ignore exception
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Move a file. The target file may even be on external SD card.
+ *
+ * @param source The source file
+ * @param target The target file
+ * @return true if the copying was successful.
+ */
+ public static boolean moveFile(Context context, @NonNull final File source, @NonNull final File
+ target) {
+ // First try the normal rename.
+ boolean success = source.renameTo(target);
+
+ if (!success) {
+ success = copyFile(context, source, target);
+ if (success) {
+ success = deleteFile(context, source);
+ }
+ }
+
+ return success;
+ }
+
+ /**
+ * Get an Uri from an file path.
+ *
+ * @param path The file path.
+ * @return The Uri.
+ */
+ public static Uri getUriFromFile(Context context, final String path) {
+ ContentResolver resolver = context.getContentResolver();
+
+ Cursor filecursor = resolver.query(MediaStore.Files.getContentUri("external"),
+ new String[] {BaseColumns._ID}, MediaStore.MediaColumns.DATA + " = ?",
+ new String[] {path}, MediaStore.MediaColumns.DATE_ADDED + " desc");
+ if (filecursor == null) {
+ return null;
+ }
+ filecursor.moveToFirst();
+
+ if (filecursor.isAfterLast()) {
+ filecursor.close();
+ ContentValues values = new ContentValues();
+ values.put(MediaStore.MediaColumns.DATA, path);
+ return resolver.insert(MediaStore.Files.getContentUri("external"), values);
+ }
+ else {
+ int imageId = filecursor.getInt(filecursor.getColumnIndex(BaseColumns._ID));
+ Uri uri = MediaStore.Files.getContentUri("external").buildUpon().appendPath(
+ Integer.toString(imageId)).build();
+ filecursor.close();
+ return uri;
+ }
+ }
+
+ /**
+ * Delete a folder.
+ *
+ * @param file The folder name.
+ * @return true if successful.
+ */
+ public static boolean rmdir(Context context, @NonNull final File file) {
+ if (!file.exists()) {
+ return true;
+ }
+ if (!file.isDirectory()) {
+ return false;
+ }
+ String[] fileList = file.list();
+ if (fileList != null && fileList.length > 0) {
+ // Delete only empty folder.
+ return false;
+ }
+
+ // Try the normal way
+ if (file.delete()) {
+ return true;
+ }
+
+ // Try with Storage Access Framework.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ DocumentFile document = getDocumentFile(context, file, true, true);
+ return document != null && document.delete();
+ }
+
+ // Try the Kitkat workaround.
+ if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
+ ContentResolver resolver = context.getContentResolver();
+ ContentValues values = new ContentValues();
+ values.put(MediaStore.MediaColumns.DATA, file.getAbsolutePath());
+ resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
+
+ // Delete the created entry, such that content provider will delete the file.
+ resolver.delete(MediaStore.Files.getContentUri("external"), MediaStore.MediaColumns.DATA + "=?",
+ new String[] {file.getAbsolutePath()});
+ }
+
+ return !file.exists();
+ }
+
+ /**
+ * Get a DocumentFile corresponding to the given file (for writing on ExtSdCard on Android 5). If the file is not
+ * existing, it is created.
+ *
+ * @param file The file.
+ * @param isDirectory flag indicating if the file should be a directory.
+ * @param createDirectories flag indicating if intermediate path directories should be created if not existing.
+ * @return The DocumentFile
+ */
+ private static DocumentFile getDocumentFile(Context context, @NonNull final File file, final boolean isDirectory, final boolean createDirectories) {
+ Uri[] treeUris = getTreeUris();
+ Uri treeUri = null;
+
+ if (treeUris.length == 0) {
+ return null;
+ }
+
+ String fullPath;
+ try {
+ fullPath = file.getCanonicalPath();
+ }
+ catch (IOException e) {
+ return null;
+ }
+
+ String baseFolder = null;
+
+ // First try to get the base folder via unofficial StorageVolume API from the URIs.
+
+ for (int i = 0; baseFolder == null && i < treeUris.length; i++) {
+ String treeBase = getFullPathFromTreeUri(context,treeUris[i]);
+ if (treeBase != null && fullPath.startsWith(treeBase)) {
+ treeUri = treeUris[i];
+ baseFolder = treeBase;
+ }
+ }
+
+ if (baseFolder == null) {
+ // Alternatively, take root folder from device and assume that base URI works.
+ treeUri = treeUris[0];
+ baseFolder = getExtSdCardFolder(context, file);
+ }
+
+ if (baseFolder == null) {
+ return null;
+ }
+
+ String relativePath = fullPath.substring(baseFolder.length() + 1);
+
+ // start with root of SD card and then parse through document tree.
+ DocumentFile document = DocumentFile.fromTreeUri(context, treeUri);
+
+ String[] parts = relativePath.split("\\/");
+ for (int i = 0; i < parts.length; i++) {
+ DocumentFile nextDocument = document.findFile(parts[i]);
+
+ if (nextDocument == null) {
+ if (i < parts.length - 1) {
+ if (createDirectories) {
+ nextDocument = document.createDirectory(parts[i]);
+ }
+ else {
+ return null;
+ }
+ }
+ else if (isDirectory) {
+ nextDocument = document.createDirectory(parts[i]);
+ }
+ else {
+ nextDocument = document.createFile("image", parts[i]);
+ }
+ }
+ document = nextDocument;
+ }
+
+ return document;
+ }
+
+ /**
+ * Get the stored tree URIs.
+ *
+ * @return The tree URIs.
+ */
+ public static Uri[] getTreeUris() {
+ List uris = new ArrayList();
+
+ Uri uri1 = getSharedPreferenceUri(R.string.key_internal_uri_extsdcard_photos);
+ if (uri1 != null) {
+ uris.add(uri1);
+ }
+
+ /*
+ Uri uri2 = getSharedPreferenceUri(R.string.key_internal_uri_extsdcard_input);
+ if (uri2 != null) {
+ uris.add(uri2);
+ }
+ */
+ return uris.toArray(new Uri[uris.size()]);
+ }
+
+ /**
+ * Retrieve the default shared preferences of the application.
+ *
+ * @return the default shared preferences.
+ */
+ private static SharedPreferences getSharedPreferences() {
+ return PreferenceManager.getDefaultSharedPreferences(MyApplication.getContext());
+ }
+
+ /**
+ * Retrieve an Uri shared preference.
+ *
+ * @param preferenceId the id of the shared preference.
+ * @return the corresponding preference value.
+ */
+ public static Uri getSharedPreferenceUri(final int preferenceId) {
+ String uriString = getSharedPreferences().getString(MyApplication.getContext().getString(preferenceId),
+ null);
+
+ if (uriString == null) {
+ return null;
+ }
+ else {
+ return Uri.parse(uriString);
+ }
+ }
+
+ /**
+ * Set a shared preference for an Uri.
+ *
+ * @param preferenceId the id of the shared preference.
+ * @param uri the target value of the preference.
+ */
+ public static void setSharedPreferenceUri(final int preferenceId, @Nullable final Uri uri) {
+ SharedPreferences.Editor editor = getSharedPreferences().edit();
+ if (uri == null) {
+ editor.putString(MyApplication.getContext().getString(preferenceId), null);
+ }
+ else {
+ editor.putString(MyApplication.getContext().getString(preferenceId), uri.toString());
+ }
+ editor.apply();
+ }
+ /**
+ * Determine the main folder of the external SD card containing the given file.
+ * @param file the file.
+ * @return The main folder of the external SD card containing this file, if the file is on an SD card. Otherwise,
+ * null is returned.
+ */
+ @TargetApi(Build.VERSION_CODES.KITKAT)
+ public static String getExtSdCardFolder(Context context, @NonNull final File file) {
+ String[] extSdPaths = getExtSdCardPaths(context);
+ try {
+ for (String extSdPath : extSdPaths) {
+ if (file.getCanonicalPath().startsWith(extSdPath)) {
+ return extSdPath;
+ }
+ }
+ }
+ catch (IOException e) {
+ return null;
+ }
+ return null;
+ }
+ /**
+ * Get the full path of a document from its tree URI.
+ *
+ * @param treeUri The tree RI.
+ * @return The path (without trailing file separator).
+ */
+ @Nullable
+ private static String getFullPathFromTreeUri(Context context, @Nullable final Uri treeUri) {
+ if (treeUri == null) {
+ return null;
+ }
+ String volumePath = getVolumePath(context, getVolumeIdFromTreeUri(treeUri));
+ if (volumePath == null) {
+ return File.separator;
+ }
+ if (volumePath.endsWith(File.separator)) {
+ volumePath = volumePath.substring(0, volumePath.length() - 1);
+ }
+
+ String documentPath = getDocumentPathFromTreeUri(treeUri);
+ if (documentPath.endsWith(File.separator)) {
+ documentPath = documentPath.substring(0, documentPath.length() - 1);
+ }
+
+ if (documentPath.length() > 0) {
+ if (documentPath.startsWith(File.separator)) {
+ return volumePath + documentPath;
+ }
+ else {
+ return volumePath + File.separator + documentPath;
+ }
+ }
+ else {
+ return volumePath;
+ }
+ }
+
+ /**
+ * Get the volume ID from the tree URI.
+ *
+ * @param treeUri The tree URI.
+ * @return The volume ID.
+ */
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ private static String getVolumeIdFromTreeUri(final Uri treeUri) {
+ final String docId = DocumentsContract.getTreeDocumentId(treeUri);
+ final String[] split = docId.split(":");
+
+ if (split.length > 0) {
+ return split[0];
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Get the document path (relative to volume name) for a tree URI (LOLLIPOP).
+ *
+ * @param treeUri The tree URI.
+ * @return the document path.
+ */
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ private static String getDocumentPathFromTreeUri(final Uri treeUri) {
+ final String docId = DocumentsContract.getTreeDocumentId(treeUri);
+ final String[] split = docId.split(":");
+ if ((split.length >= 2) && (split[1] != null)) {
+ return split[1];
+ }
+ else {
+ return File.separator;
+ }
+ }
+
+ /**
+ * Get the path of a certain volume.
+ *
+ * @param volumeId The volume id.
+ * @return The path.
+ */
+ private static String getVolumePath(Context context, final String volumeId) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
+ return null;
+ }
+
+ try {
+ StorageManager mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
+
+ Class> storageVolumeClazz = Class.forName("android.os.storage.StorageVolume");
+
+ Method getVolumeList = mStorageManager.getClass().getMethod("getVolumeList");
+ Method getUuid = storageVolumeClazz.getMethod("getUuid");
+ Method getPath = storageVolumeClazz.getMethod("getPath");
+ Method isPrimary = storageVolumeClazz.getMethod("isPrimary");
+ Object result = getVolumeList.invoke(mStorageManager);
+
+ final int length = java.lang.reflect.Array.getLength(result);
+ for (int i = 0; i < length; i++) {
+ Object storageVolumeElement = Array.get(result, i);
+ String uuid = (String) getUuid.invoke(storageVolumeElement);
+ Boolean primary = (Boolean) isPrimary.invoke(storageVolumeElement);
+
+ // primary volume?
+ if (primary && PRIMARY_VOLUME_NAME.equals(volumeId)) {
+ return (String) getPath.invoke(storageVolumeElement);
+ }
+
+ // other volumes?
+ if (uuid != null) {
+ if (uuid.equals(volumeId)) {
+ return (String) getPath.invoke(storageVolumeElement);
+ }
+ }
+ }
+
+ // not found.
+ return null;
+ }
+ catch (Exception ex) {
+ return null;
+ }
+ }
+
+ /**
+ * Delete all files in a folder.
+ *
+ * @param folder the folder
+ * @return true if successful.
+ */
+
+ public static boolean deleteFilesInFolder(Context context, @NonNull final File folder) {
+ boolean totalSuccess = true;
+
+ String[] children = folder.list();
+ if (children != null) {
+ for (String child : children) {
+ File file = new File(folder, child);
+ if (!file.isDirectory()) {
+ boolean success = deleteFile(context, file);
+ if (!success) {
+ Log.w(TAG, "Failed to delete file" + child);
+ totalSuccess = false;
+ }
+ }
+ }
+ }
+ return totalSuccess;
+ }
+
+
+
+ /**
+ * Delete a file. May be even on external SD card.
+ *
+ * @param file the file to be deleted.
+ * @return True if successfully deleted.
+ */
+ public static boolean deleteFile(Context context, @NonNull final File file) {
+ // First try the normal deletion.
+ if (file.delete()) {
+ return true;
+ }
+
+ // Try with Storage Access Framework.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ DocumentFile document = getDocumentFile(context, file, false, true);
+ return document != null && document.delete();
+ }
+
+ // Try the Kitkat workaround.
+ if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
+ ContentResolver resolver = context.getContentResolver();
+
+ try {
+ Uri uri = null;//MediaStoreUtil.getUriFromFile(file.getAbsolutePath());
+ if (uri != null) {
+ resolver.delete(uri, null, null);
+ }
+ return !file.exists();
+ }
+ catch (Exception e) {
+ Log.e(TAG, "Error when deleting file " + file.getAbsolutePath(), e);
+ return false;
+ }
+ }
+
+ return !file.exists();
+ }
+ @TargetApi(Build.VERSION_CODES.KITKAT)
+ public static String[] getExtSdCardPaths(Context context) {
+ List paths = new ArrayList();
+ for (File file : context.getExternalFilesDirs("external")) {
+ if (file != null && !file.equals(context.getExternalFilesDir("external"))) {
+ int index = file.getAbsolutePath().lastIndexOf("/Android/data");
+ if (index < 0) {
+ Log.w("asd", "Unexpected external file dir: " + file.getAbsolutePath());
+ } else {
+ String path = file.getAbsolutePath().substring(0, index);
+ try {
+ path = new File(path).getCanonicalPath();
+ }
+ catch (IOException e) {
+ // Keep non-canonical path.
+ }
+ paths.add(path);
+ }
+ }
+ }
+ return paths.toArray(new String[paths.size()]);
+ }
+
+
public static String getPath(final Context context, final Uri uri)
{
// DocumentProvider
diff --git a/app/src/main/java/com/horaapps/leafpic/utils/Costants.java b/app/src/main/java/com/horaapps/leafpic/utils/Costants.java
deleted file mode 100644
index b2e3e938c..000000000
--- a/app/src/main/java/com/horaapps/leafpic/utils/Costants.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.horaapps.leafpic.utils;
-
-/**
- * Created by dnld on 30/03/16.
- */
-public class Costants {
- public static int ALBUM_CARD_WIDTH = 1300;
- public static int ALBUM_CARD_WIDTH_test = 450;
- public static int PHOTO_CARD_WIDTH = 900;
-}
diff --git a/app/src/main/java/com/horaapps/leafpic/utils/CustomTabService.java b/app/src/main/java/com/horaapps/leafpic/utils/CustomTabService.java
index 5e4394acd..37d1b1b5e 100644
--- a/app/src/main/java/com/horaapps/leafpic/utils/CustomTabService.java
+++ b/app/src/main/java/com/horaapps/leafpic/utils/CustomTabService.java
@@ -10,13 +10,13 @@
public class CustomTabService {
- CustomTabsClient mCustomTabsClient;
- CustomTabsSession mCustomTabsSession;
- CustomTabsServiceConnection mCustomTabsServiceConnection;
- CustomTabsIntent mCustomTabsIntent;
+ private CustomTabsClient mCustomTabsClient;
+ private CustomTabsSession mCustomTabsSession;
+ private CustomTabsServiceConnection mCustomTabsServiceConnection;
+ private CustomTabsIntent mCustomTabsIntent;
- Activity activity;
- int color;
+ private Activity activity;
+ private int color;
public CustomTabService (Activity act, int c) {
this.activity = act;
diff --git a/app/src/main/java/com/horaapps/leafpic/utils/Measure.java b/app/src/main/java/com/horaapps/leafpic/utils/Measure.java
index 900a9ab13..222f1d4e9 100644
--- a/app/src/main/java/com/horaapps/leafpic/utils/Measure.java
+++ b/app/src/main/java/com/horaapps/leafpic/utils/Measure.java
@@ -3,15 +3,11 @@
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Point;
-import android.os.Build;
-import android.os.Environment;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
-import java.lang.reflect.InvocationTargetException;
-
/**
* Created by dnld on 11/03/16.
*/
@@ -19,12 +15,12 @@ public class Measure {
public static final String TAG = "Measure";
- public static int pxToDp(int dp, Context c) {
+ public static int pxToDp(int px, Context c) {
DisplayMetrics displayMetrics = c.getResources().getDisplayMetrics();
- return Math.round(dp * (displayMetrics.ydpi / DisplayMetrics.DENSITY_DEFAULT));
+ return Math.round(px * (displayMetrics.ydpi / DisplayMetrics.DENSITY_DEFAULT));
}
- public static int getScreenWidth(Context c){
+ private static int getScreenWidth(Context c){
WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
@@ -32,16 +28,43 @@ public static int getScreenWidth(Context c){
return size.x;
}
- public static int getAlbumsColumns(Context c) {
- //StringUtils.showToast(c, getRealScreenSize(c).x / Costants.ALBUM_CARD_WIDTH_test+"");
- //Log.wtf("width:dp",pxToDp(getScreenWidth(c), c)+"");
- int n = Math.round(getDensity(c) / Costants.ALBUM_CARD_WIDTH);
- return n < 2 ? 2 : n;
+ private static float getScreenWidthDp(Context context) {
+ DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
+ return pxToDp(displayMetrics.widthPixels, context);
+ //return displayMetrics.widthPixels / displayMetrics.density;
+ }
+
+ public static int getAlbumsColumns(Context context) {
+
+ float width = getScreenWidthDp(context);
+
+
+
+ /* if(width < 600)
+ return 2;
+ if (width < 840)
+ return 3;*/
+
+
+ int n = (int)( width / Constants.ALBUM_CARD_WIDTH);
+ //StringUtils.showToast(c,width + " - " + n);
+ //Log.wtf(TAG,width + " - " + n);
+ if(n < 2) n = 2;
+ else if (n > 8) n = 8;
+ return n;
+ //return n < 2 ? 2 : n;
}
- public static int getPhotosColumns(Context c){
- int n = Math.round(getDensity(c)/ Costants.PHOTO_CARD_WIDTH);
- return n < 3 ? 3 : n;
+ public static int getPhotosColumns(Context context) {
+ float width = getScreenWidthDp(context);
+ //int n = Math.round(getDensity(c)/ Constants.PHOTO_CARD_WIDTH);
+ int n = (int)( width / Constants.PHOTO_CARD_WIDTH);
+ //StringUtils.showToast(c,width + " - " + n);
+ //Log.wtf(TAG,width + " - " + n);
+ if(n < 3) n = 3;
+ else if (n > 8) n = 8;
+ return n;
+ //return n < 3 ? 3 : n;
}
public static int getDensity(Context c){
@@ -78,7 +101,7 @@ public static Point getNavigationBarSize(Context context) {
return new Point();
}
- public static Point getAppUsableScreenSize(Context context) {
+ private static Point getAppUsableScreenSize(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
Point size = new Point();
@@ -86,7 +109,7 @@ public static Point getAppUsableScreenSize(Context context) {
return size;
}
- public static Point getRealScreenSize(Context context) {
+ private static Point getRealScreenSize(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
Point size = new Point();
diff --git a/app/src/main/java/com/horaapps/leafpic/utils/PermissionUtils.java b/app/src/main/java/com/horaapps/leafpic/utils/PermissionUtils.java
index 5add950bd..7593f34ff 100644
--- a/app/src/main/java/com/horaapps/leafpic/utils/PermissionUtils.java
+++ b/app/src/main/java/com/horaapps/leafpic/utils/PermissionUtils.java
@@ -25,7 +25,7 @@ public static boolean checkPermissions(Context context, String... permissions) {
return true;
}
- public static boolean checkPermission(Context context, String permission) {
+ private static boolean checkPermission(Context context, String permission) {
return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
}
diff --git a/app/src/main/java/com/horaapps/leafpic/utils/PreferenceUtil.java b/app/src/main/java/com/horaapps/leafpic/utils/PreferenceUtil.java
new file mode 100644
index 000000000..a01997802
--- /dev/null
+++ b/app/src/main/java/com/horaapps/leafpic/utils/PreferenceUtil.java
@@ -0,0 +1,7 @@
+package com.horaapps.leafpic.utils;
+
+/**
+ * Created by dnld on 04/06/16.
+ */
+public class PreferenceUtil {
+}
diff --git a/app/src/main/java/com/horaapps/leafpic/utils/SecurityHelper.java b/app/src/main/java/com/horaapps/leafpic/utils/SecurityHelper.java
index eaab6d23f..9acd58d65 100644
--- a/app/src/main/java/com/horaapps/leafpic/utils/SecurityHelper.java
+++ b/app/src/main/java/com/horaapps/leafpic/utils/SecurityHelper.java
@@ -1,39 +1,30 @@
package com.horaapps.leafpic.utils;
import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.preference.PreferenceManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
-import android.text.InputType;
-import android.text.method.PasswordTransformationMethod;
-import android.view.Gravity;
-import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
-import android.widget.Toast;
import com.horaapps.leafpic.R;
-import com.horaapps.leafpic.SecurityActivity;
import com.horaapps.leafpic.Views.ThemedActivity;
/**
* Created by Jibo on 06/05/2016.
*/
public class SecurityHelper {
- SharedPreferences SP;
- boolean activeSecurity;
- boolean passwordOnDelete;
- boolean passwordOnHidden;
- String passwordValue;
-
- Context context;
- public SecurityHelper(Context c){
- this.context = c;
+ private boolean activeSecurity;
+ private boolean passwordOnDelete;
+ private boolean passwordOnHidden;
+ private String passwordValue;
+
+ private Context context;
+ public SecurityHelper(Context context){
+ this.context = context;
updateSecuritySetting();
}
@@ -46,17 +37,16 @@ public boolean checkPassword(String pass){
}
public void updateSecuritySetting(){
- this.SP = PreferenceManager.getDefaultSharedPreferences(context);
- this.activeSecurity = SP.getBoolean("active_security", false);
- this.passwordOnDelete = SP.getBoolean("password_on_delete", false);
- this.passwordOnHidden = SP.getBoolean("password_on_hidden", true);
- this.passwordValue = SP.getString("password_value", "");
+ SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(context);
+ this.activeSecurity = SP.getBoolean(context.getString(R.string.preference_use_password), false);
+ this.passwordOnDelete = SP.getBoolean(context.getString(R.string.preference_use_password_on_delete), false);
+ this.passwordOnHidden = SP.getBoolean(context.getString(R.string.preference_use_password_on_hidden), true);
+ this.passwordValue = SP.getString(context.getString(R.string.preference_password_value), "");
}
public EditText getInsertPasswordDialog(final ThemedActivity activity, AlertDialog.Builder passwordDialog){
- final View PasswordDialogLayout = activity.getLayoutInflater().inflate(R.layout
- .password_dialog, null);
+ final View PasswordDialogLayout = activity.getLayoutInflater().inflate(R.layout.dialog_password, null);
final TextView passwordDialogTitle = (TextView) PasswordDialogLayout.findViewById(R.id.password_dialog_title);
final CardView passwordDialogCard = (CardView) PasswordDialogLayout.findViewById(R.id.password_dialog_card);
final EditText editxtPassword = (EditText) PasswordDialogLayout.findViewById(R.id.password_edittxt);
@@ -66,9 +56,7 @@ public EditText getInsertPasswordDialog(final ThemedActivity activity, AlertDial
ThemedActivity.setCursorDrawableColor(editxtPassword, activity.getTextColor());
editxtPassword.getBackground().mutate().setColorFilter(activity.getTextColor(), PorterDuff.Mode.SRC_ATOP);
editxtPassword.setTextColor(activity.getTextColor());
-
passwordDialog.setView(PasswordDialogLayout);
-
return editxtPassword;
}
}
diff --git a/app/src/main/java/com/horaapps/leafpic/utils/StringUtils.java b/app/src/main/java/com/horaapps/leafpic/utils/StringUtils.java
index 1e800ef0b..e3742709b 100644
--- a/app/src/main/java/com/horaapps/leafpic/utils/StringUtils.java
+++ b/app/src/main/java/com/horaapps/leafpic/utils/StringUtils.java
@@ -6,6 +6,14 @@
import android.widget.Toast;
import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Created by dnld on 1/3/16.
@@ -153,7 +161,7 @@ public static String quoteReplace(String psString) {
return psString.replace("'", "{*~^]");
}
- public static String quoteReverse(String psString) {
+ private static String quoteReverse(String psString) {
return psString.replace("{*~^]", "'");
}
diff --git a/app/src/main/res/drawable/leaf_pic.png b/app/src/main/res/drawable/leaf_pic.png
new file mode 100644
index 000000000..b1fd166a0
Binary files /dev/null and b/app/src/main/res/drawable/leaf_pic.png differ
diff --git a/app/src/main/res/drawable/leafpic_big.png b/app/src/main/res/drawable/leafpic_big.png
deleted file mode 100644
index 77b4fc808..000000000
Binary files a/app/src/main/res/drawable/leafpic_big.png and /dev/null differ
diff --git a/app/src/main/res/drawable/storage_permission.png b/app/src/main/res/drawable/storage_permission.png
deleted file mode 100644
index 0f95c7550..000000000
Binary files a/app/src/main/res/drawable/storage_permission.png and /dev/null differ
diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml
index 1d923ab7e..926bb2360 100644
--- a/app/src/main/res/layout/activity_about.xml
+++ b/app/src/main/res/layout/activity_about.xml
@@ -34,20 +34,32 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
+ app:cardCornerRadius="1dp"
app:cardElevation="5dp"
>
-
-
+ >
+
+
+
-
+
+
-
+
+
+
+
+
-
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+ android:text="@string/send_email"
+ android:textSize="16sp"
+ android:textStyle="bold"
+ android:padding="10dp"
+ android:clickable="true"
+ android:background="?attr/selectableItemBackground"
+ />
+
+
+
+
+
-
-
+
+
+
-
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
-
+
-
-
-
-
-
-
-
+ android:text="@string/send_email"
+ android:textSize="16sp"
+ android:textStyle="bold"
+ android:padding="10dp"
+ android:clickable="true"
+ android:background="?attr/selectableItemBackground"
+ />
+
+
+
+
+
-
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_donate.xml b/app/src/main/res/layout/activity_donate.xml
index 20dbdb3ab..f8406b8ce 100644
--- a/app/src/main/res/layout/activity_donate.xml
+++ b/app/src/main/res/layout/activity_donate.xml
@@ -17,7 +17,7 @@
/>
@@ -29,13 +29,13 @@
android:id="@+id/donate_header_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="10dp"
- app:cardElevation="5dp"
+ android:layout_marginBottom="@dimen/card_spacing"
+ app:cardCornerRadius="@dimen/card_corner_radius"
+ app:cardElevation="@dimen/card_elevation"
>
@@ -73,9 +69,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/donate_header_text"
- android:padding="15dp"
+ android:paddingBottom="@dimen/medium_spacing"
+ android:paddingLeft="@dimen/big_spacing"
+ android:paddingRight="@dimen/big_spacing"
android:textColor="@color/md_dark_background"
- android:textSize="16sp"
+ android:textSize="@dimen/medium_text"
/>
@@ -85,9 +83,9 @@
android:id="@+id/donate_googleplay_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="10dp"
+ android:layout_marginBottom="@dimen/card_spacing"
android:visibility="gone"
- app:cardElevation="5dp"
+ app:cardElevation="@dimen/card_elevation"
>
@@ -128,17 +124,17 @@
android:id="@+id/donate_googleplay_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingRight="15dp"
- android:paddingLeft="15dp"
+ android:paddingRight="@dimen/medium_spacing"
+ android:paddingLeft="@dimen/medium_spacing"
android:text="@string/google_takes"
android:textColor="@color/md_dark_background"
- android:textSize="15sp"
+ android:textSize="@dimen/medium_text"
/>
@@ -150,8 +146,8 @@
android:id="@+id/donate_paypal_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="10dp"
- app:cardElevation="5dp"
+ android:layout_marginBottom="@dimen/card_spacing"
+ app:cardElevation="@dimen/card_elevation"
>
-
-
+
@@ -193,15 +186,16 @@
android:layout_height="wrap_content"
android:text="@string/paypal_text"
android:textColor="@color/md_dark_background"
- android:textSize="14sp"
- android:paddingRight="15dp"
- android:paddingLeft="15dp"
+ android:textSize="@dimen/sub_medium_text"
+ android:paddingRight="@dimen/medium_spacing"
+ android:paddingLeft="@dimen/medium_spacing"
/>
+
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_excluded.xml b/app/src/main/res/layout/activity_excluded.xml
index 46357966c..d4593cc90 100644
--- a/app/src/main/res/layout/activity_excluded.xml
+++ b/app/src/main/res/layout/activity_excluded.xml
@@ -29,7 +29,7 @@
android:text="@string/there_is_nothing_to_show"
android:textColor="@color/md_white_1000"
android:visibility="invisible"
- android:textSize="18sp"
+ android:textSize="@dimen/sub_big_text"
android:gravity="center"
android:layout_centerInParent="true"
/>
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index e0b183913..43a5cd4f4 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -68,11 +68,11 @@
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_gravity="bottom|end"
- android:layout_margin="15dp"
+ android:layout_margin="@dimen/medium_spacing"
android:theme="@style/ThemeOverlay.AppCompat.Light"
app:borderWidth="0dp"
- app:elevation="4dp"
- app:layout_behavior=".Views.FabScroll"
+ app:elevation="@dimen/card_elevation"
+ app:layout_behavior=".Views.FabScrollBehaviour"
/>
+ app:cardCornerRadius="@dimen/card_corner_radius">
-
-
-
+
+
@@ -144,46 +144,47 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
- android:layout_marginTop="20dp"
- android:weightSum="10"
>
-
-
-
+
+
-
-
-
+
+
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index 18e04c95d..2ca00ebef 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -29,12 +29,16 @@
android:orientation="vertical">
+
@@ -46,8 +50,8 @@
android:id="@+id/general_setting_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingLeft="15dp"
- android:paddingTop="15dp"
+ android:paddingLeft="16dp"
+ android:paddingTop="16dp"
android:text="@string/general"
android:textColor="@color/md_dark_background"
android:textSize="16sp"
@@ -60,54 +64,61 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
- android:paddingBottom="15dp"
- android:paddingTop="8dp"
- android:weightSum="10"
>
-
-
-
-
+
+
+
+
-
-
+ android:layout_gravity="center_vertical"
+ android:button="@null"
+ android:hapticFeedbackEnabled="true"
+ android:layout_centerVertical="true"
+ android:layout_alignParentEnd="true" />
+
+
@@ -122,25 +133,23 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
- android:paddingBottom="15dp"
- android:paddingTop="8dp"
- android:weightSum="10"
>
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
-
-
+
-
-
-
+
+
+
+
-
-
+
-
+
+
+
-
-
+
@@ -620,7 +773,7 @@
android:layout_height="wrap_content"
android:paddingLeft="15dp"
android:paddingTop="15dp"
- android:text="@string/picture_viewer"
+ android:text="@string/media_viewer"
android:textColor="@color/md_dark_background"
android:textSize="16sp"
android:textStyle="bold" />
@@ -631,55 +784,60 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
- android:paddingBottom="8dp"
- android:paddingTop="8dp"
- android:weightSum="10"
>
-
-
-
-
+
-
-
+
+
+
+
-
-
+
@@ -688,55 +846,59 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
- android:paddingBottom="8dp"
- android:paddingTop="8dp"
- android:weightSum="10"
>
-
-
-
+
-
-
+
+
+
+
-
-
-
+
@@ -745,65 +907,129 @@
android:layout_height="wrap_content"
app:mrl_rippleAlpha="0.05"
app:mrl_rippleDelayClick="false">
-
-
+ >
+ app:iiv_icon="gmd-image"
+ android:layout_marginLeft="@dimen/big_spacing"
+ android:layout_marginRight="@dimen/big_spacing"
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ android:layout_centerVertical="true"
+ android:orientation="vertical"
+ android:layout_marginEnd="44dp"
+ >
-
-
+ android:textSize="14sp"
+ />
-
-
-
+ android:layout_centerVertical="true"
+ android:layout_alignParentEnd="true" />
+
+
-
@@ -812,10 +1038,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
- app:cardCornerRadius="2dp"
+ app:cardCornerRadius="0dp"
app:cardElevation="5dp"
>
-
+
-
-
-
-
+
+
+
+
-
-
+
-
-
-
-
+
+
+
+
-
-
+
diff --git a/app/src/main/res/layout/activity_splash.xml b/app/src/main/res/layout/activity_splash.xml
index e24dc3ab3..dcd3a5c6b 100644
--- a/app/src/main/res/layout/activity_splash.xml
+++ b/app/src/main/res/layout/activity_splash.xml
@@ -6,31 +6,35 @@
android:layout_height="match_parent"
>
-
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/affix_dialog.xml b/app/src/main/res/layout/affix_dialog.xml
deleted file mode 100644
index f8a636ebb..000000000
--- a/app/src/main/res/layout/affix_dialog.xml
+++ /dev/null
@@ -1,242 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/album_card.xml b/app/src/main/res/layout/card_album.xml
similarity index 100%
rename from app/src/main/res/layout/album_card.xml
rename to app/src/main/res/layout/card_album.xml
diff --git a/app/src/main/res/layout/excluded_card.xml b/app/src/main/res/layout/card_excluded_album.xml
similarity index 94%
rename from app/src/main/res/layout/excluded_card.xml
rename to app/src/main/res/layout/card_excluded_album.xml
index 435941ec2..5077ae667 100644
--- a/app/src/main/res/layout/excluded_card.xml
+++ b/app/src/main/res/layout/card_excluded_album.xml
@@ -50,6 +50,8 @@
android:layout_gravity="center_vertical"
android:layout_weight="2"
app:iiv_icon="gmd-close"
+ android:clickable="true"
+ android:background="?attr/selectableItemBackgroundBorderless"
/>
diff --git a/app/src/main/res/layout/photo_card.xml b/app/src/main/res/layout/card_photo.xml
similarity index 100%
rename from app/src/main/res/layout/photo_card.xml
rename to app/src/main/res/layout/card_photo.xml
diff --git a/app/src/main/res/layout/color_piker_accent.xml b/app/src/main/res/layout/color_piker_accent.xml
index cf3ae3b50..0194106a4 100644
--- a/app/src/main/res/layout/color_piker_accent.xml
+++ b/app/src/main/res/layout/color_piker_accent.xml
@@ -27,7 +27,7 @@
android:textColor="@color/md_dark_primary_text"
android:layout_height="wrap_content"
android:background="@color/md_red_500"
- android:padding="24dp"
+ android:padding="@dimen/big_spacing"
android:text="@string/accent_color"
android:textSize="18sp"
android:textStyle="bold" />
@@ -37,11 +37,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:padding="24dp">
+ android:padding="@dimen/big_spacing">
@@ -37,11 +37,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:padding="24dp">
+ android:padding="@dimen/big_spacing">
-
-
-
-
+ android:text="@string/new_folder"
+ android:textColor="@color/md_dark_background"
+ android:textSize="16sp"
+ android:layout_marginRight="@dimen/big_spacing"
+ android:layout_marginBottom="@dimen/medium_spacing"
+ android:layout_marginTop="@dimen/medium_spacing"
+ />
\ No newline at end of file
diff --git a/app/src/main/res/layout/copy_move_bottom_sheet_item.xml b/app/src/main/res/layout/copy_move_bottom_sheet_item.xml
index e88579992..25e57741e 100644
--- a/app/src/main/res/layout/copy_move_bottom_sheet_item.xml
+++ b/app/src/main/res/layout/copy_move_bottom_sheet_item.xml
@@ -5,25 +5,25 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
- android:paddingTop="10dp"
- android:paddingBottom="5dp"
- android:weightSum="10"
>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/basic_theme_dialog.xml b/app/src/main/res/layout/dialog_basic_theme.xml
similarity index 97%
rename from app/src/main/res/layout/basic_theme_dialog.xml
rename to app/src/main/res/layout/dialog_basic_theme.xml
index 803a6288a..da523e125 100644
--- a/app/src/main/res/layout/basic_theme_dialog.xml
+++ b/app/src/main/res/layout/dialog_basic_theme.xml
@@ -21,18 +21,18 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/md_dark_appbar"
- android:padding="24dp"
+ android:padding="@dimen/big_spacing"
android:text="@string/basic_theme"
android:textColor="@color/md_dark_primary_text"
- android:textSize="18sp"
+ android:textSize="@dimen/sub_big_text"
android:textStyle="bold" />
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/dialog_explorer.xml b/app/src/main/res/layout/dialog_explorer.xml
index dde5e0344..5312613bd 100644
--- a/app/src/main/res/layout/dialog_explorer.xml
+++ b/app/src/main/res/layout/dialog_explorer.xml
@@ -4,36 +4,122 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:padding="15dp">
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/insert_text_dialog.xml b/app/src/main/res/layout/dialog_insert_text.xml
similarity index 100%
rename from app/src/main/res/layout/insert_text_dialog.xml
rename to app/src/main/res/layout/dialog_insert_text.xml
diff --git a/app/src/main/res/layout/dialog_map_provider.xml b/app/src/main/res/layout/dialog_map_provider.xml
new file mode 100644
index 000000000..d1a4d1f2f
--- /dev/null
+++ b/app/src/main/res/layout/dialog_map_provider.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/detail_dialog.xml b/app/src/main/res/layout/dialog_media_detail.xml
similarity index 99%
rename from app/src/main/res/layout/detail_dialog.xml
rename to app/src/main/res/layout/dialog_media_detail.xml
index f72d94182..de915ec7d 100644
--- a/app/src/main/res/layout/detail_dialog.xml
+++ b/app/src/main/res/layout/dialog_media_detail.xml
@@ -166,12 +166,13 @@
/>
-
+
diff --git a/app/src/main/res/layout/password_dialog.xml b/app/src/main/res/layout/dialog_password.xml
similarity index 100%
rename from app/src/main/res/layout/password_dialog.xml
rename to app/src/main/res/layout/dialog_password.xml
diff --git a/app/src/main/res/layout/progress_dialog.xml b/app/src/main/res/layout/dialog_progress.xml
similarity index 100%
rename from app/src/main/res/layout/progress_dialog.xml
rename to app/src/main/res/layout/dialog_progress.xml
diff --git a/app/src/main/res/layout/security_dialog.xml b/app/src/main/res/layout/dialog_security.xml
similarity index 100%
rename from app/src/main/res/layout/security_dialog.xml
rename to app/src/main/res/layout/dialog_security.xml
diff --git a/app/src/main/res/layout/set_password_dialog.xml b/app/src/main/res/layout/dialog_set_password.xml
similarity index 100%
rename from app/src/main/res/layout/set_password_dialog.xml
rename to app/src/main/res/layout/dialog_set_password.xml
diff --git a/app/src/main/res/layout/text_dialog.xml b/app/src/main/res/layout/dialog_text.xml
similarity index 100%
rename from app/src/main/res/layout/text_dialog.xml
rename to app/src/main/res/layout/dialog_text.xml
diff --git a/app/src/main/res/layout/drawer_main_activity.xml b/app/src/main/res/layout/drawer_main_activity.xml
index 16a450f3f..bb0604802 100644
--- a/app/src/main/res/layout/drawer_main_activity.xml
+++ b/app/src/main/res/layout/drawer_main_activity.xml
@@ -65,21 +65,22 @@
@@ -101,18 +102,19 @@
@@ -228,15 +231,17 @@
+
+
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/spinner_item_dark.xml b/app/src/main/res/layout/spinner_item_dark.xml
new file mode 100644
index 000000000..00bb945a1
--- /dev/null
+++ b/app/src/main/res/layout/spinner_item_dark.xml
@@ -0,0 +1,12 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/spinner_item_light.xml b/app/src/main/res/layout/spinner_item_light.xml
new file mode 100644
index 000000000..6d400f289
--- /dev/null
+++ b/app/src/main/res/layout/spinner_item_light.xml
@@ -0,0 +1,10 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/toolbar.xml b/app/src/main/res/layout/toolbar.xml
index 0c68797f1..0dce5ac10 100644
--- a/app/src/main/res/layout/toolbar.xml
+++ b/app/src/main/res/layout/toolbar.xml
@@ -3,5 +3,5 @@
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/MyToolbar"
android:layout_height="wrap_content"
- android:layout_width="fill_parent"
+ android:layout_width="match_parent"
/>
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_albums.xml b/app/src/main/res/menu/menu_albums.xml
index c49f4b88e..3f86248a7 100644
--- a/app/src/main/res/menu/menu_albums.xml
+++ b/app/src/main/res/menu/menu_albums.xml
@@ -61,6 +61,10 @@
android:id="@+id/size_sort_action"
android:title="@string/size"
app:showAsAction="never" />
+
+
+
+
+
تطبيق لون مظلم أساسي لشريط الإشعارات.الألبومات المستثناةاستعادة الألبومات المستثناة.
- عارض الصورة
- سمة عارض الصورة
+ عارض الصورة
+ سمة عارض الصورةتخصيص المستعرضتطبيق السمة على عارض الصور.سطوع عالي
@@ -157,8 +157,8 @@
مكتبة الترخيصتفقد مكتبات الطرف الثالث المستخدمة في LeafPic.المؤلفون
- المطور الرئيسي
- المصمم الرئيسي
+ المطور الرئيسي
+ المصمم الرئيسيدعم عجلة التطويرترجمساعدنا لنترجم LeafPic لأكثر من لغة.
diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml
index 4f7c875d1..46ca8fa78 100644
--- a/app/src/main/res/values-cs/strings.xml
+++ b/app/src/main/res/values-cs/strings.xml
@@ -110,8 +110,8 @@ Opravdu chcete vyloučit toto album? \n Můžete jej obnovit v nastavení!
Použít tmavší základní barvu pro navigační panel.Vynechaná albaObnovit vynechaná alba.
- Prohlížeč obrázků
- Motiv prohlížeče obrázků
+ Prohlížeč obrázků
+ Motiv prohlížeče obrázkůPřizpůsobit prohlížečPoužít motiv pro prohlížeč obrázků.Vysoký jas
@@ -160,8 +160,8 @@ Ahoj, \nJsme malý nezávislý tým, který s láskou pracuje na LeafPic ❤,
Licence knihovnyZkontrolovat knihovny třetích stran použité v LeafPic.Autoři
- Hlavní vývojář
- Hlavní návrhář
+ Hlavní vývojář
+ Hlavní návrhářPodpořte vývojPřeložitPomozte nám přeložit LeafPic do více jazyků.
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 58d6878c6..9f1073c55 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -106,8 +106,8 @@ In den Einstellungen können Sie diese Aktion rückgängig machen.Eine dunklere Primärfarbe in der Benachrichtigungsleiste verwenden.Ausgeschlossene AlbenAusgeschlossene Alben wieder anzeigen.
- Bildbetrachter
- Bildbetrachter Theme
+ Bildbetrachter
+ Bildbetrachter ThemeBildbetrachter anpassenTheme auf den Bildbetrachter anwenden.Hohe Helligkeit
@@ -154,8 +154,8 @@ Hallo.\nWir sind ein kleines unabhängiges Team das mit viel Liebe ❤ an LeafPi
BibliothekslizenzVon LeafPic verwendete Drittanbieter-Bibliotheken.Autoren
- Hauptentwickler
- Hauptdesigner
+ Hauptentwickler
+ HauptdesignerUnterstütze die EntwicklungÜbersetzenHilf uns LeafPic in weitere Sprachen zu übersetzen.
diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml
index 89b66b59e..163e82833 100644
--- a/app/src/main/res/values-es-rES/strings.xml
+++ b/app/src/main/res/values-es-rES/strings.xml
@@ -107,8 +107,8 @@
Aplicar un color primario más oscuro a la barra de notificaciones.Álbumes excluidosRestaurar los álbumes excluidos.
- Visor de imágenes
- Tema del visor de imágenes
+ Visor de imágenes
+ Tema del visor de imágenesPersonalizar el visorAplicar el tema al visor de imágenes.Brillo alto
@@ -157,8 +157,8 @@
Licencia de la bibliotecaVer librerías de terceros, usadas en LeafPic.Autores
- Desarrollador principal
- Diseñador principal
+ Desarrollador principal
+ Diseñador principalApoyar al desarrolloTraducirAyudanos a traducir LeafPic en más idiomas.
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 365dce91a..489e7560b 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -110,8 +110,8 @@
Appliquer une couleur principale plus sombre sur la barre d\'étatAlbums exclusRestaurer les albums exclus
- Visionneuse d\'image
- Thème visionneuse d\'image
+ Visionneuse d\'image
+ Thème visionneuse d\'imagePersonnaliser visionneuseAppliquer le thème sur la visionneuse d\'imagesHaute luminosité
@@ -160,8 +160,8 @@
Licence de bibliothèqueVérifier les bibliothèques tierces utilisées sur LeafPicAuteurs
- Développeur principal
- Concepteur principal
+ Développeur principal
+ Concepteur principalSoutenir le développementTraduireAidez-nous à traduire LeafPic en plusieurs langues
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index ddb9a5f1e..e291c9ee4 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -109,8 +109,8 @@
通知バーに暗い優先色を適用します。除外されたアルバム除外されたアルバムを元に戻します。
- 画像ビューアー
- 画像ビューアーのテーマ
+ 画像ビューアー
+ 画像ビューアーのテーマビューアーをカスタマイズ画像ビューアーにテーマを適用します高輝度
@@ -158,8 +158,8 @@
ライブラリのライセンスLeafPicで使用されている第三者のライブラリを確認します作者
- 主要プログラマー、デザイナー
- 主要デザイナー、プログラマー
+ 主要プログラマー、デザイナー
+ 主要デザイナー、プログラマー開発をサポートする翻訳LeafPicを多くの言語に翻訳する支援をしてください
diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml
index b6a54e234..8e1d41459 100644
--- a/app/src/main/res/values-lt/strings.xml
+++ b/app/src/main/res/values-lt/strings.xml
@@ -107,8 +107,8 @@ Jūs tai galite atstatyti eidami į nustatymus! Taikyti tamsesnę pirminę spalvą pranešimų skydeliuiNeįtraukti albumaiAtstatyti neįtrauktus albumus
- Paveikslėlių žiūriklis
- Paveikslėlių peržiūros tema
+ Paveikslėlių žiūriklis
+ Paveikslėlių peržiūros temaTinkinti paveikslėlių žiūriklįPritaikyti temą paveikslėlių žiūrikliuiAukštas ryškumas
@@ -157,8 +157,8 @@ Jūs tai galite atstatyti eidami į nustatymus! Bibliotekos licenzijaPatikrinti trečiąsias bibliotekas naudojamas LeafPicAutoriai
- Pagrindinis programuotojas
- Pagrindinis dizaineris
+ Pagrindinis programuotojas
+ Pagrindinis dizainerisParemti programėlės vystymąIšverskitePadėkite išversti LeafPic į daugiau kalbų
diff --git a/app/src/main/res/values-no/strings.xml b/app/src/main/res/values-no/strings.xml
index e80ac9d42..f64d1b00a 100644
--- a/app/src/main/res/values-no/strings.xml
+++ b/app/src/main/res/values-no/strings.xml
@@ -105,8 +105,8 @@ Er du sikker på at du vil ekskluder albumet? \n Du kan gjenopprette den i innst
Bruke en mørkere primærfarge på varslingslinjen.Ekskluderte albumerGjenopprette de ekskluderte albumene.
- Bildeviseren
- Bildeviseren tema
+ Bildeviseren
+ Bildeviseren temaTilpasse ViserBruk tema på bildeviser.Høy lysstyrke
@@ -155,8 +155,8 @@ Er du sikker på at du vil ekskluder albumet? \n Du kan gjenopprette den i innst
Library lisensSjekk tredje libs brukes på LeafPic.Forfattere
- Hovedutvikler
- Hoveddesigner
+ Hovedutvikler
+ HoveddesignerStøtt viderutviklingOversetteHjelp oss å oversette LeafPic til flere språk.
diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml
index 431f28fb8..4ec09965d 100644
--- a/app/src/main/res/values-pl/strings.xml
+++ b/app/src/main/res/values-pl/strings.xml
@@ -105,8 +105,8 @@
Użył ciemniejszego głównego koloru na pasku nawigacji.Wykluczone albumyPrzywróć wykluczone albumy.
- Przeglądarka zdjeć
- Skórka Przeglądarki zdjęć
+ Przeglądarka zdjeć
+ Skórka Przeglądarki zdjęćUstawienia PrzeglądarkiZastosuj skórkę na przeglądarce zdjęć.Wysoka jasność
@@ -155,8 +155,8 @@
Licencje bibliotekWyświetl zewnętrzne biblioteki używane przez LeafPic.Autorzy
- Główny programista
- Główny projektant
+ Główny programista
+ Główny projektantWesprzyj rozwójTłumaczeniaPomóż nam przetłumaczyć LeafPic na więcej języków.
diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml
index 538a9f82b..6d71ae523 100644
--- a/app/src/main/res/values-pt-rBR/strings.xml
+++ b/app/src/main/res/values-pt-rBR/strings.xml
@@ -110,8 +110,8 @@ Deseja realmente eliminar este álbum?\n
Aplica uma cor primária mais escura na barra de notificação.Álbuns eliminadosRestaura os álbuns eliminados.
- Visualizador de fotos
- Tema do visualizador de fotos
+ Visualizador de fotos
+ Tema do visualizador de fotosPersonalizar o visualizadorAplica o tema no visualizador de fotos.Brilho alto
@@ -160,8 +160,8 @@ Deseja realmente eliminar este álbum?\n
Licença da bibliotecaVerifica as bibliotecas de terceiros usadas no LeafPic.Autores
- Programador principal, Designer
- Designer principal, Programador
+ Programador principal, Designer
+ Designer principal, ProgramadorApoiar o desenvolvimentoTraduzirAjude-nos a traduzir o LeafPic para mais idiomas.
diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml
index 08c9ff5dd..19738dc8a 100644
--- a/app/src/main/res/values-ro/strings.xml
+++ b/app/src/main/res/values-ro/strings.xml
@@ -110,8 +110,8 @@
Aplica o culoare primara mai inchisa pe bara de notificare.Albume excluseRestabileste albumele excluse.
- Vizualizator de imagini
- Tema vizualizatorului de imagini
+ Vizualizator de imagini
+ Tema vizualizatorului de imaginiPersonalizeaza vizualizatorul de imaginiAplica tema vizualizatorului de imagini.Luminozitate ridicată
@@ -160,8 +160,8 @@
Licenta bibliotecaVerifica bibliotecile utilizate pe LeafPic.Autori
- Dezvoltator principal
- Designer principal
+ Dezvoltator principal
+ Designer principalSprijina dezvoltareaTraducereAjutati-ne sa traducem LeafPic in mai multe limbi.
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 1d0011923..60a7987f8 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -105,8 +105,8 @@
Использовать тёмный цвет как основной в строке уведомлений.Исключенные АльбомыВосстановить исключенные альбомы.
- Просмотрщик
- Темы просмотрщика
+ Просмотрщик
+ Темы просмотрщикаНастроить ПросмотрщикПрименить тему.High Brightness
@@ -155,8 +155,8 @@
Лицензия библиотекиПроверить сторонние библиотеки в LeafPic.Авторы
- Основной разработчик
- Основной дизайнер
+ Основной разработчик
+ Основной дизайнерПоддержать разработкуПереводПомогите с переводом.
diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml
index 2711674ad..a4012dd31 100644
--- a/app/src/main/res/values-sk/strings.xml
+++ b/app/src/main/res/values-sk/strings.xml
@@ -110,8 +110,8 @@
Použiť tmavšiu hlavnú farbu na lištu upozornení.Vylúčené albumyObnoviť vylúčené albumy.
- Prehliadač obrázkov
- Prehliadač obrázkov vzhľadu
+ Prehliadač obrázkov
+ Prehliadač obrázkov vzhľaduPrisposobiť prehliadačPoužiť vzhľad na prehliadač obrázkov.Vysoký jas
@@ -160,8 +160,8 @@
Licencia knižniceSkontrolovať knižnice tretích strán použitých v LeafPic.Autori
- Hlavný vývojár
- Hlavný dizajnér
+ Hlavný vývojár
+ Hlavný dizajnérPodporte vývojPrekladajtePomôžte nám preložiť LeafPic do viacerých jazykov.
diff --git a/app/src/main/res/values-sr/strings.xml b/app/src/main/res/values-sr/strings.xml
index 4752024f4..78e4ef77a 100644
--- a/app/src/main/res/values-sr/strings.xml
+++ b/app/src/main/res/values-sr/strings.xml
@@ -109,8 +109,8 @@
Apply a darker primary color to the notification bar.Искључени албумиВраћање искључених албума.
- Прегледач слика
- Тема прегледача слика
+ Прегледач слика
+ Тема прегледача сликаCustomize ViewerApply theme on pictures viewer.High Brightness
@@ -159,8 +159,8 @@
Лиценца библиотекеCheck third libs used on LeafPic.Аутори
- Главни програмер
- Главни дизајнер
+ Главни програмер
+ Главни дизајнерПодржите развојПреведитеПомозите превођењем Лифпика на још језика.
diff --git a/app/src/main/res/values-sv-rSE/strings.xml b/app/src/main/res/values-sv-rSE/strings.xml
index d0f826281..5d6928fd6 100644
--- a/app/src/main/res/values-sv-rSE/strings.xml
+++ b/app/src/main/res/values-sv-rSE/strings.xml
@@ -105,8 +105,8 @@
Apply a darker primary color to the notification bar.Excluded AlbumsRestore the excluded albums.
- Picture Viewer
- Picture Viewer Theme
+ Picture Viewer
+ Picture Viewer ThemeCustomize ViewerApply theme on pictures viewer.High Brightness
@@ -155,8 +155,8 @@
Bibliotek-licensCheck third libs used on LeafPic.Upphovsmän
- Major Developer
- Major Designer
+ Major Developer
+ Major DesignerStöd utvecklingenÖversättHjälp oss att översätta LeafPic på fler språk.
diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml
index b94d081a0..374ff0b16 100644
--- a/app/src/main/res/values-tr/strings.xml
+++ b/app/src/main/res/values-tr/strings.xml
@@ -108,8 +108,8 @@ Ayarlara giderek yeniden düzenleyebilirsin!Bildirim çubuğuna daha koyu bir birincil renk uygula.Hariç tutulan albümlerDışlanan albümleri geri al.
- Resim Görüntüleyici
- Resim Görüntüleyici Teması
+ Resim Görüntüleyici
+ Resim Görüntüleyici TemasıÖzelleştirilmiş GörüntüleyiciTemayı fotoğraf göstericisine uygula.Yüksek parlaklık
@@ -158,8 +158,8 @@ Ayarlara giderek yeniden düzenleyebilirsin!Kütüphane LisansıLeafPic\'e uygun üçüncü parti kütüphaneleri denetleYazarlar
- Ana Geliştirici
- Ana Düzenleyici
+ Ana Geliştirici
+ Ana DüzenleyiciGeliştirmeyi destekleÇeviriLeafPicin daha fazla dile çevrilmesine yardım et
diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml
index ea19e19ad..15b701ccd 100644
--- a/app/src/main/res/values-uk/strings.xml
+++ b/app/src/main/res/values-uk/strings.xml
@@ -106,8 +106,8 @@
Застосувати темніший основний колір до панелі стану.Виключені альбомиВідновити виключені альбоми.
- Програма перегляду зображень
- Picture Viewer Theme
+ Програма перегляду зображень
+ Picture Viewer ThemeCustomize ViewerApply theme on pictures viewer.Режим максимальної яскравості
@@ -156,8 +156,8 @@
Library LicenseCheck third libs used on LeafPic.Authors
- Головний розробник
- Головний дизайнер
+ Головний розробник
+ Головний дизайнерSupport DevelopmentTranslateHelp us to translate LeafPic in more languages.
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 4a5fbd637..c9052be0e 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -106,8 +106,8 @@
应用深色主色调的半透明通知栏。已排除的相册还原已经被排除的相册目录。
- 图像浏览器
- 图像浏览器主题
+ 图像浏览器
+ 图像浏览器主题自定义浏览器样式对图像浏览器应用自定义主题。高亮模式
@@ -156,8 +156,8 @@
查看关于库的许可查看 LeafPic 所使用的第三方库。作者
- 主要开发者
- 主要设计师
+ 主要开发者
+ 主要设计师协助开发翻译帮助我们将 LeafPic 翻译成更多语言。
diff --git a/app/src/main/res/values/dimesions.xml b/app/src/main/res/values/dimesions.xml
index 1f1949bff..195b40d89 100644
--- a/app/src/main/res/values/dimesions.xml
+++ b/app/src/main/res/values/dimesions.xml
@@ -1,4 +1,29 @@
50dp
+
+
+ 24dp
+ 20dp
+
+
+ 24dp
+ 16dp
+ 8dp
+
+
+ 44dp
+
+
+ 25sp
+ 18sp
+ 16sp
+ 14sp
+ 8sp
+
+
+ 4dip
+ 1dp
+ 5dp
+ 10dp
\ No newline at end of file
diff --git a/app/src/main/res/values/preferences-key.xml b/app/src/main/res/values/preferences-key.xml
new file mode 100644
index 000000000..8f6a2da54
--- /dev/null
+++ b/app/src/main/res/values/preferences-key.xml
@@ -0,0 +1,24 @@
+
+
+ set_internal_player
+ set_include_video
+ swipe_opposite
+ auto_update_media
+ set_delay_full_image
+ set_picture_orientation
+ set_max_luminosita
+ set_traslucent_statusbar
+ nav_bar
+ basic_theme
+ primary_color
+ accent_color
+ apply_theme_img_act
+ set_alpha
+ map_provider
+
+ password_value
+ active_security
+ password_on_hidden
+ password_on_delete
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index eafb66ab8..253778255 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,8 +1,7 @@
-
LeafPic
- A colourfull material gallery.
+ A colorful material gallery.HoraAppsWelcome To LeafPic!Color-Full Material Designed Gallery!
@@ -59,22 +58,28 @@
UploadSet as previewClear preview
-
New Folder
- Are you sure you want to hide this album?
- (it will create the .nomedia file in the folder and if there are others media them wont be
- available also from other apps! use Exclude option instead)
+
+ Hiding this album will be created a .nomedia file in the folder
+ and this could make media unreachable from other apps use exclude option to avoid this.
- Are you sure you want to unhide this album?
- (media will be available also for other apps!)
-
- Are you sure you want to delete selected album?
- Are you sure you want to delete selected medias?
+ Are you sure you want to delete this album?
+ Are you sure you want to delete selected albums?Are you sure you want to delete this media?
- Are you sure you want to exclude that album?
- \nYou can restore it in the settings section
+ Are you sure you want to delete selected media?
+ Are you sure you want to hide selected albums?
+ Un-hiding this album you will make media available also for other apps.
+ Are you sure you want to exclude selected albums?
+
+ Excluding this folder you will exclude also all sub-folders, below there is
+ a list that allow you to chose a parent if you have to exclude more folder which are on the same level.
+
+ The new folder will be created in the current path;
+ then the media will be copyed or moved in the new folder.
+
+
Photo
@@ -121,7 +126,7 @@
Insert passwordSet up a password to protect your media.
- Note: password changed if you forget it you have to clear application data.
+ Note: password changed, if you forget it you have to clear application data.Use password for
@@ -141,8 +146,8 @@
Restore the excluded albums.
- Picture Viewer
- Picture Viewer Theme
+ Media Viewer
+ Media Viewer ThemeCustomize ViewerApply theme on pictures viewer.
@@ -156,6 +161,8 @@
Set the grade of transparencyDelay load full-size imageLoad full image when zoom in
+ Swipe Direction
+ Change the swipe direction of the media viewer.(DefaultNext: Left to Right)ThemePrimary Color
@@ -195,20 +202,44 @@
Version License
- Check the license used on LeafPic.
+ Check GPLv3 license terms used on LeafPic.
- Library License
- Check third libs used on LeafPic.
+ Library Licenses
+ Check third-party libs used on LeafPic.Authors
- Major Developer
- Major Designer
+
+ I\'m 19 years old. I\'m a young software developer, I like CS in general, at most I love
+ learn doing stuff with Linux and Android. I also like TV Series.
+
+
+ I\'m 20 years old. I love music, videogames and drawing.
+ I\'m also really into computer science, programming and design.
+ Google+
+ send via…
+ SEND EMAIL
+
+ There are no email clients installed.
+ Special thanks
+ to Patryk Goworowski for the
+ awesome icon.
+
+
+ to Crowdin community for all the translations
+
+
+ to you for using the app
+ Support DevelopmentTranslateHelp us to translate LeafPic in more languages.
+ Report bug
+ Report bug or request new features.
+
RateLeave us a positive rating if you like LeafPic.
@@ -250,6 +281,12 @@
Unable to fix dateCompression settingsInclude Video
-
+ FAB options
+ Chose when display the floating button
+ Map Provider
+ Chose the source of maps
+ Insert something!
+ password doesn\'t match
+ uri_extsdcard_photos
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index a8815eb93..ef6010423 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -27,12 +27,9 @@
@drawable/ic_empty_amoled
-
-
-
-
diff --git a/build.gradle b/build.gradle
index df1865e4b..be4d5020e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.0'
+ classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files