Java Code Examples for com.eveningoutpost.dexdrip.wearintegration.WatchUpdaterService

The following examples show how to use com.eveningoutpost.dexdrip.wearintegration.WatchUpdaterService. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: xDrip   Source File: Home.java    License: GNU General Public License v3.0 6 votes vote down vote up
private boolean hideTreatmentButtonsIfAllDone() {

        // check if any active buttons are visible;
        boolean byTypeInvisible = true;
        for (int i = 0; i < maxInsulinProfiles; i++) {
            if (btnInsulinDose[i].getVisibility() != View.INVISIBLE) {
                byTypeInvisible = false;
                break;
            }
        }

        if ((btnBloodGlucose.getVisibility() == View.INVISIBLE) &&
                (btnCarbohydrates.getVisibility() == View.INVISIBLE) &&
                byTypeInvisible) {
            hideAllTreatmentButtons(); // we clear values here also
            //send toast to wear - closes the confirmation activity on the watch
            WatchUpdaterService.sendWearToast(gs(R.string.treatment_processed), Toast.LENGTH_LONG);
            return true;
        } else {
            return false;
        }
    }
 
Example 2
Source Project: xDrip   Source File: SystemStatusFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void restartButtonListener() {
    restart_collection_service.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View v) {
            v.setEnabled(false);
            JoH.static_toast_short(gs(R.string.restarting_collector));
            v.setAlpha(0.2f);
            startWatchUpdaterService(safeGetContext(), WatchUpdaterService.ACTION_START_COLLECTOR, TAG);
            CollectionServiceStarter.restartCollectionService(safeGetContext());
            set_current_values();
            JoH.runOnUiThreadDelayed(new Runnable() {
                @Override
                public void run() {
                    v.setEnabled(true);
                    v.setAlpha(1.0f);
                    set_current_values();
                }
            }, 2000);
        }
    });
}
 
Example 3
Source Project: xDrip   Source File: NewDataObserver.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void newExternalStatus(boolean receivedLocally) {

        final String statusLine = ExternalStatusService.getLastStatusLine();
        if (statusLine.length() > 0) {
            // send to wear
            if (Pref.getBooleanDefaultFalse("wear_sync")) {
                startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_SEND_STATUS, TAG, "externalStatusString", statusLine);
            }
            // send to pebble
            sendToPebble();
            sendToAmazfit();
            sendStatusToBlueJay();

            // don't send via GCM if received via GCM!
            if (receivedLocally) {
                // SEND TO GCM
                GcmActivity.push_external_status_update(JoH.tsl(), statusLine);

            }
        }

    }
 
Example 4
Source Project: xDrip-plus   Source File: Home.java    License: GNU General Public License v3.0 6 votes vote down vote up
private boolean hideTreatmentButtonsIfAllDone() {

        // check if any active buttons are visible;
        boolean byTypeInvisible = true;
        for (int i = 0; i < maxInsulinProfiles; i++) {
            if (btnInsulinDose[i].getVisibility() != View.INVISIBLE) {
                byTypeInvisible = false;
                break;
            }
        }

        if ((btnBloodGlucose.getVisibility() == View.INVISIBLE) &&
                (btnCarbohydrates.getVisibility() == View.INVISIBLE) &&
                byTypeInvisible) {
            hideAllTreatmentButtons(); // we clear values here also
            //send toast to wear - closes the confirmation activity on the watch
            WatchUpdaterService.sendWearToast(gs(R.string.treatment_processed), Toast.LENGTH_LONG);
            return true;
        } else {
            return false;
        }
    }
 
Example 5
private void restartButtonListener() {
    restart_collection_service.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View v) {
            v.setEnabled(false);
            JoH.static_toast_short(gs(R.string.restarting_collector));
            v.setAlpha(0.2f);
            startWatchUpdaterService(safeGetContext(), WatchUpdaterService.ACTION_START_COLLECTOR, TAG);
            CollectionServiceStarter.restartCollectionService(safeGetContext());
            set_current_values();
            JoH.runOnUiThreadDelayed(new Runnable() {
                @Override
                public void run() {
                    v.setEnabled(true);
                    v.setAlpha(1.0f);
                    set_current_values();
                }
            }, 2000);
        }
    });
}
 
