com.eveningoutpost.dexdrip.utils.Preferences Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.utils.Preferences. 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: ProfileEditor.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onPause() {
    super.onPause();

    if (dataChanged) {
        Profile.reloadPreferences();
        Intent intent = new Intent(ProfileEditor.this, Preferences.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.putExtra("refresh", "");
        startActivity(intent);
    }
}
 
Example #2
Source File: ProfileEditor.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onPause() {
    super.onPause();

    if (dataChanged) {
        Profile.reloadPreferences();
        Intent intent = new Intent(ProfileEditor.this, Preferences.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.putExtra("refresh", "");
        startActivity(intent);
    }
}
 
Example #3
Source File: PebbleDisplayAbstract.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public boolean getBooleanValue(String key, boolean defaultValue) {
    return Preferences.getBooleanPreferenceViaContextWithoutException(this.context, key, defaultValue);
}
 
Example #4
Source File: ThinJamActivity.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public boolean doAction(final String action) {
    switch (action) {

        case "updateconfig":
            JoH.static_toast_long("Refreshing watch config");
            validateTxId();
            break;

        case "asktxid":
            // for debug only
            setTx();
            break;

        case "showqrcode":
            JoH.static_toast_long("Showing QR code on watch");
            thinJam.showQrCode();
            break;

        case "easyauth":
            JoH.static_toast_long("Doing non-QR code Easy Auth");
            thinJam.easyAuth();
            break;

        case "reboot":
            JoH.static_toast_long("Rebooting");
            thinJam.reboot();
            break;

        case "factoryreset":
            JoH.static_toast_long("Factory Resetting");
            thinJam.factoryReset();
            break;

        case "launchstatus":
            xdrip.getAppContext().startActivity(JoH.getStartActivityIntent(MegaStatus.class).setAction("BlueJay").addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
            break;

        case "launchhelp":
            xdrip.getAppContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://bluejay.website/quickhelp")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
            break;

        case "launchsettings":
            xdrip.getAppContext().startActivity(JoH.getStartActivityIntent(Preferences.class).setAction("bluejay_preference_screen").addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
        break;



        default:
            JoH.static_toast_long("Unknown action: "+action);
            break;
    }
    return true;
}
 
Example #5
Source File: PebbleDisplayAbstract.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public boolean getBooleanValue(String key, boolean defaultValue) {
    return Preferences.getBooleanPreferenceViaContextWithoutException(this.context, key, defaultValue);
}
 
Example #6
Source File: ThinJamActivity.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public boolean doAction(final String action) {
    switch (action) {

        case "updateconfig":
            JoH.static_toast_long("Refreshing watch config");
            validateTxId();
            break;

        case "asktxid":
            // for debug only
            setTx();
            break;

        case "showqrcode":
            JoH.static_toast_long("Showing QR code on watch");
            thinJam.showQrCode();
            break;

        case "easyauth":
            JoH.static_toast_long("Doing non-QR code Easy Auth");
            thinJam.easyAuth();
            break;

        case "reboot":
            JoH.static_toast_long("Rebooting");
            thinJam.reboot();
            break;

        case "factoryreset":
            JoH.static_toast_long("Factory Resetting");
            thinJam.factoryReset();
            break;

        case "launchstatus":
            xdrip.getAppContext().startActivity(JoH.getStartActivityIntent(MegaStatus.class).setAction("BlueJay").addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
            break;

        case "launchhelp":
            xdrip.getAppContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://bluejay.website/quickhelp")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
            break;

        case "launchsettings":
            xdrip.getAppContext().startActivity(JoH.getStartActivityIntent(Preferences.class).setAction("bluejay_preference_screen").addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
        break;



        default:
            JoH.static_toast_long("Unknown action: "+action);
            break;
    }
    return true;
}
 
Example #7
Source File: NavDrawerBuilder.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
public NavDrawerBuilder(Context aContext) {
    context = aContext;
    boolean xDripViewer = XDripViewer.isxDripViewerMode(aContext);
    
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean IUnderstand = prefs.getBoolean("I_understand", false);
    if (IUnderstand == false) {
        this.nav_drawer_options.add("Settings");
        this.nav_drawer_intents.add(new Intent(context, Preferences.class));
        return;
    }

    this.nav_drawer_options.add(Home.menu_name);
    this.nav_drawer_intents.add(new Intent(context, Home.class));
    if (is_active_sensor) {
        this.nav_drawer_options.add("Calibration Graph");
        this.nav_drawer_intents.add(new Intent(context, CalibrationGraph.class));
    }

    if (prefs.getBoolean("show_data_tables", false)) {
        this.nav_drawer_options.add("BG Data Table");
        this.nav_drawer_intents.add(new Intent(context, BgReadingTable.class));
        this.nav_drawer_options.add("Calibration Data Table");
        this.nav_drawer_intents.add(new Intent(context, CalibrationDataTable.class));
    }

    if(!xDripViewer) {
        if(is_active_sensor) {
            if(!CollectionServiceStarter.isBTShare(context)) {
                if (last_two_bgReadings.size() > 1) {
                    if (last_two_calibrations.size() > 1) {
                        if (bGreadings_in_last_30_mins.size() >= 2) {
                            if (time_now - last_two_calibrations.get(0).timestamp < (1000 * 60 * 60)) { //Put steps in place to discourage over calibration
                                this.nav_drawer_options.add(CalibrationOverride.menu_name);
                                this.nav_drawer_intents.add(new Intent(context, CalibrationOverride.class));
                            } else {
                                this.nav_drawer_options.add(AddCalibration.menu_name);
                                this.nav_drawer_intents.add(new Intent(context, AddCalibration.class));
                            }
                        } else {
                            this.nav_drawer_options.add("Cannot Calibrate right now");
                            this.nav_drawer_intents.add(new Intent(context, Home.class));
                        }
                    } else {
                        this.nav_drawer_options.add(DoubleCalibrationActivity.menu_name);
                        this.nav_drawer_intents.add(new Intent(context, DoubleCalibrationActivity.class));
                    }
                }
            }
            this.nav_drawer_options.add(StopSensor.menu_name);
            this.nav_drawer_intents.add(new Intent(context, StopSensor.class));
        } else {
            this.nav_drawer_options.add(StartNewSensor.menu_name);
            this.nav_drawer_intents.add(new Intent(context, StartNewSensor.class));
        }
    }

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if(CollectionServiceStarter.isBteWixelorWifiandBtWixel(context) || CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(context)|| CollectionServiceStarter.isBTShare(context) ) {
            this.nav_drawer_options.add(BluetoothScan.menu_name);
            this.nav_drawer_intents.add(new Intent(context, BluetoothScan.class));
        }
    }

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
        this.nav_drawer_options.add(SystemStatus.menu_name);
        this.nav_drawer_intents.add(new Intent(context, SystemStatus.class));
    }

    boolean bg_alerts = prefs.getBoolean("bg_alerts_from_main_menu", false);
    if (bg_alerts) {
        this.nav_drawer_options.add(AlertList.menu_name);
        this.nav_drawer_intents.add(new Intent(context, AlertList.class));
    }
    this.nav_drawer_options.add(SnoozeActivity.menu_name);
    this.nav_drawer_intents.add(new Intent(context, SnoozeActivity.class));

    this.nav_drawer_options.add(StatsActivity.MENU_NAME);
    this.nav_drawer_intents.add(new Intent(context, StatsActivity.class));

    this.nav_drawer_options.add(BGHistory.menu_name);
    this.nav_drawer_intents.add(new Intent(context, BGHistory.class));

    this.nav_drawer_options.add("Settings");
    this.nav_drawer_intents.add(new Intent(context, Preferences.class));
}
 
Example #8
Source File: NavDrawerBuilder.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
private List<Intent> nav_drawer_intents() {
        List<Intent> options = new ArrayList<Intent>();
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        boolean IUnderstand = prefs.getBoolean("I_understand", false);
        if(IUnderstand == false) {
            options.add(new Intent(context, SettingsActivity.class));
            return options;
        }

        options.add(new Intent(context, Home.class));
        if(is_active_sensor) {
            options.add(new Intent(context, CalibrationGraph.class));
        }
        options.add(new Intent(context, BgReadingTable.class));
        options.add(new Intent(context, CalibrationDataTable.class));
//        options.add(new Intent(context, SensorDataTable.class));


        if(is_active_sensor) {
            if(!CollectionServiceStarter.isBTShare(context)) {
                if (last_two_bgReadings.size() > 1) {
                    if (last_two_calibrations.size() > 1) {
                        if (bGreadings_in_last_30_mins.size() >= 2) {
                            if (time_now - last_two_calibrations.get(0).timestamp < (1000 * 60 * 60)) { //Put steps in place to discourage over calibration
                                options.add(new Intent(context, CalibrationOverride.class));
                            } else {
                                options.add(new Intent(context, AddCalibration.class));
                            }
                        } else {
                            options.add(new Intent(context, Home.class));
                        }
                        if (last_two_calibrations.get(0).slope >= 1.4 || last_two_calibrations.get(0).slope <= 0.5) {
                            options.add(new Intent(context, DoubleCalibrationActivity.class));
                        }
                    } else {
                        options.add(new Intent(context, DoubleCalibrationActivity.class));
                    }
                }
            }
            options.add(new Intent(context, StopSensor.class));
        } else { options.add(new Intent(context, StartNewSensor.class)); }
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
            if(CollectionServiceStarter.isBTWixel(context) || CollectionServiceStarter.isBTShare(context)) {
                options.add(new Intent(context, BluetoothScan.class));
            }
        }
        options.add(new Intent(context, SystemStatus.class));
//        options.add(new Intent(context, SettingsActivity.class));
        options.add(new Intent(context, Preferences.class));
//        options.add(new Intent(context, FakeNumbers.class));
//        options.add(new Intent(context, DoubleCalibrationActivity.class));
//        options.add(new Intent(context, ShareTest.class));
        return options;
    }