Merge pull request #36 from ThePlayground/androidui
Provide a secondary selection for the base path to games
This commit is contained in:
commit
435567b7c1
|
@ -30,7 +30,6 @@
|
|||
android:ems="10"
|
||||
android:inputType="textPersonName" >
|
||||
|
||||
<requestFocus />
|
||||
</EditText>
|
||||
|
||||
<Button
|
||||
|
@ -49,11 +48,11 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/browser_path" />
|
||||
android:text="@string/games_path" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -64,18 +63,18 @@
|
|||
|
||||
<EditText
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/browse_path"
|
||||
android:id="@+id/game_path"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:inputType="textPersonName" >
|
||||
|
||||
|
||||
<requestFocus />
|
||||
</EditText>
|
||||
|
||||
<Button
|
||||
|
||||
android:id="@+id/browse_main_path"
|
||||
android:id="@+id/browse_game_path"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Browse" />
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
<string name="title_activity_main">reicast</string>
|
||||
|
||||
<string name="system_path">System Path (location of dc_boot.bin/dc_flash.bin)</string>
|
||||
<string name="browser_path">Default Browser Path</string>
|
||||
<string name="browser_path">Default System Path</string>
|
||||
|
||||
<string name="games_path">Storage Path (location of .gid .cdi or .cdh images)</string>
|
||||
<string name="game_path">Default Game Storage</string>
|
||||
|
||||
<string name="games_listing">Available Dreamcast Games</string>
|
||||
|
||||
|
|
|
@ -52,11 +52,13 @@ public class FileBrowser extends Fragment {
|
|||
Drawable orig_bg;
|
||||
Activity parentActivity;
|
||||
boolean ImgBrowse;
|
||||
private boolean games;
|
||||
OnItemSelectedListener mCallback;
|
||||
|
||||
private SharedPreferences mPrefs;
|
||||
private File sdcard = Environment.getExternalStorageDirectory();
|
||||
private String home_directory = sdcard + "/dc";
|
||||
private String game_directory = sdcard + "/";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -64,12 +66,19 @@ public class FileBrowser extends Fragment {
|
|||
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
home_directory = mPrefs.getString("home_directory", home_directory);
|
||||
game_directory = mPrefs.getString("game_directory", game_directory);
|
||||
|
||||
Bundle b = getArguments();
|
||||
if (b != null) {
|
||||
ImgBrowse = b.getBoolean("ImgBrowse", true);
|
||||
if (b.getString("browse_entry", null) != null) {
|
||||
home_directory = b.getString("browse_entry");
|
||||
if (games = b.getBoolean("games_entry", false)) {
|
||||
if (b.getString("path_entry", null) != null) {
|
||||
home_directory = b.getString("path_entry");
|
||||
}
|
||||
} else {
|
||||
if (b.getString("path_entry", null) != null) {
|
||||
game_directory = b.getString("path_entry");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +170,7 @@ public class FileBrowser extends Fragment {
|
|||
if (!ImgBrowse) {
|
||||
navigate(sdcard);
|
||||
} else {
|
||||
generate(ExternalFiles(sdcard));
|
||||
generate(ExternalFiles(new File(game_directory)));
|
||||
}
|
||||
|
||||
File bios = new File(home_directory, "data/dc_boot.bin");
|
||||
|
@ -522,17 +531,24 @@ public class FileBrowser extends Fragment {
|
|||
.getAbsolutePath())));
|
||||
vib.vibrate(250);
|
||||
|
||||
home_directory = root_sd.getAbsolutePath();
|
||||
mPrefs.edit()
|
||||
.putString("home_directory",
|
||||
home_directory).commit();
|
||||
File data_directory = new File(home_directory,
|
||||
"data");
|
||||
if (!data_directory.exists()
|
||||
|| !data_directory.isDirectory()) {
|
||||
data_directory.mkdirs();
|
||||
if (games) {
|
||||
game_directory = root_sd.getAbsolutePath();
|
||||
mPrefs.edit()
|
||||
.putString("game_directory",
|
||||
game_directory).commit();
|
||||
} else {
|
||||
home_directory = root_sd.getAbsolutePath();
|
||||
mPrefs.edit()
|
||||
.putString("home_directory",
|
||||
home_directory).commit();
|
||||
File data_directory = new File(home_directory,
|
||||
"data");
|
||||
if (!data_directory.exists()
|
||||
|| !data_directory.isDirectory()) {
|
||||
data_directory.mkdirs();
|
||||
}
|
||||
JNIdc.config(home_directory);
|
||||
}
|
||||
JNIdc.config(home_directory);
|
||||
|
||||
} else if (ImgBrowse) {
|
||||
vib.vibrate(50);
|
||||
|
|
|
@ -165,11 +165,12 @@ public class MainActivity extends FragmentActivity implements
|
|||
return;
|
||||
}
|
||||
|
||||
public void onMainBrowseSelected(String browse_entry){
|
||||
public void onMainBrowseSelected(String path_entry, boolean games){
|
||||
FileBrowser firstFragment = new FileBrowser();
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("ImgBrowse", false);
|
||||
args.putString("browse_entry", browse_entry);
|
||||
args.putString("browse_entry", path_entry);
|
||||
args.putBoolean("games_entry", games);
|
||||
// specify ImgBrowse option. true = images, false = folders only
|
||||
firstFragment.setArguments(args);
|
||||
// In case this activity was started with special instructions from
|
||||
|
|
|
@ -23,64 +23,87 @@ public class OptionsFragment extends Fragment{
|
|||
|
||||
Activity parentActivity;
|
||||
Button mainBrowse;
|
||||
Button gameBrowse;
|
||||
Button mainLocale;
|
||||
OnClickListener mCallback;
|
||||
|
||||
private SharedPreferences mPrefs;
|
||||
private File sdcard = Environment.getExternalStorageDirectory();
|
||||
private String home_directory = sdcard + "/dc";
|
||||
private String browse_entry = home_directory;
|
||||
private String game_directory = sdcard + "/";
|
||||
private String games_entry = game_directory;
|
||||
|
||||
// Container Activity must implement this interface
|
||||
public interface OnClickListener {
|
||||
public void onMainBrowseSelected(String browse_entry);
|
||||
}
|
||||
// Container Activity must implement this interface
|
||||
public interface OnClickListener {
|
||||
public void onMainBrowseSelected(String path_entry, boolean games);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
|
||||
// This makes sure that the container activity has implemented
|
||||
// the callback interface. If not, it throws an exception
|
||||
try {
|
||||
mCallback = (OnClickListener) activity;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(activity.toString()
|
||||
+ " must implement OnClickListener");
|
||||
}
|
||||
// This makes sure that the container activity has implemented
|
||||
// the callback interface. If not, it throws an exception
|
||||
try {
|
||||
mCallback = (OnClickListener) activity;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(activity.toString()
|
||||
+ " must implement OnClickListener");
|
||||
}
|
||||
|
||||
int joys[] =InputDevice.getDeviceIds();
|
||||
for(int i = 0;i<joys.length; i++){
|
||||
Log.d("reidc", "InputDevice ID: "+joys[i]);
|
||||
Log.d("reidc", "InputDevice Name: "+ InputDevice.getDevice(joys[i]).getName());
|
||||
}
|
||||
}
|
||||
int joys[] = InputDevice.getDeviceIds();
|
||||
for (int i = 0; i < joys.length; i++) {
|
||||
Log.d("reidc", "InputDevice ID: " + joys[i]);
|
||||
Log.d("reidc", "InputDevice Name: "
|
||||
+ InputDevice.getDevice(joys[i]).getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.options_fragment, container, false);
|
||||
}
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.options_fragment, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState){
|
||||
//setContentView(R.layout.activity_main);
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
// setContentView(R.layout.activity_main);
|
||||
|
||||
parentActivity = getActivity();
|
||||
mainBrowse = (Button)getView().findViewById(R.id.browse_main_path);
|
||||
parentActivity = getActivity();
|
||||
mainBrowse = (Button) getView().findViewById(R.id.browse_main_path);
|
||||
|
||||
final EditText editBrowse = (EditText)getView().findViewById(R.id.main_path);
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
home_directory = mPrefs.getString("home_directory", home_directory);
|
||||
editBrowse.setText(home_directory);
|
||||
final EditText editBrowse = (EditText) getView().findViewById(
|
||||
R.id.main_path);
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
home_directory = mPrefs.getString("home_directory", home_directory);
|
||||
editBrowse.setText(home_directory);
|
||||
|
||||
mainBrowse.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
if (editBrowse.getText() != null) {
|
||||
browse_entry = editBrowse.getText().toString();
|
||||
}
|
||||
mCallback.onMainBrowseSelected(browse_entry);
|
||||
}
|
||||
});
|
||||
}
|
||||
mainBrowse.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
if (editBrowse.getText() != null) {
|
||||
browse_entry = editBrowse.getText().toString();
|
||||
}
|
||||
mCallback.onMainBrowseSelected(browse_entry, false);
|
||||
}
|
||||
});
|
||||
|
||||
gameBrowse = (Button) getView().findViewById(R.id.browse_game_path);
|
||||
|
||||
final EditText editGames = (EditText) getView().findViewById(
|
||||
R.id.game_path);
|
||||
game_directory = mPrefs.getString("game_directory", game_directory);
|
||||
editGames.setText(game_directory);
|
||||
|
||||
gameBrowse.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
if (editBrowse.getText() != null) {
|
||||
games_entry = editGames.getText().toString();
|
||||
}
|
||||
mCallback.onMainBrowseSelected(games_entry, true);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue