Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8528f75 authored by Abhishek Aggarwal's avatar Abhishek Aggarwal
Browse files

eDrive: handle Invalid totalBytes for link parsing

parent 99b7f9d2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
        });

+9 −4
Original line number Diff line number Diff line
@@ -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);
    }