9393import timber .log .Timber ;
9494
9595public class Helper {
96- static private final String FLAVOR_SUFFIX =
97- (BuildConfig .FLAVOR .startsWith ("prod" ) ? "" : "." + BuildConfig .FLAVOR )
98- + (BuildConfig .DEBUG ? "-debug" : "" );
99-
10096 static public final String NOCRAZYPASS_FLAGFILE = ".nocrazypass" ;
10197
10298 static public final String BASE_CRYPTO = "XLA" ;
10399
104- static private final String WALLET_DIR = "scala" + FLAVOR_SUFFIX ;
105- static private final String HOME_DIR = "scala" + FLAVOR_SUFFIX ;
100+ static private final String WALLET_DIR = "wallets" ;
101+ static private final String SCALA_DIR = "scala" ;
106102
107103 static public int DISPLAY_DIGITS_INFO = 5 ;
108104
@@ -111,12 +107,7 @@ static public File getWalletRoot(Context context) {
111107 }
112108
113109 static public File getStorage (Context context , String folderName ) {
114- if (!isExternalStorageWritable ()) {
115- String msg = context .getString (R .string .message_strorage_not_writable );
116- Timber .e (msg );
117- throw new IllegalStateException (msg );
118- }
119- File dir = new File (Environment .getExternalStorageDirectory (), folderName );
110+ File dir = new File (context .getFilesDir (), folderName );
120111 if (!dir .exists ()) {
121112 Timber .i ("Creating %s" , dir .getAbsolutePath ());
122113 dir .mkdirs (); // try to make it
@@ -129,24 +120,6 @@ static public File getStorage(Context context, String folderName) {
129120 return dir ;
130121 }
131122
132- static public final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1 ;
133-
134- static public boolean getWritePermission (Activity context ) {
135- if (android .os .Build .VERSION .SDK_INT >= android .os .Build .VERSION_CODES .M ) {
136- if (context .checkSelfPermission (Manifest .permission .WRITE_EXTERNAL_STORAGE )
137- == PackageManager .PERMISSION_DENIED ) {
138- Timber .w ("Permission denied to WRITE_EXTERNAL_STORAGE - requesting it" );
139- String [] permissions = {Manifest .permission .WRITE_EXTERNAL_STORAGE };
140- context .requestPermissions (permissions , PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE );
141- return false ;
142- } else {
143- return true ;
144- }
145- } else {
146- return true ;
147- }
148- }
149-
150123 static public final int PERMISSIONS_REQUEST_CAMERA = 7 ;
151124
152125 static public boolean getCameraPermission (Activity context ) {
@@ -172,12 +145,6 @@ static public File getWalletFile(Context context, String aWalletName) {
172145 return f ;
173146 }
174147
175- /* Checks if external storage is available for read and write */
176- private static boolean isExternalStorageWritable () {
177- String state = Environment .getExternalStorageState ();
178- return Environment .MEDIA_MOUNTED .equals (state );
179- }
180-
181148 static public void showKeyboard (Activity act ) {
182149 if (act == null ) return ;
183150 if (act .getCurrentFocus () == null ) {
@@ -389,7 +356,7 @@ public static byte[] hexToBytes(String hex) {
389356
390357 static public void setScalaHome (Context context ) {
391358 try {
392- String home = getStorage (context , HOME_DIR ).getAbsolutePath ();
359+ String home = getStorage (context , SCALA_DIR ).getAbsolutePath ();
393360 Os .setenv ("HOME" , home , true );
394361 } catch (ErrnoException ex ) {
395362 throw new IllegalStateException (ex );
@@ -405,7 +372,7 @@ static public void initLogger(Context context) {
405372
406373 // TODO make the log levels refer to the WalletManagerFactory::LogLevel enum ?
407374 static public void initLogger (Context context , int level ) {
408- String home = getStorage (context , HOME_DIR ).getAbsolutePath ();
375+ String home = getStorage (context , SCALA_DIR ).getAbsolutePath ();
409376 WalletManager .initLogger (home + "/monerujo" , "monerujo.log" );
410377 if (level >= WalletManager .LOGLEVEL_SILENT )
411378 WalletManager .setLogLevel (level );
0 commit comments