Merge pull request #552 from reicast/loungekatt
BIOS Locator and fixes for KitKat Samsung directories
This commit is contained in:
commit
da1a800797
|
@ -11,6 +11,8 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -58,8 +60,8 @@ public class FileBrowser extends Fragment {
|
|||
|
||||
private SharedPreferences mPrefs;
|
||||
private File sdcard = Environment.getExternalStorageDirectory();
|
||||
private String home_directory = sdcard + "/dc";
|
||||
private String game_directory = sdcard + "/dc";
|
||||
private String home_directory = sdcard.getAbsolutePath();
|
||||
private String game_directory = sdcard.getAbsolutePath();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -84,6 +86,42 @@ public class FileBrowser extends Fragment {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public static HashSet<String> getExternalMounts() {
|
||||
final HashSet<String> out = new HashSet<String>();
|
||||
String reg = "(?i).*vold.*(vfat|ntfs|exfat|fat32|ext3|ext4|fuse).*rw.*";
|
||||
String s = "";
|
||||
try {
|
||||
final Process process = new ProcessBuilder().command("mount")
|
||||
.redirectErrorStream(true).start();
|
||||
process.waitFor();
|
||||
final InputStream is = process.getInputStream();
|
||||
final byte[] buffer = new byte[1024];
|
||||
while (is.read(buffer) != -1) {
|
||||
s = s + new String(buffer);
|
||||
}
|
||||
is.close();
|
||||
} catch (final Exception e) {
|
||||
|
||||
}
|
||||
|
||||
final String[] lines = s.split("\n");
|
||||
for (String line : lines) {
|
||||
if (StringUtils.containsIgnoreCase(line, "secure"))
|
||||
continue;
|
||||
if (StringUtils.containsIgnoreCase(line, "asec"))
|
||||
continue;
|
||||
if (line.matches(reg)) {
|
||||
String[] parts = line.split(" ");
|
||||
for (String part : parts) {
|
||||
if (part.startsWith("/"))
|
||||
if (!StringUtils.containsIgnoreCase(part, "vold"))
|
||||
out.add(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// Container Activity must implement this interface
|
||||
public interface OnItemSelectedListener {
|
||||
|
@ -155,12 +193,11 @@ public class FileBrowser extends Fragment {
|
|||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
if (!ImgBrowse) {
|
||||
// navigate(sdcard);
|
||||
if (!ImgBrowse && !games) {
|
||||
LocateGames mLocateGames = new LocateGames(R.array.flash);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
mLocateGames
|
||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, home_directory);
|
||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, home_directory);
|
||||
} else {
|
||||
mLocateGames.execute(home_directory);
|
||||
}
|
||||
|
@ -216,23 +253,39 @@ public class FileBrowser extends Fragment {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(List<File> items) {
|
||||
final LinearLayout list = (LinearLayout) parentActivity.findViewById(R.id.game_list);
|
||||
if (list != null) {
|
||||
list.removeAllViews();
|
||||
}
|
||||
|
||||
String heading = parentActivity.getString(R.string.games_listing);
|
||||
createListHeader(heading, list, array == R.array.images);
|
||||
if (items != null && !items.isEmpty()) {
|
||||
final LinearLayout list = (LinearLayout) parentActivity.findViewById(R.id.game_list);
|
||||
if (list != null) {
|
||||
list.removeAllViews();
|
||||
}
|
||||
|
||||
String heading = parentActivity.getString(R.string.games_listing);
|
||||
createListHeader(heading, list, array == R.array.images);
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
createListItem(list, items.get(i), i, array == R.array.images);
|
||||
}
|
||||
list.invalidate();
|
||||
} else {
|
||||
Toast.makeText(parentActivity, R.string.config_game, Toast.LENGTH_LONG).show();
|
||||
browseStorage();
|
||||
}
|
||||
list.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void browseStorage() {
|
||||
HashSet<String> extStorage = FileBrowser.getExternalMounts();
|
||||
if (extStorage != null && !extStorage.isEmpty()) {
|
||||
for (Iterator<String> sd = extStorage.iterator(); sd.hasNext();) {
|
||||
String sdCardPath = sd.next().replace("mnt/media_rw", "storage");
|
||||
if (!sdCardPath.equals(sdcard.getAbsolutePath())) {
|
||||
if (new File(sdCardPath).canRead()) {
|
||||
navigate(new File(sdCardPath));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
navigate(sdcard);
|
||||
}
|
||||
|
||||
private static final class DirSort implements Comparator<File> {
|
||||
|
||||
|
@ -305,12 +358,8 @@ public class FileBrowser extends Fragment {
|
|||
|
||||
final XMLParser xmlParser = new XMLParser(game, index, mPrefs);
|
||||
xmlParser.setViewParent(parentActivity, childview);
|
||||
xmlParser.execute(game.getName());
|
||||
|
||||
orig_bg = childview.getBackground();
|
||||
|
||||
// vw.findViewById(R.id.childview).setBackgroundColor(0xFFFFFFFF);
|
||||
|
||||
childview.findViewById(R.id.childview).setOnClickListener(
|
||||
new OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
|
@ -374,6 +423,7 @@ public class FileBrowser extends Fragment {
|
|||
}
|
||||
});
|
||||
list.addView(childview);
|
||||
xmlParser.execute(game.getName());
|
||||
}
|
||||
|
||||
void navigate(final File root_sd) {
|
||||
|
|
|
@ -46,7 +46,7 @@ public class MainActivity extends SlidingFragmentActivity implements
|
|||
|
||||
private SharedPreferences mPrefs;
|
||||
private static File sdcard = Environment.getExternalStorageDirectory();
|
||||
public static String home_directory = sdcard + "/dc";
|
||||
public static String home_directory = sdcard.getAbsolutePath();
|
||||
|
||||
private TextView menuHeading;
|
||||
private boolean hasAndroidMarket = false;
|
||||
|
|
|
@ -5,6 +5,8 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -23,14 +25,15 @@ import android.widget.AdapterView.OnItemSelectedListener;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Toast;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.reicast.emulator.FileBrowser;
|
||||
import com.reicast.emulator.R;
|
||||
import com.reicast.emulator.emu.GL2JNIView;
|
||||
import com.reicast.emulator.emu.JNIdc;
|
||||
|
@ -47,8 +50,8 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
private SharedPreferences mPrefs;
|
||||
private File sdcard = Environment.getExternalStorageDirectory();
|
||||
private String home_directory = sdcard + "/dc";
|
||||
private String game_directory = sdcard + "/dc";
|
||||
private String home_directory = sdcard.getAbsolutePath();
|
||||
private String game_directory = sdcard.getAbsolutePath();
|
||||
|
||||
private String[] codes;
|
||||
|
||||
|
@ -81,12 +84,20 @@ public class OptionsFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
// setContentView(R.layout.activity_main);
|
||||
|
||||
//parentActivity = getActivity();
|
||||
|
||||
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
|
||||
// Specialized handler for devices with an extSdCard mount for external
|
||||
HashSet<String> extStorage = FileBrowser.getExternalMounts();
|
||||
if (extStorage != null && !extStorage.isEmpty()) {
|
||||
for (Iterator<String> sd = extStorage.iterator(); sd.hasNext();) {
|
||||
String sdCardPath = sd.next().replace("mnt/media_rw", "storage");
|
||||
if (!sdCardPath.equals(sdcard.getAbsolutePath())) {
|
||||
game_directory = sdCardPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
home_directory = mPrefs.getString(Config.pref_home, home_directory);
|
||||
config = new Config(getActivity());
|
||||
config.getConfigurationPrefs();
|
||||
|
|
Loading…
Reference in New Issue