support for removing temp targets from GUI
This commit is contained in:
parent
8c38090031
commit
218190e92f
5 changed files with 76 additions and 5 deletions
|
@ -37,7 +37,7 @@
|
||||||
<ConfirmationsSetting value="0" id="Add" />
|
<ConfirmationsSetting value="0" id="Add" />
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
<ConfirmationsSetting value="0" id="Remove" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -974,7 +974,25 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
context.sendBroadcast(intent);
|
context.sendBroadcast(intent);
|
||||||
DbLogger.dbAdd(intent, data.toString(), NewExtendedBolusDialog.class);
|
DbLogger.dbAdd(intent, data.toString(), ConfigBuilderPlugin.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeCareportalEntryFromNS(String _id) {
|
||||||
|
try {
|
||||||
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("action", "dbRemove");
|
||||||
|
bundle.putString("collection", "treatments");
|
||||||
|
bundle.putString("_id", _id);
|
||||||
|
Intent intent = new Intent(Intents.ACTION_DATABASE);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
DbLogger.dbRemove(intent, _id, ConfigBuilderPlugin.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -18,8 +19,10 @@ import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.j256.ormlite.dao.Dao;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -79,6 +82,7 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.colorInProgress));
|
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.colorInProgress));
|
||||||
else
|
else
|
||||||
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.cardColorBackground));
|
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.cardColorBackground));
|
||||||
|
holder.remove.setTag(tempTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,13 +95,14 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
super.onAttachedToRecyclerView(recyclerView);
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TempTargetsViewHolder extends RecyclerView.ViewHolder {
|
public static class TempTargetsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
CardView cv;
|
CardView cv;
|
||||||
TextView date;
|
TextView date;
|
||||||
TextView duration;
|
TextView duration;
|
||||||
TextView low;
|
TextView low;
|
||||||
TextView high;
|
TextView high;
|
||||||
TextView reason;
|
TextView reason;
|
||||||
|
TextView remove;
|
||||||
LinearLayout dateLinearLayout;
|
LinearLayout dateLinearLayout;
|
||||||
|
|
||||||
TempTargetsViewHolder(View itemView) {
|
TempTargetsViewHolder(View itemView) {
|
||||||
|
@ -108,8 +113,32 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
low = (TextView) itemView.findViewById(R.id.temptargetrange_low);
|
low = (TextView) itemView.findViewById(R.id.temptargetrange_low);
|
||||||
high = (TextView) itemView.findViewById(R.id.temptargetrange_high);
|
high = (TextView) itemView.findViewById(R.id.temptargetrange_high);
|
||||||
reason = (TextView) itemView.findViewById(R.id.temptargetrange_reason);
|
reason = (TextView) itemView.findViewById(R.id.temptargetrange_reason);
|
||||||
|
remove = (TextView) itemView.findViewById(R.id.temptargetrange_remove);
|
||||||
|
remove.setOnClickListener(this);
|
||||||
|
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
dateLinearLayout = (LinearLayout) itemView.findViewById(R.id.temptargetrange_datelinearlayout);
|
dateLinearLayout = (LinearLayout) itemView.findViewById(R.id.temptargetrange_datelinearlayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
TempTarget tempTarget = (TempTarget) v.getTag();
|
||||||
|
switch (v.getId()) {
|
||||||
|
case R.id.temptargetrange_remove:
|
||||||
|
String _id = tempTarget._id;
|
||||||
|
if (_id != null && !_id.equals("")) {
|
||||||
|
MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id);
|
||||||
|
try {
|
||||||
|
Dao<TempTarget, Long> daoTempTargets = MainApp.getDbHelper().getDaoTempTargets();
|
||||||
|
daoTempTargets.delete(tempTarget);
|
||||||
|
MainApp.bus().post(new EventTempTargetRangeChange());
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,4 +26,14 @@ public class DbLogger {
|
||||||
} else if (Config.logNSUpload)
|
} else if (Config.logNSUpload)
|
||||||
log.debug("DBADD dbAdd " + q.size() + " receivers " + data);
|
log.debug("DBADD dbAdd " + q.size() + " receivers " + data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void dbRemove(Intent intent, String data, Class sender) {
|
||||||
|
Logger log = LoggerFactory.getLogger(sender);
|
||||||
|
List<ResolveInfo> q = MainApp.instance().getApplicationContext().getPackageManager().queryBroadcastReceivers(intent, 0);
|
||||||
|
if (q.size() < 1) {
|
||||||
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(),MainApp.sResources.getString(R.string.nsclientnotinstalled));
|
||||||
|
log.error("DBREMOVE No receivers");
|
||||||
|
} else if (Config.logNSUpload)
|
||||||
|
log.debug("DBREMOVE dbRemove " + q.size() + " receivers " + data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,10 +89,15 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="top"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="5dp"
|
|
||||||
android:text="@string/reason"
|
android:text="@string/reason"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:text=":" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/temptargetrange_reason"
|
android:id="@+id/temptargetrange_reason"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -100,8 +105,17 @@
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
android:text="Activity"
|
android:text="Activity"
|
||||||
|
android:layout_weight="1"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="@string/overview_quickwizard_item_remove_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/temptargetrange_remove"
|
||||||
|
android:textAlignment="viewEnd"
|
||||||
|
android:textColor="@android:color/holo_orange_light" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
Loading…
Reference in a new issue