Example 6
Source Project: xDrip-plus   Source File: NewDataObserver.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void newExternalStatus(boolean receivedLocally) {

        final String statusLine = ExternalStatusService.getLastStatusLine();
        if (statusLine.length() > 0) {
            // send to wear
            if (Pref.getBooleanDefaultFalse("wear_sync")) {
                startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_SEND_STATUS, TAG, "externalStatusString", statusLine);
            }
            // send to pebble
            sendToPebble();
            sendToAmazfit();
            sendStatusToBlueJay();

            // don't send via GCM if received via GCM!
            if (receivedLocally) {
                // SEND TO GCM
                GcmActivity.push_external_status_update(JoH.tsl(), statusLine);

            }
        }

    }
 
Example 7
Source Project: xDrip   Source File: BgReading.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void handleResyncWearAfterBackfill(final long earliest) {
    if (earliest_backfill == 0 || earliest < earliest_backfill) earliest_backfill = earliest;
    if (WatchUpdaterService.isEnabled()) {
        Inevitable.task("wear-backfill-sync", 10000, () -> {
            WatchUpdaterService.startServiceAndResendDataIfNeeded(earliest_backfill);
            earliest_backfill = 0;
        });
    }
}
 
Example 8
Source Project: xDrip   Source File: ErrorsActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView,
                             boolean isChecked) {
    if (isChecked && !autoRefresh) handler.postDelayed(runnable, 1000); // start timer
    autoRefresh = isChecked;

    if (autoRefresh) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        if (mPrefs.getBoolean("wear_sync", false) && mPrefs.getBoolean("sync_wear_logs", false)) {
            startWatchUpdaterService(getApplicationContext(), WatchUpdaterService.ACTION_SYNC_LOGS, TAG);
        }
    } else {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
}
 
Example 9
Source Project: xDrip   Source File: BgReading.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void handleResyncWearAfterBackfill(final long earliest) {
    if (earliest_backfill == 0 || earliest < earliest_backfill) earliest_backfill = earliest;
    if (WatchUpdaterService.isEnabled()) {
        Inevitable.task("wear-backfill-sync", 10000, () -> {
            WatchUpdaterService.startServiceAndResendDataIfNeeded(earliest_backfill);
            earliest_backfill = 0;
        });
    }
}
 
Example 10
Source Project: xDrip   Source File: AlertPlayer.java    License: GNU General Public License v3.0 5 votes vote down vote up
public synchronized void Snooze(Context ctx, int repeatTime) {
    Snooze(ctx, repeatTime, true);

    BlueJayEntry.cancelNotifyIfEnabled();

    if (Pref.getBooleanDefaultFalse("bg_notifications_watch") ) {
        startWatchUpdaterService(ctx, WatchUpdaterService.ACTION_SNOOZE_ALERT, TAG, "repeatTime", "" + repeatTime);
    }
    if (Pref.getBooleanDefaultFalse("pref_amazfit_enable_key")
            && Pref.getBooleanDefaultFalse("pref_amazfit_BG_alert_enable_key")) {
        Amazfitservice.start("xDrip_AlarmCancel");
    }
}
 
Example 11
Source Project: xDrip   Source File: MegaStatus.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void requestWearCollectorStatus() {
    if (Home.get_enable_wear()) {
        if (DexCollectionType.getDexCollectionType().equals(DexcomG5)) {
            startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG, "getBatteryStatusNow", G5CollectionService.getBatteryStatusNow);
        } else {
            startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG);
        }
    }
}
 
Example 12
Source Project: xDrip   Source File: MegaStatus.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onResume() {
    mActivity = this;
    super.onResume();

    activityVisible = true;
    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(WatchUpdaterService.ACTION_BLUETOOTH_COLLECTION_SERVICE_UPDATE);
    LocalBroadcastManager.getInstance(xdrip.getAppContext()).registerReceiver(serviceDataReceiver, intentFilter);

    if ((autoRunnable != null) || (autoStart)) startAutoFresh();

    if (sectionList.size() > 1)
        startupInfo(); // show swipe message if there is a page to swipe to
}
 
Example 13
Source Project: xDrip   Source File: Home.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void startWatchUpdaterService(Context context, String action, String logTag) {
    final boolean wear_integration = Pref.getBoolean("wear_sync", false);
    if (wear_integration) {
        Log.d(logTag, "start WatchUpdaterService with " + action);
        context.startService(new Intent(context, WatchUpdaterService.class).setAction(action));
    }
}
 
