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

Commit 783a1293 authored by Han Wang's avatar Han Wang Committed by Luca Stefani
Browse files

SystemUI: Do not convert application name to ISO-8859-15

 * ISO-8859-15 does not handle CJK chars, so all of them are
   'unknown' and empty eventually.

Change-Id: I27c689f5d737190d381146e49c1989e998b4f623
parent a10c52e0
Loading
Loading
Loading
Loading
+2 −13
Original line number Diff line number Diff line
@@ -112,7 +112,6 @@ import libcore.io.IoUtils;

import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -203,18 +202,8 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
        CharSequence appName = getRunningActivityName(context);
        boolean onKeyguard = context.getSystemService(KeyguardManager.class).isKeyguardLocked();
        if (!onKeyguard && appName != null) {
            String appNameString = appName.toString();
            try {
                // With some languages like Virgin Islands English, the Settings app gets a weird
                // long name and some special voodoo chars, so we convert the string to utf-8 to get
                // a  char instead, easy to remove it then
                final String temp = new String(appNameString.getBytes("ISO-8859-15"), "UTF-8");
                appNameString = temp.replaceAll("[]+", "");
            } catch (UnsupportedEncodingException e) {
                // Do nothing
            }
            // Now replace all spaces and special chars with an underscore
            appNameString = appNameString.replaceAll("[\\\\/:*?\"<>|\\s]+", "_");
            // Replace all spaces and special chars with an underscore
            String appNameString = appName.toString().replaceAll("[\\\\/:*?\"<>|\\s]+", "_");
            mImageFileName = String.format(SCREENSHOT_FILE_NAME_TEMPLATE_APPNAME,
                    imageDate, appNameString);
        } else {