com.eveningoutpost.dexdrip.utils.LocationHelper Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.utils.LocationHelper. 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: StartNewSensor.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public void addListenerOnButton() {
    button = (Button) findViewById(R.id.startNewSensor);

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && DexCollectionType.hasBluetooth()) {
                if (!LocationHelper.locationPermission(StartNewSensor.this)) {
                    LocationHelper.requestLocationForBluetooth(StartNewSensor.this);
                } else {
                    sensorButtonClick();
                }
            } else {
                sensorButtonClick();
            }
        }
    });
}
 
Example #2
Source File: ThinJamActivity.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 = 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 #3
Source File: StartNewSensor.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public void addListenerOnButton() {
    button = (Button) findViewById(R.id.startNewSensor);

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && DexCollectionType.hasBluetooth()) {
                if (!LocationHelper.locationPermission(StartNewSensor.this)) {
                    LocationHelper.requestLocationForBluetooth(StartNewSensor.this);
                } else {
                    sensorButtonClick();
                }
            } else {
                sensorButtonClick();
            }
        }
    });
}
 
Example #4
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 #5
Source File: StartNewSensor.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
public void addListenerOnButton() {
    button = (Button)findViewById(R.id.startNewSensor);
    linkPickers = (CheckBox)findViewById(R.id.startSensorLinkPickers);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    linkPickers.setChecked(prefs.getBoolean("start_sensor_link_pickers", false));

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                if (!LocationHelper.locationPermission(StartNewSensor.this)) {
                    requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
                } else {
                    sensorButtonClick();
                }
            } else {
                sensorButtonClick();
            }
        }
    });
}
 
Example #6
Source File: BluetoothScan.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.OldAppTheme); // or null actionbar
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bluetooth_scan);
    final BluetoothManager bluetooth_manager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);

    bluetooth_adapter = bluetooth_manager.getAdapter();
    mHandler = new Handler();


    if (bluetooth_adapter == null) {
        Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_LONG).show();
        finish();
        return;
    }
    if (!bluetooth_manager.getAdapter().isEnabled()) {
        if (Pref.getBoolean("automatically_turn_bluetooth_on", true)) {
            JoH.setBluetoothEnabled(getApplicationContext(), true);
            Toast.makeText(this, "Trying to turn Bluetooth on", Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(this, "Please turn Bluetooth on!", Toast.LENGTH_LONG).show();
        }
    } else {
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
            Toast.makeText(this, "The android version of this device is not compatible with Bluetooth Low Energy", Toast.LENGTH_LONG).show();
        }
    }
    // Will request that GPS be enabled for devices running Marshmallow or newer.
    LocationHelper.requestLocationForBluetooth(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        initializeScannerCallback();

    mLeDeviceListAdapter = new LeDeviceListAdapter();
    setListAdapter(mLeDeviceListAdapter);
}
 
Example #7
Source File: BluetoothScan.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    if (LocationHelper.isLocationPermissionOk(this) && (JoH.ratelimit("auto-start-bt-scan", 20))) {
        doScan();
    }
}
 
Example #8
Source File: BluetoothScan.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.OldAppTheme); // or null actionbar
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bluetooth_scan);
    final BluetoothManager bluetooth_manager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);

    bluetooth_adapter = bluetooth_manager.getAdapter();
    mHandler = new Handler();


    if (bluetooth_adapter == null) {
        Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_LONG).show();
        finish();
        return;
    }
    if (!bluetooth_manager.getAdapter().isEnabled()) {
        if (Pref.getBoolean("automatically_turn_bluetooth_on", true)) {
            JoH.setBluetoothEnabled(getApplicationContext(), true);
            Toast.makeText(this, "Trying to turn Bluetooth on", Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(this, "Please turn Bluetooth on!", Toast.LENGTH_LONG).show();
        }
    } else {
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
            Toast.makeText(this, "The android version of this device is not compatible with Bluetooth Low Energy", Toast.LENGTH_LONG).show();
        }
    }
    // Will request that GPS be enabled for devices running Marshmallow or newer.
    LocationHelper.requestLocationForBluetooth(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        initializeScannerCallback();

    mLeDeviceListAdapter = new LeDeviceListAdapter();
    setListAdapter(mLeDeviceListAdapter);
}
 
Example #9
Source File: BluetoothScan.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    if (LocationHelper.isLocationPermissionOk(this) && (JoH.ratelimit("auto-start-bt-scan", 20))) {
        doScan();
    }
}
 
Example #10
Source File: BluetoothScan.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bluetooth_scan);
    final BluetoothManager bluetooth_manager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);

    bluetooth_adapter = bluetooth_manager.getAdapter();
    mHandler = new Handler();

    if (bluetooth_adapter == null) {
        Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_LONG).show();
        finish();
        return;
    }
    if (!bluetooth_manager.getAdapter().isEnabled()) {
        Toast.makeText(this, "Bluetooth is turned off on this device currently", Toast.LENGTH_LONG).show();
    } else {
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
            Toast.makeText(this, "The android version of this device is not compatible with Bluetooth Low Energy", Toast.LENGTH_LONG).show();
        }
    }
    // Will request that GPS be enabled for devices running Marshmallow or newer.
    LocationHelper.requestLocationForBluetooth(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        initializeScannerCallback();

    mLeDeviceListAdapter = new LeDeviceListAdapter();
    setListAdapter(mLeDeviceListAdapter);
}
 
Example #11
Source File: EmergencyAssistActivity.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
private void checkLocationPermission() {
    LocationHelper.requestLocationForEmergencyMessage(this);
}
 
Example #12
Source File: EmergencyAssistActivity.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
private void checkLocationPermission() {
    LocationHelper.requestLocationForEmergencyMessage(this);
}