From 0aa95a320b270126dc9999ea60a43280674c3fe7 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 27 Apr 2016 18:55:40 +0100 Subject: [PATCH] Add hint on how to enable mods --- .../minetestmodmanager/ModListActivity.java | 32 +++++++++++++----- .../manager/ModManager.java | 10 ++++++ app/src/main/res/layout/mod_list.xml | 33 +++++++++++++++++++ app/src/main/res/values/strings.xml | 3 ++ 4 files changed, 70 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/rubenwardy/minetestmodmanager/ModListActivity.java b/app/src/main/java/com/rubenwardy/minetestmodmanager/ModListActivity.java index d049ad4..39119ad 100644 --- a/app/src/main/java/com/rubenwardy/minetestmodmanager/ModListActivity.java +++ b/app/src/main/java/com/rubenwardy/minetestmodmanager/ModListActivity.java @@ -153,6 +153,20 @@ public void onClick(@NonNull View v) { } }); + // Set no callback + TextView help_query_close = (TextView) findViewById(R.id.help_config_close); + assert help_query_close != null; + help_query_close.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(@NonNull View v) { + SharedPreferences settings = getSharedPreferences(DisclaimerActivity.PREFS_NAME, 0); + SharedPreferences.Editor editor = settings.edit(); + editor.putBoolean("shown_help_config", true); + editor.apply(); + findViewById(R.id.help_config).setVisibility(View.GONE); + } + }); + if (findViewById(R.id.mod_detail_container) != null) { isTwoPane = true; } @@ -228,21 +242,23 @@ protected void onResume() { checkChanges(list); } + SharedPreferences settings = getSharedPreferences(DisclaimerActivity.PREFS_NAME, 0); + assert settings != null; + // Check whether to show rate me boolean enabled = BuildConfig.ENABLE_RATE_ME; if (enabled) { - Log.e("ListV", "Rateme enabled!"); - SharedPreferences settings = getSharedPreferences(DisclaimerActivity.PREFS_NAME, 0); - assert settings != null; boolean dismissed = settings.getBoolean("shown_rate_me", false); int installs = settings.getInt("installs_so_far", 0); - final View rate_me = findViewById(R.id.rate_me); - assert rate_me != null; if (!dismissed && installs > 5) { - rate_me.setVisibility(View.VISIBLE); + findViewById(R.id.rate_me).setVisibility(View.VISIBLE); } - } else { - Log.e("ListV", "Rateme disabled!"); + } + + // Check whether to show hint + boolean shown_help_config = settings.getBoolean("shown_help_config", false); + if (!shown_help_config && modman.getNumberOfInstalledMods() > 0) { + findViewById(R.id.help_config).setVisibility(View.VISIBLE); } } diff --git a/app/src/main/java/com/rubenwardy/minetestmodmanager/manager/ModManager.java b/app/src/main/java/com/rubenwardy/minetestmodmanager/manager/ModManager.java index 58a6161..f47dd09 100644 --- a/app/src/main/java/com/rubenwardy/minetestmodmanager/manager/ModManager.java +++ b/app/src/main/java/com/rubenwardy/minetestmodmanager/manager/ModManager.java @@ -58,6 +58,16 @@ public String getInstallDir() { return null; } + public int getNumberOfInstalledMods() { + int count = 0; + for (ModList list : lists_map.values()) { + if (list.type == ModList.ModListType.EMLT_PATH) { + count += list.mods.size(); + } + } + return count; + } + @MainThread public void installModAsync(Context context, @NonNull Mod mod, @NonNull File zip, String path) { ModInstallService.startActionInstall(context, srr, mod.name, mod.author, zip, path); diff --git a/app/src/main/res/layout/mod_list.xml b/app/src/main/res/layout/mod_list.xml index 7fcbb26..d421dfc 100644 --- a/app/src/main/res/layout/mod_list.xml +++ b/app/src/main/res/layout/mod_list.xml @@ -60,6 +60,39 @@ android:text="@string/rate_txt" /> + + + + + + + Rate No + + Enable a mod by clicking the world icon. + Installing mod… Installed %1$s.