diff --git a/app/src/main/java/foundation/e/drive/activity/AccountsActivity.java b/app/src/main/java/foundation/e/drive/activity/AccountsActivity.java index dc911d456fb1c68a90a7cc510d125b4242ea2953..f40413ca15dfecd4bee2b826a77ccacfa80b8817 100644 --- a/app/src/main/java/foundation/e/drive/activity/AccountsActivity.java +++ b/app/src/main/java/foundation/e/drive/activity/AccountsActivity.java @@ -143,7 +143,7 @@ public class AccountsActivity extends AppCompatActivity { binding.upgrade.setOnClickListener(v -> { final Intent upgradeIntent = buildIntent(Intent.ACTION_VIEW, String.format(EDriveWidget.WEBPAGE, email, - dataForWeb(Long.parseLong(totalQuota)))); + dataForWeb(totalQuota))); startActivity(upgradeIntent); }); diff --git a/app/src/main/java/foundation/e/drive/widgets/EDriveWidget.java b/app/src/main/java/foundation/e/drive/widgets/EDriveWidget.java index 0041f9ab2a537a0b668b6dd7ca179659e6cd872e..25d870f7f6ff5f8aaa89a9cfe6a75591981967f6 100644 --- a/app/src/main/java/foundation/e/drive/widgets/EDriveWidget.java +++ b/app/src/main/java/foundation/e/drive/widgets/EDriveWidget.java @@ -68,8 +68,14 @@ public class EDriveWidget extends AppWidgetProvider { private RemoteViews views; private Account account = null; - public static String dataForWeb(Long bytes) { - final String space = CommonUtils.humanReadableByteCountBin(bytes); + public static String dataForWeb(String bytes) { + long convertedBytes = 0; + try { + convertedBytes = Long.parseLong(bytes); + } catch (NumberFormatException e) { + Log.i(TAG, "Invalid bytes " + bytes); + } + final String space = CommonUtils.humanReadableByteCountBin(convertedBytes); final String[] split = space.split(" "); return Math.round(Double.parseDouble(split[0])) + split[1]; } @@ -284,8 +290,7 @@ public class EDriveWidget extends AppWidgetProvider { final PendingIntent pendingIntentUpgrade = PendingIntent.getActivity(context, 0, buildIntent(Intent.ACTION_VIEW, String.format(WEBPAGE, email, - dataForWeb(Long.parseLong(totalQuota)))), - PendingIntent.FLAG_IMMUTABLE); + dataForWeb(totalQuota))), PendingIntent.FLAG_IMMUTABLE); views.setOnClickPendingIntent(R.id.upgrade, pendingIntentUpgrade); }