날짜 형식 처리 안정성 강화 및 트랜잭션 삭제 시 앱 먹통 문제 해결
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package com.lovable.zellyfinance;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import com.getcapacitor.JSObject;
|
||||
import com.getcapacitor.Plugin;
|
||||
import com.getcapacitor.PluginMethod;
|
||||
import com.getcapacitor.annotation.CapacitorPlugin;
|
||||
import com.getcapacitor.PluginCall;
|
||||
|
||||
/**
|
||||
* 애플리케이션 빌드 정보를 제공하는 Capacitor 플러그인
|
||||
*/
|
||||
@CapacitorPlugin(name = "BuildInfo")
|
||||
public class BuildInfoPlugin extends Plugin {
|
||||
private static final String TAG = "BuildInfoPlugin";
|
||||
|
||||
/**
|
||||
* 빌드 정보를 가져오는 메서드
|
||||
* @param call 플러그인 호출 정보
|
||||
*/
|
||||
@PluginMethod
|
||||
public void getBuildInfo(PluginCall call) {
|
||||
try {
|
||||
Log.d(TAG, "빌드 정보 요청 수신됨");
|
||||
|
||||
JSObject ret = new JSObject();
|
||||
|
||||
// 빌드 정보 수집
|
||||
String versionName = BuildConfig.VERSION_NAME;
|
||||
int versionCode = BuildConfig.VERSION_CODE;
|
||||
int buildNumber = BuildConfig.BUILD_NUMBER;
|
||||
String packageName = getContext().getPackageName();
|
||||
|
||||
// 디버깅을 위한 로그 출력
|
||||
Log.d(TAG, "버전명: " + versionName);
|
||||
Log.d(TAG, "버전 코드: " + versionCode);
|
||||
Log.d(TAG, "빌드 번호: " + buildNumber);
|
||||
Log.d(TAG, "패키지명: " + packageName);
|
||||
|
||||
// 결과 객체에 값 설정
|
||||
ret.put("versionName", versionName);
|
||||
ret.put("versionCode", versionCode);
|
||||
ret.put("buildNumber", buildNumber);
|
||||
ret.put("packageName", packageName);
|
||||
ret.put("androidVersion", Build.VERSION.RELEASE);
|
||||
ret.put("androidSDK", Build.VERSION.SDK_INT);
|
||||
|
||||
// 현재 날짜를 디버깅 정보로 추가
|
||||
ret.put("buildDate", new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new java.util.Date()));
|
||||
|
||||
Log.d(TAG, "빌드 정보 요청 성공 처리");
|
||||
call.resolve(ret);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "빌드 정보 가져오기 실패", e);
|
||||
JSObject errorResult = new JSObject();
|
||||
errorResult.put("versionName", "1.0.0");
|
||||
errorResult.put("versionCode", 1);
|
||||
errorResult.put("buildNumber", 1);
|
||||
errorResult.put("error", e.getMessage());
|
||||
call.resolve(errorResult); // 에러가 발생해도 앱이 중단되지 않도록 resolve 호출
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.lovable.zellyfinance;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.Base64;
|
||||
|
||||
import com.getcapacitor.JSObject;
|
||||
import com.getcapacitor.Plugin;
|
||||
import com.getcapacitor.PluginMethod;
|
||||
import com.getcapacitor.annotation.CapacitorPlugin;
|
||||
import com.getcapacitor.PluginCall;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
@CapacitorPlugin(name = "ImagePlugin")
|
||||
public class ImagePlugin extends Plugin {
|
||||
|
||||
@PluginMethod
|
||||
public void getResourceImage(PluginCall call) {
|
||||
String resourceName = call.getString("resourceName");
|
||||
|
||||
if (resourceName == null) {
|
||||
call.reject("Resource name is required");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 리소스 ID 찾기
|
||||
int resourceId = getContext().getResources().getIdentifier(
|
||||
resourceName, "drawable", getContext().getPackageName());
|
||||
|
||||
if (resourceId == 0) {
|
||||
call.reject("Resource not found: " + resourceName);
|
||||
return;
|
||||
}
|
||||
|
||||
// 비트맵으로 변환
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(getContext().getResources(), resourceId);
|
||||
|
||||
// Base64로 인코딩
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
|
||||
byte[] byteArray = byteArrayOutputStream.toByteArray();
|
||||
String base64Image = Base64.encodeToString(byteArray, Base64.DEFAULT);
|
||||
|
||||
// 응답 생성
|
||||
JSObject ret = new JSObject();
|
||||
ret.put("base64Image", "data:image/png;base64," + base64Image);
|
||||
call.resolve(ret);
|
||||
|
||||
} catch (Exception e) {
|
||||
call.reject("Error loading image", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
android/app/src/main/res/drawable/zellyy.png
Normal file
BIN
android/app/src/main/res/drawable/zellyy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
BIN
android/app/src/main/res/mipmap/zellyy.png
Normal file
BIN
android/app/src/main/res/mipmap/zellyy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
BIN
android/app/src/main/res/raw/zellyy.png
Normal file
BIN
android/app/src/main/res/raw/zellyy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
Reference in New Issue
Block a user