Android: Update the look of dialog
This commit is contained in:
parent
71ed3c0a2f
commit
8726931be5
|
@ -1,16 +1,9 @@
|
||||||
package emu.project64;
|
package emu.project64;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Timer;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import emu.project64.R;
|
import emu.project64.R;
|
||||||
import emu.project64.dialog.ProgressDialog;
|
import emu.project64.dialog.ProgressDialog;
|
||||||
|
@ -23,14 +16,10 @@ import emu.project64.settings.GameSettingsActivity;
|
||||||
import emu.project64.settings.SettingsActivity;
|
import emu.project64.settings.SettingsActivity;
|
||||||
import emu.project64.util.Strings;
|
import emu.project64.util.Strings;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.DialogInterface.OnCancelListener;
|
|
||||||
import android.content.DialogInterface.OnClickListener;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
@ -38,22 +27,21 @@ import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.text.SpannableStringBuilder;
|
|
||||||
import android.text.method.LinkMovementMethod;
|
|
||||||
import android.text.style.ClickableSpan;
|
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.webkit.WebView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.TextView.BufferType;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.view.ContextThemeWrapper;
|
||||||
import androidx.appcompat.view.menu.MenuBuilder;
|
import androidx.appcompat.view.menu.MenuBuilder;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
|
@ -117,7 +105,7 @@ public class GalleryActivity extends AppCompatActivity
|
||||||
// Lay out the content
|
// Lay out the content
|
||||||
setContentView( R.layout.gallery_activity );
|
setContentView( R.layout.gallery_activity );
|
||||||
mGridView = (RecyclerView) findViewById( R.id.gridview );
|
mGridView = (RecyclerView) findViewById( R.id.gridview );
|
||||||
mProgress = new ProgressDialog( null, this, getString( R.string.scanning_title ), "", getString( R.string.toast_pleaseWait ), false );
|
mProgress = new ProgressDialog(this, getString( R.string.scanning_title ), getString( R.string.toast_pleaseWait ), false );
|
||||||
|
|
||||||
// Load Cached Rom List
|
// Load Cached Rom List
|
||||||
NativeExports.LoadRomList();
|
NativeExports.LoadRomList();
|
||||||
|
@ -293,27 +281,21 @@ public class GalleryActivity extends AppCompatActivity
|
||||||
|
|
||||||
// Get Drawable icon
|
// Get Drawable icon
|
||||||
Drawable d = items[position].icon != 0 ? ResourcesCompat.getDrawable(getResources(), items[position].icon, null) : null;
|
Drawable d = items[position].icon != 0 ? ResourcesCompat.getDrawable(getResources(), items[position].icon, null) : null;
|
||||||
tv.setTextColor(Color.parseColor("#FFFFFF"));
|
tv.setTextColor(Color.parseColor("#000000"));
|
||||||
if (d != null)
|
if (d != null)
|
||||||
{
|
{
|
||||||
d.setColorFilter(Color.parseColor("#FFFFFF"), android.graphics.PorterDuff.Mode.SRC_ATOP);
|
d.setColorFilter(Color.parseColor("#000000"), android.graphics.PorterDuff.Mode.SRC_ATOP);
|
||||||
}
|
}
|
||||||
if (!isEnabled(position))
|
if (!isEnabled(position))
|
||||||
{
|
{
|
||||||
tv.setTextColor(Color.parseColor("#555555"));
|
tv.setTextColor(Color.parseColor("#AAAAAA"));
|
||||||
if (d != null)
|
if (d != null)
|
||||||
{
|
{
|
||||||
d.setColorFilter(Color.parseColor("#555555"), android.graphics.PorterDuff.Mode.SRC_ATOP);
|
d.setColorFilter(Color.parseColor("#AAAAAA"), android.graphics.PorterDuff.Mode.SRC_ATOP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Put the image on the TextView
|
|
||||||
tv.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
|
tv.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
|
||||||
|
tv.setCompoundDrawablePadding((int) (15 * getResources().getDisplayMetrics().density + 0.5f));
|
||||||
//Add margin between image and text (support various screen densities)
|
|
||||||
int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f);
|
|
||||||
tv.setCompoundDrawablePadding(dp5);
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,53 +320,65 @@ public class GalleryActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
final LayoutInflater inflater = (LayoutInflater) getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
||||||
|
View layout = inflater.inflate( R.layout.dialog_menu, null );
|
||||||
|
|
||||||
final Context finalContext = this;
|
final Context finalContext = this;
|
||||||
AlertDialog.Builder GameMenu = new AlertDialog.Builder(finalContext);
|
AlertDialog.Builder GameMenu = new AlertDialog.Builder(new ContextThemeWrapper(finalContext,R.style.Theme_Project64_Dialog_Alert));
|
||||||
GameMenu.setTitle(NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.toString()));
|
GameMenu.setView( layout);
|
||||||
GameMenu.setAdapter(adapter, new DialogInterface.OnClickListener()
|
|
||||||
|
TextView DlgTitle = (TextView)layout.findViewById(R.id.dlg_title);
|
||||||
|
DlgTitle.setText(NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.toString()));
|
||||||
|
|
||||||
|
ListView ListOptions = (ListView)layout.findViewById(R.id.list_options);
|
||||||
|
ListOptions.setAdapter(adapter);
|
||||||
|
AlertDialog dialog = GameMenu.create();
|
||||||
|
|
||||||
|
ListOptions.setOnItemClickListener(new AdapterView.OnItemClickListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int item)
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
||||||
{
|
{
|
||||||
if (item == 0)
|
if (position == 0)
|
||||||
{
|
{
|
||||||
launchGameActivity(false);
|
launchGameActivity(false);
|
||||||
}
|
}
|
||||||
else if (item == 1)
|
else if (position == 1)
|
||||||
{
|
{
|
||||||
launchGameActivity(true);
|
launchGameActivity(true);
|
||||||
}
|
}
|
||||||
else if (item == 2)
|
else if (position == 2)
|
||||||
{
|
{
|
||||||
AlertDialog.Builder ResetPrompt = new AlertDialog.Builder(finalContext);
|
/*AlertDialog.Builder ResetPrompt = new AlertDialog.Builder(finalContext);
|
||||||
ResetPrompt
|
ResetPrompt
|
||||||
.setTitle(getText(R.string.confirmResetGame_title))
|
.setTitle(getText(R.string.confirmResetGame_title))
|
||||||
.setMessage(getText(R.string.confirmResetGame_message))
|
.setMessage(getText(R.string.confirmResetGame_message))
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener()
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener()
|
||||||
{
|
|
||||||
public void onClick(DialogInterface dialog, int id)
|
|
||||||
{
|
|
||||||
String[]entries = SaveDir.list();
|
|
||||||
for(String s: entries)
|
|
||||||
{
|
{
|
||||||
File currentFile = new File(SaveDir.getPath(),s);
|
public void onClick(DialogInterface dialog, int id)
|
||||||
currentFile.delete();
|
{
|
||||||
}
|
String[]entries = SaveDir.list();
|
||||||
SaveDir.delete();
|
for(String s: entries)
|
||||||
launchGameActivity(false);
|
{
|
||||||
}
|
File currentFile = new File(SaveDir.getPath(),s);
|
||||||
})
|
currentFile.delete();
|
||||||
.setNegativeButton(android.R.string.cancel, this)
|
}
|
||||||
.show();
|
SaveDir.delete();
|
||||||
|
launchGameActivity(false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.cancel, this)
|
||||||
|
.show();*/
|
||||||
}
|
}
|
||||||
else if (item == 3)
|
else if (position == 3)
|
||||||
{
|
{
|
||||||
Intent SettingsIntent = new Intent(finalContext, GameSettingsActivity.class);
|
Intent SettingsIntent = new Intent(finalContext, GameSettingsActivity.class);
|
||||||
startActivityForResult( SettingsIntent, RC_SETTINGS );
|
startActivityForResult( SettingsIntent, RC_SETTINGS );
|
||||||
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GameMenu.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onGalleryItemClick( GalleryItem item )
|
public void onGalleryItemClick( GalleryItem item )
|
||||||
|
@ -552,16 +546,12 @@ public class GalleryActivity extends AppCompatActivity
|
||||||
if (mActiveGalleryActivity != null && mActiveGalleryActivity.mProgress != null)
|
if (mActiveGalleryActivity != null && mActiveGalleryActivity.mProgress != null)
|
||||||
{
|
{
|
||||||
Handler h = new Handler(Looper.getMainLooper());
|
Handler h = new Handler(Looper.getMainLooper());
|
||||||
final String ProgressText = new String(FileName);
|
|
||||||
final String ProgressSubText = new String(FullFileName);
|
|
||||||
final String ProgressMessage = new String("Added " + GoodName);
|
final String ProgressMessage = new String("Added " + GoodName);
|
||||||
|
|
||||||
h.post(new Runnable()
|
h.post(new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
mActiveGalleryActivity.mProgress.setText(ProgressText);
|
|
||||||
mActiveGalleryActivity.mProgress.setSubtext(ProgressSubText);
|
|
||||||
mActiveGalleryActivity.mProgress.setMessage(ProgressMessage);
|
mActiveGalleryActivity.mProgress.setMessage(ProgressMessage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class GalleryItem
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
if( !TextUtils.isEmpty( goodName ) )
|
if( !TextUtils.isEmpty(goodName) && !goodName.equals("#340#"))
|
||||||
{
|
{
|
||||||
return goodName;
|
return goodName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,142 +7,51 @@ import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.graphics.Color;
|
||||||
import android.content.DialogInterface.OnClickListener;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ProgressBar;
|
import android.view.WindowManager;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class ProgressDialog implements OnClickListener
|
public class ProgressDialog
|
||||||
{
|
{
|
||||||
private static final float PROGRESS_PRECISION = 1000f;
|
|
||||||
|
|
||||||
private final Activity mActivity;
|
private final Activity mActivity;
|
||||||
private final TextView mTextProgress;
|
|
||||||
private final TextView mTextSubprogress;
|
|
||||||
private final TextView mTextMessage;
|
private final TextView mTextMessage;
|
||||||
private final ProgressBar mProgressSubtotal;
|
|
||||||
private final ProgressBar mProgressTotal;
|
|
||||||
private AlertDialog mDialog;
|
private AlertDialog mDialog;
|
||||||
private AlertDialog mAbortDialog;
|
|
||||||
|
|
||||||
private long mMaxProgress = -1;
|
|
||||||
private long mMaxSubprogress = -1;
|
|
||||||
private long mProgress = 0;
|
|
||||||
private long mSubprogress = 0;
|
|
||||||
|
|
||||||
@SuppressLint( "InflateParams" )
|
@SuppressLint( "InflateParams" )
|
||||||
public ProgressDialog( Activity activity, CharSequence title,
|
public ProgressDialog( Activity activity, CharSequence title, CharSequence message, boolean cancelable )
|
||||||
CharSequence subtitle, CharSequence message, boolean cancelable )
|
|
||||||
{
|
{
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
|
|
||||||
final LayoutInflater inflater = (LayoutInflater) mActivity
|
final LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
||||||
.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
|
||||||
View layout = inflater.inflate( R.layout.progress_dialog, null );
|
View layout = inflater.inflate( R.layout.progress_dialog, null );
|
||||||
|
|
||||||
mTextProgress = (TextView) layout.findViewById( R.id.textProgress );
|
TextView DlgTitle = (TextView)layout.findViewById(R.id.dlg_title);
|
||||||
mTextSubprogress = (TextView) layout.findViewById( R.id.textSubprogress );
|
DlgTitle.setText(title);
|
||||||
mTextMessage = (TextView) layout.findViewById( R.id.textMessage );
|
mTextMessage = (TextView) layout.findViewById( R.id.textMessage );
|
||||||
mProgressSubtotal = (ProgressBar) layout.findViewById( R.id.progressSubtotal );
|
mTextMessage.setText( message );
|
||||||
mProgressTotal = (ProgressBar) layout.findViewById( R.id.progressTotal );
|
|
||||||
|
Builder builder = new Builder( activity, R.style.Theme_Project64_Dialog_Alert );
|
||||||
// Create main dialog
|
builder.setView( layout);
|
||||||
Builder builder = getBuilder( activity, title, subtitle, message, cancelable, layout );
|
builder.setCancelable( cancelable );
|
||||||
|
builder.setPositiveButton( null, null );
|
||||||
|
builder.setNegativeButton( null, null );
|
||||||
mDialog = builder.create();
|
mDialog = builder.create();
|
||||||
|
mDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||||
// Create canceling dialog
|
|
||||||
subtitle = mActivity.getString( R.string.toast_canceling );
|
|
||||||
message = mActivity.getString( R.string.toast_canceling );
|
|
||||||
layout = inflater.inflate( R.layout.progress_dialog, null );
|
|
||||||
builder = getBuilder( activity, title, subtitle, message, false, layout );
|
|
||||||
mAbortDialog = builder.create();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProgressDialog(ProgressDialog original, Activity activity, CharSequence title,
|
|
||||||
CharSequence subtitle, CharSequence message, boolean cancelable)
|
|
||||||
{
|
|
||||||
this(activity, title, subtitle, message, cancelable);
|
|
||||||
|
|
||||||
if(original != null)
|
|
||||||
{
|
|
||||||
setMaxProgress(original.mMaxProgress);
|
|
||||||
setMaxSubprogress(original.mMaxSubprogress);
|
|
||||||
|
|
||||||
mProgress = original.mProgress;
|
|
||||||
mSubprogress = original.mSubprogress;
|
|
||||||
|
|
||||||
incrementProgress(0);
|
|
||||||
incrementSubprogress(0);
|
|
||||||
|
|
||||||
mTextProgress.setText(original.mTextProgress.getText());
|
|
||||||
mTextSubprogress.setText(original.mTextSubprogress.getText());
|
|
||||||
mTextMessage.setText(original.mTextMessage.getText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void show()
|
public void show()
|
||||||
{
|
{
|
||||||
mAbortDialog.show();
|
|
||||||
mDialog.show();
|
mDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dismiss()
|
public void dismiss()
|
||||||
{
|
{
|
||||||
mAbortDialog.dismiss();
|
|
||||||
mDialog.dismiss();
|
mDialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick( DialogInterface dlg, int which )
|
|
||||||
{
|
|
||||||
if( which == DialogInterface.BUTTON_NEGATIVE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Builder getBuilder( Activity activity, CharSequence title, CharSequence subtitle,
|
|
||||||
CharSequence message, boolean cancelable, View layout )
|
|
||||||
{
|
|
||||||
TextView textSubtitle = (TextView) layout.findViewById( R.id.textSubtitle );
|
|
||||||
TextView textMessage = (TextView) layout.findViewById( R.id.textMessage );
|
|
||||||
textSubtitle.setText( subtitle );
|
|
||||||
textMessage.setText( message );
|
|
||||||
|
|
||||||
Builder builder = new Builder( activity ).setTitle( title ).setCancelable( false )
|
|
||||||
.setPositiveButton( null, null ).setView( layout );
|
|
||||||
if( cancelable )
|
|
||||||
builder.setNegativeButton( android.R.string.cancel, this );
|
|
||||||
else
|
|
||||||
builder.setNegativeButton( null, null );
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText( final CharSequence text )
|
|
||||||
{
|
|
||||||
mActivity.runOnUiThread( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
mTextProgress.setText( text );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubtext( final CharSequence text )
|
|
||||||
{
|
|
||||||
mActivity.runOnUiThread( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
mTextSubprogress.setText( text );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage( final CharSequence text )
|
public void setMessage( final CharSequence text )
|
||||||
{
|
{
|
||||||
mActivity.runOnUiThread( new Runnable()
|
mActivity.runOnUiThread( new Runnable()
|
||||||
|
@ -154,82 +63,4 @@ public class ProgressDialog implements OnClickListener
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage( final int resid )
|
|
||||||
{
|
|
||||||
mActivity.runOnUiThread( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
mTextMessage.setText( resid );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxProgress( final long size )
|
|
||||||
{
|
|
||||||
mActivity.runOnUiThread( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
mMaxProgress = size;
|
|
||||||
mProgress = 0;
|
|
||||||
mProgressTotal.setProgress( 0 );
|
|
||||||
mProgressTotal.setVisibility( mMaxProgress > 0 ? View.VISIBLE : View.GONE );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxSubprogress( final long size )
|
|
||||||
{
|
|
||||||
mActivity.runOnUiThread( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
mMaxSubprogress = size;
|
|
||||||
mSubprogress = 0;
|
|
||||||
mProgressSubtotal.setProgress( 0 );
|
|
||||||
mProgressSubtotal.setVisibility( mMaxSubprogress > 0 ? View.VISIBLE : View.GONE );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void incrementProgress( final long inc )
|
|
||||||
{
|
|
||||||
mActivity.runOnUiThread( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if( mMaxProgress > 0 )
|
|
||||||
{
|
|
||||||
mProgress += inc;
|
|
||||||
int pctProgress = Math.round( ( PROGRESS_PRECISION * mProgress )
|
|
||||||
/ mMaxProgress );
|
|
||||||
mProgressTotal.setProgress( pctProgress );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void incrementSubprogress( final long inc )
|
|
||||||
{
|
|
||||||
mActivity.runOnUiThread( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if( mMaxSubprogress > 0 )
|
|
||||||
{
|
|
||||||
mSubprogress += inc;
|
|
||||||
int pctSubprogress = Math.round( ( PROGRESS_PRECISION * mSubprogress )
|
|
||||||
/ mMaxSubprogress );
|
|
||||||
mProgressSubtotal.setProgress( pctSubprogress );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,33 +20,30 @@ public class GameSettingsActivity extends AppCompatActivity implements SharedPre
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.settings_activity);
|
setContentView(R.layout.settings_activity);
|
||||||
|
|
||||||
// Add the tool bar to the activity (which supports the fancy menu/arrow animation)
|
|
||||||
Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar );
|
Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar );
|
||||||
toolbar.setTitle( getString(R.string.settings_title) );
|
|
||||||
setSupportActionBar( toolbar );
|
setSupportActionBar( toolbar );
|
||||||
ActionBar actionbar = getSupportActionBar();
|
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||||
|
toolbar.setTitle(getString(R.string.game_settings_title));
|
||||||
if (AndroidDevice.IS_ICE_CREAM_SANDWICH)
|
if (AndroidDevice.IS_ICE_CREAM_SANDWICH)
|
||||||
{
|
{
|
||||||
|
ActionBar actionbar = getSupportActionBar();
|
||||||
actionbar.setHomeButtonEnabled(true);
|
actionbar.setHomeButtonEnabled(true);
|
||||||
actionbar.setDisplayHomeAsUpEnabled(true);
|
actionbar.setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
sharedPrefs.edit().clear()
|
sharedPrefs.edit().clear()
|
||||||
.putString("Game_CpuType",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Game_CpuType.toString())))
|
.putString("Game_CpuType",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Game_CpuType.toString())))
|
||||||
.putBoolean("Game_BlockLinking",NativeExports.SettingsLoadBool(SettingsID.Game_BlockLinking.toString()))
|
.putBoolean("Game_BlockLinking",NativeExports.SettingsLoadBool(SettingsID.Game_BlockLinking.toString()))
|
||||||
.apply();
|
.apply();
|
||||||
|
|
||||||
sharedPrefs.registerOnSharedPreferenceChangeListener(this);
|
sharedPrefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
if (savedInstanceState == null)
|
if (savedInstanceState == null)
|
||||||
{
|
{
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, new GameSettingsFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, new GameSettingsFragment()).commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
|
@ -54,11 +51,11 @@ public class GameSettingsActivity extends AppCompatActivity implements SharedPre
|
||||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
sharedPrefs.unregisterOnSharedPreferenceChangeListener(this);
|
sharedPrefs.unregisterOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item)
|
public boolean onOptionsItemSelected(MenuItem item)
|
||||||
{
|
{
|
||||||
switch (item.getItemId())
|
switch (item.getItemId())
|
||||||
{
|
{
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
if (!getSupportFragmentManager().popBackStackImmediate())
|
if (!getSupportFragmentManager().popBackStackImmediate())
|
||||||
|
|
|
@ -0,0 +1,139 @@
|
||||||
|
package emu.project64.settings;
|
||||||
|
|
||||||
|
import emu.project64.R;
|
||||||
|
import emu.project64.jni.NativeExports;
|
||||||
|
import emu.project64.jni.SettingsID;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.appcompat.view.ContextThemeWrapper;
|
||||||
|
import androidx.core.content.res.TypedArrayUtils;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class ListPreference extends Preference {
|
||||||
|
private CharSequence[] mEntries;
|
||||||
|
private CharSequence[] mEntryValues;
|
||||||
|
private CharSequence[] mEntriesSubtitles;
|
||||||
|
private String mValue;
|
||||||
|
private String mTitle;
|
||||||
|
private int mValueIndex;
|
||||||
|
private boolean mValueSet;
|
||||||
|
|
||||||
|
public ListPreference(Context context, AttributeSet attrs)
|
||||||
|
{
|
||||||
|
super(context, attrs, getAttr(context, R.attr.ListPreferenceStyle, android.R.attr.preferenceStyle));
|
||||||
|
|
||||||
|
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListPreference);
|
||||||
|
mEntries = a.getTextArray(R.styleable.ListPreference_entries);
|
||||||
|
mEntryValues = a.getTextArray(R.styleable.ListPreference_entryValues);
|
||||||
|
mTitle = String.valueOf(getTitle());
|
||||||
|
mValueIndex = 0;
|
||||||
|
a.recycle();
|
||||||
|
updateSummary();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onClick()
|
||||||
|
{
|
||||||
|
String[] mEntriesString = new String[mEntries.length];
|
||||||
|
int i=0;
|
||||||
|
for(CharSequence ch: mEntries)
|
||||||
|
{
|
||||||
|
mEntriesString[i++] = ch.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
||||||
|
View layout = inflater.inflate( R.layout.dialog_menu, null );
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getContext(),R.style.Theme_Project64_Dialog_Alert));
|
||||||
|
TextView DlgTitle = (TextView)layout.findViewById(R.id.dlg_title);
|
||||||
|
DlgTitle.setText(mTitle);
|
||||||
|
ListView ListOptions = (ListView)layout.findViewById(R.id.list_options);
|
||||||
|
ListAdapter adapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_single_choice,mEntriesString);
|
||||||
|
ListOptions.setAdapter(adapter);
|
||||||
|
ListOptions.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||||
|
ListOptions.setItemChecked(mValueIndex,true);
|
||||||
|
builder.setView( layout);
|
||||||
|
builder.setPositiveButton( null, null );
|
||||||
|
builder.setNegativeButton( null, null );
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
ListOptions.setOnItemClickListener(new AdapterView.OnItemClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView parent, View view, int position, long id)
|
||||||
|
{
|
||||||
|
setValueIndex(position);
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSummary()
|
||||||
|
{
|
||||||
|
if (mValueIndex < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setSummary(mEntries[mValueIndex].toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setValueIndex(int index)
|
||||||
|
{
|
||||||
|
String value = mEntryValues[index].toString();
|
||||||
|
final boolean changed = !TextUtils.equals(mValue, value);
|
||||||
|
if (changed || !mValueSet)
|
||||||
|
{
|
||||||
|
mValueIndex = index;
|
||||||
|
mValue = value;
|
||||||
|
mValueSet = true;
|
||||||
|
persistString(value);
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
updateSummary();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getAttr(Context context, int attr, int fallbackAttr)
|
||||||
|
{
|
||||||
|
TypedValue value = new TypedValue();
|
||||||
|
context.getTheme().resolveAttribute(attr, value, true);
|
||||||
|
if (value.resourceId != 0)
|
||||||
|
{
|
||||||
|
return attr;
|
||||||
|
}
|
||||||
|
return fallbackAttr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSetInitialValue(Object defaultValue)
|
||||||
|
{
|
||||||
|
if (getSharedPreferences().contains(getKey()))
|
||||||
|
{
|
||||||
|
String Value = getPersistedString( Integer.toString(mValueIndex));
|
||||||
|
for (int i = 0, n = mEntryValues.length; i < n; i++)
|
||||||
|
{
|
||||||
|
if (mEntryValues[i].equals(Value))
|
||||||
|
{
|
||||||
|
mValueIndex = i;
|
||||||
|
updateSummary();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,6 @@ import emu.project64.jni.NativeExports;
|
||||||
import emu.project64.jni.SettingsID;
|
import emu.project64.jni.SettingsID;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<shape
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle"
|
||||||
|
>
|
||||||
|
<solid
|
||||||
|
android:color="@android:color/white" >
|
||||||
|
</solid>
|
||||||
|
|
||||||
|
<stroke
|
||||||
|
android:width="5dp"
|
||||||
|
android:color="@color/colorPrimary" />
|
||||||
|
|
||||||
|
<padding
|
||||||
|
android:left="12dp"
|
||||||
|
android:top="12dp"
|
||||||
|
android:right="12dp"
|
||||||
|
android:bottom="12dp" >
|
||||||
|
</padding>
|
||||||
|
|
||||||
|
<corners
|
||||||
|
android:radius="15dp" >
|
||||||
|
</corners>
|
||||||
|
|
||||||
|
</shape>
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/linearLayout1"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@drawable/border"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dlg_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/list_options"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -2,65 +2,38 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/linearLayout1"
|
android:id="@+id/linearLayout1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical"
|
||||||
android:padding="16dp" >
|
android:background="@drawable/border"
|
||||||
|
>
|
||||||
|
|
||||||
<ProgressBar
|
<TextView
|
||||||
android:id="@+id/circleAnimation"
|
android:id="@+id/dlg_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="30sp"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/linearLayout2"
|
android:id="@+id/linearLayout2"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
tools:ignore="RtlHardcoded">
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingRight="10dp"
|
|
||||||
tools:ignore="RtlHardcoded" >
|
|
||||||
|
|
||||||
<TextView
|
<ProgressBar
|
||||||
android:id="@+id/textSubtitle"
|
android:id="@+id/circleAnimation"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" />
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textProgress"
|
android:id="@+id/textMessage"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
<ProgressBar
|
android:paddingRight="16dp" />
|
||||||
android:id="@+id/progressTotal"
|
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:max="1000"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/progressSubtotal"
|
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:max="1000"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textSubprogress"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textMessage"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -45,6 +45,7 @@
|
||||||
<string name="reset_summary">Restore default settings</string>
|
<string name="reset_summary">Restore default settings</string>
|
||||||
<string name="reset_title">Reset</string>
|
<string name="reset_title">Reset</string>
|
||||||
<string name="settings_title">Settings</string>
|
<string name="settings_title">Settings</string>
|
||||||
|
<string name="game_settings_title">Game Settings</string>
|
||||||
<string name="preferences">Preferences</string>
|
<string name="preferences">Preferences</string>
|
||||||
<string name="displayFps_title">Framerate</string>
|
<string name="displayFps_title">Framerate</string>
|
||||||
<string name="displayFps_summary">Display FPS on screen</string>
|
<string name="displayFps_summary">Display FPS on screen</string>
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<style name="Theme.Project64" parent="@android:style/Theme">
|
<style name="Theme.Project64" parent="@android:style/Theme">
|
||||||
<item name="android:alertDialogTheme">@style/Theme.Project64.Dialog</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Project64.Base" parent="Theme.Project64.Base.7" />
|
<style name="Theme.Project64.Base" parent="Theme.Project64.Base.7" />
|
||||||
|
@ -61,6 +60,10 @@
|
||||||
<item name="iconSpaceReserved">false</item>
|
<item name="iconSpaceReserved">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Project64.ListPreference" parent="Preference.Material">
|
||||||
|
<item name="iconSpaceReserved">false</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Project64.PreferenceLogLevel" parent="Preference.Material">
|
<style name="Theme.Project64.PreferenceLogLevel" parent="Preference.Material">
|
||||||
<item name="iconSpaceReserved">false</item>
|
<item name="iconSpaceReserved">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
@ -80,7 +83,7 @@
|
||||||
<item name="preferenceCategoryStyle">@style/Theme.Project64.PreferenceCategory</item>
|
<item name="preferenceCategoryStyle">@style/Theme.Project64.PreferenceCategory</item>
|
||||||
<item name="checkBoxPreferenceStyle">@style/Theme.Project64.PreferenceCheckBox</item>
|
<item name="checkBoxPreferenceStyle">@style/Theme.Project64.PreferenceCheckBox</item>
|
||||||
<item name="LogLevelPreferenceStyle">@style/Theme.Project64.PreferenceLogLevel</item>
|
<item name="LogLevelPreferenceStyle">@style/Theme.Project64.PreferenceLogLevel</item>
|
||||||
<item name="ListPreferenceStyle">@style/Theme.Project64.PreferenceList</item>
|
<item name="ListPreferenceStyle">@style/Theme.Project64.PreferenceNoIcon</item>
|
||||||
<item name="colorAccent">@color/colorPrimary</item>
|
<item name="colorAccent">@color/colorPrimary</item>
|
||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
<item name="android:textSize">18sp</item>
|
<item name="android:textSize">18sp</item>
|
||||||
|
@ -92,6 +95,23 @@
|
||||||
<item name="android:textColor">@color/TextColor</item>
|
<item name="android:textColor">@color/TextColor</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Project64.Dialog.Title">
|
||||||
|
<item name="android:background">@color/white</item>
|
||||||
|
<item name="android:textColor">@color/grey700</item>
|
||||||
|
<item name="android:textSize">30sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Project64.Dialog.Alert" parent="Base.Theme.AppCompat.Dialog.Alert">
|
||||||
|
<item name="android:windowBackground">#00FF00</item>
|
||||||
|
<item name="android:windowTitleStyle">@style/Theme.Project64.Dialog.Title</item>
|
||||||
|
<item name="android:background">@android:color/transparent</item>
|
||||||
|
<item name="android:dividerHorizontal">@null</item>
|
||||||
|
<item name="android:dividerVertical">@null</item>
|
||||||
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
<item name="android:padding">0dp</item>
|
||||||
|
<item name="android:backgroundDimEnabled">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="btnMappable" parent="@android:style/Widget.Button">
|
<style name="btnMappable" parent="@android:style/Widget.Button">
|
||||||
<item name="android:layout_width">@dimen/inputMapPreferenceButtonSize</item>
|
<item name="android:layout_width">@dimen/inputMapPreferenceButtonSize</item>
|
||||||
<item name="android:layout_height">@dimen/inputMapPreferenceButtonSize</item>
|
<item name="android:layout_height">@dimen/inputMapPreferenceButtonSize</item>
|
||||||
|
|
Loading…
Reference in New Issue