Search in sources :

Example 1 with WatchViewStub

use of android.support.wearable.view.WatchViewStub in project xDrip by NightscoutFoundation.

the class BaseWatchFace method performViewSetup.

public void performViewSetup() {
    final WatchViewStub stub = (WatchViewStub) layoutView.findViewById(R.id.watch_view_stub);
    IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);
    messageReceiver = new MessageReceiver();
    localBroadcastManager = LocalBroadcastManager.getInstance(this);
    localBroadcastManager.registerReceiver(messageReceiver, messageFilter);
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {

        @Override
        public void onLayoutInflated(WatchViewStub stub) {
            mTime = (TextView) stub.findViewById(R.id.watch_time);
            mDate = (TextView) stub.findViewById(R.id.watch_date);
            mSgv = (TextView) stub.findViewById(R.id.sgv);
            mDirection = (TextView) stub.findViewById(R.id.direction);
            mTimestamp = (TextView) stub.findViewById(R.id.timestamp);
            mStatus = (TextView) stub.findViewById(R.id.externaltstatus);
            mRaw = (TextView) stub.findViewById(R.id.raw);
            mUploaderBattery = (TextView) stub.findViewById(R.id.uploader_battery);
            mUploaderXBattery = (TextView) stub.findViewById(R.id.uploader_xbattery);
            mDelta = (TextView) stub.findViewById(R.id.delta);
            stepsButton = (Button) stub.findViewById(R.id.walkButton);
            try {
                heartButton = (Button) stub.findViewById(R.id.heartButton);
            } catch (Exception e) {
            // 
            }
            mStepsLinearLayout = (LinearLayout) stub.findViewById(R.id.steps_layout);
            menuButton = (Button) stub.findViewById(R.id.menuButton);
            mMenuLinearLayout = (LinearLayout) stub.findViewById(R.id.menu_layout);
            mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout);
            mLinearLayout = (LinearLayout) stub.findViewById(R.id.secondary_layout);
            mDirectionDelta = (LinearLayout) stub.findViewById(R.id.directiondelta_layout);
            setSmallFontsize(false);
            chart = (LineChartView) stub.findViewById(R.id.chart);
            layoutSet = true;
            Context context = xdrip.getAppContext();
            if (Home.get_forced_wear()) {
                if (d)
                    Log.d(TAG, "performViewSetup FORCE WEAR init BGs for graph");
                BgSendQueue.resendData(context);
            }
            if ((chart != null) && sharedPrefs.getBoolean("show_wear_treatments", false)) {
                if (d)
                    Log.d(TAG, "performViewSetup init Treatments for graph");
                ListenerService.showTreatments(context, "all");
            }
            showAgoRawBattStatus();
            mRelativeLayout.measure(specW, specH);
            mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(), mRelativeLayout.getMeasuredHeight());
            showSteps();
            showHeartRate();
        }
    });
    Log.d(TAG, "performViewSetup requestData");
    ListenerService.requestData(this);
    wakeLock.acquire(50);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Button(android.widget.Button) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) LineChartView(lecho.lib.hellocharts.view.LineChartView) WatchViewStub(android.support.wearable.view.WatchViewStub) LinearLayout(android.widget.LinearLayout)

Example 2 with WatchViewStub

use of android.support.wearable.view.WatchViewStub in project xDrip by NightscoutFoundation.

