4646import java .util .stream .Stream ;
4747
4848public class MainActivity extends Activity implements
49- OnPermissionCallback ,
50- DialogInterface .OnClickListener ,
51- AdapterView .OnItemClickListener ,
52- View .OnClickListener {
49+ OnPermissionCallback ,
50+ DialogInterface .OnClickListener ,
51+ AdapterView .OnItemClickListener ,
52+ View .OnClickListener {
5353 private ImageView background ;
5454 private ImageView btnSettings ;
5555 private ImageView cover ;
@@ -77,12 +77,12 @@ protected void onCreate(Bundle savedInstanceState) {
7777 ONSVariable .dh = displayMetrics .heightPixels ;
7878 int phoneType = ((TelephonyManager ) getSystemService (Context .TELEPHONY_SERVICE )).getPhoneType ();
7979 double doubleValue = new BigDecimal (
80- ONSVariable .dw / ONSVariable .dh
80+ ONSVariable .dw / ONSVariable .dh
8181 ).setScale (
82- 2 ,
83- RoundingMode .HALF_UP
82+ 2 ,
83+ RoundingMode .HALF_UP
8484 ).doubleValue ();
85- if ((float )ONSVariable .dw / (float )ONSVariable .dh == 1.5d || doubleValue == 1.33d ) {
85+ if ((float ) ONSVariable .dw / (float ) ONSVariable .dh == 1.5d || doubleValue == 1.33d ) {
8686 setContentView (R .layout .activity_ft );
8787 } else if (phoneType == 0 ) {
8888 setContentView (R .layout .activity_pad );
@@ -102,7 +102,7 @@ protected void onCreate(Bundle savedInstanceState) {
102102 this .items .setOnPlayClickListener (this );
103103 }
104104
105- private <T extends View > T bindView (int i ) {
105+ private <T extends View > T bindView (int i ) {
106106 return findViewById (i );
107107 }
108108
@@ -118,18 +118,19 @@ private void externalStoragePermission() {
118118 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .R ) {
119119 if (!Environment .isExternalStorageManager ()) {
120120 XXPermissions .with (this ).permission (
121- Permission .MANAGE_EXTERNAL_STORAGE
121+ Permission .MANAGE_EXTERNAL_STORAGE
122122 ).request (this );
123123 }
124124 } else {
125125 XXPermissions .with (this ).permission (
126- Permission .READ_MEDIA_IMAGES ,
127- Permission .READ_MEDIA_VIDEO ,
128- Permission .READ_MEDIA_AUDIO
126+ Permission .READ_MEDIA_IMAGES ,
127+ Permission .READ_MEDIA_VIDEO ,
128+ Permission .READ_MEDIA_AUDIO
129129// Permission.WRITE_EXTERNAL_STORAGE
130130 ).request (this );
131131 }
132132 }
133+
133134 @ Override
134135 public void onGranted (List <String > permissions , boolean all ) {
135136 // Toast.makeText(MainActivity.this, "权限申请成功", Toast.LENGTH_SHORT).show();
@@ -152,16 +153,16 @@ public void setting() {
152153 int width = size .x ;
153154 int height = size .y ;
154155 settingPopupWindow = new PopupWindow (
155- linearLayout ,
156- width / 4 ,
157- height / 3 ,
158- true
156+ linearLayout ,
157+ width / 4 ,
158+ height / 3 ,
159+ true
159160 );
160161 settingPopupWindow .setAnimationStyle (R .style .Animation_ConfigPanelAnimation );
161162 settingPopupWindow .setTouchable (true );
162163 settingPopupWindow .setOutsideTouchable (true );
163164 settingPopupWindow .setBackgroundDrawable (getResources ().getDrawable (R .drawable .popup ));
164- settingPopupWindow .showAtLocation (this .background , Gravity .END | Gravity .BOTTOM , width / 14 , height / 24 );
165+ settingPopupWindow .showAtLocation (this .background , Gravity .END | Gravity .BOTTOM , width / 14 , height / 24 );
165166 View popupButton = linearLayout .findViewById (R .id .popup_path );
166167 popupButton .setOnClickListener (view -> this .chooseDir ());
167168 }
@@ -173,7 +174,7 @@ private void chooseDir() {
173174 strArr [strArr .length - 1 ] = getString (R .string .Other ) + "..." ;
174175 AlertDialog .Builder builder = new AlertDialog .Builder (this );
175176 builder .setInverseBackgroundForced (true );
176- builder .setTitle (getString (R .string .Launch_ChooseDirectory ));
177+ builder .setTitle (getString (R .string .Launch_AutoChooseDirectory ));
177178 builder .setItems (strArr , this );
178179 builder .setNegativeButton (getString (R .string .Cancel ), null );
179180 builder .setCancelable (true );
@@ -218,6 +219,20 @@ public void run() {
218219 }
219220 }
220221
222+ private void onOther () {
223+ AlertDialog .Builder builder = new AlertDialog .Builder (this );
224+ builder .setTitle (getString (R .string .Launch_OtherChooseDirectory ));
225+ this .mDirBrowserDirFileArray = new File [Globals .FallbackDirectoryValidPathArray .length ];
226+ for (int index = 0 ; index < Globals .FallbackDirectoryValidPathArray .length ; index ++) {
227+ this .mDirBrowserDirFileArray [index ] = new File (Globals .FallbackDirectoryValidPathArray [index ]);
228+ }
229+ builder .setItems (Globals .FallbackDirectoryValidPathArray , this );
230+ builder .setNegativeButton (getString (R .string .Cancel ), null );
231+ builder .setCancelable (true );
232+ this .mDirBrowserDialog = builder .create ();
233+ this .mDirBrowserDialog .show ();
234+ }
235+
221236 @ Override
222237 public void onClick (DialogInterface dialogInterface , int i ) {
223238 if (dialogInterface == this .mDirBrowserDialog ) {
@@ -229,15 +244,9 @@ public void onClick(DialogInterface dialogInterface, int i) {
229244 Settings .SaveGlobals (this );
230245 loadCurrentDirectory ();
231246 return ;
232- } else if (Globals .CurrentDirectoryPathForLauncher == null || Globals .CurrentDirectoryPathForLauncher .equals ("" )) {
233- File f = new File ("/storage" );
234- if (f .exists () && f .isDirectory () && f .canRead ()) {
235- this .mDirBrowserCurDirPath = "/storage" ;
236- } else {
237- this .mDirBrowserCurDirPath = "/mnt" ;
238- }
239247 } else {
240- this .mDirBrowserCurDirPath = Globals .CurrentDirectoryPathForLauncher ;
248+ this .onOther ();
249+ return ;
241250 }
242251 File file = new File (this .mDirBrowserCurDirPath );
243252 File parentFile = file .getParentFile ();
@@ -249,7 +258,7 @@ public void onClick(DialogInterface dialogInterface, int i) {
249258 try (Stream <Path > stream = Files .list (Paths .get (this .mDirBrowserCurDirPath ))) {
250259 stream .forEach (path -> {
251260 if (Files .isDirectory (path )
252- && Files .isReadable (path )) {
261+ && Files .isReadable (path )) {
253262 dirs .add (new File (path .toAbsolutePath ().toString ()));
254263 }
255264 });
@@ -316,11 +325,11 @@ private void loadGameItem(Game game) {
316325 }
317326
318327 private void updateCover (String cover , boolean b ) {
319- ImageLoader .getInstance ().displayImage ("file:/" + cover , this .cover , Settings .getDisplayImageOptions ());
328+ ImageLoader .getInstance ().displayImage ("file:/" + cover , this .cover , Settings .getDisplayImageOptions ());
320329 }
321330
322331 private void updateBackground (String background ) {
323- ImageLoader .getInstance ().displayImage ("file:/" + background , this .background , Settings .getDisplayImageOptions ());
332+ ImageLoader .getInstance ().displayImage ("file:/" + background , this .background , Settings .getDisplayImageOptions ());
324333 }
325334
326335 @ Override
@@ -332,14 +341,14 @@ public void onClick(View view) {
332341 // types(0:全局文字,1:普通文字, 2:精灵文字, 3: 菜单文字, 4: 弹窗文字, 5: ruby 文字),字体大小,字体大小倍率,字体颜色,是否描边,描边宽度,描边颜色,文字换行距离边距,文字换列距离边距
333342 // 大部分游戏只有 1, 2 生效,后面的文字都是用精灵文字去做的,还有不少弹框是用图片做的。
334343 extras .putStringArray (ONScripter .ARGS_KEY , new String []{
335- "-r" ,
336- selectedItem .path ,
337- "--scale-window" ,
338- "--fontcache" ,
344+ "-r" ,
345+ selectedItem .path ,
346+ "--scale-window" ,
347+ "--fontcache" ,
339348// "--font-config",
340349// "1:,1.2",
341- // "--sharpness",
342- // "1.0",
350+ // "--sharpness",
351+ // "1.0",
343352 });
344353 intent .putExtras (extras );
345354 startActivity (intent );
0 commit comments