2929import io .github .muntashirakon .AppManager .utils .BetterActivityResult ;
3030import io .github .muntashirakon .AppManager .utils .UIUtils ;
3131import io .github .muntashirakon .adapters .SelectedArrayAdapter ;
32+ import io .github .muntashirakon .util .AccessibilityUtils ;
3233import io .github .muntashirakon .util .UiUtils ;
3334import io .github .muntashirakon .view .ProgressIndicatorCompat ;
3435import io .github .muntashirakon .widget .MaterialSpinner ;
@@ -43,6 +44,8 @@ public class AppUsageActivity extends BaseActivity implements SwipeRefreshLayout
4344 R .id .action_sort_by_wifi_data };
4445
4546 AppUsageViewModel viewModel ;
47+ MaterialSpinner spinner ;
48+ RecyclerView recyclerView ;
4649 LinearProgressIndicator progressIndicator ;
4750 private SwipeRefreshLayout mSwipeRefresh ;
4851 private AppUsageAdapter mAppUsageAdapter ;
@@ -68,7 +71,7 @@ protected void onAuthenticated(Bundle savedInstanceState) {
6871 progressIndicator .setVisibilityAfterHide (View .GONE );
6972
7073 // Interval
71- MaterialSpinner spinner = findViewById (R .id .spinner );
74+ spinner = findViewById (R .id .spinner );
7275 UiUtils .applyWindowInsetsAsMargin (spinner , false , false );
7376 spinner .requestFocus ();
7477 ArrayAdapter <CharSequence > intervalSpinnerAdapter = SelectedArrayAdapter .createFromResource (this ,
@@ -82,7 +85,7 @@ protected void onAuthenticated(Bundle savedInstanceState) {
8285
8386 // Get usage stats
8487 mAppUsageAdapter = new AppUsageAdapter (this );
85- RecyclerView recyclerView = findViewById (R .id .scrollView );
88+ recyclerView = findViewById (R .id .scrollView );
8689 recyclerView .setEmptyView (findViewById (android .R .id .empty ));
8790 recyclerView .setLayoutManager (UIUtils .getGridLayoutAt450Dp (this ));
8891 recyclerView .setAdapter (mAppUsageAdapter );
@@ -94,6 +97,15 @@ protected void onAuthenticated(Bundle savedInstanceState) {
9497 viewModel .getPackageUsageInfoList ().observe (this , packageUsageInfoList -> {
9598 ProgressIndicatorCompat .setVisibility (progressIndicator , false );
9699 mAppUsageAdapter .setDefaultList (packageUsageInfoList );
100+ // Focus on the first item
101+ recyclerView .post (() -> {
102+ if (recyclerView .getChildCount () > 0 ) {
103+ View firstChild = recyclerView .getChildAt (0 );
104+ if (firstChild != null ) {
105+ AccessibilityUtils .requestAccessibilityFocus (firstChild );
106+ }
107+ }
108+ });
97109 });
98110 viewModel .getPackageUsageInfo ().observe (this , packageUsageInfo -> {
99111 AppUsageDetailsDialog fragment = AppUsageDetailsDialog .getInstance (packageUsageInfo ,
0 commit comments