the class KeypadInputActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {

        @Override
        public void onLayoutInflated(WatchViewStub stub) {
            mDialTextView = (TextView) stub.findViewById(R.id.dialed_no_textview);
            zeroButton = (Button) stub.findViewById(R.id.zero_button);
            oneButton = (Button) stub.findViewById(R.id.one_button);
            twoButton = (Button) stub.findViewById(R.id.two_button);
            threeButton = (Button) stub.findViewById(R.id.three_button);
            fourButton = (Button) stub.findViewById(R.id.four_button);
            fiveButton = (Button) stub.findViewById(R.id.five_button);
            sixButton = (Button) stub.findViewById(R.id.six_button);
            sevenButton = (Button) stub.findViewById(R.id.seven_button);
            eightButton = (Button) stub.findViewById(R.id.eight_button);
            nineButton = (Button) stub.findViewById(R.id.nine_button);
            starButton = (Button) stub.findViewById(R.id.star_button);
            backSpaceButton = (Button) stub.findViewById(R.id.backspace_button);
            // callImageButton = (ImageButton) stub.findViewById(R.id.call_image_button);
            // backspaceImageButton = (ImageButton) stub.findViewById(R.id.backspace_image_button);
            insulintabbutton = (ImageButton) stub.findViewById(R.id.insulintabbutton);
            bloodtesttabbutton = (ImageButton) stub.findViewById(R.id.bloodtesttabbutton);
            timetabbutton = (ImageButton) stub.findViewById(R.id.timetabbutton);
            carbstabbutton = (ImageButton) stub.findViewById(R.id.carbstabbutton);
            mDialTextView.setText("");
            mDialTextView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    submitAll();
                }
            });
            zeroButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    appCurrent("0");
                }
            });
            // zeroButton.setOnLongClickListener(new View.OnLongClickListener() {
            // @Override
            // public boolean onLongClick(View v) {
            // mDialTextView.setText(mDialTextView.getText() + "+");
            // return true;
            // }
            // });
            oneButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    appCurrent("1");
                }
            });
            twoButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    appCurrent("2");
                }
            });
            threeButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    appCurrent("3");
                }
            });
            fourButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    appCurrent("4");
                }
            });
            fiveButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    appCurrent("5");
                }
            });
            sixButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    appCurrent("6");
                }
            });
            sevenButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    appCurrent("7");
                }
            });
            eightButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    appCurrent("8");
                }
            });
            nineButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    appCurrent("9");
                }
            });
            starButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    if (!getValue(currenttab).contains("."))
                        appCurrent(".");
                }
            });
            // hashButton.setOnClickListener(new View.OnClickListener() {
            // @Override
            // public void onClick(View v) {
            // mDialTextView.setText(mDialTextView.getText() + "#");
            // }
            // });
            backSpaceButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    appBackSpace();
                }
            });
            backSpaceButton.setOnLongClickListener(new View.OnLongClickListener() {

                @Override
                public boolean onLongClick(View v) {
                    values.put(currenttab, "");
                    updateTab();
                    return true;
                }
            });
            bloodtesttabbutton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    currenttab = "bloodtest";
                    updateTab();
                }
            });
            insulintabbutton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    currenttab = "insulin";
                    updateTab();
                }
            });
            carbstabbutton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    currenttab = "carbs";
                    updateTab();
                }
            });
            timetabbutton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    currenttab = "time";
                    updateTab();
                }
            });
            updateTab();
        /*   callImageButton.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (!mDialTextView.getText().toString().isEmpty()) {
                            sendMessage(mDialTextView.getText().toString(), null);
                            Toast.makeText(getApplicationContext(), "Calling " + mDialTextView.getText(), Toast.LENGTH_SHORT).show();
                            mDialTextView.setText(null);
                        }
                    }
                });*/
        }
    });
}
Also used : ImageButton(android.widget.ImageButton) ImageButton(android.widget.ImageButton) Button(android.widget.Button) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) WatchViewStub(android.support.wearable.view.WatchViewStub)

Example 3 with WatchViewStub

use of android.support.wearable.view.WatchViewStub in project xDrip-plus by jamorham.

the class Simulation method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_simulation);
    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    final Intent intent = this.getIntent();
    stub.setOnLayoutInflatedListener(stub1 -> {
        mTextView = (TextView) stub1.findViewById(R.id.text);
        mBloodText = (TextView) stub1.findViewById(R.id.textBloodGlucose);
        mCarbsText = (TextView) stub1.findViewById(R.id.textCarbohydrate);
        mInsulinText = (TextView) stub1.findViewById(R.id.textInsulinUnits);
        mTimeText = (TextView) findViewById(R.id.textTimeButton);
        btnBloodGlucose = (ImageButton) findViewById(R.id.bloodTestButton);
        btnCarbohydrates = (ImageButton) findViewById(R.id.buttonCarbs);
        btnInsulinDose = (ImageButton) findViewById(R.id.buttonInsulin);
        btnCancel = (ImageButton) findViewById(R.id.cancelTreatment);
        btnApprove = (ImageButton) findViewById(R.id.approveTreatment);
        btnTime = (ImageButton) findViewById(R.id.timeButton);
        mTextView.setText("");
        mBloodText.setVisibility(View.INVISIBLE);
        mCarbsText.setVisibility(View.INVISIBLE);
        mInsulinText.setVisibility(View.INVISIBLE);
        mTimeText.setVisibility(View.INVISIBLE);
        btnBloodGlucose.setVisibility(View.INVISIBLE);
        btnCarbohydrates.setVisibility(View.INVISIBLE);
        btnInsulinDose.setVisibility(View.INVISIBLE);
        btnCancel.setVisibility(View.INVISIBLE);
        btnApprove.setVisibility(View.INVISIBLE);
        btnTime.setVisibility(View.INVISIBLE);
        inflated = true;
        final boolean debug = false;
        if (intent != null) {
            // debug section
            final Bundle bundle = intent.getExtras();
            if ((bundle != null) && (debug)) {
                for (String key : bundle.keySet()) {
                    Object value = bundle.get(key);
                    if (value != null) {
                        Log.d(TAG, String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
                    }
                }
            }
            processIncomingIntent(intent);
        }
    });
    Log.i(TAG, "triggered");
    final Bundle bundle = intent.getExtras();
    if (bundle == null)
        promptSpeechInput();
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent) WatchViewStub(android.support.wearable.view.WatchViewStub)

Example 4 with WatchViewStub

use of android.support.wearable.view.WatchViewStub in project xDrip-plus by jamorham.

the class BIGChart method performViewSetup.

