Refactoring, fix theme
This commit is contained in:
parent
72e3313c30
commit
0d1d899d7c
7 changed files with 196 additions and 182 deletions
|
@ -1,4 +1,4 @@
|
||||||
ANDROID_JAR=../android-14_.jar
|
ANDROID_JAR=../android-24.jar
|
||||||
AAPT=./../aapt
|
AAPT=./../aapt
|
||||||
DX=./../dx
|
DX=./../dx
|
||||||
APKBUILDER=./../apkbuilder
|
APKBUILDER=./../apkbuilder
|
||||||
|
@ -19,7 +19,7 @@ rm assets/extras.pak
|
||||||
python2.7 makepak.py xash-extras assets/extras.pak
|
python2.7 makepak.py xash-extras assets/extras.pak
|
||||||
$AAPT package -m -J gen/ --rename-manifest-package in.celest.xash3d.hl -M AndroidManifest.xml -S test/res -I $ANDROID_JAR
|
$AAPT package -m -J gen/ --rename-manifest-package in.celest.xash3d.hl -M AndroidManifest.xml -S test/res -I $ANDROID_JAR
|
||||||
echo "package in.celest.xash3d.hl;public final class BuildConfig {public final static boolean DEBUG = true;}" > gen/in/celest/xash3d/hl/BuildConfig.java
|
echo "package in.celest.xash3d.hl;public final class BuildConfig {public final static boolean DEBUG = true;}" > gen/in/celest/xash3d/hl/BuildConfig.java
|
||||||
$JAVAC -d bin/classes -s bin/classes -cp $ANDROID_JAR gen/in/celest/xash3d/hl/* src/in/celest/xash3d/*.java
|
$JAVAC -d bin/classes -s bin/classes -cp $ANDROID_JAR gen/in/celest/xash3d/hl/* src/in/celest/xash3d/*.java src/su/xash/fwgslib/*.java
|
||||||
$DX --dex --output=bin/classes.dex bin/classes/
|
$DX --dex --output=bin/classes.dex bin/classes/
|
||||||
$AAPT package -f -M test/AndroidManifest.xml -S test/res -I $ANDROID_JAR -F bin/xash3d.apk.unaligned
|
$AAPT package -f -M test/AndroidManifest.xml -S test/res -I $ANDROID_JAR -F bin/xash3d.apk.unaligned
|
||||||
zip bin/xash3d.apk.unaligned assets/*
|
zip bin/xash3d.apk.unaligned assets/*
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import su.xash.fwgslib.FWGSLib;
|
||||||
|
|
||||||
import in.celest.xash3d.hl.R;
|
import in.celest.xash3d.hl.R;
|
||||||
|
|
||||||
|
@ -59,6 +60,9 @@ public class FPicker extends Activity {
|
||||||
onFileClick(v);
|
onFileClick(v);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
FWGSLib.changeButtonsStyle((ViewGroup)mSelectBtn.getParent());
|
||||||
|
|
||||||
fill(currentDir);
|
fill(currentDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,49 +38,6 @@ public class LauncherActivity extends Activity
|
||||||
|
|
||||||
static int mEngineWidth, mEngineHeight;
|
static int mEngineWidth, mEngineHeight;
|
||||||
|
|
||||||
public static void changeButtonsStyle( ViewGroup parent )
|
|
||||||
{
|
|
||||||
if( sdk >= 21 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
for( int i = parent.getChildCount() - 1; i >= 0; i-- )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
final View child = parent.getChildAt(i);
|
|
||||||
|
|
||||||
if( child == null )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if( child instanceof ViewGroup )
|
|
||||||
{
|
|
||||||
changeButtonsStyle((ViewGroup) child);
|
|
||||||
// DO SOMETHING WITH VIEWGROUP, AFTER CHILDREN HAS BEEN LOOPED
|
|
||||||
}
|
|
||||||
else if( child instanceof Button )
|
|
||||||
{
|
|
||||||
final Button b = (Button)child;
|
|
||||||
final Drawable bg = b.getBackground();
|
|
||||||
if(bg!= null)bg.setAlpha( 96 );
|
|
||||||
b.setTextColor( 0xFFFFFFFF );
|
|
||||||
b.setTextSize( 15f );
|
|
||||||
//b.setText(b.getText().toString().toUpperCase());
|
|
||||||
b.setTypeface( b.getTypeface(),Typeface.BOLD );
|
|
||||||
}
|
|
||||||
else if( child instanceof EditText )
|
|
||||||
{
|
|
||||||
final EditText b = ( EditText )child;
|
|
||||||
b.setBackgroundColor( 0xFF353535 );
|
|
||||||
b.setTextColor( 0xFFFFFFFF );
|
|
||||||
b.setTextSize( 15f );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( Exception e )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
|
@ -91,7 +48,7 @@ public class LauncherActivity extends Activity
|
||||||
super.setTheme( 0x01030224 );
|
super.setTheme( 0x01030224 );
|
||||||
else super.setTheme( 0x01030005 );
|
else super.setTheme( 0x01030005 );
|
||||||
|
|
||||||
if( CertCheck.dumbAntiPDALifeCheck( this ) )
|
if( sdk >= 8 && CertCheck.dumbAntiPDALifeCheck( this ) )
|
||||||
{
|
{
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
|
@ -301,7 +258,7 @@ public class LauncherActivity extends Activity
|
||||||
{
|
{
|
||||||
new CheckUpdate(true, false).execute(UPDATE_LINK);
|
new CheckUpdate(true, false).execute(UPDATE_LINK);
|
||||||
}
|
}
|
||||||
changeButtonsStyle((ViewGroup)tabHost.getParent());
|
FWGSLib.changeButtonsStyle((ViewGroup)tabHost.getParent());
|
||||||
hideResolutionSettings( !resolution.isChecked() );
|
hideResolutionSettings( !resolution.isChecked() );
|
||||||
hideRodirSettings( !useRoDir.isChecked() );
|
hideRodirSettings( !useRoDir.isChecked() );
|
||||||
updateResolutionResult();
|
updateResolutionResult();
|
||||||
|
@ -450,6 +407,7 @@ public class LauncherActivity extends Activity
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
FWGSLib.changeButtonsStyle((ViewGroup)dialog.findViewById( R.id.show_firstrun ).getParent());
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class XashActivity extends Activity {
|
||||||
super.onCreate( savedInstanceState );
|
super.onCreate( savedInstanceState );
|
||||||
mEngineReady = false;
|
mEngineReady = false;
|
||||||
|
|
||||||
if( CertCheck.dumbAntiPDALifeCheck( this ) )
|
if( sdk >= 8 && CertCheck.dumbAntiPDALifeCheck( this ) )
|
||||||
{
|
{
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -25,136 +25,6 @@ public class XashTutorialActivity extends Activity implements View.OnClickListen
|
||||||
private int currentItem;
|
private int currentItem;
|
||||||
|
|
||||||
private int prevText, nextText, finishText, cancelText, numPages;
|
private int prevText, nextText, finishText, cancelText, numPages;
|
||||||
static class PagedView extends HorizontalScrollView
|
|
||||||
{
|
|
||||||
boolean isDelayed, isInc, anim;
|
|
||||||
int lastScroll, pageWidth, currentPage, numPages, targetPage;
|
|
||||||
float firstx,lastx;
|
|
||||||
LinearLayout pageContainer;
|
|
||||||
ViewGroup.LayoutParams pageParams;
|
|
||||||
|
|
||||||
// allow detect animation end
|
|
||||||
static abstract class OnPageListener
|
|
||||||
{
|
|
||||||
abstract public void onPage(int page);
|
|
||||||
}
|
|
||||||
OnPageListener listener;
|
|
||||||
|
|
||||||
public PagedView(Context ctx, int pagewidth)
|
|
||||||
{
|
|
||||||
super(ctx);
|
|
||||||
pageContainer = new LinearLayout(ctx);
|
|
||||||
pageContainer.setOrientation(LinearLayout.HORIZONTAL);
|
|
||||||
setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));
|
|
||||||
setScrollBarStyle(SCROLLBARS_INSIDE_INSET);
|
|
||||||
addView(pageContainer);
|
|
||||||
pageWidth = pagewidth;
|
|
||||||
// this will be applied to every page
|
|
||||||
pageParams = new ViewGroup.LayoutParams(pagewidth, LayoutParams.FILL_PARENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void animateScroll()
|
|
||||||
{
|
|
||||||
if( !anim )
|
|
||||||
{
|
|
||||||
// allow only correct position if anim disabled
|
|
||||||
scrollTo(pageWidth*currentPage,0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if( isInc && lastScroll >= pageWidth * targetPage || !isInc && lastScroll <= pageWidth * targetPage )
|
|
||||||
{
|
|
||||||
// got target page, stop now
|
|
||||||
anim = false;
|
|
||||||
currentPage = targetPage;
|
|
||||||
scrollTo(pageWidth*targetPage,0);
|
|
||||||
if( listener != null )
|
|
||||||
listener.onPage(currentPage);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !isDelayed ) //semaphore
|
|
||||||
{
|
|
||||||
isDelayed = true;
|
|
||||||
postDelayed(new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
isDelayed = false;
|
|
||||||
// animate to 1/50 of page every 10 ms
|
|
||||||
scrollBy(isInc?pageWidth/50:-pageWidth/50,0);
|
|
||||||
}
|
|
||||||
},10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add view and set layout
|
|
||||||
public void addPage(View view)
|
|
||||||
{
|
|
||||||
view.setLayoutParams(pageParams);
|
|
||||||
pageContainer.addView(view);
|
|
||||||
numPages++;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onScrollChanged(int l, int t, int oldl, int oldt)
|
|
||||||
{
|
|
||||||
// this called on every scrollTo/scrollBy and touch scroll
|
|
||||||
super.onScrollChanged(l,t,oldl,oldt);
|
|
||||||
lastScroll=l;
|
|
||||||
isInc = l>oldl;
|
|
||||||
animateScroll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onTouchEvent(MotionEvent e)
|
|
||||||
{
|
|
||||||
switch( e.getAction() )
|
|
||||||
{
|
|
||||||
case MotionEvent.ACTION_DOWN:
|
|
||||||
// store swipe start
|
|
||||||
lastx = firstx = e.getX();
|
|
||||||
// animation will be started on next scroll event
|
|
||||||
anim = true;
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
|
||||||
// animation will start in supercall, so select direction now
|
|
||||||
isInc = e.getX() < lastx;
|
|
||||||
targetPage = isInc?currentPage+1:currentPage-1;
|
|
||||||
lastx = e.getX();
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_UP:
|
|
||||||
// detect misstouch (<100 pixels)
|
|
||||||
if( Math.abs(e.getX()-firstx) < 100)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
anim = false;
|
|
||||||
targetPage = currentPage;
|
|
||||||
scrollTo(currentPage*pageWidth,0);*/
|
|
||||||
targetPage = currentPage;
|
|
||||||
isInc = currentPage * pageWidth > lastScroll;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return super.onTouchEvent(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set page number
|
|
||||||
public void changePage(int page)
|
|
||||||
{
|
|
||||||
targetPage = page;
|
|
||||||
anim = true;
|
|
||||||
isInc = targetPage > currentPage;
|
|
||||||
animateScroll();
|
|
||||||
}
|
|
||||||
|
|
||||||
// call when animation ends
|
|
||||||
public void setOnPageListener(OnPageListener listener1)
|
|
||||||
{
|
|
||||||
listener = listener1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PagedView scroll;
|
PagedView scroll;
|
||||||
|
|
||||||
|
@ -170,7 +40,6 @@ public class XashTutorialActivity extends Activity implements View.OnClickListen
|
||||||
initViews();
|
initViews();
|
||||||
initPages();
|
initPages();
|
||||||
changeFragment(0);
|
changeFragment(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -229,6 +98,8 @@ public class XashTutorialActivity extends Activity implements View.OnClickListen
|
||||||
controlPosition();
|
controlPosition();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if( FWGSLib.sdk < 14 ) // pre-ics does not apply buttons background
|
||||||
|
FWGSLib.changeButtonsStyle((ViewGroup)container.getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void controlPosition()
|
private void controlPosition()
|
||||||
|
@ -291,7 +162,7 @@ public class XashTutorialActivity extends Activity implements View.OnClickListen
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (currentItem == 0) {
|
if (currentItem == 0) {
|
||||||
super.onBackPressed();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
changeFragment(false);
|
changeFragment(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,6 +182,50 @@ public class FWGSLib
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void changeButtonsStyle( ViewGroup parent )
|
||||||
|
{
|
||||||
|
if( sdk >= 21 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
for( int i = parent.getChildCount() - 1; i >= 0; i-- )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final View child = parent.getChildAt(i);
|
||||||
|
|
||||||
|
if( child == null )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if( child instanceof ViewGroup )
|
||||||
|
{
|
||||||
|
changeButtonsStyle((ViewGroup) child);
|
||||||
|
// DO SOMETHING WITH VIEWGROUP, AFTER CHILDREN HAS BEEN LOOPED
|
||||||
|
}
|
||||||
|
else if( child instanceof Button )
|
||||||
|
{
|
||||||
|
final Button b = (Button)child;
|
||||||
|
final Drawable bg = b.getBackground();
|
||||||
|
if(bg!= null)bg.setAlpha( 96 );
|
||||||
|
b.setTextColor( 0xFFFFFFFF );
|
||||||
|
b.setTextSize( 15f );
|
||||||
|
//b.setText(b.getText().toString().toUpperCase());
|
||||||
|
b.setTypeface( b.getTypeface(),Typeface.BOLD );
|
||||||
|
}
|
||||||
|
else if( child instanceof EditText )
|
||||||
|
{
|
||||||
|
final EditText b = ( EditText )child;
|
||||||
|
b.setBackgroundColor( 0xFF353535 );
|
||||||
|
b.setTextColor( 0xFFFFFFFF );
|
||||||
|
b.setTextSize( 15f );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( Exception e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final int sdk = Integer.valueOf(Build.VERSION.SDK);
|
public static final int sdk = Integer.valueOf(Build.VERSION.SDK);
|
||||||
}
|
}
|
||||||
|
|
137
src/su/xash/fwgslib/PagedView.java
Normal file
137
src/su/xash/fwgslib/PagedView.java
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
package su.xash.fwgslib;
|
||||||
|
|
||||||
|
import android.view.*;
|
||||||
|
import android.view.View.*;
|
||||||
|
import android.widget.*;
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
public class PagedView extends HorizontalScrollView
|
||||||
|
{
|
||||||
|
boolean isDelayed, isInc, anim;
|
||||||
|
int lastScroll, pageWidth, currentPage, numPages, targetPage;
|
||||||
|
float firstx,lastx;
|
||||||
|
LinearLayout pageContainer;
|
||||||
|
ViewGroup.LayoutParams pageParams;
|
||||||
|
|
||||||
|
// allow detect animation end
|
||||||
|
public static abstract class OnPageListener
|
||||||
|
{
|
||||||
|
abstract public void onPage(int page);
|
||||||
|
}
|
||||||
|
OnPageListener listener;
|
||||||
|
|
||||||
|
public PagedView(Context ctx, int pagewidth)
|
||||||
|
{
|
||||||
|
super(ctx);
|
||||||
|
pageContainer = new LinearLayout(ctx);
|
||||||
|
pageContainer.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));
|
||||||
|
setScrollBarStyle(SCROLLBARS_INSIDE_INSET);
|
||||||
|
addView(pageContainer);
|
||||||
|
pageWidth = pagewidth;
|
||||||
|
// this will be applied to every page
|
||||||
|
pageParams = new ViewGroup.LayoutParams(pagewidth, LayoutParams.FILL_PARENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void animateScroll()
|
||||||
|
{
|
||||||
|
if( !anim )
|
||||||
|
{
|
||||||
|
// allow only correct position if anim disabled
|
||||||
|
scrollTo(pageWidth*currentPage,0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if( isInc && lastScroll >= pageWidth * targetPage || !isInc && lastScroll <= pageWidth * targetPage )
|
||||||
|
{
|
||||||
|
// got target page, stop now
|
||||||
|
anim = false;
|
||||||
|
currentPage = targetPage;
|
||||||
|
scrollTo(pageWidth*targetPage,0);
|
||||||
|
if( listener != null )
|
||||||
|
listener.onPage(currentPage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !isDelayed ) //semaphore
|
||||||
|
{
|
||||||
|
isDelayed = true;
|
||||||
|
postDelayed(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
isDelayed = false;
|
||||||
|
// animate to 1/50 of page every 10 ms
|
||||||
|
scrollBy(isInc?pageWidth/50:-pageWidth/50,0);
|
||||||
|
}
|
||||||
|
},10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add view and set layout
|
||||||
|
public void addPage(View view)
|
||||||
|
{
|
||||||
|
view.setLayoutParams(pageParams);
|
||||||
|
pageContainer.addView(view);
|
||||||
|
numPages++;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onScrollChanged(int l, int t, int oldl, int oldt)
|
||||||
|
{
|
||||||
|
// this called on every scrollTo/scrollBy and touch scroll
|
||||||
|
super.onScrollChanged(l,t,oldl,oldt);
|
||||||
|
lastScroll=l;
|
||||||
|
isInc = l>oldl;
|
||||||
|
animateScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onTouchEvent(MotionEvent e)
|
||||||
|
{
|
||||||
|
switch( e.getAction() )
|
||||||
|
{
|
||||||
|
case MotionEvent.ACTION_DOWN:
|
||||||
|
// store swipe start
|
||||||
|
lastx = firstx = e.getX();
|
||||||
|
// animation will be started on next scroll event
|
||||||
|
anim = true;
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_MOVE:
|
||||||
|
// animation will start in supercall, so select direction now
|
||||||
|
isInc = e.getX() < lastx;
|
||||||
|
targetPage = isInc?currentPage+1:currentPage-1;
|
||||||
|
lastx = e.getX();
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_UP:
|
||||||
|
// detect misstouch (<100 pixels)
|
||||||
|
if( Math.abs(e.getX()-firstx) < 100)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
anim = false;
|
||||||
|
targetPage = currentPage;
|
||||||
|
scrollTo(currentPage*pageWidth,0);*/
|
||||||
|
targetPage = currentPage;
|
||||||
|
isInc = currentPage * pageWidth > lastScroll;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return super.onTouchEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set page number
|
||||||
|
public void changePage(int page)
|
||||||
|
{
|
||||||
|
targetPage = page;
|
||||||
|
anim = true;
|
||||||
|
isInc = targetPage > currentPage;
|
||||||
|
animateScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
// call when animation ends
|
||||||
|
public void setOnPageListener(OnPageListener listener1)
|
||||||
|
{
|
||||||
|
listener = listener1;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue