Search in sources :

Example 1 with NightscoutPreferences

use of com.nightscout.core.preferences.NightscoutPreferences in project android-uploader by nightscout.

the class SyncingService method startActionSingleSync.

/**
     * Starts this service to perform action Single Sync with the given parameters. If
     * the service is already performing a task this action will be queued.
     *
     * @see IntentService
     */
public static void startActionSingleSync(Context context, int numOfPages) {
    NightscoutPreferences preferences = new AndroidPreferences(context);
    // Exit if the user hasn't selected "I understand"
    if (!preferences.getIUnderstand()) {
        Toast.makeText(context, R.string.message_user_not_understand, Toast.LENGTH_LONG).show();
        return;
    }
    Intent intent = new Intent(context, SyncingService.class);
    intent.setAction(ACTION_SYNC);
    intent.putExtra(SYNC_PERIOD, numOfPages);
    context.startService(intent);
}
Also used : AndroidPreferences(com.nightscout.android.preferences.AndroidPreferences) NightscoutPreferences(com.nightscout.core.preferences.NightscoutPreferences) Intent(android.content.Intent)

Example 2 with NightscoutPreferences

use of com.nightscout.core.preferences.NightscoutPreferences in project android-uploader by nightscout.

the class SettingsActivity method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    NightscoutPreferences prefs = new AndroidPreferences(this);
    if (scanResult != null && scanResult.getContents() != null) {
        NSBarcodeConfig barcode = new NSBarcodeConfig(scanResult.getContents());
        if (barcode.hasMongoConfig()) {
            prefs.setMongoUploadEnabled(true);
            if (barcode.getMongoUri().isPresent()) {
                prefs.setMongoClientUri(barcode.getMongoUri().get());
                prefs.setMongoCollection(barcode.getMongoCollection().orNull());
                prefs.setMongoDeviceStatusCollection(barcode.getMongoDeviceStatusCollection().orNull());
            }
        } else {
            prefs.setMongoUploadEnabled(false);
        }
        if (barcode.hasApiConfig()) {
            prefs.setRestApiEnabled(true);
            prefs.setRestApiBaseUris(barcode.getApiUris());
        } else {
            prefs.setRestApiEnabled(false);
        }
        refreshFragments();
    }
}
Also used : AndroidPreferences(com.nightscout.android.preferences.AndroidPreferences) IntentResult(com.google.zxing.integration.android.IntentResult) NightscoutPreferences(com.nightscout.core.preferences.NightscoutPreferences) NSBarcodeConfig(com.nightscout.core.barcode.NSBarcodeConfig)

Aggregations

AndroidPreferences (com.nightscout.android.preferences.AndroidPreferences)2 NightscoutPreferences (com.nightscout.core.preferences.NightscoutPreferences)2 Intent (android.content.Intent)1 IntentResult (com.google.zxing.integration.android.IntentResult)1 NSBarcodeConfig (com.nightscout.core.barcode.NSBarcodeConfig)1