wear temp target activity
This commit is contained in:
parent
3ff41af939
commit
eb96cf6713
|
@ -103,8 +103,8 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".interaction.NWPreferences"
|
||||
android:label="@string/label_xdrip_activity">
|
||||
android:name=".interaction.AAPSPreferences"
|
||||
android:label="SETTINGS">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".interaction.actions.WizardActivity"
|
||||
|
@ -122,5 +122,13 @@
|
|||
android:name=".interaction.actions.BolusActivity"
|
||||
android:label="Bolus">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".interaction.actions.FillActivity"
|
||||
android:label="Fill">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".interaction.actions.TempTargetActivity"
|
||||
android:label="TempTarget">
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
|
@ -24,7 +24,7 @@ import com.google.android.gms.wearable.WearableListenerService;
|
|||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import info.nightscout.androidaps.interaction.NWPreferences;
|
||||
import info.nightscout.androidaps.interaction.AAPSPreferences;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
||||
/**
|
||||
|
@ -227,7 +227,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
|||
|
||||
String path = event.getDataItem().getUri().getPath();
|
||||
if (path.equals(OPEN_SETTINGS)) {
|
||||
Intent intent = new Intent(this, NWPreferences.class);
|
||||
Intent intent = new Intent(this, AAPSPreferences.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
} else if (path.equals(BOLUS_PROGRESS_PATH)) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.preference.PreferenceActivity;
|
|||
import info.nightscout.androidaps.R;
|
||||
import preference.WearPreferenceActivity;
|
||||
|
||||
public class NWPreferences extends WearPreferenceActivity {
|
||||
public class AAPSPreferences extends WearPreferenceActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -15,4 +15,10 @@ public class NWPreferences extends WearPreferenceActivity {
|
|||
addPreferencesFromResource(R.xml.preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause(){
|
||||
super.onPause();
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package info.nightscout.androidaps.interaction.actions;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.wearable.view.DotsPageIndicator;
|
||||
import android.support.wearable.view.GridPagerAdapter;
|
||||
import android.support.wearable.view.GridViewPager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
|
||||
import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||
|
||||
/**
|
||||
* Created by adrian on 09/02/17.
|
||||
*/
|
||||
|
||||
|
||||
public class FillActivity extends Activity {
|
||||
|
||||
PlusMinusEditText editInsulin;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.grid_layout);
|
||||
final Resources res = getResources();
|
||||
final GridViewPager pager = (GridViewPager) findViewById(R.id.pager);
|
||||
|
||||
pager.setAdapter(new MyGridViewPagerAdapter());
|
||||
DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator);
|
||||
dotsPageIndicator.setPager(pager);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||
@Override
|
||||
public int getColumnCount(int arg0) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||
|
||||
if(col == 0){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("insulin");
|
||||
editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false);
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else {
|
||||
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||
final ImageView confirmbutton = (ImageView) view.findViewById(R.id.confirmbutton);
|
||||
confirmbutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
//check if it can happen that the fagment is never created that hold data?
|
||||
// (you have to swipe past them anyways - but still)
|
||||
|
||||
String actionstring = "fill " +SafeParse.stringToDouble(editInsulin.editText.getText().toString());
|
||||
ListenerService.initiateAction(FillActivity.this, actionstring);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int row, int col, Object view) {
|
||||
// Handle this to get the data before the view is destroyed?
|
||||
// Object should still be kept by this, just setup for reinit?
|
||||
container.removeView((View)view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view==object;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package info.nightscout.androidaps.interaction.actions;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.wearable.view.DotsPageIndicator;
|
||||
import android.support.wearable.view.GridPagerAdapter;
|
||||
import android.support.wearable.view.GridViewPager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
|
||||
import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||
|
||||
import static android.preference.PreferenceManager.getDefaultSharedPreferences;
|
||||
|
||||
/**
|
||||
* Created by adrian on 09/02/17.
|
||||
*/
|
||||
|
||||
|
||||
public class TempTargetActivity extends Activity {
|
||||
|
||||
PlusMinusEditText lowRange;
|
||||
PlusMinusEditText highRange;
|
||||
PlusMinusEditText time;
|
||||
boolean isMGDL;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.grid_layout);
|
||||
final Resources res = getResources();
|
||||
final GridViewPager pager = (GridViewPager) findViewById(R.id.pager);
|
||||
|
||||
pager.setAdapter(new MyGridViewPagerAdapter());
|
||||
DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator);
|
||||
dotsPageIndicator.setPager(pager);
|
||||
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
isMGDL = sp.getBoolean("units_mgdl", true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||
@Override
|
||||
public int getColumnCount(int arg0) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||
|
||||
if(col == 0){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("duration");
|
||||
time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 24*60d, 1d, new DecimalFormat("0"), false);
|
||||
container.addView(view);
|
||||
return view;
|
||||
|
||||
} else if(col == 1){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("low");
|
||||
if (isMGDL){
|
||||
lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 72d, 180d, 1d, new DecimalFormat("0"), false);
|
||||
} else {
|
||||
lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 5.5, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false);
|
||||
}
|
||||
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 2){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("high");
|
||||
if (isMGDL){
|
||||
highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 72d, 180d, 1d, new DecimalFormat("0"), false);
|
||||
} else {
|
||||
highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 5.5, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false);
|
||||
}
|
||||
|
||||
container.addView(view);
|
||||
return view;
|
||||
}else {
|
||||
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||
final ImageView confirmbutton = (ImageView) view.findViewById(R.id.confirmbutton);
|
||||
confirmbutton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
//check if it can happen that the fagment is never created that hold data?
|
||||
// (you have to swipe past them anyways - but still)
|
||||
|
||||
String actionstring = "temptarget "
|
||||
+ SafeParse.stringToInt(time.editText.getText().toString())
|
||||
+ " " + isMGDL
|
||||
+ " " + SafeParse.stringToDouble(lowRange.editText.getText().toString())
|
||||
+ " " + SafeParse.stringToDouble(highRange.editText.getText().toString())
|
||||
;
|
||||
|
||||
ListenerService.initiateAction(TempTargetActivity.this, actionstring);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int row, int col, Object view) {
|
||||
// Handle this to get the data before the view is destroyed?
|
||||
// Object should still be kept by this, just setup for reinit?
|
||||
container.removeView((View)view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view==object;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package info.nightscout.androidaps.interaction.menus;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.actions.FillActivity;
|
||||
import info.nightscout.androidaps.interaction.utils.MenuListActivity;
|
||||
|
||||
/**
|
||||
|
@ -14,7 +17,9 @@ public class FillMenuActivity extends MenuListActivity {
|
|||
return new String[] {
|
||||
"Preset 1",
|
||||
"Preset 2",
|
||||
"Preset 3"};
|
||||
"Preset 3",
|
||||
"Free amount"
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,6 +34,11 @@ public class FillMenuActivity extends MenuListActivity {
|
|||
case 2:
|
||||
ListenerService.initiateAction(this, "fillpreset 3");
|
||||
break;
|
||||
case 3:
|
||||
Intent intent = new Intent(this, FillActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,8 +3,9 @@ package info.nightscout.androidaps.interaction.menus;
|
|||
import android.content.Intent;
|
||||
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.NWPreferences;
|
||||
import info.nightscout.androidaps.interaction.AAPSPreferences;
|
||||
import info.nightscout.androidaps.interaction.actions.BolusActivity;
|
||||
import info.nightscout.androidaps.interaction.actions.TempTargetActivity;
|
||||
import info.nightscout.androidaps.interaction.utils.MenuListActivity;
|
||||
import info.nightscout.androidaps.interaction.actions.WizardActivity;
|
||||
|
||||
|
@ -32,6 +33,9 @@ public class MainMenuActivity extends MenuListActivity {
|
|||
Intent intent;
|
||||
switch (position) {
|
||||
case 0:
|
||||
intent = new Intent(this, TempTargetActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
break;
|
||||
case 1:
|
||||
intent = new Intent(this, BolusActivity.class);
|
||||
|
@ -44,7 +48,7 @@ public class MainMenuActivity extends MenuListActivity {
|
|||
this.startActivity(intent);
|
||||
break;
|
||||
case 3:
|
||||
intent = new Intent(this, NWPreferences.class);
|
||||
intent = new Intent(this, AAPSPreferences.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
break;
|
||||
|
|
|
@ -24,6 +24,12 @@ public abstract class MenuListActivity extends Activity
|
|||
|
||||
protected abstract void doAction(int position);
|
||||
|
||||
@Override
|
||||
protected void onPause(){
|
||||
super.onPause();
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
Loading…
Reference in a new issue