mirror of
https://github.com/jamessanford/kegs.git
synced 2024-06-01 22:41:31 +00:00
Use ActionBarSherlock and the Support Library to support API 10 and later.
This commit is contained in:
parent
8d72b4b84d
commit
2d2ff27518
|
@ -3,7 +3,7 @@
|
|||
package="com.froop.app.kegs"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="16" />
|
||||
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="16" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# The ARMv7 is significanly faster due to the use of the hardware FPU
|
||||
APP_ABI := armeabi armeabi-v7a
|
||||
APP_ABI := armeabi armeabi-v7a x86
|
||||
#APP_ABI := armeabi-v7a
|
||||
APP_PLATFORM := android-9
|
||||
|
|
|
@ -112,6 +112,11 @@ void child_sound_init_android() {
|
|||
g_audio_rate = 44100;
|
||||
set_audio_rate(g_audio_rate);
|
||||
|
||||
if(engineObject != NULL) {
|
||||
// Already active.
|
||||
return;
|
||||
}
|
||||
|
||||
SLresult result;
|
||||
result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
|
||||
assert(SL_RESULT_SUCCESS == result);
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
target=android-16
|
||||
android.library.reference.1=ActionBarSherlock/library
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
|
||||
android:paddingRight="?android:attr/listPreferredItemPaddingRight" >
|
||||
|
||||
<ImageView android:id="@+id/icon"
|
||||
android:layout_width="64dip"
|
||||
android:layout_height="64dip"
|
||||
android:visibility="gone"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingLeft="8dip"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView android:id="@+id/cached"
|
||||
android:layout_width="32dip"
|
||||
android:layout_height="32dip"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:scaleType="fitCenter"
|
||||
android:paddingRight="?android:attr/listPreferredItemPaddingRight" />
|
||||
|
||||
</FrameLayout>
|
|
@ -3,7 +3,7 @@
|
|||
<!-- For API level 11 and later, use a parent of Theme.Holo. -->
|
||||
|
||||
<resources>
|
||||
<style name="Theme.BlackBackground" parent="android:Theme.Holo">
|
||||
<style name="Theme.BlackBackground" parent="Theme.Sherlock">
|
||||
<item name="android:windowBackground">@drawable/screen_background_black</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
<string name="rom_error">Unable to obtain ROM. Find ROM.01 or ROM.03 and put it in /Android/data/com.froop.app.kegs/files/ on your SD Card.</string>
|
||||
|
||||
<string-array name="rom_choices">
|
||||
<item>I don\'t own a GS</item>
|
||||
<item>I have a ROM 01</item>
|
||||
<item>I have a ROM 03</item>
|
||||
</string-array>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<resources>
|
||||
<style name="Theme.BlackBackground" parent="android:Theme">
|
||||
<style name="Theme.BlackBackground" parent="Theme.Sherlock">
|
||||
<item name="android:windowBackground">@drawable/screen_background_black</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package com.froop.app.kegs;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.ProgressDialog;
|
||||
import android.util.Log;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
|
|
|
@ -137,6 +137,6 @@ class BitmapSize {
|
|||
mCropped = crop;
|
||||
mScaleFactorX = scaleX;
|
||||
mScaleFactorY = scaleY;
|
||||
Log.w("kegs", "using scale " + scaleX + ":" + scaleY + " crop=" + crop + " from screen " + width + "x" + height);
|
||||
Log.i("kegs", "using scale " + scaleX + ":" + scaleY + " crop=" + crop + " from screen " + width + "x" + height);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package com.froop.app.kegs;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -13,8 +11,6 @@ import android.os.Bundle;
|
|||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -22,7 +18,13 @@ import android.view.View.OnTouchListener;
|
|||
import android.widget.Button;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
public class KegsMain extends Activity implements KegsKeyboard.StickyReset, AssetImages.AssetsReady {
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.app.SherlockDialogFragment;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.StickyReset, AssetImages.AssetsReady {
|
||||
private static final String FRAGMENT_ROM = "rom";
|
||||
private static final String FRAGMENT_DOWNLOAD = "download";
|
||||
private static final String FRAGMENT_ERROR = "error";
|
||||
|
@ -101,14 +103,14 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
|
|||
}
|
||||
|
||||
private void loadConfigWhenReady(final String configfile) {
|
||||
final AssetFragment frag = (AssetFragment)getFragmentManager().findFragmentByTag(FRAGMENT_ASSET);
|
||||
final AssetFragment frag = (AssetFragment)getSupportFragmentManager().findFragmentByTag(FRAGMENT_ASSET);
|
||||
|
||||
if (!getThread().nowWaitingForPowerOn() || !mAssetsReady) {
|
||||
if (frag == null && !mAssetsReady) {
|
||||
// Only the asset part will take time, so only show the dialog
|
||||
// when waiting for the asset.
|
||||
final DialogFragment assetProgress = new AssetFragment();
|
||||
assetProgress.show(getFragmentManager(), FRAGMENT_ASSET);
|
||||
final SherlockDialogFragment assetProgress = new AssetFragment();
|
||||
assetProgress.show(getSupportFragmentManager(), FRAGMENT_ASSET);
|
||||
}
|
||||
mKegsView.postDelayed(new Runnable() {
|
||||
public void run() { loadConfigWhenReady(configfile); }
|
||||
|
@ -128,9 +130,13 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
|
|||
}
|
||||
|
||||
protected void getRomFile(String romfile) {
|
||||
final DialogFragment download = new DownloadDialogFragment();
|
||||
download.show(getFragmentManager(), FRAGMENT_DOWNLOAD);
|
||||
new DownloadRom().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, romfile);
|
||||
final SherlockDialogFragment download = new DownloadDialogFragment();
|
||||
download.show(getSupportFragmentManager(), FRAGMENT_DOWNLOAD);
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
new DownloadRom().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, romfile);
|
||||
} else {
|
||||
new DownloadRom().execute(romfile);
|
||||
}
|
||||
}
|
||||
|
||||
class DownloadRom extends AsyncTask<String, Void, Boolean> {
|
||||
|
@ -142,26 +148,26 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
|
|||
mConfigFile.getConfigPath() + "/" + mRomfile);
|
||||
}
|
||||
protected void onPostExecute(Boolean success) {
|
||||
final DialogFragment frag = (DialogFragment)getFragmentManager().findFragmentByTag(FRAGMENT_DOWNLOAD);
|
||||
final SherlockDialogFragment frag = (SherlockDialogFragment)getSupportFragmentManager().findFragmentByTag(FRAGMENT_DOWNLOAD);
|
||||
if (frag != null) {
|
||||
frag.dismiss();
|
||||
}
|
||||
if (!success) {
|
||||
if (!isCancelled()) {
|
||||
final DialogFragment dialog = new ErrorDialogFragment();
|
||||
dialog.show(getFragmentManager(), FRAGMENT_ERROR);
|
||||
final SherlockDialogFragment dialog = new ErrorDialogFragment();
|
||||
dialog.show(getSupportFragmentManager(), FRAGMENT_ERROR);
|
||||
}
|
||||
} else {
|
||||
mConfigFile.defaultConfig();
|
||||
getThread().setReady(true);
|
||||
mKegsView.postDelayed(new Runnable() { public void run() {
|
||||
new DiskImageFragment().show(getFragmentManager(), FRAGMENT_DISKIMAGE);
|
||||
new DiskImageFragment().show(getSupportFragmentManager(), FRAGMENT_DISKIMAGE);
|
||||
} }, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DownloadDialogFragment extends DialogFragment {
|
||||
class DownloadDialogFragment extends SherlockDialogFragment {
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
ProgressDialog dialog = new ProgressDialog(getActivity());
|
||||
|
@ -185,7 +191,7 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
|
|||
}
|
||||
}
|
||||
|
||||
class ErrorDialogFragment extends DialogFragment {
|
||||
class ErrorDialogFragment extends SherlockDialogFragment {
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
|
@ -208,7 +214,7 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
|
|||
}
|
||||
}
|
||||
|
||||
class AssetFragment extends DialogFragment {
|
||||
class AssetFragment extends SherlockDialogFragment {
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
ProgressDialog dialog = new ProgressDialog(getActivity());
|
||||
|
@ -231,7 +237,7 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
|
|||
}
|
||||
|
||||
private void updateActionBar(boolean showActionBar) {
|
||||
final ActionBar actionBar = getActionBar();
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
if (showActionBar) {
|
||||
if (actionBar != null && !actionBar.isShowing()) {
|
||||
actionBar.show();
|
||||
|
@ -302,7 +308,7 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
|
|||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// BUG: no overflow menu on devices with menu button
|
||||
// BUG: when action bar is hidden, menu bar only shows overflow items
|
||||
getMenuInflater().inflate(R.menu.actions, menu);
|
||||
getSupportMenuInflater().inflate(R.menu.actions, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -310,7 +316,7 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
|
|||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
|
||||
// remember to call invalidateOptionsMenu() for this to be run
|
||||
// remember to call supportInvalidateOptionsMenu() for this to be run
|
||||
MenuItem item;
|
||||
item = menu.findItem(R.id.action_joystick);
|
||||
if (item != null) {
|
||||
|
@ -331,14 +337,14 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
|
|||
}
|
||||
return true;
|
||||
} else if (item_id == R.id.action_speed) {
|
||||
new SpeedFragment().show(getFragmentManager(), FRAGMENT_SPEED);
|
||||
new SpeedFragment().show(getSupportFragmentManager(), FRAGMENT_SPEED);
|
||||
return true;
|
||||
} else if (item_id == R.id.action_joystick) {
|
||||
mModeMouse = !mModeMouse;
|
||||
invalidateOptionsMenu(); // update icon
|
||||
supportInvalidateOptionsMenu(); // update icon
|
||||
return true;
|
||||
} else if (item_id == R.id.action_diskimage) {
|
||||
new DiskImageFragment().show(getFragmentManager(), FRAGMENT_DISKIMAGE);
|
||||
new DiskImageFragment().show(getSupportFragmentManager(), FRAGMENT_DISKIMAGE);
|
||||
return true;
|
||||
} else if (item_id == R.id.action_more_keys) {
|
||||
final int vis = areControlsVisible() ? View.GONE : View.VISIBLE;
|
||||
|
@ -408,17 +414,21 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
|
|||
findViewById(R.id.key_down).setOnClickListener(mButtonClick);
|
||||
|
||||
// Make sure local copy of internal disk images exist.
|
||||
new AssetImages(this, mConfigFile).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
new AssetImages(this, mConfigFile).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
} else {
|
||||
new AssetImages(this, mConfigFile).execute();
|
||||
}
|
||||
|
||||
final String romfile = mConfigFile.whichRomFile();
|
||||
if (romfile == null) {
|
||||
final DialogFragment chooseRom = new RomDialogFragment();
|
||||
chooseRom.show(getFragmentManager(), FRAGMENT_ROM);
|
||||
final SherlockDialogFragment chooseRom = new RomDialogFragment();
|
||||
chooseRom.show(getSupportFragmentManager(), FRAGMENT_ROM);
|
||||
} else {
|
||||
mConfigFile.defaultConfig();
|
||||
getThread().setReady(true);
|
||||
mKegsView.postDelayed(new Runnable() { public void run() {
|
||||
new DiskImageFragment().show(getFragmentManager(), FRAGMENT_DISKIMAGE);
|
||||
new DiskImageFragment().show(getSupportFragmentManager(), FRAGMENT_DISKIMAGE);
|
||||
} }, 1000);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,6 +224,6 @@ class KegsRenderer implements GLSurfaceView.Renderer {
|
|||
mCropBorder = bitmapSize.doCropBorder();
|
||||
mScaled = bitmapSize.isScaled();
|
||||
mSizeChange = true;
|
||||
Log.i("kegs", "screen size " + mWidth + "x" + mHeight + " " + mScaleX + ":" + mScaleY + " crop=" + mCropBorder);
|
||||
Log.i("kegs", "screen size " + mWidth + "x" + mHeight + " " + mScaleX + ":" + mScaleY + " crop=" + mCropBorder + " unscaledY=" + mHeightUnscaled);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,13 @@ package com.froop.app.kegs;
|
|||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
public class RomDialogFragment extends DialogFragment {
|
||||
import com.actionbarsherlock.app.SherlockDialogFragment;
|
||||
|
||||
public class RomDialogFragment extends SherlockDialogFragment {
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
|
@ -17,10 +18,8 @@ public class RomDialogFragment extends DialogFragment {
|
|||
public void onClick(DialogInterface dialog, int item) {
|
||||
dismiss();
|
||||
if (item == 0) {
|
||||
((KegsMain)getActivity()).finish();
|
||||
} else if (item == 1) {
|
||||
((KegsMain)getActivity()).getRomFile(ConfigFile.ROM01);
|
||||
} else if (item == 2) {
|
||||
} else if (item == 1) {
|
||||
((KegsMain)getActivity()).getRomFile(ConfigFile.ROM03);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,13 @@ package com.froop.app.kegs;
|
|||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
public class SpeedFragment extends DialogFragment {
|
||||
import com.actionbarsherlock.app.SherlockDialogFragment;
|
||||
|
||||
public class SpeedFragment extends SherlockDialogFragment {
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.froop.app.kegs;
|
|||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.content.Context;
|
||||
|
@ -16,19 +15,18 @@ import android.widget.BaseAdapter;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockDialogFragment;
|
||||
|
||||
public class DiskImageFragment extends DialogFragment {
|
||||
public class DiskImageFragment extends SherlockDialogFragment {
|
||||
private String[] mImages = {
|
||||
"System 6", "X-MAS Demo (FTA)"};
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
DiskImageAdapter items = new DiskImageAdapter(getActivity());
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
|
||||
builder.setTitle(R.string.diskimage_title);
|
||||
builder.setSingleChoiceItems(items, -1,
|
||||
new DialogInterface.OnClickListener() {
|
||||
builder.setItems(mImages, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
dismiss();
|
||||
if (item == 0) {
|
||||
|
@ -41,42 +39,4 @@ public class DiskImageFragment extends DialogFragment {
|
|||
final AlertDialog dialog = builder.create();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public class DiskImageAdapter extends BaseAdapter {
|
||||
private LayoutInflater mInflater;
|
||||
private Bitmap mBitmap;
|
||||
private Bitmap mBitmap2;
|
||||
|
||||
public DiskImageAdapter(Context context) {
|
||||
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon);
|
||||
mBitmap2 = BitmapFactory.decodeResource(context.getResources(), R.drawable.jog_tab_target_green);
|
||||
}
|
||||
|
||||
public Object getItem(int pos) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public long getItemId(int pos) {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return mImages.length;
|
||||
}
|
||||
|
||||
public View getView(int pos, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(
|
||||
R.layout.disk_image_list_item, parent, false);
|
||||
}
|
||||
|
||||
int item = pos; // BUG: this should be getItem(pos)
|
||||
// ((ImageView)convertView.findViewById(R.id.icon)).setImageBitmap(mBitmap);
|
||||
((TextView)convertView.findViewById(android.R.id.text1)).setText(mImages[item]);
|
||||
// If cached, this puts a nice green dot next to the name:
|
||||
// ((ImageView)convertView.findViewById(R.id.cached)).setImageBitmap(mBitmap2);
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user