Wear curved titles
This commit is contained in:
parent
a83eb1c456
commit
0969d8339f
16 changed files with 189 additions and 292 deletions
|
@ -53,7 +53,7 @@ def generateGitBuild = { ->
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 31
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "info.nightscout.androidaps"
|
applicationId "info.nightscout.androidaps"
|
||||||
|
@ -119,8 +119,6 @@ allprojects {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
//implementation files("libs/hellocharts-library-1.5.5.jar")
|
|
||||||
//compile "com.ustwo.android:clockwise-wearable:1.0.2"
|
|
||||||
|
|
||||||
implementation "androidx.appcompat:appcompat:$appcompat_version"
|
implementation "androidx.appcompat:appcompat:$appcompat_version"
|
||||||
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
|
||||||
|
@ -131,10 +129,12 @@ dependencies {
|
||||||
implementation(name: 'ustwo-clockwise-debug', ext: 'aar')
|
implementation(name: 'ustwo-clockwise-debug', ext: 'aar')
|
||||||
implementation(name: 'wearpreferenceactivity-0.5.0', ext: 'aar')
|
implementation(name: 'wearpreferenceactivity-0.5.0', ext: 'aar')
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation 'androidx.percentlayout:percentlayout:1.0.0'
|
implementation 'androidx.wear:wear:1.2.0'
|
||||||
implementation 'androidx.wear:wear:1.1.0'
|
|
||||||
implementation('com.github.lecho:hellocharts-library:1.5.8@aar')
|
implementation('com.github.lecho:hellocharts-library:1.5.8@aar')
|
||||||
|
|
||||||
|
implementation "androidx.core:core-ktx:$coreVersion"
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
|
|
||||||
testImplementation "junit:junit:$junit_version"
|
testImplementation "junit:junit:$junit_version"
|
||||||
testImplementation 'org.json:json:20211205'
|
testImplementation 'org.json:json:20211205'
|
||||||
testImplementation("org.mockito:mockito-core:${mockitoVersion}") {
|
testImplementation("org.mockito:mockito-core:${mockitoVersion}") {
|
||||||
|
@ -157,8 +157,6 @@ dependencies {
|
||||||
}
|
}
|
||||||
testImplementation "org.skyscreamer:jsonassert:1.5.0"
|
testImplementation "org.skyscreamer:jsonassert:1.5.0"
|
||||||
testImplementation "org.hamcrest:hamcrest-all:1.3"
|
testImplementation "org.hamcrest:hamcrest-all:1.3"
|
||||||
implementation "androidx.core:core-ktx:$coreVersion"
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
package info.nightscout.androidaps.interaction.actions;
|
package info.nightscout.androidaps.interaction.actions;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import androidx.core.app.NotificationManagerCompat;
|
|
||||||
import android.support.wearable.view.DotsPageIndicator;
|
|
||||||
import android.support.wearable.view.GridPagerAdapter;
|
import android.support.wearable.view.GridPagerAdapter;
|
||||||
import android.support.wearable.view.GridViewPager;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -24,10 +19,8 @@ import info.nightscout.androidaps.data.ListenerService;
|
||||||
* Created by adrian on 09/02/17.
|
* Created by adrian on 09/02/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public class AcceptActivity extends ViewSelectorActivity {
|
public class AcceptActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
|
|
||||||
String title = "";
|
String title = "";
|
||||||
String message = "";
|
String message = "";
|
||||||
String actionstring = "";
|
String actionstring = "";
|
||||||
|
@ -45,30 +38,25 @@ public class AcceptActivity extends ViewSelectorActivity {
|
||||||
message = extras.getString("message", "");
|
message = extras.getString("message", "");
|
||||||
actionstring = extras.getString("actionstring", "");
|
actionstring = extras.getString("actionstring", "");
|
||||||
|
|
||||||
if ("".equals(message) || "".equals(actionstring) ){
|
if ("".equals(message) || "".equals(actionstring)) {
|
||||||
finish(); return;
|
finish();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setContentView(R.layout.grid_layout);
|
setContentView(R.layout.grid_layout);
|
||||||
|
setAdapter(new MyGridViewPagerAdapter());
|
||||||
final GridViewPager pager = findViewById(R.id.pager);
|
|
||||||
pager.setAdapter(new MyGridViewPagerAdapter());
|
|
||||||
DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator);
|
|
||||||
dotsPageIndicator.setPager(pager);
|
|
||||||
|
|
||||||
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
long[] vibratePattern = new long[]{0, 100, 50, 100, 50};
|
long[] vibratePattern = new long[]{0, 100, 50, 100, 50};
|
||||||
v.vibrate(vibratePattern, -1);
|
v.vibrate(vibratePattern, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount(int arg0) {
|
public int getColumnCount(int arg0) {
|
||||||
|
@ -83,7 +71,7 @@ public class AcceptActivity extends ViewSelectorActivity {
|
||||||
@Override
|
@Override
|
||||||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||||
|
|
||||||
if(col == 0){
|
if (col == 0) {
|
||||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_confirm_text, container, false);
|
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_confirm_text, container, false);
|
||||||
final TextView headingView = view.findViewById(R.id.title);
|
final TextView headingView = view.findViewById(R.id.title);
|
||||||
headingView.setText(title);
|
headingView.setText(title);
|
||||||
|
@ -110,29 +98,29 @@ public class AcceptActivity extends ViewSelectorActivity {
|
||||||
public void destroyItem(ViewGroup container, int row, int col, Object view) {
|
public void destroyItem(ViewGroup container, int row, int col, Object view) {
|
||||||
// Handle this to get the data before the view is destroyed?
|
// Handle this to get the data before the view is destroyed?
|
||||||
// Object should still be kept by this, just setup for reinit?
|
// Object should still be kept by this, just setup for reinit?
|
||||||
container.removeView((View)view);
|
container.removeView((View) view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isViewFromObject(View view, Object object) {
|
public boolean isViewFromObject(View view, Object object) {
|
||||||
return view==object;
|
return view == object;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onDestroy(){
|
public synchronized void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if(dismissThread != null){
|
if (dismissThread != null) {
|
||||||
dismissThread.invalidate();
|
dismissThread.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DismissThread extends Thread{
|
private class DismissThread extends Thread {
|
||||||
private boolean valid = true;
|
private boolean valid = true;
|
||||||
|
|
||||||
public synchronized void invalidate(){
|
public synchronized void invalidate() {
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +128,7 @@ public class AcceptActivity extends ViewSelectorActivity {
|
||||||
public void run() {
|
public void run() {
|
||||||
SystemClock.sleep(60 * 1000);
|
SystemClock.sleep(60 * 1000);
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if(valid) {
|
if (valid) {
|
||||||
AcceptActivity.this.finish();
|
AcceptActivity.this.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,11 +138,11 @@ public class AcceptActivity extends ViewSelectorActivity {
|
||||||
@Override
|
@Override
|
||||||
protected synchronized void onNewIntent(Intent intent) {
|
protected synchronized void onNewIntent(Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
if(dismissThread != null) dismissThread.invalidate();
|
if (dismissThread != null) dismissThread.invalidate();
|
||||||
Bundle extras = intent.getExtras();
|
Bundle extras = intent.getExtras();
|
||||||
Intent msgIntent = new Intent(this, AcceptActivity.class);
|
Intent msgIntent = new Intent(this, AcceptActivity.class);
|
||||||
msgIntent.putExtras(extras);
|
msgIntent.putExtras(extras);
|
||||||
startActivity(msgIntent);
|
startActivity(msgIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
package info.nightscout.androidaps.interaction.actions;
|
package info.nightscout.androidaps.interaction.actions;
|
||||||
|
|
||||||
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.wearable.view.DotsPageIndicator;
|
|
||||||
import android.support.wearable.view.GridPagerAdapter;
|
import android.support.wearable.view.GridPagerAdapter;
|
||||||
import android.support.wearable.view.GridViewPager;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
@ -23,7 +18,6 @@ import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||||
* Created by adrian on 09/02/17.
|
* Created by adrian on 09/02/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public class BolusActivity extends ViewSelectorActivity {
|
public class BolusActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
PlusMinusEditText editCarbs;
|
PlusMinusEditText editCarbs;
|
||||||
|
@ -32,32 +26,7 @@ public class BolusActivity extends ViewSelectorActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.grid_layout);
|
setAdapter(new MyGridViewPagerAdapter());
|
||||||
|
|
||||||
final TextView title = findViewById(R.id.title);
|
|
||||||
title.setText(getString(R.string.menu_bolus));
|
|
||||||
|
|
||||||
final GridViewPager pager = findViewById(R.id.pager);
|
|
||||||
pager.setAdapter(new MyGridViewPagerAdapter());
|
|
||||||
DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator);
|
|
||||||
dotsPageIndicator.setPager(pager);
|
|
||||||
pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) {
|
|
||||||
dotsPageIndicator.onPageScrolled(row, column, rowOffset, columnOffset, rowOffsetPixels,
|
|
||||||
columnOffsetPixels);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int row, int column) {
|
|
||||||
dotsPageIndicator.onPageSelected(row, column);
|
|
||||||
View view = pager.getChildAt(column);
|
|
||||||
view.requestFocus();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int state) {
|
|
||||||
dotsPageIndicator.onPageScrollStateChanged(state);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -109,10 +78,8 @@ public class BolusActivity extends ViewSelectorActivity {
|
||||||
confirmbutton.setOnClickListener(new View.OnClickListener() {
|
confirmbutton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
//check if it can happen that the fagment is never created that hold data?
|
//check if it can happen that the fagment is never created that hold data?
|
||||||
// (you have to swipe past them anyways - but still)
|
// (you have to swipe past them anyways - but still)
|
||||||
|
|
||||||
String actionstring = "bolus " + SafeParse.stringToDouble(editInsulin.editText.getText().toString())
|
String actionstring = "bolus " + SafeParse.stringToDouble(editInsulin.editText.getText().toString())
|
||||||
+ " " + SafeParse.stringToInt(editCarbs.editText.getText().toString());
|
+ " " + SafeParse.stringToInt(editCarbs.editText.getText().toString());
|
||||||
ListenerService.initiateAction(BolusActivity.this, actionstring);
|
ListenerService.initiateAction(BolusActivity.this, actionstring);
|
||||||
|
@ -136,6 +103,5 @@ public class BolusActivity extends ViewSelectorActivity {
|
||||||
return view == object;
|
return view == object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
package info.nightscout.androidaps.interaction.actions;
|
package info.nightscout.androidaps.interaction.actions;
|
||||||
|
|
||||||
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.wearable.view.DotsPageIndicator;
|
|
||||||
import android.support.wearable.view.GridPagerAdapter;
|
import android.support.wearable.view.GridPagerAdapter;
|
||||||
import android.support.wearable.view.GridViewPager;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
@ -23,7 +18,6 @@ import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||||
* Created by adrian on 09/02/17.
|
* Created by adrian on 09/02/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public class CPPActivity extends ViewSelectorActivity {
|
public class CPPActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
PlusMinusEditText editPercentage;
|
PlusMinusEditText editPercentage;
|
||||||
|
@ -47,42 +41,15 @@ public class CPPActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
if (timeshift < 0) timeshift += 24;
|
if (timeshift < 0) timeshift += 24;
|
||||||
|
|
||||||
setContentView(R.layout.grid_layout);
|
setAdapter(new MyGridViewPagerAdapter());
|
||||||
|
|
||||||
final TextView title = findViewById(R.id.title);
|
|
||||||
title.setText(getString(R.string.status_cpp));
|
|
||||||
|
|
||||||
final GridViewPager pager = findViewById(R.id.pager);
|
|
||||||
pager.setAdapter(new MyGridViewPagerAdapter());
|
|
||||||
DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator);
|
|
||||||
dotsPageIndicator.setPager(pager);
|
|
||||||
pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) {
|
|
||||||
dotsPageIndicator.onPageScrolled(row, column, rowOffset, columnOffset, rowOffsetPixels,
|
|
||||||
columnOffsetPixels);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int row, int column) {
|
|
||||||
dotsPageIndicator.onPageSelected(row, column);
|
|
||||||
View view = pager.getChildAt(column);
|
|
||||||
view.requestFocus();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int state) {
|
|
||||||
dotsPageIndicator.onPageScrollStateChanged(state);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount(int arg0) {
|
public int getColumnCount(int arg0) {
|
||||||
|
@ -152,6 +119,5 @@ public class CPPActivity extends ViewSelectorActivity {
|
||||||
return view == object;
|
return view == object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
package info.nightscout.androidaps.interaction.actions;
|
package info.nightscout.androidaps.interaction.actions;
|
||||||
|
|
||||||
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.wearable.view.DotsPageIndicator;
|
|
||||||
import android.support.wearable.view.GridPagerAdapter;
|
import android.support.wearable.view.GridPagerAdapter;
|
||||||
import android.support.wearable.view.GridViewPager;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
@ -23,53 +18,24 @@ import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||||
* Created by adrian on 04/08/18.
|
* Created by adrian on 04/08/18.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public class ECarbActivity extends ViewSelectorActivity {
|
public class ECarbActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
PlusMinusEditText editCarbs;
|
PlusMinusEditText editCarbs;
|
||||||
PlusMinusEditText editStartTime;
|
PlusMinusEditText editStartTime;
|
||||||
PlusMinusEditText editDuration;
|
PlusMinusEditText editDuration;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.grid_layout);
|
setAdapter(new MyGridViewPagerAdapter());
|
||||||
|
|
||||||
final TextView title = findViewById(R.id.title);
|
|
||||||
title.setText(getString(R.string.menu_ecarb));
|
|
||||||
|
|
||||||
final GridViewPager pager = findViewById(R.id.pager);
|
|
||||||
pager.setAdapter(new MyGridViewPagerAdapter());
|
|
||||||
DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator);
|
|
||||||
dotsPageIndicator.setPager(pager);
|
|
||||||
pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) {
|
|
||||||
dotsPageIndicator.onPageScrolled(row, column, rowOffset, columnOffset, rowOffsetPixels,
|
|
||||||
columnOffsetPixels);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int row, int column) {
|
|
||||||
dotsPageIndicator.onPageSelected(row, column);
|
|
||||||
View view = pager.getChildAt(column);
|
|
||||||
view.requestFocus();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int state) {
|
|
||||||
dotsPageIndicator.onPageScrollStateChanged(state);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount(int arg0) {
|
public int getColumnCount(int arg0) {
|
||||||
|
@ -84,10 +50,10 @@ public class ECarbActivity extends ViewSelectorActivity {
|
||||||
@Override
|
@Override
|
||||||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||||
|
|
||||||
if(col == 0){
|
if (col == 0) {
|
||||||
final View view = getInflatedPlusMinusView(container);
|
final View view = getInflatedPlusMinusView(container);
|
||||||
double def = 0;
|
double def = 0;
|
||||||
if (editCarbs != null){
|
if (editCarbs != null) {
|
||||||
def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
|
def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
|
||||||
}
|
}
|
||||||
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), true);
|
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), true);
|
||||||
|
@ -95,20 +61,20 @@ public class ECarbActivity extends ViewSelectorActivity {
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
view.requestFocus();
|
view.requestFocus();
|
||||||
return view;
|
return view;
|
||||||
} else if(col == 1){
|
} else if (col == 1) {
|
||||||
final View view = getInflatedPlusMinusView(container);
|
final View view = getInflatedPlusMinusView(container);
|
||||||
double def = 0;
|
double def = 0;
|
||||||
if (editStartTime != null){
|
if (editStartTime != null) {
|
||||||
def = SafeParse.stringToDouble(editStartTime.editText.getText().toString());
|
def = SafeParse.stringToDouble(editStartTime.editText.getText().toString());
|
||||||
}
|
}
|
||||||
editStartTime = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 300d, 15d, new DecimalFormat("0"), false);
|
editStartTime = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 300d, 15d, new DecimalFormat("0"), false);
|
||||||
setLabelToPlusMinusView(view, getString(R.string.action_start_min));
|
setLabelToPlusMinusView(view, getString(R.string.action_start_min));
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
return view;
|
return view;
|
||||||
} else if(col == 2){
|
} else if (col == 2) {
|
||||||
final View view = getInflatedPlusMinusView(container);
|
final View view = getInflatedPlusMinusView(container);
|
||||||
double def = 0;
|
double def = 0;
|
||||||
if (editDuration != null){
|
if (editDuration != null) {
|
||||||
def = SafeParse.stringToDouble(editDuration.editText.getText().toString());
|
def = SafeParse.stringToDouble(editDuration.editText.getText().toString());
|
||||||
}
|
}
|
||||||
editDuration = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 8d, 1d, new DecimalFormat("0"), false);
|
editDuration = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 8d, 1d, new DecimalFormat("0"), false);
|
||||||
|
@ -126,7 +92,7 @@ public class ECarbActivity extends ViewSelectorActivity {
|
||||||
//check if it can happen that the fagment is never created that hold data?
|
//check if it can happen that the fagment is never created that hold data?
|
||||||
// (you have to swipe past them anyways - but still)
|
// (you have to swipe past them anyways - but still)
|
||||||
|
|
||||||
String actionstring = "ecarbs " +SafeParse.stringToInt(editCarbs.editText.getText().toString())
|
String actionstring = "ecarbs " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
|
||||||
+ " " + SafeParse.stringToInt(editStartTime.editText.getText().toString())
|
+ " " + SafeParse.stringToInt(editStartTime.editText.getText().toString())
|
||||||
+ " " + SafeParse.stringToInt(editDuration.editText.getText().toString());
|
+ " " + SafeParse.stringToInt(editDuration.editText.getText().toString());
|
||||||
ListenerService.initiateAction(ECarbActivity.this, actionstring);
|
ListenerService.initiateAction(ECarbActivity.this, actionstring);
|
||||||
|
@ -142,14 +108,13 @@ public class ECarbActivity extends ViewSelectorActivity {
|
||||||
public void destroyItem(ViewGroup container, int row, int col, Object view) {
|
public void destroyItem(ViewGroup container, int row, int col, Object view) {
|
||||||
// Handle this to get the data before the view is destroyed?
|
// Handle this to get the data before the view is destroyed?
|
||||||
// Object should still be kept by this, just setup for reinit?
|
// Object should still be kept by this, just setup for reinit?
|
||||||
container.removeView((View)view);
|
container.removeView((View) view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isViewFromObject(View view, Object object) {
|
public boolean isViewFromObject(View view, Object object) {
|
||||||
return view==object;
|
return view == object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
package info.nightscout.androidaps.interaction.actions;
|
package info.nightscout.androidaps.interaction.actions;
|
||||||
|
|
||||||
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.wearable.view.DotsPageIndicator;
|
|
||||||
import android.support.wearable.view.GridPagerAdapter;
|
import android.support.wearable.view.GridPagerAdapter;
|
||||||
import android.support.wearable.view.GridViewPager;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
@ -23,7 +18,6 @@ import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||||
* Created by adrian on 09/02/17.
|
* Created by adrian on 09/02/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public class FillActivity extends ViewSelectorActivity {
|
public class FillActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
PlusMinusEditText editInsulin;
|
PlusMinusEditText editInsulin;
|
||||||
|
@ -31,25 +25,15 @@ public class FillActivity extends ViewSelectorActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.grid_layout);
|
setAdapter(new MyGridViewPagerAdapter());
|
||||||
|
|
||||||
final TextView title = findViewById(R.id.title);
|
|
||||||
title.setText(getString(R.string.menu_prime_fill));
|
|
||||||
|
|
||||||
final GridViewPager pager = findViewById(R.id.pager);
|
|
||||||
pager.setAdapter(new MyGridViewPagerAdapter());
|
|
||||||
DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator);
|
|
||||||
dotsPageIndicator.setPager(pager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount(int arg0) {
|
public int getColumnCount(int arg0) {
|
||||||
|
@ -108,6 +92,5 @@ public class FillActivity extends ViewSelectorActivity {
|
||||||
return view == object;
|
return view == object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
package info.nightscout.androidaps.interaction.actions;
|
package info.nightscout.androidaps.interaction.actions;
|
||||||
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.wearable.view.DotsPageIndicator;
|
|
||||||
import android.support.wearable.view.GridPagerAdapter;
|
import android.support.wearable.view.GridPagerAdapter;
|
||||||
import android.support.wearable.view.GridViewPager;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -25,7 +21,6 @@ import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||||
* Created by adrian on 09/02/17.
|
* Created by adrian on 09/02/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public class TempTargetActivity extends ViewSelectorActivity {
|
public class TempTargetActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
PlusMinusEditText lowRange;
|
PlusMinusEditText lowRange;
|
||||||
|
@ -37,46 +32,19 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.grid_layout);
|
setAdapter(new MyGridViewPagerAdapter());
|
||||||
|
|
||||||
final TextView title = findViewById(R.id.title);
|
|
||||||
title.setText(getString(R.string.menu_tempt));
|
|
||||||
|
|
||||||
final GridViewPager pager = findViewById(R.id.pager);
|
|
||||||
pager.setAdapter(new MyGridViewPagerAdapter());
|
|
||||||
DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator);
|
|
||||||
dotsPageIndicator.setPager(pager);
|
|
||||||
|
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
isMGDL = sp.getBoolean("units_mgdl", true);
|
isMGDL = sp.getBoolean("units_mgdl", true);
|
||||||
isSingleTarget = sp.getBoolean("singletarget", true);
|
isSingleTarget = sp.getBoolean("singletarget", true);
|
||||||
pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) {
|
|
||||||
dotsPageIndicator.onPageScrolled(row, column, rowOffset, columnOffset, rowOffsetPixels,
|
|
||||||
columnOffsetPixels);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int row, int column) {
|
|
||||||
dotsPageIndicator.onPageSelected(row, column);
|
|
||||||
View view = pager.getChildAt(column);
|
|
||||||
view.requestFocus();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int state) {
|
|
||||||
dotsPageIndicator.onPageScrollStateChanged(state);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount(int arg0) {
|
public int getColumnCount(int arg0) {
|
||||||
|
@ -184,6 +152,5 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
||||||
return view == object;
|
return view == object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,26 +2,83 @@ package info.nightscout.androidaps.interaction.actions;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
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.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.wear.widget.CurvedTextView;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by adrian on 13/02/17.
|
* Created by adrian on 13/02/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ViewSelectorActivity extends Activity {
|
public class ViewSelectorActivity extends Activity {
|
||||||
|
|
||||||
|
private GridViewPager pager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.grid_layout);
|
||||||
|
|
||||||
|
setTitleBasedOnScreenShape(String.valueOf(getTitle()));
|
||||||
|
|
||||||
|
pager = findViewById(R.id.pager);
|
||||||
|
DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator);
|
||||||
|
dotsPageIndicator.setPager(pager);
|
||||||
|
pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) {
|
||||||
|
dotsPageIndicator.onPageScrolled(row, column, rowOffset, columnOffset, rowOffsetPixels,
|
||||||
|
columnOffsetPixels);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int row, int column) {
|
||||||
|
dotsPageIndicator.onPageSelected(row, column);
|
||||||
|
View view = pager.getChildAt(column);
|
||||||
|
view.requestFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
dotsPageIndicator.onPageScrollStateChanged(state);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdapter(GridPagerAdapter adapter) {
|
||||||
|
pager.setAdapter(adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTitleBasedOnScreenShape(String title) {
|
||||||
|
CurvedTextView titleViewCurved = findViewById(R.id.title_curved);
|
||||||
|
TextView titleView = findViewById(R.id.title);
|
||||||
|
if (this.getResources().getConfiguration().isScreenRound()) {
|
||||||
|
titleViewCurved.setText(title);
|
||||||
|
titleViewCurved.setVisibility(View.VISIBLE);
|
||||||
|
titleView.setVisibility((View.GONE));
|
||||||
|
} else {
|
||||||
|
titleView.setText(title);
|
||||||
|
titleView.setVisibility(View.VISIBLE);
|
||||||
|
titleViewCurved.setVisibility((View.GONE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
View getInflatedPlusMinusView(ViewGroup container) {
|
View getInflatedPlusMinusView(ViewGroup container) {
|
||||||
SharedPreferences sharedPrefs = PreferenceManager
|
SharedPreferences sharedPrefs = PreferenceManager
|
||||||
.getDefaultSharedPreferences(this);
|
.getDefaultSharedPreferences(this);
|
||||||
int design = Integer.parseInt(sharedPrefs.getString("input_design", "1"));
|
int design = Integer.parseInt(sharedPrefs.getString("input_design", "1"));
|
||||||
|
|
||||||
if (design == 2){
|
if (design == 2) {
|
||||||
return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item_quickrighty, container, false);
|
return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item_quickrighty, container, false);
|
||||||
} else if (design == 3) {
|
} else if (design == 3) {
|
||||||
return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item_quicklefty, container, false);
|
return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item_quicklefty, container, false);
|
||||||
|
@ -33,12 +90,12 @@ public class ViewSelectorActivity extends Activity {
|
||||||
return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLabelToPlusMinusView(View view, String labelText){
|
void setLabelToPlusMinusView(View view, String labelText) {
|
||||||
SharedPreferences sharedPrefs = PreferenceManager
|
SharedPreferences sharedPrefs = PreferenceManager
|
||||||
.getDefaultSharedPreferences(this);
|
.getDefaultSharedPreferences(this);
|
||||||
int design = Integer.parseInt(sharedPrefs.getString("input_design", "1"));
|
int design = Integer.parseInt(sharedPrefs.getString("input_design", "1"));
|
||||||
|
|
||||||
if (design == 4){
|
if (design == 4) {
|
||||||
//@LadyViktoria: Here the label can be set differently, if you like.
|
//@LadyViktoria: Here the label can be set differently, if you like.
|
||||||
final TextView textView = view.findViewById(R.id.label);
|
final TextView textView = view.findViewById(R.id.label);
|
||||||
textView.setText(labelText);
|
textView.setText(labelText);
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
package info.nightscout.androidaps.interaction.actions;
|
package info.nightscout.androidaps.interaction.actions;
|
||||||
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.wearable.view.DotsPageIndicator;
|
|
||||||
import android.support.wearable.view.GridPagerAdapter;
|
import android.support.wearable.view.GridPagerAdapter;
|
||||||
import android.support.wearable.view.GridViewPager;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
@ -25,7 +20,6 @@ import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||||
* Created by adrian on 09/02/17.
|
* Created by adrian on 09/02/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public class WizardActivity extends ViewSelectorActivity {
|
public class WizardActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
PlusMinusEditText editCarbs;
|
PlusMinusEditText editCarbs;
|
||||||
|
@ -33,48 +27,20 @@ public class WizardActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
boolean hasPercentage;
|
boolean hasPercentage;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.grid_layout);
|
setAdapter(new MyGridViewPagerAdapter());
|
||||||
|
|
||||||
final TextView title = findViewById(R.id.title);
|
|
||||||
title.setText(getString(R.string.menu_wizard));
|
|
||||||
|
|
||||||
final GridViewPager pager = findViewById(R.id.pager);
|
|
||||||
pager.setAdapter(new MyGridViewPagerAdapter());
|
|
||||||
DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator);
|
|
||||||
dotsPageIndicator.setPager(pager);
|
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
hasPercentage = sp.getBoolean("wizardpercentage", false);
|
hasPercentage = sp.getBoolean("wizardpercentage", false);
|
||||||
pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) {
|
|
||||||
dotsPageIndicator.onPageScrolled(row, column, rowOffset, columnOffset, rowOffsetPixels,
|
|
||||||
columnOffsetPixels);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int row, int column) {
|
|
||||||
dotsPageIndicator.onPageSelected(row, column);
|
|
||||||
View view = pager.getChildAt(column);
|
|
||||||
view.requestFocus();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int state) {
|
|
||||||
dotsPageIndicator.onPageScrollStateChanged(state);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount(int arg0) {
|
public int getColumnCount(int arg0) {
|
||||||
|
@ -96,7 +62,6 @@ public class WizardActivity extends ViewSelectorActivity {
|
||||||
} else {
|
} else {
|
||||||
double def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
|
double def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
|
||||||
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), false);
|
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), false);
|
||||||
|
|
||||||
}
|
}
|
||||||
setLabelToPlusMinusView(view, getString(R.string.action_carbs));
|
setLabelToPlusMinusView(view, getString(R.string.action_carbs));
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
|
@ -152,6 +117,5 @@ public class WizardActivity extends ViewSelectorActivity {
|
||||||
return view == object;
|
return view == object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@ public class MainMenuActivity extends MenuListActivity {
|
||||||
return menuItems;
|
return menuItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean showPrimeFill = sp.getBoolean("primefill", false);
|
boolean showPrimeFill = sp.getBoolean("primefill", false);
|
||||||
boolean showWizard = sp.getBoolean("showWizard", true);
|
boolean showWizard = sp.getBoolean("showWizard", true);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.wear.widget.CurvedTextView;
|
||||||
import androidx.wear.widget.WearableLinearLayoutManager;
|
import androidx.wear.widget.WearableLinearLayoutManager;
|
||||||
import androidx.wear.widget.WearableRecyclerView;
|
import androidx.wear.widget.WearableRecyclerView;
|
||||||
|
|
||||||
|
@ -23,10 +24,12 @@ import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
public abstract class MenuListActivity extends Activity {
|
public abstract class MenuListActivity extends Activity {
|
||||||
List<MenuItem> elements;
|
List<MenuItem> elements;
|
||||||
|
|
||||||
protected abstract List<MenuItem> getElements();
|
protected abstract List<MenuItem> getElements();
|
||||||
|
|
||||||
protected abstract void doAction(String position);
|
protected abstract void doAction(String position);
|
||||||
|
|
||||||
public interface AdapterCallback{
|
public interface AdapterCallback {
|
||||||
void onItemClicked(MenuAdapter.ItemViewHolder v);
|
void onItemClicked(MenuAdapter.ItemViewHolder v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,18 +37,22 @@ public abstract class MenuListActivity extends Activity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.actions_list_activity);
|
setContentView(R.layout.actions_list_activity);
|
||||||
TextView titleView = findViewById(R.id.title);
|
setTitleBasedOnScreenShape(String.valueOf(getTitle()));
|
||||||
titleView.setText(getTitle());
|
|
||||||
|
|
||||||
elements = getElements();
|
elements = getElements();
|
||||||
CustomScrollingLayoutCallback customScrollingLayoutCallback = new CustomScrollingLayoutCallback();
|
CustomScrollingLayoutCallback customScrollingLayoutCallback = new CustomScrollingLayoutCallback();
|
||||||
WearableLinearLayoutManager layoutManager = new WearableLinearLayoutManager(this);
|
WearableLinearLayoutManager layoutManager = new WearableLinearLayoutManager(this);
|
||||||
if (this.getResources().getConfiguration().isScreenRound()) {
|
|
||||||
layoutManager.setLayoutCallback(customScrollingLayoutCallback);
|
|
||||||
}
|
|
||||||
WearableRecyclerView listView = findViewById(R.id.action_list);
|
WearableRecyclerView listView = findViewById(R.id.action_list);
|
||||||
|
boolean isScreenRound = this.getResources().getConfiguration().isScreenRound();
|
||||||
|
if (isScreenRound) {
|
||||||
|
layoutManager.setLayoutCallback(customScrollingLayoutCallback);
|
||||||
|
listView.setEdgeItemsCenteringEnabled(true);
|
||||||
|
} else {
|
||||||
|
// Bug in androidx.wear:wear:1.2.0
|
||||||
|
// WearableRecyclerView setEdgeItemsCenteringEnabled requires fix for square screen
|
||||||
|
listView.setPadding(0, 50, 0, 0);
|
||||||
|
}
|
||||||
listView.setHasFixedSize(true);
|
listView.setHasFixedSize(true);
|
||||||
listView.setEdgeItemsCenteringEnabled(true);
|
|
||||||
listView.setLayoutManager(layoutManager);
|
listView.setLayoutManager(layoutManager);
|
||||||
listView.setAdapter(new MenuAdapter(elements, v -> {
|
listView.setAdapter(new MenuAdapter(elements, v -> {
|
||||||
String tag = (String) v.itemView.getTag();
|
String tag = (String) v.itemView.getTag();
|
||||||
|
@ -53,16 +60,30 @@ public abstract class MenuListActivity extends Activity {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MenuAdapter extends RecyclerView.Adapter<MenuAdapter.ItemViewHolder> {
|
private void setTitleBasedOnScreenShape(String title) {
|
||||||
|
CurvedTextView titleViewCurved = findViewById(R.id.title_curved);
|
||||||
|
TextView titleView = findViewById(R.id.title);
|
||||||
|
if (this.getResources().getConfiguration().isScreenRound()) {
|
||||||
|
titleViewCurved.setText(title);
|
||||||
|
titleViewCurved.setVisibility(View.VISIBLE);
|
||||||
|
titleView.setVisibility((View.GONE));
|
||||||
|
} else {
|
||||||
|
titleView.setText(title);
|
||||||
|
titleView.setVisibility(View.VISIBLE);
|
||||||
|
titleViewCurved.setVisibility((View.GONE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class MenuAdapter extends RecyclerView.Adapter<MenuAdapter.ItemViewHolder> {
|
||||||
private final List<MenuItem> mDataset;
|
private final List<MenuItem> mDataset;
|
||||||
private AdapterCallback callback;
|
private final AdapterCallback callback;
|
||||||
|
|
||||||
public MenuAdapter(List<MenuItem> dataset, AdapterCallback callback) {
|
public MenuAdapter(List<MenuItem> dataset, AdapterCallback callback) {
|
||||||
mDataset = dataset;
|
mDataset = dataset;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ItemViewHolder extends RecyclerView.ViewHolder {
|
public static class ItemViewHolder extends RecyclerView.ViewHolder {
|
||||||
protected final RelativeLayout menuContainer;
|
protected final RelativeLayout menuContainer;
|
||||||
protected final TextView actionItem;
|
protected final TextView actionItem;
|
||||||
protected final ImageView actionIcon;
|
protected final ImageView actionIcon;
|
||||||
|
@ -78,9 +99,8 @@ public abstract class MenuListActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
|
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
|
||||||
ItemViewHolder recyclerViewHolder = new ItemViewHolder(view);
|
|
||||||
|
|
||||||
return recyclerViewHolder;
|
return new ItemViewHolder(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -89,9 +109,7 @@ public abstract class MenuListActivity extends Activity {
|
||||||
holder.actionItem.setText(item.actionItem);
|
holder.actionItem.setText(item.actionItem);
|
||||||
holder.actionIcon.setImageResource(item.actionIcon);
|
holder.actionIcon.setImageResource(item.actionIcon);
|
||||||
holder.itemView.setTag(item.actionItem);
|
holder.itemView.setTag(item.actionItem);
|
||||||
holder.menuContainer.setOnClickListener(v -> {
|
holder.menuContainer.setOnClickListener(v -> callback.onItemClicked(holder));
|
||||||
callback.onItemClicked(holder);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,19 +118,19 @@ public abstract class MenuListActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class MenuItem {
|
protected static class MenuItem {
|
||||||
public MenuItem(int actionIcon, String actionItem) {
|
public MenuItem(int actionIcon, String actionItem) {
|
||||||
this.actionIcon = actionIcon;
|
this.actionIcon = actionIcon;
|
||||||
this.actionItem = actionItem;
|
this.actionItem = actionItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int actionIcon;
|
public int actionIcon;
|
||||||
public String actionItem;
|
public String actionItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CustomScrollingLayoutCallback extends WearableLinearLayoutManager.LayoutCallback {
|
public static class CustomScrollingLayoutCallback extends WearableLinearLayoutManager.LayoutCallback {
|
||||||
// How much should we scale the icon at most.
|
// How much should we scale the icon at most.
|
||||||
private static final float MAX_ICON_PROGRESS = 0.65f;
|
private static final float MAX_ICON_PROGRESS = 0.65f;
|
||||||
private float progressToCenter;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLayoutFinished(View child, RecyclerView parent) {
|
public void onLayoutFinished(View child, RecyclerView parent) {
|
||||||
|
@ -121,7 +139,7 @@ public abstract class MenuListActivity extends Activity {
|
||||||
float yRelativeToCenterOffset = (child.getY() / parent.getHeight()) + centerOffset;
|
float yRelativeToCenterOffset = (child.getY() / parent.getHeight()) + centerOffset;
|
||||||
|
|
||||||
// Normalize for center
|
// Normalize for center
|
||||||
progressToCenter = Math.abs(0.5f - yRelativeToCenterOffset);
|
float progressToCenter = Math.abs(0.5f - yRelativeToCenterOffset);
|
||||||
// Adjust to the maximum scale
|
// Adjust to the maximum scale
|
||||||
progressToCenter = Math.min(progressToCenter, MAX_ICON_PROGRESS);
|
progressToCenter = Math.min(progressToCenter, MAX_ICON_PROGRESS);
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/menu_container"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/menu_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="8dp"
|
android:background="@drawable/menu_item_layout_bg"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
android:background="@drawable/menu_item_layout_bg">
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/menuItemIcon"
|
android:id="@+id/menuItemIcon"
|
||||||
|
@ -25,13 +25,13 @@
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_toEndOf="@+id/menuItemIcon"
|
android:layout_toEndOf="@+id/menuItemIcon"
|
||||||
android:layout_toRightOf="@+id/menuItemIcon"
|
android:layout_toRightOf="@+id/menuItemIcon"
|
||||||
|
android:autoSizeMaxTextSize="32sp"
|
||||||
|
android:autoSizeMinTextSize="12sp"
|
||||||
|
android:autoSizeStepGranularity="2sp"
|
||||||
|
android:autoSizeTextType="uniform"
|
||||||
android:text="action item"
|
android:text="action item"
|
||||||
android:textColor="@color/dark_statusView"
|
android:textColor="@color/dark_statusView"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:autoSizeTextType="uniform"
|
|
||||||
android:autoSizeMinTextSize="12sp"
|
|
||||||
android:autoSizeMaxTextSize="32sp"
|
|
||||||
android:autoSizeStepGranularity="2sp"
|
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -1,27 +1,41 @@
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" >
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<androidx.wear.widget.WearableRecyclerView
|
<androidx.wear.widget.WearableRecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/action_list"
|
android:id="@+id/action_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scrollbars="vertical" >
|
android:scrollbars="vertical">
|
||||||
|
|
||||||
<requestFocus />
|
<requestFocus />
|
||||||
|
|
||||||
</androidx.wear.widget.WearableRecyclerView>
|
</androidx.wear.widget.WearableRecyclerView>
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="26dp"
|
android:layout_height="28dp"
|
||||||
android:gravity="center"
|
android:background="@color/titleHeader">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="26dp"
|
||||||
|
android:autoSizeMaxTextSize="18sp"
|
||||||
|
android:autoSizeMinTextSize="12sp"
|
||||||
|
android:autoSizeTextType="uniform"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Title"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.wear.widget.CurvedTextView
|
||||||
|
android:id="@+id/title_curved"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:text="Title"
|
android:text="Title"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:autoSizeTextType="uniform"
|
android:visibility="gone" />
|
||||||
android:autoSizeMinTextSize="12sp"
|
|
||||||
android:autoSizeMaxTextSize="18sp"
|
|
||||||
android:background="#D9000000"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
@ -1,14 +1,26 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" >
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.wear.widget.CurvedTextView
|
||||||
|
android:id="@+id/title_curved"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Title"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="26dp"
|
android:layout_height="26dp"
|
||||||
|
android:autoSizeMaxTextSize="18sp"
|
||||||
|
android:autoSizeMinTextSize="12sp"
|
||||||
|
android:autoSizeTextType="uniform"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="18sp"/>
|
android:text="Title"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
<android.support.wearable.view.GridViewPager
|
<android.support.wearable.view.GridViewPager
|
||||||
android:id="@+id/pager"
|
android:id="@+id/pager"
|
||||||
|
@ -20,7 +32,6 @@
|
||||||
android:id="@+id/page_indicator"
|
android:id="@+id/page_indicator"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal|bottom">
|
android:layout_gravity="center_horizontal|bottom" />
|
||||||
</android.support.wearable.view.DotsPageIndicator>
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/menu_container"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/menu_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="8dp"
|
android:background="@drawable/menu_item_layout_bg"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
android:background="@drawable/menu_item_layout_bg">
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/menuItemIcon"
|
android:id="@+id/menuItemIcon"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<color name="cardObjectiveText">#779ECB</color>
|
<color name="cardObjectiveText">#779ECB</color>
|
||||||
|
<color name="titleHeader">#D9000000</color>
|
||||||
|
|
||||||
|
|
||||||
<!-- light colors -->
|
<!-- light colors -->
|
||||||
|
|
Loading…
Reference in a new issue