wear fragment and reset button

This commit is contained in:
AdrianLxM 2016-11-24 12:54:14 +01:00
parent b306de49dc
commit c633904e8c
3 changed files with 60 additions and 12 deletions

View file

@ -1,14 +1,20 @@
package info.nightscout.androidaps.plugins.Wear;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase;
/**
* Created by adrian on 17/11/16.
*/
public class WearFragment implements FragmentBase {
public class WearFragment extends Fragment implements FragmentBase {
private static WearPlugin wearPlugin;
@ -21,6 +27,23 @@ public class WearFragment implements FragmentBase {
return wearPlugin;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.wear_fragment, container, false);
view.findViewById(R.id.wear_resend).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getPlugin(getContext()).resendDataToWatch();
}
});
return view;
}
//TODO Adrian: setting for short/long status string
//TODO Adrian: resend buttons

View file

@ -23,6 +23,7 @@ import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterServi
public class WearPlugin implements PluginBase {
static boolean fragmentEnabled = true;
static boolean fragmentVisible = false;
private static WatchUpdaterService watchUS;
private final Context ctx;
@ -43,7 +44,7 @@ public class WearPlugin implements PluginBase {
@Override
public String getName() {
return "WearPlugin";
return "Wear";
}
@Override
@ -53,7 +54,7 @@ public class WearPlugin implements PluginBase {
@Override
public boolean isVisibleInTabs(int type) {
return false;
return fragmentVisible;
}
@Override
@ -71,7 +72,7 @@ public class WearPlugin implements PluginBase {
@Override
public void setFragmentVisible(int type, boolean fragmentVisible) {
WearPlugin.fragmentVisible = fragmentVisible;
}
private void sendDataToWatch(boolean status, boolean basals, boolean bgValue){
@ -88,11 +89,14 @@ public class WearPlugin implements PluginBase {
if(status){
ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_STATUS));
}
}
}
void resendDataToWatch(){
ctx.startService(new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_RESEND));
}
/* @Subscribe
public void onStatusEvent(final EventPreferenceChange ev) {
@ -125,12 +129,6 @@ public class WearPlugin implements PluginBase {
sendDataToWatch(true, true, true);
}
/* @Subscribe
public void onStatusEvent(final EventNewOpenLoopNotification ev) {
//TODO Adrian: Do they come through as notification cards already? update status?
sendDataToWatch();
}*/
@Subscribe
public void onStatusEvent(final EventNewBasalProfile ev) {
sendDataToWatch(false, true, false);

View file

@ -0,0 +1,27 @@
<FrameLayout 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="info.nightscout.androidaps.plugins.Wear.WearFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="@+id/wear_resend"
style="?android:attr/buttonStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:layout_weight="0.5"
android:text="Resend All Data"
android:textColor="@color/colorProfileSwitchButton" />
</LinearLayout>
</FrameLayout>