Skip to content

Commit

Permalink
Release 1.1.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoneTinella committed Apr 3, 2020
1 parent 0cc166a commit cbe2cc8
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 31 deletions.
Binary file modified StatoCovid19Italia.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "org.twistedappdeveloper.statocovid19italia"
minSdkVersion 14
targetSdkVersion 29
versionCode 17
versionName "1.1.8"
versionCode 18
versionName "1.1.8.1"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class BarChartActivity extends AppCompatActivity implements View.OnClickL
ImageButton btnChangeOrder;

private Button btnPercentage;
private ImageButton btnIndietro, btnAvanti, btnCambiaMisura;
private ImageButton btnIndietro, btnAvanti, btnCambiaMisura;

private int cursore, dataLen;

Expand Down Expand Up @@ -187,11 +187,11 @@ private void setData(String trendKey) {
DataStorage regionalDataStore = dataStorage.getDataStorageByDataContext(dataContext);
TrendValue trendValue = regionalDataStore.getTrendByKey(trendKey).getTrendValueByIndex(cursore);
currentValues.put(dataContext, trendValue);
if(dispalyPercentage){
if (dispalyPercentage) {
chart.getAxisLeft().resetAxisMinimum();
chart.getAxisRight().resetAxisMinimum();
barValues.add(new BarEntry(i++, trendValue.getDeltaPercentage() * 100, dataContext));
}else{
} else {
chart.getAxisLeft().setAxisMinimum(0);
chart.getAxisRight().setAxisMinimum(0);
barValues.add(new BarEntry(i++, trendValue.getValue(), dataContext));
Expand Down Expand Up @@ -313,18 +313,18 @@ public void onClick(View v) {

case R.id.btnChangeOrder:
orderTrend = !orderTrend;
if(!orderTrend){
if (!orderTrend) {
btnChangeOrder.setImageResource(R.drawable.baseline_bar_chart_white_24);
}else{
} else {
btnChangeOrder.setImageResource(R.drawable.baseline_signal_cellular_alt_white_24);
}
setData(selectedTrendKey);
break;
case R.id.btnPercentage:
dispalyPercentage = !dispalyPercentage;
if(!dispalyPercentage){
if (!dispalyPercentage) {
btnPercentage.setText("123");
}else{
} else {
btnPercentage.setText("%");
}
setData(selectedTrendKey);
Expand Down Expand Up @@ -362,7 +362,7 @@ private void btnEnableStatusCheck() {
}
}

private void checkBarValueVisualization(){
private void checkBarValueVisualization() {
Configuration configuration = getResources().getConfiguration();
if (configuration.orientation == ORIENTATION_LANDSCAPE) {
chart.getData().setDrawValues(true);
Expand Down Expand Up @@ -420,14 +420,20 @@ public MPPointF getOffset() {
@Override
public void refreshContent(Entry e, Highlight highlight) {
int position = (int) e.getX();
String dataContext = chart.getData().getDataSetByIndex(0).getEntryForIndex(position).getData().toString();
String dataContext = chart.getData().getDataSetByIndex(0).getEntryForIndex(position).getData().toString();
txtBarMarkerTitle.setText(dataContext);

TrendValue trendValue = currentValues.get(dataContext);
txtBarMarkerCurrentValue.setText(String.format("%s",trendValue.getValue()));
txtBarPrecValue.setText(String.format("%s",trendValue.getPrecValue()));
txtBarMarkerPercentage.setText(String.format(Locale.ITALIAN,"%.2f%%",trendValue.getDeltaPercentage()*100));
txtBarMarkerVariazione.setText(String.format("%s",trendValue.getDelta()));
txtBarMarkerCurrentValue.setText(String.format("%s", trendValue.getValue()));
txtBarPrecValue.setText(String.format("%s", trendValue.getPrecValue()));
txtBarMarkerPercentage.setText(String.format(Locale.ITALIAN, "%.2f%%", trendValue.getDeltaPercentage() * 100));
txtBarMarkerVariazione.setText(String.format("%s", trendValue.getDelta()));

int color = TrendUtils.getColorByTrendKey(getApplicationContext(), selectedTrendKey);
txtBarMarkerCurrentValue.setTextColor(color);
txtBarPrecValue.setTextColor(color);
txtBarMarkerVariazione.setTextColor(color);
txtBarMarkerPercentage.setTextColor(color);

super.refreshContent(e, highlight);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.twistedappdeveloper.statocovid19italia;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Configuration;
import android.graphics.Color;
Expand All @@ -19,12 +20,16 @@

import com.github.mikephil.charting.charts.BarChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.BarDataSet;
import com.github.mikephil.charting.data.BarEntry;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.formatter.ValueFormatter;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
import com.github.mikephil.charting.utils.MPPointF;

import org.twistedappdeveloper.statocovid19italia.adapters.ProvinceAdapter;
import org.twistedappdeveloper.statocovid19italia.datastorage.DataStorage;
Expand Down Expand Up @@ -72,6 +77,8 @@ public class ProvincialBarChartActivity extends AppCompatActivity implements Vie
public static final int MIN_ELEMENTS = 3;
public static final int MAX_ELEMENTS = 30;

private Map<String, TrendValue> currentValues = new HashMap<>();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -123,8 +130,9 @@ protected void onCreate(Bundle savedInstanceState) {
btnProvince.setOnClickListener(this);
btnCambiaMisura.setOnClickListener(this);
btnChangeOrder.setOnClickListener(this);
btnPercentage.setOnClickListener(this);

chart.setTouchEnabled(false);
chart.setTouchEnabled(true);
chart.setBackgroundColor(Color.WHITE);
chart.setDrawBarShadow(false);
chart.setDrawValueAboveBar(true);
Expand All @@ -138,6 +146,9 @@ protected void onCreate(Bundle savedInstanceState) {
chart.getAxisLeft().setAxisMinimum(0);
chart.getAxisRight().setAxisMinimum(0);

BarChartActivityMaker maker = new BarChartActivityMaker(getApplicationContext());
chart.setMarker(maker);

ValueFormatter xAxisFormatter = new ProvinceFormatter();
XAxis xAxis = chart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
Expand Down Expand Up @@ -165,7 +176,7 @@ protected void onCreate(Bundle savedInstanceState) {
setData();
}

private void calcolaProvinceListMap(){
private void calcolaProvinceListMap() {
provinceListMap = new HashMap<>();
for (String regione : dataStorage.getSubLevelDataKeys()) {
for (String provincia : dataStorage.getDataStorageByDataContext(regione).getSubLevelDataKeys()) {
Expand All @@ -188,11 +199,15 @@ private void calcolaProvinceListMap(){


private void setData() {
currentValues.clear();
ArrayList<BarEntry> values = new ArrayList<>();

int i = 0;
for (String selectedProvincia : selectedProvince) {
TrendValue trendValue = dataStorageMap.get(selectedProvincia).getTrendByKey(selectedTrendKey).getTrendValues().get(cursore);
currentValues.put(selectedProvincia, trendValue);
chart.getAxisLeft().setAxisMinimum(0);
chart.getAxisRight().setAxisMinimum(0);
values.add(new BarEntry(i++, trendValue.getValue(), selectedProvincia));
txtMarkerData.setText(String.format(getString(R.string.dati_relativi_al), trendValue.getDate()));
}
Expand Down Expand Up @@ -374,7 +389,7 @@ private class ProvinceFormatter extends ValueFormatter {
@Override
public String getFormattedValue(float value) {
IBarDataSet dataSetByIndex = chart.getData().getDataSetByIndex(0);
if(value >= dataSetByIndex.getEntryCount()){
if (value >= dataSetByIndex.getEntryCount()) {
return "";
}
BarEntry barEntry = dataSetByIndex.getEntryForIndex((int) value);
Expand All @@ -390,4 +405,44 @@ private int getMaxLength(String nomeRegione) {
return Math.min(maxLen, nomeRegione.length());
}
}

public class BarChartActivityMaker extends MarkerView {

private TextView txtBarMarkerTitle, txtBarMarkerCurrentValue, txtBarPrecValue, txtBarMarkerVariazione;

public BarChartActivityMaker(Context context) {
super(context, R.layout.bar_chart_marker);
txtBarMarkerTitle = findViewById(R.id.txtBarMarkerTitle);
txtBarMarkerCurrentValue = findViewById(R.id.txtBarMarkerCurrentValue);
txtBarPrecValue = findViewById(R.id.txtBarPrecValue);
txtBarMarkerVariazione = findViewById(R.id.txtBarMarkerVariazione);
findViewById(R.id.txtBarMarkerPercentage).setVisibility(GONE);
findViewById(R.id.txtBarMarkerPercentageTitle).setVisibility(GONE);
}

@Override
public MPPointF getOffset() {
super.getOffset().x = -getWidth();
super.getOffset().y = -getHeight();
return super.getOffset();
}

@Override
public void refreshContent(Entry e, Highlight highlight) {
int position = (int) e.getX();
String dataContext = chart.getData().getDataSetByIndex(0).getEntryForIndex(position).getData().toString();
txtBarMarkerTitle.setText(dataContext);

TrendValue trendValue = currentValues.get(dataContext);
txtBarMarkerCurrentValue.setText(String.format("%s", trendValue.getValue()));
txtBarPrecValue.setText(String.format("%s", trendValue.getPrecValue()));
txtBarMarkerVariazione.setText(String.format("%s", trendValue.getDelta()));
int color = TrendUtils.getColorByTrendKey(getApplicationContext(), selectedTrendKey);
txtBarMarkerCurrentValue.setTextColor(color);
txtBarPrecValue.setTextColor(color);
txtBarMarkerVariazione.setTextColor(color);

super.refreshContent(e, highlight);
}
}
}
28 changes: 16 additions & 12 deletions app/src/main/res/layout/bar_chart_marker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:gravity="end"
android:textAlignment="textEnd"
android:textColor="@android:color/black"
android:textSize="14sp"
tools:text="TextView"
android:textAlignment="textEnd"
android:gravity="end" />
android:textStyle="bold"
tools:text="TextView" />
</LinearLayout>

<LinearLayout
Expand All @@ -66,11 +67,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:gravity="end"
android:textAlignment="textEnd"
android:textColor="@android:color/black"
android:textSize="14sp"
tools:text="TextView"
android:textAlignment="textEnd"
android:gravity="end"/>
android:textStyle="bold"
tools:text="TextView" />
</LinearLayout>

<LinearLayout
Expand All @@ -93,11 +95,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:gravity="end"
android:textAlignment="textEnd"
android:textColor="@android:color/black"
android:textSize="14sp"
tools:text="TextView"
android:textAlignment="textEnd"
android:gravity="end"/>
android:textStyle="bold"
tools:text="TextView" />
</LinearLayout>

<LinearLayout
Expand All @@ -120,11 +123,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
android:gravity="end"
android:textAlignment="textEnd"
android:textColor="@android:color/black"
android:textSize="14sp"
tools:text="TextView"
android:textAlignment="textEnd"
android:gravity="end"/>
android:textStyle="bold"
tools:text="TextView" />
</LinearLayout>


Expand Down
6 changes: 5 additions & 1 deletion notification.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"latest_app_version": 17,
"latest_app_version": 18,
"changelog": [
{
"ver": "1.1.8.1",
"description": "-Adesso è possibile premere le barre dell'istogramma Provinciale per visualizzare ulteriori dettagli.\n-Piccole migliorie grafiche."
},
{
"ver": "1.1.8",
"description": "-Aggiunta possibilità di confrontare la variazione percentuale delle misure nell'istogramma regionale. Adesso è anche possibile premere le barre dell'istogramma per visualizzare ulteriori dettagli.\n-Cambiate alcune icone\n\nNota: Questa funzionalità è stata aggiunta sono nell'istogramma relativo alle regioni in quanto le misure disponibili per le province sono poche e spesso poco affidabili."
Expand Down

0 comments on commit cbe2cc8

Please sign in to comment.