44import android .content .pm .PackageInfo ;
55import android .content .pm .PackageManager ;
66import android .content .pm .Signature ;
7+ import android .content .res .Resources ;
8+ import android .os .Build ;
9+ import android .support .annotation .StringRes ;
710import android .util .Log ;
811
912import java .io .ByteArrayInputStream ;
1619import java .security .cert .CertificateFactory ;
1720import java .security .cert .X509Certificate ;
1821import java .util .Arrays ;
22+ import java .util .Locale ;
1923
2024import javax .crypto .Cipher ;
2125import javax .crypto .SecretKey ;
@@ -148,7 +152,7 @@ private static String byteArrayToHexString(byte[] bytes) {
148152 * @param id
149153 * @return String
150154 */
151- public static String getString (int id ) {
155+ public static String getString (@ StringRes int id ) {
152156 if (context == null ) {
153157 Log .e (TAG , "Library not initialized: SC.init(Context)" );
154158 return null ;
@@ -163,6 +167,17 @@ public static String getString(int id) {
163167 return context .getString (id ); // returns original value, maybe not encrypted
164168 }
165169
170+ public static String getString (@ StringRes int id , Object ... formatArgs ) {
171+ String value = getString (id );
172+ Locale locale ;
173+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
174+ locale = Resources .getSystem ().getConfiguration ().getLocales ().get (0 );
175+ } else {
176+ locale = Resources .getSystem ().getConfiguration ().locale ;
177+ }
178+ return String .format (locale , value , formatArgs );
179+ }
180+
166181 /**
167182 * encrypts the given value
168183 * @param value
0 commit comments