Merge pull request #7 from TanguyHerbron/master

Update unstable to correct some bugs hot fixed
This commit is contained in:
Tanguy Herbron 2018-07-31 13:14:30 +02:00 committed by GitHub
commit 38723b7dca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 212 additions and 62 deletions

Binary file not shown.

2
.idea/gradle.xml generated
View File

@ -5,7 +5,7 @@
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-4.4" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-4.9" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

View File

@ -583,6 +583,7 @@ public class Charts extends Fragment {
dataSet.setHighlightEnabled(true);
dataSet.setDrawHorizontalHighlightIndicator(false);
dataSet.setHighLightColor(currency.getChartColor());
dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
return new LineData(dataSet);
}

View File

@ -264,35 +264,44 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
File cacheDir = new File(getContext().getCacheDir().getAbsolutePath());
File[] cacheFiles = cacheDir.listFiles();
for(int i = 0; i < 4; i++)
if(cacheFiles.length > 4)
{
File cachedIcon = null;
while(cachedIcon == null || cachedIcon.isDirectory())
for(int i = 0; i < 4; i++)
{
cachedIcon = cacheFiles[random.nextInt(cacheFiles.length)];
File cachedIcon = null;
while(cachedIcon == null || cachedIcon.isDirectory())
{
cachedIcon = cacheFiles[random.nextInt(cacheFiles.length)];
}
Bitmap icon = BitmapFactory.decodeFile(cachedIcon.getAbsolutePath());
Bitmap result = Bitmap.createBitmap(150, 150, icon.getConfig());
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(ContextCompat.getColor(getContext(), R.color.white));
Canvas canvas = new Canvas(result);
canvas.drawCircle(result.getHeight()/2, result.getWidth()/2, 75, paint);
canvas.drawBitmap(Bitmap.createScaledBitmap(icon, 100, 100, false), result.getHeight()/2 - 50, result.getWidth()/2 - 50, null);
((ImageView) animatedLayout.getChildAt(i)).setImageBitmap(result);
ObjectAnimator animator = ObjectAnimator.ofFloat(animatedLayout.getChildAt(i), "translationY", 0, -100, 0);
animator.setInterpolator(new EasingInterpolator(Ease.CIRC_IN_OUT));
animator.setStartDelay(i*200);
animator.setDuration(1500);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.start();
}
Bitmap icon = BitmapFactory.decodeFile(cachedIcon.getAbsolutePath());
Bitmap result = Bitmap.createBitmap(150, 150, icon.getConfig());
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(ContextCompat.getColor(getContext(), R.color.white));
Canvas canvas = new Canvas(result);
canvas.drawCircle(result.getHeight()/2, result.getWidth()/2, 75, paint);
canvas.drawBitmap(Bitmap.createScaledBitmap(icon, 100, 100, false), result.getHeight()/2 - 50, result.getWidth()/2 - 50, null);
((ImageView) animatedLayout.getChildAt(i)).setImageBitmap(result);
ObjectAnimator animator = ObjectAnimator.ofFloat(animatedLayout.getChildAt(i), "translationY", 0, -100, 0);
animator.setInterpolator(new EasingInterpolator(Ease.CIRC_IN_OUT));
animator.setStartDelay(i*200);
animator.setDuration(1500);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.start();
}
else
{
TextView appNameTextView = splashLayout.findViewById(R.id.appNameTextView);
appNameTextView.setVisibility(View.VISIBLE);
animatedLayout.setVisibility(View.GONE);
}
loadingDialog.setContentView(splashLayout);

View File