Example 14
Source Project: xDrip   Source File: Home.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void startWatchUpdaterService(Context context, String action, String logTag, String key, String value) {
    final boolean wear_integration = Pref.getBoolean("wear_sync", false);
    if (wear_integration) {
        Log.d(logTag, "start WatchUpdaterService with " + action);
        context.startService(new Intent(context, WatchUpdaterService.class).setAction(action).putExtra(key, value));
    }
}
 
Example 15
Source Project: xDrip   Source File: Home.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void startWatchUpdaterService(Context context, String action, String logTag, String key, boolean value) {
    final boolean wear_integration = Pref.getBoolean("wear_sync", false);
    if (wear_integration) {
        Log.d(logTag, "start WatchUpdaterService with " + action);
        context.startService(new Intent(context, WatchUpdaterService.class).setAction(action).putExtra(key, value));
    }
}
 
Example 16
Source Project: xDrip   Source File: SystemStatusFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void requestWearCollectorStatus() {
    final PowerManager.WakeLock wl = JoH.getWakeLock("ACTION_STATUS_COLLECTOR",120000);
    if (Home.get_enable_wear()) {
        if (DexCollectionType.getDexCollectionType().equals(DexcomG5)) {
            startWatchUpdaterService(safeGetContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG, "getBatteryStatusNow", G5CollectionService.getBatteryStatusNow);
        }
        else {
            startWatchUpdaterService(safeGetContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG);
        }
    }
    JoH.releaseWakeLock(wl);
}
 
Example 17
Source Project: xDrip   Source File: SystemStatusFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(WatchUpdaterService.ACTION_BLUETOOTH_COLLECTION_SERVICE_UPDATE);
    LocalBroadcastManager.getInstance(safeGetContext()).registerReceiver(serviceDataReceiver, intentFilter);
}
 
Example 18
Source Project: xDrip   Source File: NewDataObserver.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static void sendToWear() {
    if ((Pref.getBooleanDefaultFalse("wear_sync")) && !Home.get_forced_wear()) {//KS not necessary since MongoSendTask sends UploaderQueue.newEntry BG to WatchUpdaterService.sendWearUpload
        JoH.startService(WatchUpdaterService.class);
        // I don't think this wakelock is really needed anymore
        if (Pref.getBoolean("excessive_wakelocks", false)) {
            JoH.getWakeLock("wear-quickFix3", 15000); // dangling wakelock
        }
    }
}
 
Example 19
Source Project: xDrip-plus   Source File: BgReading.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void handleResyncWearAfterBackfill(final long earliest) {
    if (earliest_backfill == 0 || earliest < earliest_backfill) earliest_backfill = earliest;
    if (WatchUpdaterService.isEnabled()) {
        Inevitable.task("wear-backfill-sync", 10000, () -> {
            WatchUpdaterService.startServiceAndResendDataIfNeeded(earliest_backfill);
            earliest_backfill = 0;
        });
    }
}
 
Example 20
Source Project: xDrip-plus   Source File: ErrorsActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCheckedChanged(CompoundButton buttonView,
                             boolean isChecked) {
    if (isChecked && !autoRefresh) handler.postDelayed(runnable, 1000); // start timer
    autoRefresh = isChecked;

    if (autoRefresh) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        if (mPrefs.getBoolean("wear_sync", false) && mPrefs.getBoolean("sync_wear_logs", false)) {
            startWatchUpdaterService(getApplicationContext(), WatchUpdaterService.ACTION_SYNC_LOGS, TAG);
        }
    } else {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
}
 
Example 21
Source Project: xDrip-plus   Source File: BgReading.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void handleResyncWearAfterBackfill(final long earliest) {
    if (earliest_backfill == 0 || earliest < earliest_backfill) earliest_backfill = earliest;
    if (WatchUpdaterService.isEnabled()) {
        Inevitable.task("wear-backfill-sync", 10000, () -> {
            WatchUpdaterService.startServiceAndResendDataIfNeeded(earliest_backfill);
            earliest_backfill = 0;
        });
    }
}
 
