Several fixes/adjustments

- LineCharts are now smooth
- The splashscreens works 'properly' even when there is no cached icons
- Edit mode is disabled when adding a coin in the watchlist
- Add option to clear cache in the settings menu when in debug mode
This commit is contained in:
Tanguy Herbron 2018-07-31 01:19:00 +02:00
parent 533aea5bb6
commit 6fe8831c69
9 changed files with 143 additions and 71 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

@ -261,6 +261,8 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
File cacheDir = new File(getContext().getCacheDir().getAbsolutePath());
File[] cacheFiles = cacheDir.listFiles();
if(cacheFiles.length > 4)
{
for(int i = 0; i < 4; i++)
{
File cachedIcon = null;
@ -291,6 +293,13 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
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);
loadingDialog.show();

View File

@ -64,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)
@ -143,14 +144,7 @@ public class Watchlist extends Fragment {
updater.execute();
}
private void setupEditButton()
{
final ImageButton editButton = view.findViewById(R.id.edit_button);
editButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(editModeEnabled)
private void disableEdition()
{
editButton.setBackground(MoodlBox.getDrawable(R.drawable.check_to_edit, getContext()));
@ -174,7 +168,8 @@ public class Watchlist extends Fragment {
}
}
}
else
private void enableEdition()
{
editButton.setBackground(MoodlBox.getDrawable(R.drawable.edit_to_check, getContext()));
@ -198,6 +193,22 @@ public class Watchlist extends Fragment {
}
}
}
private void setupEditButton()
{
editButton = view.findViewById(R.id.edit_button);
editButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(editModeEnabled)
{
disableEdition();
}
else
{
enableEdition();
}
}
});
}
@ -208,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;
@ -414,6 +415,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

@ -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>