com.eveningoutpost.dexdrip.wearintegration.WatchUpdaterService Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.wearintegration.WatchUpdaterService. 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 File: Home.java    From xDrip-plus with 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 File: SystemStatusFragment.java    From xDrip with 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 File: NewDataObserver.java    From xDrip with 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 File: NewDataObserver.java    From xDrip-plus with 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 #5
Source File: SystemStatusFragment.java    From xDrip-plus with 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 #6
Source File: Home.java    From xDrip with 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 #7
Source File: SystemStatusFragment.java    From xDrip with 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 #8
Source File: BgReading.java    From xDrip with 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 #9
Source File: NewDataObserver.java    From xDrip with 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 #10
Source File: BgReading.java    From xDrip-plus with 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 #11
Source File: Home.java    From xDrip-plus with 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 #12
Source File: ErrorsActivity.java    From xDrip-plus with 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 #13
Source File: BgReading.java    From xDrip-plus with 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 #14
Source File: Home.java    From xDrip-plus with 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 File: Home.java    From xDrip-plus with 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 #16
Source File: AlertPlayer.java    From xDrip-plus with 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 #17
Source File: MegaStatus.java    From xDrip-plus with 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 #18
Source File: MegaStatus.java    From xDrip-plus with 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 #19
Source File: SystemStatusFragment.java    From xDrip with 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 #20
Source File: SystemStatusFragment.java    From xDrip-plus with 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 #21
Source File: Home.java    From xDrip with 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 #22
Source File: Home.java    From xDrip with 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 #23
Source File: Home.java    From xDrip with 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 #24
Source File: SystemStatusFragment.java    From xDrip-plus with 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 #25
Source File: MegaStatus.java    From xDrip with 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 #26
Source File: MegaStatus.java    From xDrip with 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 #27
Source File: AlertPlayer.java    From xDrip with 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 #28
Source File: BgReading.java    From xDrip with 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 #29
Source File: ErrorsActivity.java    From xDrip with 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 #30
Source File: NewDataObserver.java    From xDrip-plus with 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
        }
    }
}