Example 22
Source Project: xDrip-plus   Source File: AlertPlayer.java    License: GNU General Public License v3.0 5 votes vote down vote up
public synchronized void Snooze(Context ctx, int repeatTime) {
    Snooze(ctx, repeatTime, true);

    BlueJayEntry.cancelNotifyIfEnabled();

    if (Pref.getBooleanDefaultFalse("bg_notifications_watch") ) {
        startWatchUpdaterService(ctx, WatchUpdaterService.ACTION_SNOOZE_ALERT, TAG, "repeatTime", "" + repeatTime);
    }
    if (Pref.getBooleanDefaultFalse("pref_amazfit_enable_key")
            && Pref.getBooleanDefaultFalse("pref_amazfit_BG_alert_enable_key")) {
        Amazfitservice.start("xDrip_AlarmCancel");
    }
}
 
Example 23
Source Project: xDrip-plus   Source File: MegaStatus.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void requestWearCollectorStatus() {
    if (Home.get_enable_wear()) {
        if (DexCollectionType.getDexCollectionType().equals(DexcomG5)) {
            startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG, "getBatteryStatusNow", G5CollectionService.getBatteryStatusNow);
        } else {
            startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG);
        }
    }
}
 
Example 24
Source Project: xDrip-plus   Source File: MegaStatus.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onResume() {
    mActivity = this;
    super.onResume();

    activityVisible = true;
    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(WatchUpdaterService.ACTION_BLUETOOTH_COLLECTION_SERVICE_UPDATE);
    LocalBroadcastManager.getInstance(xdrip.getAppContext()).registerReceiver(serviceDataReceiver, intentFilter);

    if ((autoRunnable != null) || (autoStart)) startAutoFresh();

    if (sectionList.size() > 1)
        startupInfo(); // show swipe message if there is a page to swipe to
}
 
Example 25
Source Project: xDrip-plus   Source File: Home.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void startWatchUpdaterService(Context context, String action, String logTag) {
    final boolean wear_integration = Pref.getBoolean("wear_sync", false);
    if (wear_integration) {
        Log.d(logTag, "start WatchUpdaterService with " + action);
        context.startService(new Intent(context, WatchUpdaterService.class).setAction(action));
    }
}
 
Example 26
Source Project: xDrip-plus   Source File: Home.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void startWatchUpdaterService(Context context, String action, String logTag, String key, String value) {
    final boolean wear_integration = Pref.getBoolean("wear_sync", false);
    if (wear_integration) {
        Log.d(logTag, "start WatchUpdaterService with " + action);
        context.startService(new Intent(context, WatchUpdaterService.class).setAction(action).putExtra(key, value));
    }
}
 
Example 27
Source Project: xDrip-plus   Source File: Home.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void startWatchUpdaterService(Context context, String action, String logTag, String key, boolean value) {
    final boolean wear_integration = Pref.getBoolean("wear_sync", false);
    if (wear_integration) {
        Log.d(logTag, "start WatchUpdaterService with " + action);
        context.startService(new Intent(context, WatchUpdaterService.class).setAction(action).putExtra(key, value));
    }
}
 
Example 28
private void requestWearCollectorStatus() {
    final PowerManager.WakeLock wl = JoH.getWakeLock("ACTION_STATUS_COLLECTOR",120000);
    if (Home.get_enable_wear()) {
        if (DexCollectionType.getDexCollectionType().equals(DexcomG5)) {
            startWatchUpdaterService(safeGetContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG, "getBatteryStatusNow", G5CollectionService.getBatteryStatusNow);
        }
        else {
            startWatchUpdaterService(safeGetContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG);
        }
    }
    JoH.releaseWakeLock(wl);
}
 
Example 29
@Override
public void onResume() {
    super.onResume();
    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(WatchUpdaterService.ACTION_BLUETOOTH_COLLECTION_SERVICE_UPDATE);
    LocalBroadcastManager.getInstance(safeGetContext()).registerReceiver(serviceDataReceiver, intentFilter);
}
 
Example 30
Source Project: xDrip-plus   Source File: NewDataObserver.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static void sendToWear() {
    if ((Pref.getBooleanDefaultFalse("wear_sync")) && !Home.get_forced_wear()) {//KS not necessary since MongoSendTask sends UploaderQueue.newEntry BG to WatchUpdaterService.sendWearUpload
        JoH.startService(WatchUpdaterService.class);
        // I don't think this wakelock is really needed anymore
        if (Pref.getBoolean("excessive_wakelocks", false)) {
            JoH.getWakeLock("wear-quickFix3", 15000); // dangling wakelock
        }
    }
}