@ -3,7 +3,9 @@ package com.herbron.moodl.Activities.HomeActivityFragments;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.os.AsyncTask;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.os.Bundle;
@ -62,6 +64,7 @@ public class Watchlist extends Fragment {
private boolean detailsUpdated;
private boolean editModeEnabled;
private DatabaseManager databaseManager;
private ImageButton editButton;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
@ -141,48 +144,70 @@ public class Watchlist extends Fragment {
updater.execute();
}
private void disableEdition()
{
editButton.setBackground(MoodlBox.getDrawable(R.drawable.check_to_edit, getContext()));
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
AnimatedVectorDrawable animatedVectorDrawable = (AnimatedVectorDrawable) editButton.getBackground();
animatedVectorDrawable.start();
}
editModeEnabled = false;
for(int i = 0; i < dragLinearLayout.getChildCount(); i++)
{
View watchlistElement = dragLinearLayout.getChildAt(i);
if(watchlistElement instanceof CurrencyCardview)
{
watchlistElement.setClickable(true);
collapseW(watchlistElement.findViewById(R.id.deleteCardWatchlist));
collapseW(watchlistElement.findViewById(R.id.dragCardWatchlist));
}
}
}
private void enableEdition()
{
editButton.setBackground(MoodlBox.getDrawable(R.drawable.edit_to_check, getContext()));
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
AnimatedVectorDrawable animatedVectorDrawable = (AnimatedVectorDrawable) editButton.getBackground();
animatedVectorDrawable.start();
}
editModeEnabled = true;
for(int i = 0; i < dragLinearLayout.getChildCount(); i++)
{
View watchlistElement = dragLinearLayout.getChildAt(i);
if(watchlistElement instanceof CurrencyCardview)
{
watchlistElement.setClickable(false);
expandW(watchlistElement.findViewById(R.id.deleteCardWatchlist));
expandW(watchlistElement.findViewById(R.id.dragCardWatchlist));
}
}
}
private void setupEditButton()
{
ImageButton editButton = view.findViewById(R.id.edit_button);
editButton = view.findViewById(R.id.edit_button);
editButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(editModeEnabled)
{
((ImageView) view.findViewById(R.id.edit_button)).setBackground(MoodlBox.getDrawable(R.drawable.ic_mode_edit_white_24dp, getContext()));
editModeEnabled = false;
for(int i = 0; i < dragLinearLayout.getChildCount(); i++)
{
View watchlistElement = dragLinearLayout.getChildAt(i);
if(watchlistElement instanceof CurrencyCardview)
{
watchlistElement.setClickable(true);
collapseW(watchlistElement.findViewById(R.id.deleteCardWatchlist));
collapseW(watchlistElement.findViewById(R.id.dragCardWatchlist));
}
}
disableEdition();
}
else
{
((ImageView) view.findViewById(R.id.edit_button)).setBackground(MoodlBox.getDrawable(R.drawable.ic_check_white_24dp, getContext()));
editModeEnabled = true;
for(int i = 0; i < dragLinearLayout.getChildCount(); i++)
{
View watchlistElement = dragLinearLayout.getChildAt(i);
if(watchlistElement instanceof CurrencyCardview)
{
watchlistElement.setClickable(false);
expandW(watchlistElement.findViewById(R.id.deleteCardWatchlist));
expandW(watchlistElement.findViewById(R.id.dragCardWatchlist));
}
}
enableEdition();
}
}
});
@ -194,6 +219,11 @@ public class Watchlist extends Fragment {
addWatchlistButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(editModeEnabled)
{
disableEdition();
}
Intent selectionIntent = new Intent(getActivity(), CurrencySelectionActivity.class);
selectionIntent.putExtra("isWatchList", true);
startActivity(selectionIntent);

View File

@ -17,6 +17,7 @@ import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.preference.SwitchPreference;
@ -415,6 +416,33 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
bindPreferenceSummaryToValue(findPreference("default_currency"));
bindPreferenceSummaryToValue(findPreference("minimum_value_displayed"));
PreferenceCategory developperCategory = (PreferenceCategory) findPreference("developper_category");
if(!BuildConfig.DEBUG)
{
getPreferenceScreen().removePreference(developperCategory);
}
else
{
developperCategory.getPreference(0).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
File cacheDir = getContext().getCacheDir();
File[] cachedFiles = cacheDir.listFiles();
for(int i = 0; i < cachedFiles.length; i++)
{
if(cachedFiles[i].isFile())
{
cachedFiles[i].delete();
}
}
return false;
}
});
}
findPreference("export").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {

View File

@ -351,6 +351,7 @@ public class CurrencyCardview extends CardView {
dataSet.setDrawCircles(false);
dataSet.setDrawValues(false);
dataSet.setHighlightEnabled(false);
dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
return new LineData(dataSet);
}

View File

@ -1,6 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/separationColor">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="@color/separationColor" />
<corners android:radius="2dp" />
</shape>
</item>
<item android:id="@android:id/background">
<shape android:shape="rectangle">
<solid android:color="@color/transparent"/>
<corners android:radius="2dp"/>
@ -11,4 +20,4 @@
android:dashWidth="9dp"/>
</shape>
</item>
</selector>
</ripple>

View File

@ -0,0 +1,27 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="check"
android:pathData="M 9 16.17 L 4.83 12 L 3.41 13.41 L 9 19 L 21 7 L 19.59 5.59 Z"
android:fillColor="#FFFFFFFF"/>
</vector>
</aapt:attr>
<target android:name="check">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="200"
android:valueFrom="M 3.41 13.41 L 6.205 16.205 L 9 19 L 21 7 L 19.59 5.59 L 9 16.17 L 4.83 12 L 3.41 13.41 M 18.216 5.784 L 18.216 5.784 L 18.216 5.784 L 18.216 5.784 L 18.216 5.784 C 18.216 5.784 18.216 5.784 18.216 5.784 L 18.216 5.784 C 18.216 5.784 18.216 5.784 18.216 5.784"
android:valueTo="M 3 17.25 L 3 21 L 6.75 21 L 17.81 9.94 L 14.06 6.19 L 8.53 11.72 L 3 17.25 L 3 17.25 M 20.71 7.04 L 20.71 7.04 L 18.88 8.87 L 15.13 5.12 L 16.96 3.29 C 17.35 2.9 17.98 2.9 18.37 3.29 L 20.71 5.63 C 21.1 6.02 21.1 6.65 20.71 7.04"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</aapt:attr>
</target>
</animated-vector>

View File

@ -0,0 +1,28 @@
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="edit"
android:pathData="M 3 17.25 L 3 21 L 6.75 21 L 17.81 9.94 L 14.06 6.19 L 3 17.25 Z M 20.71 7.04 C 21.1 6.65 21.1 6.02 20.71 5.63 L 18.37 3.29 C 17.98 2.9 17.35 2.9 16.96 3.29 L 15.13 5.12 L 18.88 8.87 L 20.71 7.04 Z"
android:fillColor="#FFFFFFFF"/>
</vector>
</aapt:attr>
<target android:name="edit">
<aapt:attr name="android:animation">
<objectAnimator
android:propertyName="pathData"
android:duration="200"
android:valueFrom="M 3 17.25 L 3 17.25 L 3 21 L 6.75 21 L 17.81 9.94 L 14.06 6.19 L 3 17.25 M 20.71 5.63 L 18.37 3.29 C 17.98 2.9 17.35 2.9 16.96 3.29 L 15.13 5.12 L 18.88 8.87 L 20.71 7.04 L 20.71 7.04 C 21.1 6.65 21.1 6.02 20.71 5.63"
android:valueTo="M 9 16.17 L 4.83 12 L 3.41 13.41 L 9 19 L 21 7 L 19.59 5.59 L 9 16.17 M 18.216 5.784 L 18.216 5.784 C 18.216 5.784 18.216 5.784 18.216 5.784 L 18.216 5.784 L 18.216 5.784 L 18.216 5.784 L 18.216 5.784 C 18.216 5.784 18.216 5.784 18.216 5.784"
android:valueType="pathType"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
</aapt:attr>
</target>
</animated-vector>

View File

@ -4,6 +4,14 @@
android:layout_width="match_parent"
android:background="@color/colorPrimaryDark">
<TextView
android:id="@+id/appNameTextView"
android:text="@string/app_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_gravity="center"/>
<LinearLayout
android:id="@+id/animatedViewsLayout"
android:layout_width="match_parent"

View File

@ -27,7 +27,7 @@
<PreferenceCategory
android:title="@string/pref_title_category_data_backup">
<PreferenceScreen android:title="@string/pref_title_export"
<Preference android:title="@string/pref_title_export"
android:key="export"/>
<Preference android:title="@string/pref_title_import"
@ -57,4 +57,13 @@
</PreferenceCategory>
<PreferenceCategory
android:title="Developper"
android:key="developper_category">
<Preference android:title="Wipe cache"
android:key="wipe_cache"/>
</PreferenceCategory>
</PreferenceScreen>