@@ -461,25 +461,11 @@ public void changeStatusBarColor(final String color, final int appearanceMode) {
461461 private int parseColor (String str ) {
462462 try {
463463 str = str .trim ();
464- if (str .toLowerCase ().contains ("rgb" )) {
465- String splitStr = str .substring (str .indexOf ('(' ) + 1 , str .indexOf (')' ));
466- String [] splitString = splitStr .split ("," );
467-
468- final int [] colorValues = new int [splitString .length ];
469- for (int i = 0 ; i < splitString .length ; i ++) {
470- colorValues [i ] = Integer .parseInt (splitString [i ].trim ());
471- }
472- return Color .rgb (colorValues [0 ], colorValues [1 ], colorValues [2 ]);
473- }
474- if (7 > str .length ()) {
475- // https://stackoverflow.com/questions/10230331/how-to-convert-3-digit-html-hex-colors-to-6-digit-flex-hex-colors
476- str = str .replaceAll ("#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])" , "#$1$1$2$2$3$3" );
477- }
478- if (9 == str .length () && '#' == str .charAt (0 )) {
479- // The status bar color on Android is incorrect https://github.com/siyuan-note/siyuan/issues/10278
480- // 将 #RRGGBBAA 转换为 #AARRGGBB
481- str = "#" + str .substring (7 , 9 ) + str .substring (1 , 7 );
464+ if (9 != str .length () || '#' != str .charAt (0 )) {
465+ throw new IllegalArgumentException ("invalid color format" );
482466 }
467+ // 将 #RRGGBBAA 转换为 #AARRGGBB
468+ str = "#" + str .substring (7 , 9 ) + str .substring (1 , 7 );
483469 return Color .parseColor (str );
484470 } catch (final Exception e ) {
485471 Utils .logError ("js" , "parse color [" + str + "] failed" , e );
0 commit comments