com.eveningoutpost.dexdrip.R Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.R. 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: FindNearby.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void btCallback(final String mac, final String status) {
    switch (status) {
        case ScanMeister.SCAN_FOUND_CALLBACK:
            UserError.Log.e(TAG, "Found! " + mac);
            InPen.setMac(mac);
            InPenEntry.startWithRefresh();
            if (JoH.ratelimit("found-inpen-first-time",86000)) {
                JoH.playResourceAudio(R.raw.labbed_musical_chime);
            }
            break;

        case ScanMeister.SCAN_FAILED_CALLBACK:
        case ScanMeister.SCAN_TIMEOUT_CALLBACK:
            UserError.Log.d(TAG, "Scan callback: " + status);
            JoH.static_toast_long(status);
            break;

    }
}
 
Example #2
Source File: HeyFamUpdateOptInDialog.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static void heyFam(final Activity activity) {
    if (DEBUG || (!Pref.getBooleanDefaultFalse(AUTO_UPDATE_PREFS_NAME)
            && Experience.ageOfThisBuildAtLeast(Constants.DAY_IN_MS * 60)
            && Experience.installedForAtLeast(Constants.DAY_IN_MS * 30)
            && Experience.gotData()
            && JoH.pratelimit("hey-fam-update-reminder", 86400 * 60))) {
        ask1(activity, new Runnable() {
            @Override
            public void run() {
                ask2(activity, new Runnable() {
                    @Override
                    public void run() {
                        Pref.setBoolean(AUTO_UPDATE_PREFS_NAME, true);
                        JoH.static_toast_long(activity.getString(R.string.update_checking_enabled));
                    }
                });
            }
        });
    }
}
 
Example #3
Source File: VersionTracker.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static boolean checkChanges(String old, String nu, boolean numeric) {
    if (!old.equals(nu)) {
        savePhoneVersions();
        if (numeric) {
            try {
                UserError.Log.ueh(TAG, xdrip.getAppContext().getString(R.string.xdrip_software_changed_format, dateTimeText(Long.parseLong(old)), dateTimeText(Long.parseLong(nu))));
            } catch (Exception e) {
                UserError.Log.ueh(TAG, xdrip.getAppContext().getString(R.string.xdrip_software_changed_format, old, nu + " (parse failure)"));
            }
        } else {
            UserError.Log.ueh(TAG, xdrip.getAppContext().getString(R.string.xdrip_software_changed_format, old, nu));
        }
        return true;
    }
    return false;
}
 
Example #4
Source File: LocationHelper.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Prompt the user to enable location if it isn't already on.
 *
 * @param parent The currently visible activity.
 */
public static void requestLocation(final Activity parent) {
    if (LocationHelper.isLocationEnabled(parent)) {
        return;
    }

    // Shamelessly borrowed from http://stackoverflow.com/a/10311877/868533

    AlertDialog.Builder builder = new AlertDialog.Builder(parent);
    builder.setTitle(R.string.location_not_found_title);
    builder.setMessage(R.string.location_not_found_message);
    builder.setPositiveButton(R.string.location_yes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogInterface, int i) {
            parent.startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
        }
    });
    builder.setNegativeButton(R.string.no, null);
    try {
        builder.create().show();
    } catch (RuntimeException e) {
        Looper.prepare();
        builder.create().show();
    }
}
 
Example #5
Source File: SelectAudioDevice.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    binding = ActivitySelectAudioDeviceBinding.inflate(getLayoutInflater());
    binding.setI(new AudioDeviceOJO());
    binding.setVm(this);

    if (binding.getI().mac.get().equals("")) {
        JoH.static_toast_long(getString(R.string.no_bluetooth_audio_found));
        finish();
        return;
    }

    setContentView(binding.getRoot());
    JoH.fixActionBar(this);

}
 
Example #6
Source File: VersionTracker.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static boolean checkChanges(String old, String nu, boolean numeric) {
    if (!old.equals(nu)) {
        savePhoneVersions();
        if (numeric) {
            try {
                UserError.Log.ueh(TAG, xdrip.getAppContext().getString(R.string.xdrip_software_changed_format, dateTimeText(Long.parseLong(old)), dateTimeText(Long.parseLong(nu))));
            } catch (Exception e) {
                UserError.Log.ueh(TAG, xdrip.getAppContext().getString(R.string.xdrip_software_changed_format, old, nu + " (parse failure)"));
            }
        } else {
            UserError.Log.ueh(TAG, xdrip.getAppContext().getString(R.string.xdrip_software_changed_format, old, nu));
        }
        return true;
    }
    return false;
}
 
Example #7
Source File: DoNothingService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static SpannableString nanoStatus() {
    SpannableString pingStatus = null;
    if (lastMessageReceived > 0) {
        long pingSince = JoH.msSince(lastMessageReceived);
        if (pingSince > Constants.MINUTE_IN_MS * 30) {
            pingStatus = Span.colorSpan("No follower sync for: " + JoH.niceTimeScalar(pingSince), BAD.color());
        }
    }
    if (Home.get_follower()) {
        updateLastBg();
        final SpannableString remoteStatus = NanoStatus.getRemote();
        if (last_bg != null) {
            if (JoH.msSince(last_bg.timestamp) > Constants.MINUTE_IN_MS * 15) {
                final SpannableString lastBgStatus = Span.colorSpan("Last from master: " + JoH.niceTimeSince(last_bg.timestamp) + " ago", NOTICE.color());
                return Span.join(true, remoteStatus, pingStatus, lastBgStatus);
            }
        } else {
            return Span.join(true, pingStatus, new SpannableString(gs(R.string.no_data_received_from_master_yet)));
        }
    } else {
        return Span.join(true, pingStatus);
    }
    return null;
}
 
Example #8
Source File: InstallPebbleWatchFace.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private boolean checkPermissions() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (ContextCompat.checkSelfPermission(getApplicationContext(),
                Manifest.permission.WRITE_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED) {
            final Activity activity = this;
            JoH.show_ok_dialog(activity, gs(R.string.please_allow_permission), "Need storage permission to install watchface", new Runnable() {
                @Override
                public void run() {
                    ActivityCompat.requestPermissions(activity,
                            new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_STORAGE);
                }
            });
            return false;
        }
    }
    return true;
}
 
Example #9
Source File: BasalProfileEditor.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_basal_profile_editor);
    JoH.fixActionBar(this);
    //  getSupportActionBar().setCustomView(R.layout.custom_action_bar_title);
    //  getSupportActionBar().setDisplayShowCustomEnabled(true);

    chart = (ColumnChartView) findViewById(R.id.basalChart);
    basalSelectSpinner = findViewById(R.id.basalProfileSpinner);
    basalStepSpinner = findViewById(R.id.basalStepSpinner);
    setValue = (EditText) findViewById(R.id.basalSetText);
    setButton = (Button) findViewById(R.id.basalSetButton);
    plusButton = (Button) findViewById(R.id.basalPlusButton);
    minusButton = (Button) findViewById(R.id.basalMinusButton);

    chart.setDataAnimationListener(this);
    chart.setOnValueTouchListener(new ValueTouchListener());
    chart.setColumnChartData(BasalChart.columnData());

    autoSetViewPort(true);
    refreshScreenElements();
    chart.setZoomType(ZoomType.HORIZONTAL);
    chart.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);
    //chart.setZoomLevel(0,0,1);
    chart.setMaxZoom(4f);
    chart.setZoomLevel(getNewMaxViewport().centerX(), getNewMaxViewport().centerY(), 1f);
    chart.setTapZoomEnabled(false);

    populateBasalStepSpinner();

}
 
Example #10
Source File: BasalProfileEditor.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private void populateBasalStepSpinner() {
    ArrayList<String> stepSpinnerArray = new ArrayList<>();
    stepSpinnerArray.add("0.5");
    stepSpinnerArray.add("0.2");
    stepSpinnerArray.add("0.1");
    stepSpinnerArray.add("0.05");
    stepSpinnerArray.add("0.02");
    stepSpinnerArray.add("0.01");
    ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, stepSpinnerArray);
    basalStepSpinner.setAdapter(spinnerArrayAdapter);

    basalStepSpinner.setOnItemSelectedListener(this);

    final int stored = (int) PersistentStore.getLong(PREF_STORED_BASAL_STEP);
    // check if unset
    if (stored == 0) {
        basalStepSpinner.setSelection(3); // 0.05 default
    } else {
        basalStepSpinner.setSelection(stored - 1);
    }

    buttonsToMatchStep();
}
 
