mirror of https://github.com/NekoX-Dev/NekoX.git
fix qrcode scanner
This commit is contained in:
parent
c1a21028e4
commit
4b010e3b11
|
@ -123,6 +123,7 @@ public class CameraScanActivity extends BaseFragment {
|
||||||
//private BarcodeDetector visionQrReader;
|
//private BarcodeDetector visionQrReader;
|
||||||
|
|
||||||
private boolean needGalleryButton;
|
private boolean needGalleryButton;
|
||||||
|
private boolean any;
|
||||||
|
|
||||||
private int currentType;
|
private int currentType;
|
||||||
|
|
||||||
|
@ -144,7 +145,13 @@ public class CameraScanActivity extends BaseFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Official Signature
|
||||||
public static ActionBarLayout[] showAsSheet(BaseFragment parentFragment, boolean gallery, int type, CameraScanActivityDelegate cameraDelegate) {
|
public static ActionBarLayout[] showAsSheet(BaseFragment parentFragment, boolean gallery, int type, CameraScanActivityDelegate cameraDelegate) {
|
||||||
|
return showAsSheet(parentFragment, gallery, type, cameraDelegate, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the any parameter
|
||||||
|
public static ActionBarLayout[] showAsSheet(BaseFragment parentFragment, boolean gallery, int type, CameraScanActivityDelegate cameraDelegate, boolean any) {
|
||||||
if (parentFragment == null || parentFragment.getParentActivity() == null) {
|
if (parentFragment == null || parentFragment.getParentActivity() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -165,6 +172,7 @@ public class CameraScanActivity extends BaseFragment {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fragment.needGalleryButton = gallery;
|
fragment.needGalleryButton = gallery;
|
||||||
|
fragment.any = any;
|
||||||
actionBarLayout[0].addFragmentToStack(fragment);
|
actionBarLayout[0].addFragmentToStack(fragment);
|
||||||
actionBarLayout[0].showLastFragment();
|
actionBarLayout[0].showLastFragment();
|
||||||
actionBarLayout[0].setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);
|
actionBarLayout[0].setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);
|
||||||
|
@ -206,63 +214,7 @@ public class CameraScanActivity extends BaseFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ActionBarLayout[] showAsSheet(BaseFragment parentFragment, CameraScanActivityDelegate cameraDelegate) {
|
public static ActionBarLayout[] showAsSheet(BaseFragment parentFragment, CameraScanActivityDelegate cameraDelegate) {
|
||||||
if (parentFragment == null || parentFragment.getParentActivity() == null) {
|
return showAsSheet(parentFragment, true, TYPE_QR, cameraDelegate, true);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ActionBarLayout[] actionBarLayout = new ActionBarLayout[]{new ActionBarLayout(parentFragment.getParentActivity())};
|
|
||||||
BottomSheet bottomSheet = new BottomSheet(parentFragment.getParentActivity(), false) {
|
|
||||||
CameraScanActivity fragment;
|
|
||||||
{
|
|
||||||
actionBarLayout[0].init(new ArrayList<>());
|
|
||||||
fragment = new CameraScanActivity(TYPE_QR) {
|
|
||||||
@Override
|
|
||||||
public void finishFragment() {
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeSelfFromStack() {
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
fragment.needGalleryButton = true;
|
|
||||||
actionBarLayout[0].addFragmentToStack(fragment);
|
|
||||||
actionBarLayout[0].showLastFragment();
|
|
||||||
actionBarLayout[0].setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);
|
|
||||||
fragment.setDelegate(cameraDelegate);
|
|
||||||
containerView = actionBarLayout[0];
|
|
||||||
setApplyBottomPadding(false);
|
|
||||||
setApplyBottomPadding(false);
|
|
||||||
setOnDismissListener(dialog -> fragment.onFragmentDestroy());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean canDismissWithSwipe() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
if (actionBarLayout[0] == null || actionBarLayout[0].fragmentsStack.size() <= 1) {
|
|
||||||
super.onBackPressed();
|
|
||||||
} else {
|
|
||||||
actionBarLayout[0].onBackPressed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dismiss() {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
final Window window = fragment.getParentActivity().getWindow();
|
|
||||||
fragment.updateNavigationBarColor(fragment.wasNavigationBarColor);
|
|
||||||
AndroidUtilities.setLightNavigationBar(window, fragment.wasLightNavigationBar);
|
|
||||||
}
|
|
||||||
super.dismiss();
|
|
||||||
actionBarLayout[0] = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
bottomSheet.show();
|
|
||||||
return actionBarLayout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CameraScanActivity(int type) {
|
public CameraScanActivity(int type) {
|
||||||
|
@ -1017,11 +969,26 @@ public class CameraScanActivity extends BaseFragment {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
text = result.getText();
|
text = result.getText();
|
||||||
|
if (result.getResultPoints() == null || result.getResultPoints().length == 0) {
|
||||||
|
bounds = null;
|
||||||
|
} else {
|
||||||
|
float minX = Float.MAX_VALUE,
|
||||||
|
maxX = Float.MIN_VALUE,
|
||||||
|
minY = Float.MAX_VALUE,
|
||||||
|
maxY = Float.MIN_VALUE;
|
||||||
|
for (ResultPoint point : result.getResultPoints()) {
|
||||||
|
minX = Math.min(minX, point.getX());
|
||||||
|
maxX = Math.max(maxX, point.getX());
|
||||||
|
minY = Math.min(minY, point.getY());
|
||||||
|
maxY = Math.max(maxY, point.getY());
|
||||||
|
}
|
||||||
|
bounds.set(minX, minY, maxX, maxY);
|
||||||
|
}
|
||||||
if (TextUtils.isEmpty(text)) {
|
if (TextUtils.isEmpty(text)) {
|
||||||
onNoQrFound();
|
onNoQrFound();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (any) return new QrResult(text, bounds);
|
||||||
if (needGalleryButton) {
|
if (needGalleryButton) {
|
||||||
if (!text.startsWith("ton://transfer/")) {
|
if (!text.startsWith("ton://transfer/")) {
|
||||||
//onNoWalletFound(bitmap != null);
|
//onNoWalletFound(bitmap != null);
|
||||||
|
|
|
@ -3936,6 +3936,12 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||||
public void didFindQr(String text) {
|
public void didFindQr(String text) {
|
||||||
ProxyUtil.showLinkAlert(getParentActivity(), text);
|
ProxyUtil.showLinkAlert(getParentActivity(), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean processQr(String text, Runnable onLoadEnd) {
|
||||||
|
onLoadEnd.run();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if (id >= 10 && id < 10 + accounts) {
|
} else if (id >= 10 && id < 10 + accounts) {
|
||||||
if (getParentActivity() == null) {
|
if (getParentActivity() == null) {
|
||||||
|
|
Loading…
Reference in New Issue