wear bolus activity and refactoring

This commit is contained in:
AdrianLxM 2017-02-09 20:54:41 +01:00
parent dc476a6600
commit 3ff41af939
34 changed files with 222 additions and 83 deletions

View file

@ -42,15 +42,7 @@ public class WearFragment extends Fragment implements FragmentBase {
view.findViewById(R.id.wear_opensettings).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//TODO: revert after debugging!
//getPlugin(getContext()).openSettings();
String title = "CONFIRM"; //TODO: i18n
String message = "Insulin: 7.0U \n" +
"Carbs: 26 \n" +
"CONSTRAINTS APPLIED!!!"; //TODO: apply constraints
String actionstring = "Bolus 7.0 Carbs 26"; //TODO: to be returned by watch if confirmed
getPlugin(getContext()).requestActionConfirmation(title, message, actionstring);
getPlugin(getContext()).openSettings();
}
});

View file

@ -17,7 +17,7 @@
android:value="@integer/google_play_services_version" />
<service
android:name=".BIGChart"
android:name=".watchfaces.BIGChart"
android:allowEmbedded="true"
android:label="@string/label_xdrip_big_chart"
android:permission="android.permission.BIND_WALLPAPER">
@ -35,7 +35,7 @@
</intent-filter>
</service>
<service
android:name=".Home"
android:name=".watchfaces.Home"
android:allowEmbedded="true"
android:label="@string/label_xdrip"
android:permission="android.permission.BIND_WALLPAPER">
@ -53,7 +53,7 @@
</intent-filter>
</service>
<service
android:name=".LargeHome"
android:name=".watchfaces.LargeHome"
android:allowEmbedded="true"
android:label="@string/label_xdrip_large"
android:permission="android.permission.BIND_WALLPAPER">
@ -71,7 +71,7 @@
</intent-filter>
</service>
<service
android:name=".CircleWatchface"
android:name=".watchfaces.CircleWatchface"
android:allowEmbedded="true"
android:label="@string/label_xdrip_circle"
android:permission="android.permission.BIND_WALLPAPER">
@ -88,22 +88,14 @@
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>
</service>
<service android:name=".ListenerService">
<service android:name=".data.ListenerService">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
<activity
android:name=".NWPreferences"
android:label="@string/label_xdrip_activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".actions.MainMenuActivity"
android:name=".interaction.menus.MainMenuActivity"
android:label="@string/label_actions_activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -111,16 +103,24 @@
</intent-filter>
</activity>
<activity
android:name=".actions.wizard.WizardActivity"
android:name=".interaction.NWPreferences"
android:label="@string/label_xdrip_activity">
</activity>
<activity
android:name=".interaction.actions.WizardActivity"
android:label="Wizard">
</activity>
<activity
android:name=".actions.FillMenuActivity"
android:name=".interaction.menus.FillMenuActivity"
android:label="Fillmenu">
</activity>
<activity
android:name=".actions.StatusMenuActivity"
android:name=".interaction.menus.StatusMenuActivity"
android:label="Status">
</activity>
<activity
android:name=".interaction.actions.BolusActivity"
android:label="Bolus">
</activity>
</application>
</manifest>

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps;
package info.nightscout.androidaps.data;
/**
* Created by adrian on 18/11/16.

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps;
package info.nightscout.androidaps.data;
/**
* Created by emmablack on 1/7/15.

View file

@ -1,9 +1,8 @@
package info.nightscout.androidaps;
package info.nightscout.androidaps.data;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
@ -25,6 +24,9 @@ import com.google.android.gms.wearable.WearableListenerService;
import java.util.concurrent.TimeUnit;
import info.nightscout.androidaps.interaction.NWPreferences;
import info.nightscout.androidaps.R;
/**
* Created by emmablack on 12/26/14.
*/

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps;
package info.nightscout.androidaps.data;
/**
* Created by adrian on 17/11/16.

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps;
package info.nightscout.androidaps.interaction;
import android.os.Bundle;

View file

@ -0,0 +1,117 @@
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 BolusActivity extends Activity {
PlusMinusEditText editCarbs;
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 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("carbs");
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 100d, 1d, new DecimalFormat("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 = "bolus " +SafeParse.stringToDouble(editInsulin.editText.getText().toString())
+ " " + SafeParse.stringToInt(editCarbs.editText.getText().toString());
ListenerService.initiateAction(BolusActivity.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;
}
}
}

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.actions.wizard;
package info.nightscout.androidaps.interaction.actions;
import android.app.Activity;
@ -15,10 +15,10 @@ import android.widget.TextView;
import java.text.DecimalFormat;
import info.nightscout.androidaps.ListenerService;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.actions.utils.PlusMinusEditText;
import info.nightscout.androidaps.actions.utils.SafeParse;
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
import info.nightscout.androidaps.interaction.utils.SafeParse;
/**
* Created by adrian on 09/02/17.

View file

@ -1,11 +1,7 @@
package info.nightscout.androidaps.actions;
package info.nightscout.androidaps.interaction.menus;
import android.content.Intent;
import info.nightscout.androidaps.ListenerService;
import info.nightscout.androidaps.NWPreferences;
import info.nightscout.androidaps.actions.utils.MenuListActivity;
import info.nightscout.androidaps.actions.wizard.WizardActivity;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.interaction.utils.MenuListActivity;
/**
* Created by adrian on 09/02/17.

View file

@ -1,11 +1,12 @@
package info.nightscout.androidaps.actions;
package info.nightscout.androidaps.interaction.menus;
import android.content.Intent;
import info.nightscout.androidaps.ListenerService;
import info.nightscout.androidaps.NWPreferences;
import info.nightscout.androidaps.actions.utils.MenuListActivity;
import info.nightscout.androidaps.actions.wizard.WizardActivity;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.interaction.NWPreferences;
import info.nightscout.androidaps.interaction.actions.BolusActivity;
import info.nightscout.androidaps.interaction.utils.MenuListActivity;
import info.nightscout.androidaps.interaction.actions.WizardActivity;
/**
* Created by adrian on 09/02/17.
@ -17,6 +18,7 @@ public class MainMenuActivity extends MenuListActivity {
protected String[] getElements() {
return new String[] {
"TTarget",
"Bolus",
"Wizard",
"Settings",
"Re-Sync",
@ -32,24 +34,29 @@ public class MainMenuActivity extends MenuListActivity {
case 0:
break;
case 1:
intent = new Intent(this, WizardActivity.class);
intent = new Intent(this, BolusActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
break;
case 2:
intent = new Intent(this, NWPreferences.class);
intent = new Intent(this, WizardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
break;
case 3:
ListenerService.requestData(this);
intent = new Intent(this, NWPreferences.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
break;
case 4:
ListenerService.requestData(this);
break;
case 5:
intent = new Intent(this, StatusMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
break;
case 5:
case 6:
intent = new Intent(this, FillMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.actions;
package info.nightscout.androidaps.interaction.menus;
import info.nightscout.androidaps.ListenerService;
import info.nightscout.androidaps.actions.utils.MenuListActivity;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.interaction.utils.MenuListActivity;
/**
* Created by adrian on 09/02/17.

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.actions.utils;
package info.nightscout.androidaps.interaction.utils;
import android.app.Activity;
import android.content.Context;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.actions.utils;
package info.nightscout.androidaps.interaction.utils;
import android.os.Handler;
import android.os.Message;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.actions.utils;
package info.nightscout.androidaps.interaction.utils;
/**
* Created by mike on 23.06.2016.

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.actions;
package info.nightscout.androidaps.interaction.utils;
import android.content.Context;
import android.graphics.drawable.GradientDrawable;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps;
package info.nightscout.androidaps.watchfaces;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -39,7 +39,12 @@ import com.ustwo.clockwise.common.WatchShape;
import java.util.ArrayList;
import java.util.Date;
import info.nightscout.androidaps.actions.MainMenuActivity;
import info.nightscout.androidaps.data.BasalWatchData;
import info.nightscout.androidaps.data.BgWatchData;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.TempWatchData;
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
import lecho.lib.hellocharts.view.LineChartView;
/**

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps;
package info.nightscout.androidaps.watchfaces;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -34,6 +34,11 @@ import com.ustwo.clockwise.common.WatchShape;
import java.util.ArrayList;
import java.util.Date;
import info.nightscout.androidaps.data.BasalWatchData;
import info.nightscout.androidaps.data.BgWatchData;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.TempWatchData;
import lecho.lib.hellocharts.view.LineChartView;
/**

View file

@ -1,9 +1,8 @@
package info.nightscout.androidaps;
package info.nightscout.androidaps.watchfaces;
import android.content.Context;
import android.graphics.DashPathEffect;
import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
import android.text.format.DateFormat;
import java.text.SimpleDateFormat;
@ -14,6 +13,9 @@ import java.util.GregorianCalendar;
import java.util.List;
import java.util.TimeZone;
import info.nightscout.androidaps.data.BasalWatchData;
import info.nightscout.androidaps.data.BgWatchData;
import info.nightscout.androidaps.data.TempWatchData;
import lecho.lib.hellocharts.model.Axis;
import lecho.lib.hellocharts.model.AxisValue;
import lecho.lib.hellocharts.model.Line;

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps;
package info.nightscout.androidaps.watchfaces;
import android.content.BroadcastReceiver;
import android.content.Context;
@ -36,7 +36,9 @@ import java.util.Date;
import java.util.HashSet;
import java.util.TreeSet;
import info.nightscout.androidaps.actions.MainMenuActivity;
import info.nightscout.androidaps.data.BgWatchData;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
public class CircleWatchface extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps;
package info.nightscout.androidaps.watchfaces;
import android.content.Intent;
import android.graphics.Color;
@ -8,7 +8,8 @@ import android.view.LayoutInflater;
import com.ustwo.clockwise.common.WatchMode;
import info.nightscout.androidaps.actions.MainMenuActivity;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
public class Home extends BaseWatchFace {

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps;
package info.nightscout.androidaps.watchfaces;
import android.content.Intent;
import android.graphics.Color;
@ -8,7 +8,8 @@ import android.view.LayoutInflater;
import com.ustwo.clockwise.common.WatchMode;
import info.nightscout.androidaps.actions.MainMenuActivity;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
public class LargeHome extends BaseWatchFace {

View file

@ -8,5 +8,5 @@
android:layout_height="match_parent"
app:rectLayout="@layout/rect_activity_bigchart"
app:roundLayout="@layout/round_activity_bigchart"
tools:context=".Home"
tools:context=".watchfaces.Home"
tools:deviceIds="wear"/>

View file

@ -8,5 +8,5 @@
android:layout_height="match_parent"
app:rectLayout="@layout/rect_activity_home"
app:roundLayout="@layout/round_activity_home"
tools:context=".Home"
tools:context=".watchfaces.Home"
tools:deviceIds="wear"/>

View file

@ -8,5 +8,5 @@
android:layout_height="match_parent"
app:rectLayout="@layout/rect_activity_home_large"
app:roundLayout="@layout/round_activity_home_large"
tools:context=".Home"
tools:context=".watchfaces.Home"
tools:deviceIds="wear"/>

View file

@ -1,4 +1,4 @@
<info.nightscout.androidaps.actions.WearableListItemLayout
<info.nightscout.androidaps.interaction.utils.WearableListItemLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center_vertical"
android:layout_width="match_parent"
@ -19,5 +19,5 @@
android:lineSpacingExtra="-4sp"
android:textColor="@color/dark_statusView"
android:textSize="32sp"/>
</info.nightscout.androidaps.actions.WearableListItemLayout>
</info.nightscout.androidaps.interaction.utils.WearableListItemLayout>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".Home" tools:deviceIds="wear_square"
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
android:background="@color/black"
android:id="@+id/main_layout">

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".Home" tools:deviceIds="wear_square"
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
android:background="@color/black"
android:id="@+id/main_layout">

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".Home" tools:deviceIds="wear_square"
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
android:background="@color/black"
android:id="@+id/main_layout">

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".Home" tools:deviceIds="wear_square"
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
android:background="@color/black"
android:id="@+id/main_layout">

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".Home" tools:deviceIds="wear_round"
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_round"
android:background="@color/black"
android:id="@+id/main_layout">

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".Home" tools:deviceIds="wear_round"
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_round"
android:background="@color/black"
android:id="@+id/main_layout">

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">AAPS Prefs.</string>
<string name="label_actions_activity">AAPS Actions</string>
<string name="app_name">AAPS</string>
<string name="label_actions_activity">AAPS</string>
<string-array name="chart_timeframe">
<item>1 hour</item>

View file

@ -9,6 +9,15 @@
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
android:key="units_mgdl"
android:title="Units for Actions"
android:summaryOn="mg/dl"
android:summaryOff="mmol/l"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
android:key="showExternalStatus"