Example #11
Source File: MiBandEntry.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    try {
        String key = preference.getKey();
        if (key.equals(MiBandEntry.PREF_MIBAND_NIGHTMODE_INTERVAL)) {
            setNightModeInterval((int) value);
            final String minutes = xdrip.gs(R.string.unit_minutes);
            final String title_text = xdrip.gs(R.string.title_miband_interval_in_nightmode);

            Integer nightModeInterval = MiBandEntry.getNightModeInterval();
            if (nightModeInterval == MiBandEntry.NIGHT_MODE_INTERVAL_STEP)
                preference.setTitle(String.format("%s (%s)", title_text, "live"));
            else
                preference.setTitle(String.format("%s (%d %s)", title_text, nightModeInterval, minutes));
        }
    } catch (Exception e) {
        //
    }
    return true;
}
 
Example #12
Source File: AbstractPluginActivity.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onMenuItemSelected(final int featureId, final MenuItem item)
{
    final int id = item.getItemId();

    if (android.R.id.home == id)
    {
        finish();
        return true;
    }
    else if (R.id.twofortyfouram_locale_menu_dontsave == id)
    {
        mIsCancelled = true;
        finish();
        return true;
    }
    else if (R.id.twofortyfouram_locale_menu_save == id)
    {
        finish();
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example #13
Source File: ThinJamActivity.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = ActivityThinJamBinding.inflate(getLayoutInflater());
    binding.setVm(new ViewModel(this));
    setContentView(binding.getRoot());
    JoH.fixActionBar(this);

    scanMeister.setFilter(customFilter);
    scanMeister.allowWide().unlimitedMatches();
    scanMeister.addCallBack2(this, TAG);

    ((TextView) findViewById(R.id.tjLogText)).setMovementMethod(new ScrollingMovementMethod());

    // handle incoming extras - TODO do we need to wait for service connect?
    final Bundle bundle = getIntent().getExtras();
    processIncomingBundle(bundle);

    LocationHelper.requestLocationForBluetooth(this);
}
 
Example #14
Source File: BgToSpeech.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private static String calculateText(double value, String delta_name) {

        final boolean doMgdl = (Pref.getString("units", "mgdl").equals("mgdl"));
        final boolean bg_to_speech_repeat_twice = (Pref.getBooleanDefaultFalse("bg_to_speech_repeat_twice"));
        String text = "";

        // TODO does some of this need unifying from best glucose etc?
        final DecimalFormat df = new DecimalFormat("#");
        if (value >= 400) {
            text = xdrip.getAppContext().getString(R.string.high);
        } else if (value >= 40) {
            if (doMgdl) {
                df.setMaximumFractionDigits(0);
                text = df.format(value);
            } else {
                df.setMaximumFractionDigits(1);
                df.setMinimumFractionDigits(1);
                text = df.format(value * Constants.MGDL_TO_MMOLL);
                try {
                    // we check the locale but it may not actually be available if the instance isn't created yet
                    if (SpeechUtil.getLocale().getLanguage().startsWith("en")) {
                        // in case the text has a comma in current locale but TTS defaults to English
                        text = text.replace(",", ".");
                    }
                } catch (NullPointerException e) {
                    Log.e(TAG, "Null pointer for TTS in calculateText");
                }
            }
            if (delta_name != null) text += " " + mungeDeltaName(delta_name);
            if (bg_to_speech_repeat_twice) text = text + TWICE_DELIMITER + text;
        } else if (value > 12) {
            text = xdrip.getAppContext().getString(R.string.low);
        } else {
            text = xdrip.getAppContext().getString(R.string.error);
        }
        Log.d(TAG, "calculated text: " + text);
        return text;
    }
 
Example #15
Source File: ExampleChartPreferenceView.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
protected void refreshView(View view) {
    LineChartView chart = (LineChartView) view.findViewById(R.id.example_linechart);
    BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getContext());
    chart.setLineChartData(bgGraphBuilder.lineData());
    Viewport viewport = chart.getMaximumViewport();
    chart.setViewportCalculationEnabled(false);
    chart.setInteractive(false);
    chart.setCurrentViewport(viewport);
    chart.setPadding(0, 0, 0, 0);
    chart.setLeft(0);
    chart.setTop(0);
    Log.d(TAG, "onBindExampleChart: refreshview " + chart.getHeight());
}
 
Example #16
Source File: Preferences.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void refreshFragments(final String jumpTo) {
    this.preferenceFragment = new AllPrefsFragment(jumpTo);
    this.preferenceFragment.setParent(this);
    pFragment = this.preferenceFragment;
    getFragmentManager().beginTransaction().replace(android.R.id.content,
            this.preferenceFragment).commit();
}
 
