DanaR Stats fixes

This commit is contained in:
viktoria 2017-01-18 04:31:47 +01:00
parent 9ba24b4ffd
commit b70e895b95
3 changed files with 45 additions and 31 deletions

View file

@ -14,6 +14,7 @@ import android.os.IBinder;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
@ -137,15 +138,15 @@ public class DanaRStatsActivity extends Activity {
totalBaseBasal = (EditText) findViewById(R.id.danar_stats_editTotalBaseBasal); totalBaseBasal = (EditText) findViewById(R.id.danar_stats_editTotalBaseBasal);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
TBB = preferences.getString("TBB", "10"); TBB = preferences.getString("TBB", "18");
totalBaseBasal.setHint(TBB); totalBaseBasal.setHint(TBB);
totalBaseBasal.addTextChangedListener(new TextWatcher() { totalBaseBasal.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
SharedPreferences.Editor edit = preferences.edit(); SharedPreferences.Editor edit = preferences.edit();
edit.putString("TBB",totalBaseBasal.getText().toString()); edit.putString("TBB",totalBaseBasal.getText().toString());
edit.commit(); edit.commit();
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
TBB = preferences.getString("TBB", ""); TBB = preferences.getString("TBB", "");
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
} }
public void beforeTextChanged(CharSequence s, int start, int count, int after) {} public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int before, int count) {} public void onTextChanged(CharSequence s, int start, int before, int count) {}
@ -304,9 +305,13 @@ public class DanaRStatsActivity extends Activity {
cleanTable(etl); cleanTable(etl);
DateFormat df = new SimpleDateFormat("dd.MM."); DateFormat df = new SimpleDateFormat("dd.MM.");
magicNumber = 18d; if(TextUtils.isEmpty(TBB)) {
String[] separatedTBB = TBB.split(" "); totalBaseBasal.setError("Please Enter Total Base Basal");
magicNumber = Double.parseDouble(separatedTBB[0]); return;
}
else {
magicNumber = Double.parseDouble(TBB);
}
ProfileInterface pi = ConfigBuilderPlugin.getActiveProfile(); ProfileInterface pi = ConfigBuilderPlugin.getActiveProfile();
if (pi instanceof CircadianPercentageProfilePlugin){ if (pi instanceof CircadianPercentageProfilePlugin){

View file

@ -14,6 +14,7 @@ import android.os.IBinder;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
@ -137,15 +138,15 @@ public class DanaRStatsActivity extends Activity {
totalBaseBasal = (EditText) findViewById(R.id.danar_stats_editTotalBaseBasal); totalBaseBasal = (EditText) findViewById(R.id.danar_stats_editTotalBaseBasal);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
TBB = preferences.getString("TBB", "10"); TBB = preferences.getString("TBB", "18");
totalBaseBasal.setHint(TBB); totalBaseBasal.setHint(TBB);
totalBaseBasal.addTextChangedListener(new TextWatcher() { totalBaseBasal.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
SharedPreferences.Editor edit = preferences.edit(); SharedPreferences.Editor edit = preferences.edit();
edit.putString("TBB",totalBaseBasal.getText().toString()); edit.putString("TBB",totalBaseBasal.getText().toString());
edit.commit(); edit.commit();
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
TBB = preferences.getString("TBB", ""); TBB = preferences.getString("TBB", "");
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
} }
public void beforeTextChanged(CharSequence s, int start, int count, int after) {} public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int before, int count) {} public void onTextChanged(CharSequence s, int start, int before, int count) {}
@ -304,9 +305,13 @@ public class DanaRStatsActivity extends Activity {
cleanTable(etl); cleanTable(etl);
DateFormat df = new SimpleDateFormat("dd.MM."); DateFormat df = new SimpleDateFormat("dd.MM.");
magicNumber = 18d; if(TextUtils.isEmpty(TBB)) {
String[] separatedTBB = TBB.split(" "); totalBaseBasal.setError("Please Enter Total Base Basal");
magicNumber = Double.parseDouble(separatedTBB[0]); return;
}
else {
magicNumber = Double.parseDouble(TBB);
}
ProfileInterface pi = ConfigBuilderPlugin.getActiveProfile(); ProfileInterface pi = ConfigBuilderPlugin.getActiveProfile();
if (pi instanceof CircadianPercentageProfilePlugin){ if (pi instanceof CircadianPercentageProfilePlugin){

View file

@ -90,7 +90,9 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -109,6 +111,28 @@
android:layout_weight="1"> android:layout_weight="1">
</TableLayout> </TableLayout>
<Space
android:layout_width="10dp"
android:layout_height="30dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="18"
android:textSize="50px"
android:gravity="center"
android:inputType="numberDecimal"
android:id="@+id/danar_stats_editTotalBaseBasal" />
<TextView
android:text="@string/danar_stats_tbb"
android:labelFor="@+id/danar_stats_editTotalBaseBasal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/danar_stats_editTotalBaseBasal_label"
android:gravity="center"
android:layout_weight="1" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
@ -135,26 +159,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1"> android:layout_weight="1">
<EditText
android:layout_width="70dp"
android:layout_height="wrap_content"
android:hint="TBB"
android:ems="10"
android:gravity="center"
android:inputType="numberDecimal"
android:id="@+id/danar_stats_editTotalBaseBasal" />
<TextView
android:text="@string/danar_stats_tbb"
android:labelFor="@+id/danar_stats_editTotalBaseBasal"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:id="@+id/danar_stats_editTotalBaseBasal_label"
android:gravity="top" />
<Space
android:layout_width="match_parent"
android:layout_height="20dp" />
<TextView <TextView
android:id="@+id/danar_stats_Message" android:id="@+id/danar_stats_Message"