Skip to content

Commit

Permalink
Add hint on how to enable mods
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Apr 27, 2016
1 parent deea8e3 commit 0aa95a3
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/res/layout/mod_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,39 @@
android:text="@string/rate_txt" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/help_config"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#ccc"
android:visibility="gone">

<TextView
android:id="@+id/help_config_close"
android:layout_width="wrap_content"
android:gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/dialog_close"
android:singleLine="true"
android:padding="10dp"
android:textAllCaps="true"
android:textColor="@color/colorAccent"
android:textSize="16sp"
android:textStyle="bold"
android:clickable="true"
android:focusable="true" />

<TextView
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@id/help_config_close"
android:text="@string/help_config" />
</RelativeLayout>

<android.support.v7.widget.RecyclerView
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<string name="rate_yes">Rate</string>
<string name="rate_no">No</string>

<!-- Help -->
<string name="help_config">Enable a mod by clicking the world icon.</string>

<!-- Mod Events -->
<string name="installing_mod">Installing mod…</string>
<string name="installed_mod">Installed %1$s.</string>
Expand Down

0 comments on commit 0aa95a3

Please sign in to comment.