Example #17
Source File: ActivityWithMenu.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onResume(){
    try {
        super.onResume();
    } catch (IllegalArgumentException e) {
        UserError.Log.wtf("ActivityWithMenu", "Nasty error trying to call onResume() " + e);
    }
    menu_name = getMenuName();
    NavDrawerBuilder navDrawerBuilder = new NavDrawerBuilder(getApplicationContext());
    List<String> menu_option_list = navDrawerBuilder.nav_drawer_options;
    menu_position = menu_option_list.indexOf(menu_name);

  mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer);
  mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), menu_name, this);
}
 
Example #18
Source File: BgReadingTable.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public View newView(Context context, ViewGroup parent) {
    final View view = LayoutInflater.from(context).inflate(R.layout.raw_data_list_item, parent, false);

    final BgReadingCursorAdapterViewHolder holder = new BgReadingCursorAdapterViewHolder(view);
    view.setTag(holder);

    return view;
}
 
Example #19
Source File: SdcardImportExport.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public void savePreferencesToSD(View myview) {

        if (savePreferencesToSD()) {
            toast(getString(R.string.preferences_saved_in_sdcard_downloads));
        } else {
            if (checkPermissions(this, false, MY_PERMISSIONS_REQUEST_STORAGE)) {
                toast(getString(R.string.could_not_write_to_sdcard_check_perms));
            }
        }
    }
 
Example #20
Source File: ListActivityWithMenu.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onResume(){
    super.onResume();
    menu_name = getMenuName();
    NavDrawerBuilder  navDrawerBuilder = new NavDrawerBuilder(getApplicationContext());
    List<String> menu_option_list = navDrawerBuilder.nav_drawer_options;
    menu_position = menu_option_list.indexOf(menu_name);

    mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer);
    mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), menu_name, this);
}
 
Example #21
Source File: JoH.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void fixActionBar(AppCompatActivity context) {
    try {
        context.getSupportActionBar().setDisplayShowHomeEnabled(true);
        context.getSupportActionBar().setIcon(R.drawable.ic_launcher);
    } catch (Exception e) {
        Log.e(TAG, "Got exception with supportactionbar: " + e.toString());

    }
}
 
Example #22
Source File: Notifications.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private void doubleCalibrationRequest() {
    UserNotification userNotification = UserNotification.lastDoubleCalibrationAlert();
    if ((userNotification == null) || (userNotification.timestamp <= ((new Date().getTime()) - (60000 * calibration_snooze)))) {
        if (userNotification != null) { userNotification.delete(); }
        UserNotification.create("Double Calibration", "double_calibration_alert", new Date().getTime());
        String title = "Sensor is ready";
        String content = getString(R.string.sensor_is_ready_please_enter_double_calibration) + "  (@" + JoH.hourMinuteString() + ")";
        Intent intent = new Intent(mContext, DoubleCalibrationActivity.class);
        calibrationNotificationCreate(title, content, intent, calibrationNotificationId);
    }
}
 
Example #23
Source File: JoH.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static String niceTimeScalar(double t, int digits) {
    String unit = xdrip.getAppContext().getString(R.string.unit_second);
    t = t / 1000;
    if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_seconds);
    if (t > 59) {
        unit = xdrip.getAppContext().getString(R.string.unit_minute);
        t = t / 60;
        if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_minutes);
        if (t > 59) {
            unit = xdrip.getAppContext().getString(R.string.unit_hour);
            t = t / 60;
            if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_hours);
            if (t > 24) {
                unit = xdrip.getAppContext().getString(R.string.unit_day);
                t = t / 24;
                if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_days);
                if (t > 28) {
                    unit = xdrip.getAppContext().getString(R.string.unit_week);
                    t = t / 7;
                    if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_weeks);
                }
            }
        }
    }
    //if (t != 1) unit = unit + "s"; //implemented plurality in every step, because in other languages plurality of time is not every time adding the same character
    return qs( t, digits) + " " + unit;
}
 
Example #24
Source File: Preferences.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();
    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);

    } else if (preference instanceof RingtonePreference) {
        // For ringtone preferences, look up the correct display value
        // using RingtoneManager.
        if (TextUtils.isEmpty(stringValue)) {
            // Empty values correspond to 'silent' (no ringtone).
            preference.setSummary(R.string.pref_ringtone_silent);

        } else {
            Ringtone ringtone = RingtoneManager.getRingtone(
                    preference.getContext(), Uri.parse(stringValue));

            if (ringtone == null) {
                // Clear the summary if there was a lookup error.
                preference.setSummary(null);
            } else {
                // Set the summary to reflect the new ringtone display
                // name.
                String name = ringtone.getTitle(preference.getContext());
                preference.setSummary(name);
            }
        }

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
Example #25
Source File: JoH.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private static Notification.Builder notificationBuilder(String title, String content, PendingIntent intent) {
    return new Notification.Builder(xdrip.getAppContext())
            .setSmallIcon(R.drawable.ic_action_communication_invert_colors_on)
            .setContentTitle(title)
            .setContentText(content)
            .setContentIntent(intent);
}
 
Example #26
Source File: AbstractPluginActivity.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
    {
        setupTitleApi11();
    }
    else
    {
        setTitle(BreadCrumber.generateBreadcrumb(getApplicationContext(), getIntent(),
                                                 getString(R.string.plugin_name)));
    }
}
 
