mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-30 03:30:30 +02:00
Don't start data entry activity if no user is selected
Also, don't allow search for bluetooth scale if no user is selected. Fixes #192 and potentially also #158.
This commit is contained in:
@@ -323,10 +323,18 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
drawerLayout.closeDrawers();
|
drawerLayout.closeDrawers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showNoSelectedUserDialog() {
|
||||||
|
AlertDialog.Builder infoDialog = new AlertDialog.Builder(this);
|
||||||
|
|
||||||
|
infoDialog.setMessage(getResources().getString(R.string.info_no_selected_user));
|
||||||
|
infoDialog.setPositiveButton(getResources().getString(R.string.label_ok), null);
|
||||||
|
infoDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
|
||||||
if(drawerToggle.onOptionsItemSelected(item)){
|
if (drawerToggle.onOptionsItemSelected(item)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,6 +343,11 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
drawerLayout.openDrawer(GravityCompat.START);
|
drawerLayout.openDrawer(GravityCompat.START);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_add_measurement:
|
case R.id.action_add_measurement:
|
||||||
|
if (OpenScale.getInstance(getApplicationContext()).getSelectedScaleUserId() == -1) {
|
||||||
|
showNoSelectedUserDialog();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(getApplicationContext(), DataEntryActivity.class);
|
Intent intent = new Intent(getApplicationContext(), DataEntryActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
@@ -380,6 +393,11 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void invokeSearchBluetoothDevice() {
|
private void invokeSearchBluetoothDevice() {
|
||||||
|
if (OpenScale.getInstance(getApplicationContext()).getSelectedScaleUserId() == -1) {
|
||||||
|
showNoSelectedUserDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
String deviceName = prefs.getString("btDeviceName", "-");
|
String deviceName = prefs.getString("btDeviceName", "-");
|
||||||
|
@@ -388,11 +388,6 @@ public class DataEntryActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
OpenScale openScale = OpenScale.getInstance(getApplicationContext());
|
OpenScale openScale = OpenScale.getInstance(getApplicationContext());
|
||||||
if (openScale.getSelectedScaleUserId() == -1) {
|
if (openScale.getSelectedScaleUserId() == -1) {
|
||||||
AlertDialog.Builder infoDialog = new AlertDialog.Builder(context);
|
|
||||||
|
|
||||||
infoDialog.setMessage(getResources().getString(R.string.info_no_selected_user));
|
|
||||||
infoDialog.setPositiveButton(getResources().getString(R.string.label_ok), null);
|
|
||||||
infoDialog.show();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user