@@ -16,15 +16,22 @@ import android.graphics.drawable.Icon
16
16
import android.os.Build
17
17
import android.os.Bundle
18
18
import android.os.storage.StorageManager
19
+ import android.util.Log
19
20
import android.view.ContextMenu
20
21
import android.view.KeyEvent
22
+ import android.view.Menu
21
23
import android.view.MenuItem
22
24
import android.view.View
23
25
import android.widget.Toast
24
26
import androidx.appcompat.app.AppCompatActivity
27
+ import androidx.appcompat.widget.Toolbar
25
28
import androidx.fragment.app.Fragment
26
29
import androidx.lifecycle.lifecycleScope
27
30
import androidx.preference.PreferenceManager
31
+ import com.getkeepsafe.taptargetview.TapTarget
32
+ import com.getkeepsafe.taptargetview.TapTargetSequence
33
+ import com.getkeepsafe.taptargetview.TapTargetView
34
+ import com.google.android.material.appbar.MaterialToolbar
28
35
import com.google.android.material.bottomnavigation.BottomNavigationView
29
36
import com.micewine.emu.BuildConfig
30
37
import com.micewine.emu.R
@@ -109,22 +116,23 @@ import com.micewine.emu.activities.GeneralSettings.Companion.WINE_LOG_LEVEL
109
116
import com.micewine.emu.activities.GeneralSettings.Companion.WINE_LOG_LEVEL_DEFAULT_VALUE
110
117
import com.micewine.emu.core.EnvVars
111
118
import com.micewine.emu.core.EnvVars.getEnv
119
+ import com.micewine.emu.core.HighlightState
112
120
import com.micewine.emu.core.RatPackageManager
113
121
import com.micewine.emu.core.RatPackageManager.installRat
114
122
import com.micewine.emu.core.ShellLoader.runCommand
115
123
import com.micewine.emu.core.ShellLoader.runCommandWithOutput
116
124
import com.micewine.emu.core.WineWrapper
117
125
import com.micewine.emu.databinding.ActivityMainBinding
118
- import com.micewine.emu.fragments.AboutFragment
126
+ import com.micewine.emu.fragments.HomeFragment
119
127
import com.micewine.emu.fragments.AskInstallRatPackageFragment
120
128
import com.micewine.emu.fragments.AskInstallRatPackageFragment.Companion.ratCandidate
121
129
import com.micewine.emu.fragments.DeleteGameItemFragment
122
130
import com.micewine.emu.fragments.FileManagerFragment
123
131
import com.micewine.emu.fragments.FileManagerFragment.Companion.refreshFiles
124
132
import com.micewine.emu.fragments.FloatingFileManagerFragment
125
- import com.micewine.emu.fragments.HomeFragment
126
- import com.micewine.emu.fragments.HomeFragment .Companion.saveToGameList
127
- import com.micewine.emu.fragments.HomeFragment .Companion.setIconToGame
133
+ import com.micewine.emu.fragments.ShortcutsFragment
134
+ import com.micewine.emu.fragments.ShortcutsFragment .Companion.saveToGameList
135
+ import com.micewine.emu.fragments.ShortcutsFragment .Companion.setIconToGame
128
136
import com.micewine.emu.fragments.RenameGameItemFragment
129
137
import com.micewine.emu.fragments.RenameGameItemFragment.Companion.initialTextRenameGameFragment
130
138
import com.micewine.emu.fragments.SettingsFragment
@@ -258,14 +266,17 @@ class MainActivity : AppCompatActivity() {
258
266
}
259
267
}
260
268
269
+ private var appToolbar: MaterialToolbar ? = null
261
270
private var bottomNavigation: BottomNavigationView ? = null
262
271
private var runningXServer = false
263
- private val homeFragment : HomeFragment = HomeFragment ()
272
+ private val shortcutsFragment : ShortcutsFragment = ShortcutsFragment ()
264
273
private val settingsFragment: SettingsFragment = SettingsFragment ()
265
274
private val fileManagerFragment: FileManagerFragment = FileManagerFragment ()
266
- private val aboutFragment : AboutFragment = AboutFragment ()
275
+ private val homeFragment : HomeFragment = HomeFragment ()
267
276
private var preferences: SharedPreferences ? = null
268
277
278
+ private var currentState: HighlightState ? = null
279
+
269
280
@SuppressLint(" UnspecifiedRegisterReceiverFlag" )
270
281
override fun onCreate (savedInstanceState : Bundle ? ) {
271
282
super .onCreate(savedInstanceState)
@@ -279,12 +290,16 @@ class MainActivity : AppCompatActivity() {
279
290
280
291
preferences = PreferenceManager .getDefaultSharedPreferences(this )
281
292
293
+ appToolbar = findViewById(R .id.appToolbar)
294
+ setSupportActionBar(appToolbar)
295
+
296
+
282
297
bottomNavigation = findViewById(R .id.bottom_navigation)
283
298
bottomNavigation?.setOnItemSelectedListener { item: MenuItem ->
284
299
when (item.itemId) {
285
- R .id.nav_home -> {
286
- selectedFragment = " HomeFragment "
287
- fragmentLoader(homeFragment , false )
300
+ R .id.nav_shortcuts -> {
301
+ selectedFragment = " ShortcutsFragment "
302
+ fragmentLoader(shortcutsFragment , false )
288
303
}
289
304
290
305
R .id.nav_settings -> {
@@ -297,9 +312,9 @@ class MainActivity : AppCompatActivity() {
297
312
fragmentLoader(fileManagerFragment, false )
298
313
}
299
314
300
- R .id.nav_about_micewine -> {
301
- selectedFragment = " AboutFragment "
302
- fragmentLoader(aboutFragment , false )
315
+ R .id.nav_home -> {
316
+ selectedFragment = " HomeFragment "
317
+ fragmentLoader(homeFragment , false )
303
318
}
304
319
}
305
320
@@ -332,6 +347,10 @@ class MainActivity : AppCompatActivity() {
332
347
}
333
348
}
334
349
350
+ override fun onCreateOptionsMenu (menu : Menu ? ): Boolean {
351
+ return true
352
+ }
353
+
335
354
override fun onPostCreate (savedInstanceState : Bundle ? ) {
336
355
super .onPostCreate(savedInstanceState)
337
356
@@ -341,6 +360,7 @@ class MainActivity : AppCompatActivity() {
341
360
)
342
361
} else {
343
362
setupDone = true
363
+ showHighlightSequence()
344
364
}
345
365
}
346
366
@@ -357,7 +377,7 @@ class MainActivity : AppCompatActivity() {
357
377
}
358
378
359
379
if (selectedFragment != " HomeFragment" ) {
360
- bottomNavigation?.selectedItemId = R .id.nav_home
380
+ bottomNavigation?.selectedItemId = R .id.nav_shortcuts
361
381
362
382
return true
363
383
}
@@ -375,7 +395,7 @@ class MainActivity : AppCompatActivity() {
375
395
v : View ? ,
376
396
menuInfo : ContextMenu .ContextMenuInfo ?
377
397
) {
378
- if (selectedFragment == " HomeFragment " ) {
398
+ if (selectedFragment == " ShortcutsFragment " ) {
379
399
menuInflater.inflate(R .menu.game_list_context_menu, menu)
380
400
} else if (selectedFragment == " FileManagerFragment" ) {
381
401
menuInflater.inflate(R .menu.file_list_context_menu, menu)
@@ -653,7 +673,7 @@ class MainActivity : AppCompatActivity() {
653
673
val shell = ShellLink (exePath)
654
674
val drive = DriveUtils .parseWindowsPath(shell.resolveTarget())
655
675
if (drive != null ) {
656
- WineWrapper .wine(" '${drive.getUnixPath()} '" , " '${File (drive.getUnixPath()).parent!! } '" )
676
+ WineWrapper .wine(" '${WineWrapper .getSanatizedPath( drive.getUnixPath()) } '" , " '${WineWrapper .getSanatizedPath( File (drive.getUnixPath()).parent!! ) } '" )
657
677
}
658
678
}
659
679
catch (e: ShellLinkException ) {
@@ -663,7 +683,7 @@ class MainActivity : AppCompatActivity() {
663
683
}
664
684
}
665
685
else {
666
- WineWrapper .wine(" '$exePath '" , " '${File (exePath).parent!! } '" )
686
+ WineWrapper .wine(" '${ WineWrapper .getSanatizedPath( exePath)} '" , " '${File (WineWrapper .getSanatizedPath( exePath) ).parent!! } '" )
667
687
}
668
688
}
669
689
@@ -763,6 +783,11 @@ class MainActivity : AppCompatActivity() {
763
783
764
784
fileManagerCwd = fileManagerDefaultDir
765
785
setupDone = true
786
+ withContext(Dispatchers .Main ) {
787
+ supportFragmentManager.beginTransaction().detach(homeFragment).commit()
788
+ supportFragmentManager.beginTransaction().attach(homeFragment).commit()
789
+ showHighlightSequence()
790
+ }
766
791
}
767
792
}
768
793
@@ -804,6 +829,76 @@ class MainActivity : AppCompatActivity() {
804
829
super .onNewIntent(intent)
805
830
}
806
831
832
+ private fun showHighlightSequence () {
833
+ currentState = HighlightState .fromOrdinal(preferences!! .getInt(HighlightState .HIGHLIGHT_PREFERENCE_KEY , 0 ))
834
+ if (currentState == HighlightState .HIGHLIGHT_DONE )
835
+ return
836
+ TapTargetSequence (this )
837
+ .targets(
838
+ TapTarget .forView(
839
+ findViewById(R .id.nav_shortcuts),
840
+ getString(R .string.highlight_nav_shortcuts)
841
+ ),
842
+
843
+ TapTarget .forView(
844
+ findViewById(R .id.nav_settings),
845
+ getString(R .string.highlight_nav_settings)
846
+ ),
847
+
848
+ TapTarget .forView(
849
+ findViewById(R .id.nav_file_manager),
850
+ getString(R .string.highlight_nav_files),
851
+ getString(R .string.highlight_nav_files_description)
852
+ )
853
+ )
854
+ .listener(object : TapTargetSequence .Listener {
855
+ override fun onSequenceFinish () {
856
+
857
+ }
858
+
859
+ override fun onSequenceStep (lastTarget : TapTarget , targetClicked : Boolean ) {
860
+ if (targetClicked) {
861
+ when (currentState) {
862
+ HighlightState .HIGHLIGHT_SHORTCUTS -> {
863
+ selectedFragment = " ShortcutsFragment"
864
+ fragmentLoader(shortcutsFragment, false )
865
+
866
+ val editor = preferences!! .edit()
867
+ currentState = HighlightState .HIGHLIGHT_SETTINGS
868
+ editor.putInt(HighlightState .HIGHLIGHT_PREFERENCE_KEY , currentState!! .ordinal)
869
+ editor.apply ()
870
+ }
871
+ HighlightState .HIGHLIGHT_SETTINGS -> {
872
+ selectedFragment = " SettingsFragment"
873
+ fragmentLoader(settingsFragment, false )
874
+
875
+ val editor = preferences!! .edit()
876
+ currentState = HighlightState .HIGHLIGHT_FILES
877
+ editor.putInt(HighlightState .HIGHLIGHT_PREFERENCE_KEY , currentState!! .ordinal)
878
+ editor.apply ()
879
+ }
880
+ HighlightState .HIGHLIGHT_FILES -> {
881
+ selectedFragment = " FileManagerFragment"
882
+ fragmentLoader(fileManagerFragment, false )
883
+
884
+ val editor = preferences!! .edit()
885
+ currentState = HighlightState .HIGHLIGHT_DONE
886
+ editor.putInt(HighlightState .HIGHLIGHT_PREFERENCE_KEY , currentState!! .ordinal)
887
+ editor.apply ()
888
+ }
889
+ else -> {
890
+ return
891
+ }
892
+ }
893
+ }
894
+ }
895
+
896
+ override fun onSequenceCanceled (lastTarget : TapTarget ) {
897
+ }
898
+ })
899
+ .start()
900
+ }
901
+
807
902
companion object {
808
903
@SuppressLint(" SdCardPath" )
809
904
val appRootDir = File (" /data/data/com.micewine.emu/files" )
0 commit comments