Set OpenTracks selection spinner to current package

This commit is contained in:
José Rebelo 2023-07-27 23:01:54 +01:00 committed by José Rebelo
parent 47a757bd91
commit f3c74267c5
1 changed files with 13 additions and 13 deletions

View File

@ -435,6 +435,13 @@ public class SettingsActivity extends AbstractSettingsActivityV2 {
addListenerOnSpinnerDeviceSelection(selectionListSpinner);
Prefs prefs1 = GBApplication.getPrefs();
String packageName = prefs1.getString("opentracks_packagename", "de.dennisguse.opentracks");
// Set the spinner to the selected package name by default
for (int i = 0; i < appListArray.length; i++) {
if (appListArray[i].equals(packageName)) {
selectionListSpinner.setSelection(i);
break;
}
}
fitnessAppEditText = new EditText(requireContext());
fitnessAppEditText.setText(packageName);
innerLayout.addView(fitnessAppEditText);
@ -445,20 +452,13 @@ public class SettingsActivity extends AbstractSettingsActivityV2 {
.setCancelable(true)
.setTitle(R.string.pref_title_opentracks_packagename)
.setView(outerLayout)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
SharedPreferences.Editor editor = GBApplication.getPrefs().getPreferences().edit();
editor.putString("opentracks_packagename", fitnessAppEditText.getText().toString());
editor.apply();
editor.commit();
}
})
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
.setPositiveButton(R.string.ok, (dialog, which) -> {
SharedPreferences.Editor editor = GBApplication.getPrefs().getPreferences().edit();
editor.putString("opentracks_packagename", fitnessAppEditText.getText().toString());
editor.apply();
editor.commit();
})
.setNegativeButton(R.string.Cancel, (dialog, which) -> {})
.show();
return false;
});