first confirm activity

This commit is contained in:
AdrianLxM 2018-06-27 08:04:57 +02:00
parent 2b799d9f71
commit aad2b94c8e
6 changed files with 163 additions and 4 deletions

View file

@ -30,7 +30,7 @@ android {
defaultConfig {
applicationId "info.nightscout.androidaps"
minSdkVersion 21
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0.2"
@ -67,6 +67,7 @@ dependencies {
implementation "com.google.android.support:wearable:${wearableVersion}"
implementation "com.google.android.gms:play-services-wearable:7.3.0"
implementation(name:"ustwo-clockwise-debug", ext:"aar")
implementation "com.android.support:support-v4:23.0.1"
implementation "com.android.support:support-v4:27.0.1"
implementation 'com.android.support:wear:27.0.1'
implementation "me.denley.wearpreferenceactivity:wearpreferenceactivity:0.5.0"
}

View file

@ -204,6 +204,10 @@
android:name=".interaction.actions.CPPActivity"
android:label="CPP">
</activity>
<activity
android:name=".interaction.actions.AcceptActivity"
android:label="CPP">
</activity>
<activity
android:name=".interaction.actions.FillActivity"
android:label="Fill">

View file

@ -436,6 +436,13 @@ public class ListenerService extends WearableListenerService implements GoogleAp
context.startService(intent);
}
public static void confirmAction(Context context, String actionstring) {
Intent intent = new Intent(context, ListenerService.class);
intent.putExtra("actionstring", actionstring);
intent.setAction(ACTION_CONFIRMATION);
context.startService(intent);
}
@Override
public void onConnected(Bundle bundle) {
requestData();

View file

@ -0,0 +1,111 @@
package info.nightscout.androidaps.interaction.actions;
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 AcceptActivity extends ViewSelectorActivity {
String text = "";
String actionstring = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
text = extras.getString("text", "");
actionstring = extras.getString("actionstring", "");
if ("".equals(text) || "".equals(actionstring) ){
finish(); return;
}
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 2;
}
@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_confirm_text, container, false);
final TextView textView = (TextView) view.findViewById(R.id.confirmtext);
textView.setText(text);
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) {
ListenerService.confirmAction(AcceptActivity.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

@ -9,6 +9,7 @@ import java.util.Vector;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.interaction.AAPSPreferences;
import info.nightscout.androidaps.interaction.actions.AcceptActivity;
import info.nightscout.androidaps.interaction.actions.BolusActivity;
import info.nightscout.androidaps.interaction.actions.ECarbActivity;
import info.nightscout.androidaps.interaction.actions.TempTargetActivity;
@ -34,7 +35,7 @@ public class MainMenuActivity extends MenuListActivity {
protected String[] getElements() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
if(!sharedPreferences.getBoolean("wearcontrol", false)){
if(false && !sharedPreferences.getBoolean("wearcontrol", false)){
return new String[] {
"Settings",
"Re-Sync"};
@ -84,9 +85,17 @@ public class MainMenuActivity extends MenuListActivity {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
} else if ("Prime/Fill".equals(action)) {
intent = new Intent(this, FillMenuActivity.class);
/*intent = new Intent(this, FillMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
*/
intent = new Intent(this, AcceptActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle params = new Bundle();
params.putString("text", "dies\nist ein\nhoffentlich\n langer text\n\ndies\nist ein\nhoffentlich\n langer text\n\ndies\nist ein\nhoffentlich\n langer text\n\ndies\nist ein\nhoffentlich\n langer text\n\n");
params.putString("actionstring", "blablubb");
intent.putExtras(params);
startActivity(intent);
} else if ("eCarb".equals(action)) {
intent = new Intent(this, ECarbActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

View file

@ -0,0 +1,27 @@
<android.support.wear.widget.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
app:boxedEdges="all">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/confirmtext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="asdfas"
android:textColor="@color/white" />
</android.support.v4.widget.NestedScrollView>
</FrameLayout>
</android.support.wear.widget.BoxInsetLayout>