// SPDX-License-Identifier: AGPL-3.0-or-later using System; using Android.App; using Android.Content; using Android.OS; using Android.Support.Design.Widget; using Android.Support.V7.App; using Android.Widget; using Npgsql; namespace phms { using R = Resource; [Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)] public class MainActivity : AppCompatActivity { private const string DatabaseUriPref = "db_uri"; protected override void OnCreate(Bundle? savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); var prefs = GetPreferences(FileCreationMode.Private) ?? throw new Exception("Couldn't GetPreferences."); var databaseUri = FindViewById(R.Id.databaseUri) ?? throw new Exception("Couldn't FindViewById."); databaseUri.Text = prefs.GetString(DatabaseUriPref, ""); databaseUri.AfterTextChanged += (sender, e) => { using var prefsEditor = prefs.Edit() ?? throw new Exception("Couldn't Edit preferences."); var newValue = databaseUri.Text; prefsEditor.PutString(DatabaseUriPref, newValue); prefsEditor.Apply(); }; var connect = FindViewById