Example #27
Source File: InPenService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private synchronized void processRecordsQueue() {
    boolean newRecord = false;
    while (!records.isEmpty()) {
        final byte[] record = records.poll();
        if (record != null) {
            final RecordRx recordRx = new RecordRx(currentPenTime).fromBytes(record);
            if (recordRx != null) {
                UserError.Log.d(TAG, "RECORD RECORD: " + recordRx.toS());
                final PenData penData = PenData.create(I.address, ID_INPEN, recordRx.index, recordRx.units, recordRx.getRealTimeStamp(), recordRx.temperature, record);
                if (penData == null) {
                    UserError.Log.wtf(TAG, "Error creating PenData record from " + HexDump.dumpHexString(record));
                } else {
                    penData.battery = recordRx.battery;
                    penData.flags = recordRx.flags;
                    UserError.Log.d(TAG, "Saving Record index: " + penData.index);
                    penData.save();
                    newRecord = true;
                    gotIndex = (int) penData.index;
                    gotAll = lastIndex == gotIndex;
                    if (InPen.soundsEnabled() && JoH.ratelimit("pen_data_in", 1)) {
                        JoH.playResourceAudio(R.raw.bt_meter_data_in);
                    }
                    lastPenData = penData;
                }
            } else {
                UserError.Log.e(TAG, "Error creating record from: " + HexDump.dumpHexString(record));
            }
        }
    }
    if (newRecord) {
        Inevitable.task("process-inpen-data", 1000, ProcessPenData::process);
    }
}
 
Example #28
Source File: EditActivity.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void finish()
{
    if (!isCanceled())
    {
        final String message = ((EditText) findViewById(R.id.editTextTasker)).getText().toString();

        if (message.length() > 0)
        {
            final Intent resultIntent = new Intent();

            /*
             * This extra is the data to ourselves: either for the Activity or the BroadcastReceiver. Note
             * that anything placed in this Bundle must be available to Locale's class loader. So storing
             * String, int, and other standard objects will work just fine. Parcelable objects are not
             * acceptable, unless they also implement Serializable. Serializable objects must be standard
             * Android platform objects (A Serializable class private to this plug-in's APK cannot be
             * stored in the Bundle, as Locale's classloader will not recognize it).
             */
            final Bundle resultBundle =
                    PluginBundleManager.generateBundle(getApplicationContext(), message);
            resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, resultBundle);

            if ( TaskerPlugin.Setting.hostSupportsOnFireVariableReplacement( this ) )
                TaskerPlugin.Setting.setVariableReplaceKeys( resultBundle, new String[] {
                        PluginBundleManager.BUNDLE_EXTRA_STRING_MESSAGE });


            /*
             * The blurb is concise status text to be displayed in the host's UI.
             */
            final String blurb = generateBlurb(getApplicationContext(), message);
            resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB, blurb);

            setResult(RESULT_OK, resultIntent);
        }
    }

    super.finish();
}
 
Example #29
Source File: BgReadingTable.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer);
    mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), menu_name, this);

    getData();
}
 
Example #30
Source File: Notifications.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void doubleCalibrationRequest() {
    UserNotification userNotification = UserNotification.lastDoubleCalibrationAlert();
    if ((userNotification == null) || (userNotification.timestamp <= ((new Date().getTime()) - (60000 * calibration_snooze)))) {
        if (userNotification != null) { userNotification.delete(); }
        UserNotification.create("Double Calibration", "double_calibration_alert", new Date().getTime());
        String title = "Sensor is ready";
        String content = getString(R.string.sensor_is_ready_please_enter_double_calibration) + "  (@" + JoH.hourMinuteString() + ")";
        Intent intent = new Intent(mContext, DoubleCalibrationActivity.class);
        calibrationNotificationCreate(title, content, intent, calibrationNotificationId);
    }
}