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

Commit bd90a9d3 authored by xutianguo's avatar xutianguo Committed by Myles Watson
Browse files

OPP: Format transfer percentage using DecimalFormat



The percentage text should be displayed in suitable
style in specific language.

Bug: 65226679
Test: Change language to Arabic and do Bluetooth sharing, the
percentage text is displayed in the correct style.

Change-Id: I3318610530122a25457adc0abc2e15196bea7d73
Signed-off-by: default avatarxutianguo <xutianguo@xiaomi.com>
parent b805ffe8
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ import android.util.Log;

import java.io.File;
import java.io.IOException;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@@ -271,14 +273,13 @@ public class BluetoothOppUtility {
     * Helper function to build the progress text.
     */
    public static String formatProgressText(long totalBytes, long currentBytes) {
        if (totalBytes <= 0) {
            return "0%";
        }
        long progress = currentBytes * 100 / totalBytes;
        StringBuilder sb = new StringBuilder();
        sb.append(progress);
        sb.append('%');
        return sb.toString();
        DecimalFormat df = new DecimalFormat("0%");
        df.setRoundingMode(RoundingMode.DOWN);
        double percent = 0.0;
        if (totalBytes > 0) {
            percent = currentBytes / (double) totalBytes;
        }
        return df.format(percent);
    }

    /**