Add change paper and fix a paste stack bug
- Fix paste stack bug. - Add Change Paper (clean) action in the printer simulator.
This commit is contained in:
parent
a527aa1fd4
commit
3e9d0fb564
11 changed files with 181 additions and 209 deletions
|
@ -60,6 +60,7 @@ CHANGES
|
|||
|
||||
Version 1.5 (2019-06-xx)
|
||||
|
||||
- Add Change Paper (clean) action in the printer simulator.
|
||||
- Fix: Selecting an empty KML folder prevent to select the default embedded KML folder (Github Fix: #5)!
|
||||
- Fix: Bad text characters when copy/paste the stack.
|
||||
|
||||
|
|
|
@ -27,6 +27,12 @@ if (keystorePropertiesFile.exists()) {
|
|||
""")
|
||||
}
|
||||
|
||||
//allprojects {
|
||||
// tasks.withType(JavaCompile) {
|
||||
// options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
|
||||
// }
|
||||
//}
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
|
@ -76,13 +82,13 @@ android {
|
|||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha5'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
|
||||
implementation 'androidx.preference:preference:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha05'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha07'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0-alpha04'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha04'
|
||||
androidTestImplementation 'androidx.test:runner:1.3.0-alpha01'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha01'
|
||||
implementation 'androidx.viewpager:viewpager:1.0.0'
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ const TCHAR * clipboardPasteText() {
|
|||
for (int i = 0; i <= length; ++i)
|
||||
pasteText[i] = strReturn[i] & 0xFF;
|
||||
pasteText[length] = 0;
|
||||
(*jniEnv)->ReleaseStringUTFChars(jniEnv, result, strReturn);
|
||||
(*jniEnv)->ReleaseStringChars(jniEnv, result, strReturn);
|
||||
return pasteText;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,16 +15,10 @@
|
|||
package org.emulator.forty.eight;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.opengl.GLES10;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.microedition.khronos.egl.EGL10;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.egl.EGLContext;
|
||||
import javax.microedition.khronos.egl.EGLDisplay;
|
||||
|
||||
/*
|
||||
* Based on the free HP82240B Printer Simulator by Christoph Giesselink
|
||||
*/
|
||||
|
@ -54,12 +48,12 @@ public class PrinterSimulator {
|
|||
|
||||
int maxBitmapHeight = 2048;
|
||||
try {
|
||||
maxBitmapHeight = getMaximumTextureSize();
|
||||
maxBitmapHeight = Utils.getMaximumTextureSize();
|
||||
} catch(Exception ex) {
|
||||
Log.d(TAG, "Cannot get the MaximumTextureSize (Set default to 2048). Error: " + ex.getMessage());
|
||||
}
|
||||
|
||||
maxBitmapHeight = Math.max(maxBitmapHeight, 8192); //32768);
|
||||
maxBitmapHeight = Math.min(maxBitmapHeight, 8192); //32768);
|
||||
MAXPRTLINES = maxBitmapHeight / LINE_HEIGHT;
|
||||
mBitmap = Bitmap.createBitmap(LINE_WIDTH, MAXPRTLINES*LINE_HEIGHT, Bitmap.Config.ALPHA_8); //ARGB_8888); //ALPHA_8);
|
||||
mBitmap.eraseColor(0xFFFFFFFF);
|
||||
|
@ -76,6 +70,25 @@ public class PrinterSimulator {
|
|||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the printer type.
|
||||
* @param enable true to set the printer as a model 82240A or 82240B otherwise.
|
||||
*/
|
||||
public void setPrinterModel82240A(boolean enable) {
|
||||
m_bPrinter82240A = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the paper, so we cleanup everything.
|
||||
*/
|
||||
public void changePaper() {
|
||||
reset();
|
||||
m_Text.setLength(0);
|
||||
mBitmap.eraseColor(0xFFFFFFFF);
|
||||
m_nCurCol = 0;
|
||||
m_nCurRow = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked when the printer just has print something.
|
||||
*/
|
||||
|
@ -96,9 +109,9 @@ public class PrinterSimulator {
|
|||
this.onPrinterUpdateListener = onPrinterUpdateListener;
|
||||
}
|
||||
|
||||
//
|
||||
// reset printer state machine
|
||||
//
|
||||
/**
|
||||
* Reset the printer state machine.
|
||||
*/
|
||||
void reset() {
|
||||
m_bExpChar = false; // printing normal-width characters
|
||||
m_bUnderLined = false; // printing non underlined characters
|
||||
|
@ -110,9 +123,9 @@ public class PrinterSimulator {
|
|||
m_byGraphLength = 0; // no remaining graphic bytes
|
||||
}
|
||||
|
||||
//
|
||||
// printer selftest
|
||||
//
|
||||
/**
|
||||
* Printer self test.
|
||||
*/
|
||||
void selftest() {
|
||||
// self test normally run in an endless loop, that's very hard to implement,
|
||||
// so this implementation printing all characters only one time and then
|
||||
|
@ -143,6 +156,10 @@ public class PrinterSimulator {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point of the data coming in the printer.
|
||||
* @param byData
|
||||
*/
|
||||
public synchronized void write(int byData) {
|
||||
data.add(byData);
|
||||
|
||||
|
@ -211,7 +228,9 @@ public class PrinterSimulator {
|
|||
|
||||
// Text Printer
|
||||
|
||||
// ROMAN8 Unicode table
|
||||
/**
|
||||
* ROMAN8 Unicode table
|
||||
*/
|
||||
static final int[] wcRoman8 = new int[]
|
||||
{
|
||||
0x00A0, 0x00F7, 0x00D7, 0x221A, 0x222B, 0x03A3, 0x25B6, 0x03C0,
|
||||
|
@ -232,7 +251,9 @@ public class PrinterSimulator {
|
|||
0x00BD, 0x00AA, 0x00BA, 0x00AB, 0x2587, 0x00BB, 0x00B1, 0x00A0
|
||||
};
|
||||
|
||||
// ECMA94 Unicode table
|
||||
/**
|
||||
* ECMA94 Unicode table
|
||||
*/
|
||||
static final int[] wcEcma94 = new int[]
|
||||
{
|
||||
0x2221, 0x0101, 0x2207, 0x221A, 0x222B, 0x03A3, 0x25B6, 0x03C0,
|
||||
|
@ -280,6 +301,10 @@ public class PrinterSimulator {
|
|||
} while (false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the text sent to the printer.
|
||||
* @return All the text.
|
||||
*/
|
||||
public String getText() {
|
||||
return m_Text.toString();
|
||||
}
|
||||
|
@ -288,25 +313,42 @@ public class PrinterSimulator {
|
|||
|
||||
private final Bitmap mBitmap;
|
||||
|
||||
/**
|
||||
* Get the full paper as an image limited by the paper height (see getPaperHeight().
|
||||
* The size of the bitmap is limited by the hardware constraint (max texture size).
|
||||
* @return The image containing all the paper.
|
||||
*/
|
||||
public Bitmap getImage() {
|
||||
return mBitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current printer head position to know the paper length.
|
||||
* @return The current printer head position in pixel from the start of the paper in the bitmap.
|
||||
*/
|
||||
public int getPaperHeight() {
|
||||
return m_nCurRow + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printer title following the configuration.
|
||||
* @return The printer title.
|
||||
*/
|
||||
public String getTitle() {
|
||||
return "HP-82240" + (m_bPrinter82240A ? "A" : "B") + " Printer";
|
||||
}
|
||||
|
||||
private int MAXPRTLINES = 500; //32768; // maximum printable lines (out of paper)
|
||||
private final int LINE_WIDTH = 166;
|
||||
private final int LINE_HEIGHT = 8;
|
||||
|
||||
int m_nCurCol; // current column in bitmap
|
||||
int m_nCurRow; // current row in bitmap
|
||||
private int m_nCurCol; // current column in bitmap
|
||||
private int m_nCurRow; // current row in bitmap
|
||||
|
||||
boolean m_bPrinter82240A; // HP82240A ROMAN8 font only
|
||||
private boolean m_bPrinter82240A = false; // HP82240A ROMAN8 font only
|
||||
|
||||
|
||||
void SetColumn(int byData)
|
||||
private void SetColumn(int byData)
|
||||
{
|
||||
// set column in line
|
||||
if (m_nCurCol >= LINE_WIDTH)
|
||||
|
@ -334,7 +376,7 @@ public class PrinterSimulator {
|
|||
return;
|
||||
}
|
||||
|
||||
void SetSeparatorColumn()
|
||||
private void SetSeparatorColumn()
|
||||
{
|
||||
int byData = m_bUnderLined ? 0x80 : 0x00;
|
||||
|
||||
|
@ -424,7 +466,9 @@ public class PrinterSimulator {
|
|||
|
||||
// the printer font data
|
||||
|
||||
// HP82240A ROMAN8 font table
|
||||
/**
|
||||
* HP82240A ROMAN8 font table.
|
||||
*/
|
||||
private static final int sFontRoman8_A[][] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 32
|
||||
|
@ -653,7 +697,9 @@ public class PrinterSimulator {
|
|||
{ 0x00, 0x00, 0x00, 0x00, 0x00 } // 255
|
||||
};
|
||||
|
||||
// HP82240B ROMAN8 font table
|
||||
/**
|
||||
* HP82240B ROMAN8 font table.
|
||||
*/
|
||||
private static final int sFontRoman8_B[][] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 32
|
||||
|
@ -882,7 +928,9 @@ public class PrinterSimulator {
|
|||
{ 0x00, 0x00, 0x00, 0x00, 0x00 } // 255
|
||||
};
|
||||
|
||||
// HP82240B ECMA94 font table
|
||||
/**
|
||||
* HP82240B ECMA94 font table.
|
||||
*/
|
||||
private static final int sFontEcma94_B[][] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // 32
|
||||
|
@ -1110,50 +1158,4 @@ public class PrinterSimulator {
|
|||
{ 0x00, 0xFE, 0x24, 0x24, 0x18 }, // 254
|
||||
{ 0x18, 0xA1, 0xA0, 0xA1, 0x78 } // 255
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Misc
|
||||
|
||||
// https://community.khronos.org/t/get-maximum-texture-size/67795
|
||||
public int getMaximumTextureSize() {
|
||||
EGL10 egl = (EGL10) EGLContext.getEGL();
|
||||
EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
|
||||
|
||||
// Initialise
|
||||
int[] version = new int[2];
|
||||
egl.eglInitialize(display, version);
|
||||
|
||||
// Query total number of configurations
|
||||
int[] totalConfigurations = new int[1];
|
||||
egl.eglGetConfigs(display, null, 0, totalConfigurations);
|
||||
|
||||
// Query actual list configurations
|
||||
EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]];
|
||||
egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations);
|
||||
|
||||
int[] textureSize = new int[1];
|
||||
int maximumTextureSize = 0;
|
||||
|
||||
// Iterate through all the configurations to located the maximum texture size
|
||||
for (int i = 0; i < totalConfigurations[0]; i++)
|
||||
{
|
||||
// Only need to check for width since opengl textures are always squared
|
||||
egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize);
|
||||
|
||||
// Keep track of the maximum texture size
|
||||
if (maximumTextureSize < textureSize[0])
|
||||
{
|
||||
maximumTextureSize = textureSize[0];
|
||||
}
|
||||
|
||||
Log.i("GLHelper", Integer.toString(textureSize[0]));
|
||||
}
|
||||
|
||||
// Release
|
||||
egl.eglTerminate(display);
|
||||
Log.i("GLHelper", "Maximum GL texture size: " + Integer.toString(maximumTextureSize));
|
||||
|
||||
return maximumTextureSize;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatDialogFragment;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
@ -60,6 +61,7 @@ public class PrinterSimulatorFragment extends AppCompatDialogFragment {
|
|||
|
||||
//setStyle(STYLE_NO_FRAME, android.R.style.Theme_Holo_Light);
|
||||
//setStyle(STYLE_NO_FRAME, 0);
|
||||
//setStyle(STYLE_NO_TITLE, android.R.style.Theme_Material_Light_Dialog_Alert); //Theme_Holo_Light);
|
||||
setStyle(STYLE_NO_TITLE, android.R.style.Theme_Holo_Light);
|
||||
//setStyle(STYLE_NO_TITLE, 0);
|
||||
}
|
||||
|
@ -85,6 +87,8 @@ public class PrinterSimulatorFragment extends AppCompatDialogFragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
String title = getString(R.string.dialog_printer_simulator_title);
|
||||
if(printerSimulator != null)
|
||||
title = printerSimulator.getTitle();
|
||||
getDialog().setTitle(title);
|
||||
|
||||
|
||||
|
@ -95,6 +99,7 @@ public class PrinterSimulatorFragment extends AppCompatDialogFragment {
|
|||
|
||||
toolbar = view.findViewById(R.id.my_toolbar);
|
||||
toolbar.setTitle(title);
|
||||
toolbar.setOverflowIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_more_vert_white_24dp));
|
||||
//toolbar.setLogo(R.drawable.ic_launcher);
|
||||
toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_white_24dp);
|
||||
toolbar.setNavigationOnClickListener(
|
||||
|
@ -146,7 +151,10 @@ public class PrinterSimulatorFragment extends AppCompatDialogFragment {
|
|||
e.printStackTrace();
|
||||
((MainActivity)getActivity()).showAlert(e.getMessage());
|
||||
}
|
||||
|
||||
} else if(item.getItemId() == R.id.menu_printer_simulator_change_paper) {
|
||||
printerSimulator.changePaper();
|
||||
printerGraphView.updatePaper();
|
||||
updatePaper();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -175,91 +183,6 @@ public class PrinterSimulatorFragment extends AppCompatDialogFragment {
|
|||
case 0: {
|
||||
ViewGroup layoutPagePrinterText = container.findViewById(R.id.page_printer_text);
|
||||
textViewPrinterText = container.findViewById(R.id.printer_text);
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// textViewPrinterText.setOnScrollChangeListener(new View.OnScrollChangeListener() {
|
||||
// @Override
|
||||
// public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
|
||||
// int virtualHeight = -1;
|
||||
// final Layout layout = textViewPrinterText.getLayout();
|
||||
// if(layout != null) {
|
||||
// virtualHeight = layout.getLineTop(textViewPrinterText.getLineCount());
|
||||
// }
|
||||
//
|
||||
// Log.d(TAG, "onScrollChange() getScrollY: " + textViewPrinterText.getScrollY() + ", getHeight: " + textViewPrinterText.getHeight() + ", virtualHeight: " + virtualHeight);
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// if(textViewPrinterText != null) {
|
||||
// textViewPrinterText.setTextIsSelectable(true);
|
||||
// final Context context = getActivity();
|
||||
//
|
||||
//// final ColorStateList colors = textViewPrinterText.getTextColors();
|
||||
//// textViewPrinterText.setTextColor(colors.withAlpha(255));
|
||||
//
|
||||
// textViewPrinterText.setHorizontallyScrolling(true);
|
||||
//
|
||||
// // http://stackoverflow.com/a/34316896
|
||||
// final Scroller scroller = new Scroller(context);
|
||||
// textViewPrinterText.setMovementMethod(new ScrollingMovementMethod());
|
||||
// textViewPrinterText.setScroller(scroller);
|
||||
// //final Layout textViewResultLayout = textViewPrinterText.getLayout();
|
||||
// textViewPrinterText.setOnTouchListener(new View.OnTouchListener() {
|
||||
//
|
||||
// // Could make this a field member on your activity
|
||||
// GestureDetector gesture = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
|
||||
// @Override
|
||||
// public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||
//
|
||||
// Layout textViewResultLayout = textViewPrinterText.getLayout();
|
||||
// if(textViewResultLayout != null) {
|
||||
// int scrollWidth = (int) textViewResultLayout.getLineWidth(0);
|
||||
// int maxX = scrollWidth - textViewPrinterText.getWidth();
|
||||
// int scrollHeight = textViewResultLayout.getHeight();
|
||||
// //int scrollHeight = textViewPrinterText.getLineCount() * textViewPrinterText.getLineHeight();
|
||||
// int maxY = scrollHeight - textViewPrinterText.getHeight();
|
||||
// scroller.fling(
|
||||
// textViewPrinterText.getScrollX(), textViewPrinterText.getScrollY(), // int startX, int startY
|
||||
// (int) -velocityX, (int) -velocityY, // int velocityX, int velocityY,
|
||||
// 0, maxX, // int minX, int maxX
|
||||
// 0, maxY // int minY, int maxY
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// return super.onFling(e1, e2, velocityX, velocityY);
|
||||
// }
|
||||
//
|
||||
// });
|
||||
//
|
||||
// @Override
|
||||
// public boolean onTouch(View v, MotionEvent event) {
|
||||
// gesture.onTouchEvent(event);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// });
|
||||
// textViewPrinterText.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
// @Override
|
||||
// public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
// Layout textViewResultLayout = textViewPrinterText.getLayout();
|
||||
// if(textViewResultLayout != null) {
|
||||
// int scrollWidth = (int) textViewResultLayout.getLineWidth(0);
|
||||
// int maxX = Math.max(0, scrollWidth - textViewPrinterText.getWidth());
|
||||
// int scrollHeight = textViewResultLayout.getHeight();
|
||||
// //int scrollHeight = textViewPrinterText.getLineCount() * textViewPrinterText.getLineHeight();
|
||||
// int maxY = Math.max(0, scrollHeight - textViewPrinterText.getHeight());
|
||||
//
|
||||
// int scrollX = textViewPrinterText.getScrollX();
|
||||
// if(scrollX > maxX)
|
||||
// textViewPrinterText.setScrollX(maxX);
|
||||
// int scrollY = textViewPrinterText.getScrollY();
|
||||
// if(scrollY > maxY)
|
||||
// textViewPrinterText.setScrollY(maxY);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
addToPrinterText(printerSimulator.getText());
|
||||
return layoutPagePrinterText;
|
||||
}
|
||||
|
@ -348,17 +271,20 @@ public class PrinterSimulatorFragment extends AppCompatDialogFragment {
|
|||
Runnable onPrinterUpdate = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(textViewPrinterText != null) {
|
||||
addToPrinterText(printerSimulator.getText());
|
||||
}
|
||||
if(printerGraphView != null) {
|
||||
printerGraphView.setVirtualSize(printerSimulator.getImage().getWidth(), printerSimulator.getPaperHeight());
|
||||
printerGraphView.updateLayoutView();
|
||||
printerGraphView.invalidate();
|
||||
}
|
||||
updatePaper();
|
||||
}
|
||||
};
|
||||
|
||||
private void updatePaper() {
|
||||
if(textViewPrinterText != null) {
|
||||
addToPrinterText(printerSimulator.getText());
|
||||
}
|
||||
if(printerGraphView != null) {
|
||||
printerGraphView.updatePaper();
|
||||
printerGraphView.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPrinterSimulator(final PrinterSimulator printerSimulator) {
|
||||
this.printerSimulator = printerSimulator;
|
||||
this.printerSimulator.setOnPrinterUpdateListener(new PrinterSimulator.OnPrinterUpdateListener() {
|
||||
|
@ -421,6 +347,11 @@ public class PrinterSimulatorFragment extends AppCompatDialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
public void updatePaper() {
|
||||
setVirtualSize(bitmap.getWidth(), printerSimulator.getPaperHeight());
|
||||
updateLayoutView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int viewWidth, int viewHeight, int oldViewWidth, int oldViewHeight) {
|
||||
//super.onSizeChanged(viewWidth, viewHeight, oldViewWidth, oldViewHeight);
|
||||
|
@ -428,8 +359,7 @@ public class PrinterSimulatorFragment extends AppCompatDialogFragment {
|
|||
viewSizeWidth = viewWidth;
|
||||
viewSizeHeight = viewHeight;
|
||||
|
||||
setVirtualSize(bitmap.getWidth(), printerSimulator.getPaperHeight());
|
||||
updateLayoutView();
|
||||
updatePaper();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,6 +4,12 @@ import android.content.Context;
|
|||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.OpenableColumns;
|
||||
import android.util.Log;
|
||||
|
||||
import javax.microedition.khronos.egl.EGL10;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.egl.EGLContext;
|
||||
import javax.microedition.khronos.egl.EGLDisplay;
|
||||
|
||||
public class Utils {
|
||||
static String getFileName(Context context, String url) {
|
||||
|
@ -39,4 +45,46 @@ public class Utils {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
// https://community.khronos.org/t/get-maximum-texture-size/67795
|
||||
static int getMaximumTextureSize() {
|
||||
EGL10 egl = (EGL10) EGLContext.getEGL();
|
||||
EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
|
||||
|
||||
// Initialise
|
||||
int[] version = new int[2];
|
||||
egl.eglInitialize(display, version);
|
||||
|
||||
// Query total number of configurations
|
||||
int[] totalConfigurations = new int[1];
|
||||
egl.eglGetConfigs(display, null, 0, totalConfigurations);
|
||||
|
||||
// Query actual list configurations
|
||||
EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]];
|
||||
egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations);
|
||||
|
||||
int[] textureSize = new int[1];
|
||||
int maximumTextureSize = 0;
|
||||
|
||||
// Iterate through all the configurations to located the maximum texture size
|
||||
for (int i = 0; i < totalConfigurations[0]; i++)
|
||||
{
|
||||
// Only need to check for width since opengl textures are always squared
|
||||
egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize);
|
||||
|
||||
// Keep track of the maximum texture size
|
||||
if (maximumTextureSize < textureSize[0])
|
||||
{
|
||||
maximumTextureSize = textureSize[0];
|
||||
}
|
||||
|
||||
Log.i("GLHelper", Integer.toString(textureSize[0]));
|
||||
}
|
||||
|
||||
// Release
|
||||
egl.eglTerminate(display);
|
||||
Log.i("GLHelper", "Maximum GL texture size: " + Integer.toString(maximumTextureSize));
|
||||
|
||||
return maximumTextureSize;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="m 16,9.5 -4,5 h 12 l -3,-4 -2.03,2.71 z m 7,-1.4264 c 0,-0.83 -0.67,-1.5 -1.5,-1.5 -0.83,0 -1.5,0.67 -1.5,1.5 0,0.83 0.67,1.5 1.5,1.5 0.83,0 1.5,-0.67 1.5,-1.5 z"/>
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="m 14.492087,15.116493 c -0.582265,0 -1.10324,0.229842 -1.501632,0.589928 L 7.5278825,12.526943 c 0.038307,-0.176212 0.068952,-0.352424 0.068952,-0.536297 0,-0.183874 -0.030646,-0.360086 -0.068952,-0.536298 L 12.929164,8.3055162 c 0.413715,0.3830696 0.957674,0.6205727 1.562923,0.6205727 1.271791,0 2.298418,-1.0266265 2.298418,-2.2984175 0,-1.271791 -1.026627,-2.2984175 -2.298418,-2.2984175 -1.271791,0 -2.298417,1.0266265 -2.298417,2.2984175 0,0.1838734 0.03065,0.3600854 0.06895,0.5362974 L 6.8613414,10.312801 C 6.4476262,9.9297312 5.9036674,9.6922281 5.2984175,9.6922281 4.0266265,9.6922281 3,10.718855 3,11.990646 c 0,1.271791 1.0266265,2.298417 2.2984175,2.298417 0.6052499,0 1.1492087,-0.237503 1.5629239,-0.620573 l 5.4549106,3.187139 c -0.03831,0.160889 -0.06129,0.32944 -0.06129,0.497991 0,1.233484 1.003642,2.237126 2.237126,2.237126 1.233484,0 2.237127,-1.003642 2.237127,-2.237126 0,-1.233484 -1.003643,-2.237127 -2.237127,-2.237127 z" />
|
||||
</vector>
|
|
@ -1,12 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="m 21.739513,11.299304 h -9.716906 v 1.143165 h 9.716906 z m 0,-2.2863306 h -9.716906 v 1.1431656 h 9.716906 z M 12.022607,14.7288 h 7.430575 v -1.143165 h -7.430575 z"/>
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="m 14.492087,15.116493 c -0.582265,0 -1.10324,0.229842 -1.501632,0.589928 L 7.5278825,12.526943 c 0.038307,-0.176212 0.068952,-0.352424 0.068952,-0.536297 0,-0.183874 -0.030646,-0.360086 -0.068952,-0.536298 L 12.929164,8.3055162 c 0.413715,0.3830696 0.957674,0.6205727 1.562923,0.6205727 1.271791,0 2.298418,-1.0266265 2.298418,-2.2984175 0,-1.271791 -1.026627,-2.2984175 -2.298418,-2.2984175 -1.271791,0 -2.298417,1.0266265 -2.298417,2.2984175 0,0.1838734 0.03065,0.3600854 0.06895,0.5362974 L 6.8613414,10.312801 C 6.4476262,9.9297312 5.9036674,9.6922281 5.2984175,9.6922281 4.0266265,9.6922281 3,10.718855 3,11.990646 c 0,1.271791 1.0266265,2.298417 2.2984175,2.298417 0.6052499,0 1.1492087,-0.237503 1.5629239,-0.620573 l 5.4549106,3.187139 c -0.03831,0.160889 -0.06129,0.32944 -0.06129,0.497991 0,1.233484 1.003642,2.237126 2.237126,2.237126 1.233484,0 2.237127,-1.003642 2.237127,-2.237126 0,-1.233484 -1.003643,-2.237127 -2.237127,-2.237127 z" />
|
||||
</vector>
|
9
app/src/main/res/drawable/ic_more_vert_white_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_more_vert_white_24dp.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
|
||||
</vector>
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/frameLayout"
|
||||
|
@ -7,15 +8,18 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:context=".PrinterSimulatorFragment">
|
||||
|
||||
<!--<androidx.viewpager.widget.ViewPager-->
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/my_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="?attr/actionBarTheme"
|
||||
app:navigationIcon="?android:attr/homeAsUpIndicator" />
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navigationIcon="?android:attr/homeAsUpIndicator"
|
||||
/>
|
||||
|
||||
<org.emulator.forty.eight.ViewPagerNoSwipe
|
||||
android:id="@+id/viewPagerPrinter"
|
||||
|
@ -49,5 +53,4 @@
|
|||
|
||||
</org.emulator.forty.eight.ViewPagerNoSwipe>
|
||||
|
||||
<!--</androidx.viewpager.widget.ViewPager>-->
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1,17 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/menu_printer_simulator_share_text"
|
||||
android:icon="@drawable/ic_menu_share_text"
|
||||
android:title="@string/menu_printer_simulator_share_text"
|
||||
app:showAsAction="ifRoom|withText" />
|
||||
android:icon="@drawable/ic_menu_share"
|
||||
android:title="@string/menu_printer_simulator_share_text" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_printer_simulator_share_graphic"
|
||||
android:icon="@drawable/ic_menu_share_graphic"
|
||||
android:title="@string/menu_printer_simulator_share_graphic"
|
||||
app:showAsAction="ifRoom|withText" />
|
||||
android:icon="@drawable/ic_menu_share"
|
||||
android:title="@string/menu_printer_simulator_share_graphic" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_printer_simulator_change_paper"
|
||||
|
|
Loading…
Reference in a new issue