タイポをところどころ修正しました。
This commit is contained in:
1 parent
aef4ba4bea
commit
895732b1b3
15 files changed
+77
-79
No files matched your search
@@ -1,19 +1,14 @@
|
||||
package com.example.childguard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.util.AndroidRuntimeException;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.print.PrintHelper;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.WriterException;
|
||||
@@ -30,20 +25,20 @@ public class QrUtils {
|
||||
|
||||
public Bitmap getBitmap(String key) {
|
||||
Log.d("getBitmap", "getBitmap: " + key);
|
||||
String KoteiURL = "https://practicefirestore1-8808c.web.app/?id=";
|
||||
String fixationURL = "https://practicefirestore1-8808c.web.app/?id=";
|
||||
//すべてのドメイン
|
||||
String AllURL;
|
||||
//IdPrefにの値が初期値の場合
|
||||
AllURL=KoteiURL+key;
|
||||
AllURL = fixationURL + key;
|
||||
|
||||
|
||||
int qrCodeSize = calculateQRCodeSize(); // 画面密度に応じてサイズを計算
|
||||
Bitmap QRGazou;
|
||||
Bitmap bitmapqr;
|
||||
Bitmap QRImage;
|
||||
Bitmap bitmapQR;
|
||||
try {
|
||||
//QRコード生成
|
||||
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
|
||||
bitmapqr = barcodeEncoder.encodeBitmap(AllURL, BarcodeFormat.QR_CODE, qrCodeSize, qrCodeSize);
|
||||
bitmapQR = barcodeEncoder.encodeBitmap(AllURL, BarcodeFormat.QR_CODE, qrCodeSize, qrCodeSize);
|
||||
} catch (WriterException e) {
|
||||
throw new AndroidRuntimeException("Barcode Error.", e);
|
||||
}
|
||||
@@ -51,19 +46,20 @@ public class QrUtils {
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(this.context.getResources(), R.drawable.a_group_qr_sos_2);
|
||||
int width = bitmap.getWidth();
|
||||
int height = bitmap.getHeight();
|
||||
QRGazou = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
QRImage = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
|
||||
// Canvasの準備
|
||||
Canvas canvas = new Canvas(QRGazou);
|
||||
Canvas canvas = new Canvas(QRImage);
|
||||
|
||||
// 画像のサイズの調整
|
||||
int disWidth = (width - bitmapqr.getWidth()) / 2;
|
||||
int disHeight = (int) ((height - bitmapqr.getHeight()) / 1.5);
|
||||
int disWidth = (width - bitmapQR.getWidth()) / 2;
|
||||
int disHeight = (int) ((height - bitmapQR.getHeight()) / 1.5);
|
||||
canvas.drawBitmap(bitmap, 0, 0, (Paint) null);
|
||||
canvas.drawBitmap(bitmapqr, disWidth, disHeight, (Paint) null); // 画像合成
|
||||
canvas.drawBitmap(bitmapQR, disWidth, disHeight, (Paint) null); // 画像合成
|
||||
//Androidからプリンターへ印刷指示を出すサポートライブラリ
|
||||
return QRGazou;
|
||||
return QRImage;
|
||||
}
|
||||
|
||||
private int calculateQRCodeSize() {
|
||||
// 画面解像度を取得
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
|
||||
Reference in new issue
Block a user