Merge pull request #557 from reicast/loungekatt
Fancy toast, Forgiving BIOS directory selection
This commit is contained in:
commit
dbc6f5a43c
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/toast_layout_root"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="#50000000"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dp" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="5dip"
|
||||
android:layout_marginTop="2dip"
|
||||
android:layout_toRightOf="@+id/ImageView01"
|
||||
android:includeFontPadding="false"
|
||||
android:lineSpacingMultiplier="1.0"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18sp"
|
||||
android:typeface="sans" />
|
||||
|
||||
</LinearLayout>
|
|
@ -7,6 +7,7 @@
|
|||
<string name="games_path">Storage Path (location of *.gdi, *.chd or *.cdi images)</string>
|
||||
<string name="game_path">Default Game Storage</string>
|
||||
<string name="config_home">Please configure a home directory.</string>
|
||||
<string name="config_data">Please move BIOS to %1$s/data/</string>
|
||||
<string name="config_game">Please configure a game directory.</string>
|
||||
<string name="unsupported">Unsupported kernel version!</string>
|
||||
<string name="locate">Locate</string>
|
||||
|
|
|
@ -189,8 +189,9 @@ public class FileBrowser extends Fragment {
|
|||
|
||||
File home = new File(mPrefs.getString(Config.pref_home, home_directory));
|
||||
if (!home.exists() || !home.isDirectory()) {
|
||||
Toast.makeText(getActivity(), R.string.config_home,
|
||||
Toast.LENGTH_LONG).show();
|
||||
MainActivity.showToastMessage(getActivity(),
|
||||
getActivity().getString(R.string.config_home),
|
||||
Toast.LENGTH_LONG);
|
||||
}
|
||||
|
||||
if (!ImgBrowse && !games) {
|
||||
|
@ -401,6 +402,11 @@ public class FileBrowser extends Fragment {
|
|||
.fromFile(game) : Uri.EMPTY);
|
||||
home_directory = game.getAbsolutePath().substring(0,
|
||||
game.getAbsolutePath().lastIndexOf(File.separator));
|
||||
if (!DataDirectoryBIOS()) {
|
||||
MainActivity.showToastMessage(getActivity(),
|
||||
getActivity().getString(R.string.config_data, home_directory),
|
||||
Toast.LENGTH_LONG);
|
||||
}
|
||||
mPrefs.edit().putString("home_directory",
|
||||
home_directory.replace("/data", "")).commit();
|
||||
JNIdc.config(home_directory.replace("/data", ""));
|
||||
|
@ -498,11 +504,10 @@ public class FileBrowser extends Fragment {
|
|||
mPrefs.edit()
|
||||
.putString(Config.pref_home,
|
||||
heading).commit();
|
||||
File data_directory = new File(heading,
|
||||
"data");
|
||||
if (!data_directory.exists()
|
||||
|| !data_directory.isDirectory()) {
|
||||
data_directory.mkdirs();
|
||||
if (!DataDirectoryBIOS()) {
|
||||
MainActivity.showToastMessage(getActivity(),
|
||||
getActivity().getString(R.string.config_data, home_directory),
|
||||
Toast.LENGTH_LONG);
|
||||
}
|
||||
JNIdc.config(heading);
|
||||
}
|
||||
|
@ -529,4 +534,18 @@ public class FileBrowser extends Fragment {
|
|||
}
|
||||
v.invalidate();
|
||||
}
|
||||
|
||||
private boolean DataDirectoryBIOS() {
|
||||
File data_directory = new File(home_directory, "data");
|
||||
if (!data_directory.exists() || !data_directory.isDirectory()) {
|
||||
data_directory.mkdirs();
|
||||
File bios = new File(home_directory, "dc_boot.bin");
|
||||
boolean success = bios.renameTo(new File(home_directory + "/data", "dc_boot.bin"));
|
||||
File flash = new File(home_directory, "dc_flash.bin");
|
||||
success = flash.renameTo(new File(home_directory + "/data", "dc_flash.bin"));
|
||||
return success;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,14 +20,18 @@ import android.os.Bundle;
|
|||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnSystemUiVisibilityChangeListener;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -393,8 +397,7 @@ public class MainActivity extends SlidingFragmentActivity implements
|
|||
|
||||
public void onGameSelected(Uri uri) {
|
||||
if (Config.readOutput("uname -a").equals(getString(R.string.error_kernel))) {
|
||||
Toast.makeText(MainActivity.this, R.string.unsupported,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
MainActivity.showToastMessage(MainActivity.this, getString(R.string.unsupported), Toast.LENGTH_SHORT);
|
||||
}
|
||||
String msg = null;
|
||||
if (!isBiosExisting(MainActivity.this))
|
||||
|
@ -635,4 +638,29 @@ public class MainActivity extends SlidingFragmentActivity implements
|
|||
intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
return list.size() > 0;
|
||||
}
|
||||
|
||||
public static void showToastMessage(Context context, String message,
|
||||
int duration) {
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View layout = inflater.inflate(R.layout.toast_layout, null);
|
||||
|
||||
ImageView image = (ImageView) layout.findViewById(R.id.image);
|
||||
image.setImageResource(R.drawable.ic_notification);
|
||||
TextView text = (TextView) layout.findViewById(R.id.text);
|
||||
text.setText(message);
|
||||
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
WindowManager winman = (WindowManager) context
|
||||
.getSystemService(Context.WINDOW_SERVICE);
|
||||
winman.getDefaultDisplay().getMetrics(metrics);
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
int toastPixels = (int) ((metrics.widthPixels * scale + 0.5f) / 18);
|
||||
|
||||
Toast toast = new Toast(context);
|
||||
toast.setGravity(Gravity.BOTTOM, 0, toastPixels);
|
||||
toast.setDuration(duration);
|
||||
toast.setView(layout);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue