2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-23 02:15:55 +01:00

Implement Immediate Mode(sticky) on 4.4 or higher

This commit is contained in:
a1batross 2016-08-05 19:17:03 +06:00
parent e75f120cf7
commit 8133cd9d01
6 changed files with 77 additions and 33 deletions

View File

@ -1,10 +1,10 @@
#!/bin/sh
ndk-build NDK_TOOLCHAIN_VERSION=4.8 NDK_DEBUG=0 V=0 XASH_SDL=1 -j 8 APP_CFLAGS="-w -Wl,--no-undefined" APP_LDFLAGS="-Wl,--no-undefined"
ndk-build NDK_TOOLCHAIN_VERSION=4.8 NDK_DEBUG=0 V=0 XASH_SDL=0 -j 8 APP_CFLAGS="-w -Wl,--no-undefined" APP_LDFLAGS="-Wl,--no-undefined"
sh gen-version.sh default-release
rm assets/extras.pak 2>/dev/null
python2 makepak.py xash-extras assets/extras.pak
ant release
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../myks.keystore bin/xashdroid-release-unsigned.apk xashdroid
rm bin/xashdroid-release.apk
/home/a1ba/.android/android-sdk-linux/build-tools/22.0.1/zipalign 4 bin/xashdroid-release-unsigned.apk bin/xashdroid-release.apk
#/home/a1ba/.android/android-sdk-linux/build-tools/22.0.1/zipalign 4 bin/xashdroid-release-unsigned.apk bin/xashdroid-release.apk

View File

@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-13
target=android-19

View File

@ -254,6 +254,15 @@
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:text="@string/update_to_beta" />
<CheckBox
android:id="@+id/immersive_mode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:text="@string/immersive_mode" />
<TextView
android:id="@+id/textView7"
android:layout_marginBottom="10dp"

View File

@ -56,4 +56,5 @@
<string name="cancel">Cancel</string>
<string name="no_updates">No updates was found</string>
<string name="checking_updates">Working...</string>
<string name="immersive_mode">Enable Immersive Mode(fullscreen, KitKat or higher)</string>
</resources>

View File