public void performViewSetup() {
    final WatchViewStub stub = (WatchViewStub) layoutView.findViewById(R.id.watch_view_stub);
    IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);
    messageReceiver = new MessageReceiver();
    localBroadcastManager = LocalBroadcastManager.getInstance(this);
    localBroadcastManager.registerReceiver(messageReceiver, messageFilter);
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {

        @Override
        public void onLayoutInflated(WatchViewStub stub) {
            mTime = (TextView) stub.findViewById(R.id.watch_time);
            mDate = (TextView) stub.findViewById(R.id.watch_date);
            mSgv = (TextView) stub.findViewById(R.id.sgv);
            mTimestamp = (TextView) stub.findViewById(R.id.timestamp);
            mDelta = (TextView) stub.findViewById(R.id.delta);
            mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout);
            chart = (LineChartView) stub.findViewById(R.id.chart);
            statusView = (TextView) stub.findViewById(R.id.aps_status);
            stepsButton = (Button) stub.findViewById(R.id.walkButton);
            mStepsLinearLayout = (LinearLayout) stub.findViewById(R.id.steps_layout);
            menuButton = (Button) stub.findViewById(R.id.menuButton);
            mMenuLinearLayout = (LinearLayout) stub.findViewById(R.id.menu_layout);
            mDirectionDelta = (LinearLayout) stub.findViewById(R.id.directiondelta_layout);
            layoutSet = true;
            Context context = xdrip.getAppContext();
            if (Home.get_forced_wear()) {
                if (d)
                    Log.d(TAG, "performViewSetup FORCE WEAR init BGs for graph");
                BgSendQueue.resendData(context);
            }
            if ((chart != null) && sharedPrefs.getBoolean("show_wear_treatments", false)) {
                if (d)
                    Log.d(TAG, "performViewSetup init Treatments for graph");
                ListenerService.showTreatments(context, "all");
            }
            showAgeAndStatus();
            mRelativeLayout.measure(specW, specH);
            mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(), mRelativeLayout.getMeasuredHeight());
        }
    });
    Log.d(TAG, "performViewSetup requestData");
    ListenerService.requestData(this);
    wakeLock.acquire(50);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Button(android.widget.Button) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) LineChartView(lecho.lib.hellocharts.view.LineChartView) WatchViewStub(android.support.wearable.view.WatchViewStub) LinearLayout(android.widget.LinearLayout)

Example 5 with WatchViewStub

use of android.support.wearable.view.WatchViewStub in project xDrip by NightscoutFoundation.

the class MenuActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_menu);
    currenttab = "";
    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {

        @Override
        public void onLayoutInflated(WatchViewStub stub) {
            // mDialTextView = (TextView) stub.findViewById(R.id.dialed_no_textview);
            addtreatmentbutton = (ImageButton) stub.findViewById(R.id.addtreatmentbutton);
            restartcollectorbutton = (ImageButton) stub.findViewById(R.id.restartcollectorbutton);
            refreshdbbutton = (ImageButton) stub.findViewById(R.id.refreshdbbutton);
            xdripprefsbutton = (ImageButton) stub.findViewById(R.id.xdripprefsbutton);
            bloodtesttabbutton = (ImageButton) stub.findViewById(R.id.bloodtesttabbutton);
            treatmenttabbutton = (ImageButton) stub.findViewById(R.id.treatmenttabbutton);
            calibrationtabbutton = (ImageButton) stub.findViewById(R.id.calibrationtabbutton);
            bgtabbutton = (ImageButton) stub.findViewById(R.id.bgtabbutton);
            if (Home.get_forced_wear())
                restartcollectorbutton.setVisibility(View.VISIBLE);
            else
                restartcollectorbutton.setVisibility(View.GONE);
            /*mDialTextView.setText("");

                mDialTextView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        submitAll();
                    }
                });*/
            addtreatmentbutton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    currenttab = "addtreatment";
                    updateTab();
                }
            });
            refreshdbbutton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    currenttab = "refreshdb";
                    updateTab();
                }
            });
            restartcollectorbutton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    currenttab = "restartcollector";
                    updateTab();
                }
            });
            xdripprefsbutton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    currenttab = "xdripprefs";
                    updateTab();
                }
            });
            bloodtesttabbutton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    currenttab = "bloodtest";
                    updateTab();
                }
            });
            treatmenttabbutton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    currenttab = "treatments";
                    updateTab();
                }
            });
            calibrationtabbutton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    currenttab = "calibrations";
                    updateTab();
                }
            });
            bgtabbutton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    currenttab = "bgreadings";
                    updateTab();
                }
            });
            updateTab();
        }
    });
}
Also used : ImageButton(android.widget.ImageButton) TextView(android.widget.TextView) View(android.view.View) WatchViewStub(android.support.wearable.view.WatchViewStub)

Aggregations

WatchViewStub (android.support.wearable.view.WatchViewStub)10 TextView (android.widget.TextView)8 Button (android.widget.Button)6 Context (android.content.Context)4 IntentFilter (android.content.IntentFilter)4 View (android.view.View)4 ImageButton (android.widget.ImageButton)4 LinearLayout (android.widget.LinearLayout)4 RelativeLayout (android.widget.RelativeLayout)4 LineChartView (lecho.lib.hellocharts.view.LineChartView)4 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 RecognizerIntent (android.speech.RecognizerIntent)2