Make displaying game details in launcher a preference

This commit is contained in:
TwistedUmbrella 2014-04-14 20:29:32 -04:00
parent 4c965b883c
commit 5b94408a63
5 changed files with 64 additions and 5 deletions

View File

@ -78,6 +78,41 @@
android:text="Browse" />
</LinearLayout>
</LinearLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:stretchColumns="*" >
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/details_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_details" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<de.ankri.views.Switch
android:id="@+id/details_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>

View File

@ -23,6 +23,7 @@
<string name="optimization_opts">Optimization and Debugging Options</string>
<string name="experimental_opts">Experimental (May cause widespread panic)</string>
<string name="select_details">Enable Game Details</string>
<string name="select_native">Enable Native Interface</string>
<string name="select_dynarec">Dynarec Options</string>
<string name="select_unstable">Unstable Optimisations</string>

View File

@ -321,13 +321,19 @@ public class FileBrowser extends Fragment {
new OnClickListener() {
public void onClick(View view) {
vib.vibrate(50);
String title = "";
if (name.contains("[")) {
title = name.substring(0, name.lastIndexOf("["));
if (mPrefs.getBoolean(Config.pref_gamedetails, true)) {
String title = "";
if (name.contains("[")) {
title = name.substring(0, name.lastIndexOf("["));
} else {
title = name.substring(0, name.lastIndexOf("."));
}
displayDetails(game_index + title.replace(" ", "+"), game);
} else {
title = name.substring(0, name.lastIndexOf("."));
mCallback.onGameSelected(game != null ? Uri
.fromFile(game) : Uri.EMPTY);
vib.vibrate(250);
}
displayDetails(game_index + title.replace(" ", "+"), game);
}
});

View File

@ -16,6 +16,7 @@ public class Config {
public static final String pref_home = "home_directory";
public static final String pref_games = "game_directory";
public static final String pref_gamedetails = "game_details";
public static final String pref_nativeact = "enable_native";
public static final String pref_dynarecopt = "dynarec_opt";
public static final String pref_unstable = "unstable_opt";

View File

@ -14,11 +14,15 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.Toast;
import com.reicast.emulator.R;
import de.ankri.views.Switch;
public class OptionsFragment extends Fragment {
private Button mainBrowse;
@ -99,6 +103,18 @@ public class OptionsFragment extends Fragment {
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
});
OnCheckedChangeListener details_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_gamedetails, isChecked).commit();
}
};
Switch details_opt = (Switch) getView().findViewById(
R.id.details_option);
details_opt.setChecked(mPrefs.getBoolean(Config.pref_gamedetails, true));
details_opt.setOnCheckedChangeListener(details_options);
gameBrowse = (Button) getView().findViewById(R.id.browse_game_path);