@ -13,6 +13,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.content.Intent;
import android.content.ComponentName;
@ -63,6 +64,7 @@ public class LauncherActivity extends Activity {
static ToggleButton resizeWorkaround;
static CheckBox checkUpdates;
static CheckBox updateToBeta;
static CheckBox immersiveMode;
static SharedPreferences mPref;
static Spinner pixelSpinner;
static TextView tvResPath;
@ -82,7 +84,9 @@ public class LauncherActivity extends Activity {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//super.setTheme( 0x01030005 );
if ( sdk >= 21 )
{
super.setTheme( 0x01030224 );
}
setContentView(R.layout.activity_launcher);
@ -101,14 +105,15 @@ public class LauncherActivity extends Activity {
tabHost.addTab(tabSpec);
mPref = getSharedPreferences("engine", 0);
cmdArgs = (EditText)findViewById(R.id.cmdArgs);
cmdArgs = (EditText) findViewById(R.id.cmdArgs);
useVolume = (ToggleButton) findViewById( R.id.useVolume );
resPath = (EditText) findViewById( R.id.cmdPath );
checkUpdates = (CheckBox)findViewById(R.id.check_updates);
updateToBeta = (CheckBox)findViewById(R.id.check_betas);
pixelSpinner = (Spinner) findViewById(R.id.pixelSpinner);
checkUpdates = (CheckBox)findViewById( R.id.check_updates );
updateToBeta = (CheckBox)findViewById( R.id.check_betas );
pixelSpinner = (Spinner) findViewById( R.id.pixelSpinner );
resizeWorkaround = (ToggleButton) findViewById( R.id.enableResizeWorkaround );
tvResPath = (TextView) findViewById( R.id.textView_path );
immersiveMode = (CheckBox) findViewById( R.id.immersive_mode );
final String[] list = {
"32 bit (RGBA8888)",
@ -121,31 +126,6 @@ public class LauncherActivity extends Activity {
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, list);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
pixelSpinner.setAdapter(adapter);
Button selectFolderButton = ( Button ) findViewById( R.id.button_select );
selectFolderButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
selectFolder(v);
}
});
((Button)findViewById( R.id.button_launch )).setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
startXash(v);
}
});
((Button)findViewById( R.id.button_shortcut )).setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
createShortcut(v);
}
});
((Button)findViewById( R.id.button_about )).setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
aboutXash(v);
}
});
useVolume.setChecked(mPref.getBoolean("usevolume",true));
checkUpdates.setChecked(mPref.getBoolean("check_updates",true));
updateToBeta.setChecked(mPref.getBoolean("check_betas", false));
@ -154,6 +134,15 @@ public class LauncherActivity extends Activity {
pixelSpinner.setSelection(mPref.getInt("pixelformat", 0));
resizeWorkaround.setChecked(mPref.getBoolean("enableResizeWorkaround", true));
if( sdk >= 19 )
{
immersiveMode.setChecked(mPref.getBoolean("immersive_mode", true));
}
else
{
immersiveMode.setVisibility(View.GONE); // not available
}
resPath.setOnFocusChangeListener( new View.OnFocusChangeListener()
{
@Override
@ -188,6 +177,10 @@ public class LauncherActivity extends Activity {
editor.putInt("pixelformat", pixelSpinner.getSelectedItemPosition());
editor.putBoolean("enableResizeWorkaround",resizeWorkaround.isChecked());
editor.putBoolean("check_updates", checkUpdates.isChecked());
if( sdk >= 19 )
editor.putBoolean("immersive_mode", immersiveMode.isChecked());
else
editor.putBoolean("immersive_mode", false); // just in case...
editor.commit();
startActivity(intent);
}

View File

@ -57,6 +57,8 @@ public class XashActivity extends Activity {
// Preferences
public static SharedPreferences mPref = null;
private static boolean mUseVolume;
private static boolean mEnableImmersive;
private static View mDecorView;
// Audio
private static Thread mAudioThread;
@ -68,6 +70,7 @@ public class XashActivity extends Activity {
}
// Setup
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.v(TAG, "onCreate()");
super.onCreate(savedInstanceState);
@ -153,18 +156,41 @@ public class XashActivity extends Activity {
mUseVolume = mPref.getBoolean("usevolume", false);
if( mPref.getBoolean("enableResizeWorkaround", true) )
AndroidBug5497Workaround.assistActivity(this);
// Immersive Mode is available only at >KitKat
mEnableImmersive = (sdk >= 19 && mPref.getBoolean("immersive_mode", true));
mDecorView = getWindow().getDecorView();
}
// Events
@Override
protected void onPause() {
Log.v(TAG, "onPause()");
super.onPause();
}
@Override
protected void onResume() {
Log.v(TAG, "onResume()");
super.onResume();
}
@Override
public void onWindowFocusChanged(boolean hasFocus)
{
super.onWindowFocusChanged(hasFocus);
if( mEnableImmersive && hasFocus )
{
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
public static native int nativeInit(Object arguments);
public static native void nativeQuit();
@ -206,6 +232,11 @@ public class XashActivity extends Activity {
public static void toggleEGL(int toggle) {
mSurface.toggleEGL(toggle);
}
public static boolean deleteGLContext() {
mSurface.ShutdownGL();
return true;
}
public static Context getContext() {
return mSingleton;
@ -539,7 +570,6 @@ View.OnKeyListener {
// EGL functions
public boolean InitGL() {
try
{
EGL10 egl = (EGL10)EGLContext.getEGL();
@ -664,6 +694,17 @@ View.OnKeyListener {
mEGLSurface = null;
}
}
public void ShutdownGL()
{
mEGL.eglDestroyContext(mEGLDisplay, mEGLContext);
mEGLContext = null;
mEGL.eglDestroySurface(mEGLDisplay, mEGLSurface);
mEGLSurface = null;
mEGL.eglTerminate(mEGLDisplay);
mEGLDisplay = null;
}
@Override