From b99764128aec28d4c30f07371852556d9d31151a Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 16 Apr 2021 22:43:35 +0200 Subject: add menu option to launch ant+ plugin manager --- app/src/main/AndroidManifest.xml | 4 ++- .../java/com/javispedro/rempe/MainActivity.java | 32 ++++++++++++++++++++++ .../com/javispedro/rempe/SettingsActivity.java | 6 ++++ app/src/main/res/menu/menu_main.xml | 4 +++ app/src/main/res/values/strings.xml | 8 +++++- 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cc27544..3e81d66 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,7 +11,9 @@ android:theme="@style/Theme.Rempe"> + android:label="@string/settings_title" + android:parentActivityName=".MainActivity"> + addDevice(device)); + } else if (result == RequestAccessResult.DEPENDENCY_NOT_INSTALLED) { + final String dependency = AntPluginPcc.getMissingDependencyName(); + final String packageName = AntPluginPcc.getMissingDependencyPackageName(); + runOnUiThread(() -> { + showDependencyRequiredMsg(dependency, packageName); + }); } else if (result != RequestAccessResult.USER_CANCELLED) { runOnUiThread(() -> { final String resultText = Device.connectionRequestAccessResultToString(MainActivity.this, result); @@ -193,6 +208,23 @@ public class MainActivity extends AppCompatActivity { } }; + public void showDependencyRequiredMsg(String name, String packageName) { + Log.d(TAG, "showDependencyRequiredMsg for " + name + " (" + packageName + ")"); + new MaterialAlertDialogBuilder(this) + .setTitle(R.string.antplus_required_title) + .setMessage(getString(R.string.antplus_required_msg, name)) + .setPositiveButton(R.string.antplus_required_go_to_store, (dialog, which) -> { + dialog.dismiss(); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("market://details?id=" + packageName)); + startActivity(intent); + }) + .setNeutralButton(R.string.antplus_required_close, (dialog, which) -> { + dialog.dismiss(); + }) + .show(); + } + public void searchForNewDevice() { if (mSearchDevice != null) { mSearchDevice.close(); diff --git a/app/src/main/java/com/javispedro/rempe/SettingsActivity.java b/app/src/main/java/com/javispedro/rempe/SettingsActivity.java index f660c70..d42c493 100644 --- a/app/src/main/java/com/javispedro/rempe/SettingsActivity.java +++ b/app/src/main/java/com/javispedro/rempe/SettingsActivity.java @@ -24,6 +24,12 @@ public class SettingsActivity extends AppCompatActivity { } } + @Override + public boolean onSupportNavigateUp() { + finish(); + return true; + } + public static class SettingsFragment extends PreferenceFragmentCompat { @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index b11af65..c39abfd 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -8,4 +8,8 @@ android:orderInCategory="100" android:title="@string/action_settings" app:showAsAction="never" /> + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index df21b28..3ab9a52 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,6 +1,12 @@ Rempe Settings + ANT+ Plugin Manager + + App required + The following app is required to connect to ANT+ devices:\n\n%s + Go to Store + Close Add device… Cannot connect to device: %1$s @@ -10,7 +16,7 @@ Device Status - dev#%d + ID<%d> %.1f °C -- cgit v1.2.3