Loading src/com/android/documentsui/ActionModeController.java +9 −7 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.documentsui; import static com.android.documentsui.base.SharedMinimal.DEBUG; import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled; import static com.android.documentsui.util.Material3Config.getRes; import android.app.Activity; import android.util.Log; Loading Loading @@ -100,8 +101,9 @@ public class ActionModeController extends SelectionObserver<String> if (mActionMode != null) { assert(!mSelected.isEmpty()); final String title = mMessages.getQuantityString( R.plurals.elements_selected, mSelected.size()); final String title = mMessages.getQuantityString( getRes(R.plurals.elements_selected), mSelected.size()); mActionMode.setTitle(title); mActivity.getWindow().setTitle(title); } Loading Loading @@ -139,8 +141,8 @@ public class ActionModeController extends SelectionObserver<String> // Re-enable TalkBack for the toolbars, as they are no longer covered by action mode. int[] toolbarIds = isUseMaterial3FlagEnabled() ? new int[] {R.id.toolbar} : new int[] {R.id.toolbar, R.id.roots_toolbar}; ? new int[] {getRes(R.id.toolbar)} : new int[] {getRes(R.id.toolbar), getRes(R.id.roots_toolbar)}; mScope.accessibilityImportanceSetter.setAccessibilityImportance( View.IMPORTANT_FOR_ACCESSIBILITY_AUTO, toolbarIds); Loading @@ -150,7 +152,7 @@ public class ActionModeController extends SelectionObserver<String> @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { int size = mSelectionMgr.getSelection().size(); mode.getMenuInflater().inflate(R.menu.action_mode_menu, menu); mode.getMenuInflater().inflate(getRes(R.menu.action_mode_menu), menu); mode.setTitle(mActivity.getResources().getQuantityString(R.plurals.selected_count, size)); if (size > 0) { Loading @@ -160,8 +162,8 @@ public class ActionModeController extends SelectionObserver<String> // these controls when using linear navigation. int[] toolbarIds = isUseMaterial3FlagEnabled() ? new int[] {R.id.toolbar} : new int[] {R.id.toolbar, R.id.roots_toolbar}; ? new int[] {getRes(R.id.toolbar)} : new int[] {getRes(R.id.toolbar), getRes(R.id.roots_toolbar)}; mScope.accessibilityImportanceSetter.setAccessibilityImportance( View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, toolbarIds); Loading src/com/android/documentsui/BaseActivity.java +65 −53 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.documentsui.base.SharedMinimal.DEBUG; import static com.android.documentsui.base.State.MODE_GRID; import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled; import static com.android.documentsui.util.FlagUtils.isUsePeekPreviewFlagEnabled; import static com.android.documentsui.util.Material3Config.getRes; import android.content.Context; import android.content.Intent; Loading Loading @@ -184,7 +185,7 @@ public abstract class BaseActivity // ToDo Create tool to check resource version before applyStyle for the theme // If version code is not match, we should reset overlay package to default, // in case Activity continuously encounter resource not found exception. getTheme().applyStyle(R.style.DocumentsDefaultTheme, false); getTheme().applyStyle(getRes(R.style.DocumentsDefaultTheme), false); if (isUseMaterial3FlagEnabled() && SdkLevel.isAtLeastS()) { DynamicColors.applyToActivityIfAvailable(this); Loading @@ -208,10 +209,10 @@ public abstract class BaseActivity Metrics.logActivityLaunch(mState, intent); if (isUseMaterial3FlagEnabled()) { View navRailRoots = findViewById(R.id.nav_rail_container_roots); View navRailRoots = findViewById(getRes(R.id.nav_rail_container_roots)); if (navRailRoots != null) { // Bind event listener for the burger menu on nav rail. MaterialButton burgerMenu = findViewById(R.id.nav_rail_burger_menu); MaterialButton burgerMenu = findViewById(getRes(R.id.nav_rail_burger_menu)); burgerMenu.setOnClickListener(v -> mDrawer.setOpen(true)); burgerMenu.setOnFocusChangeListener(this::onBurgerMenuFocusChange); } Loading @@ -220,16 +221,16 @@ public abstract class BaseActivity mProviders = DocumentsApplication.getProvidersCache(this); mDocs = DocumentsAccess.create(this, mState); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(getRes(R.id.toolbar)); setSupportActionBar(toolbar); Breadcrumb breadcrumb = findViewById(R.id.horizontal_breadcrumb); Breadcrumb breadcrumb = findViewById(getRes(R.id.horizontal_breadcrumb)); assert (breadcrumb != null); View profileTabsContainer = findViewById(R.id.tabs_container); View profileTabsContainer = findViewById(getRes(R.id.tabs_container)); assert (profileTabsContainer != null); mNavigator = getNavigationViewManager(breadcrumb, profileTabsContainer); AppBarLayout appBarLayout = findViewById(R.id.app_bar); AppBarLayout appBarLayout = findViewById(getRes(R.id.app_bar)); if (appBarLayout != null) { appBarLayout.addOnOffsetChangedListener(mNavigator); } Loading Loading @@ -329,10 +330,10 @@ public abstract class BaseActivity mInjector.debugHelper::toggleDebugMode, cmdInterceptor); ViewGroup chipGroup = findViewById(R.id.search_chip_group); ViewGroup chipGroup = findViewById(getRes(R.id.search_chip_group)); View searchOptionsView = null; if (isUseMaterial3FlagEnabled()) { searchOptionsView = findViewById(R.id.search_options_row); searchOptionsView = findViewById(getRes(R.id.search_options_row)); } mUserIdManager = DocumentsApplication.getUserIdManager(this); Loading Loading @@ -409,7 +410,7 @@ public abstract class BaseActivity mSortController = SortController.create(this, mState.derivedMode, mState.sortModel); if (isUseMaterial3FlagEnabled()) { View previewIconPlaceholder = findViewById(R.id.preview_icon_placeholder); View previewIconPlaceholder = findViewById(getRes(R.id.preview_icon_placeholder)); if (previewIconPlaceholder != null) { previewIconPlaceholder.setVisibility( mState.shouldShowPreview() ? View.VISIBLE : View.GONE); Loading Loading @@ -504,18 +505,18 @@ public abstract class BaseActivity } boolean showMenu = super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.activity, menu); getMenuInflater().inflate(getRes(R.menu.activity), menu); mNavigator.update(); boolean fullBarSearch = getResources().getBoolean(R.bool.full_bar_search_view); boolean showSearchBar = getResources().getBoolean(R.bool.show_search_bar); mSearchManager.install(menu, fullBarSearch, showSearchBar); // Remove the subMenu when material3 is launched b/379776735. final ActionMenuView subMenuView = findViewById(R.id.sub_menu); final ActionMenuView subMenuView = findViewById(getRes(R.id.sub_menu)); // If size is 0, it means the menu has not inflated and it should only do once. if (subMenuView != null && subMenuView.getMenu().size() == 0) { subMenuView.setOnMenuItemClickListener(this::onOptionsItemSelected); getMenuInflater().inflate(R.menu.sub_menu, subMenuView.getMenu()); getMenuInflater().inflate(getRes(R.menu.sub_menu), subMenuView.getMenu()); } return showMenu; Loading @@ -532,7 +533,7 @@ public abstract class BaseActivity } } else { mSearchManager.showMenu(mState.stack); final ActionMenuView subMenuView = findViewById(R.id.sub_menu); final ActionMenuView subMenuView = findViewById(getRes(R.id.sub_menu)); mInjector.menuManager.updateSubMenu(subMenuView.getMenu()); } Loading Loading @@ -582,7 +583,7 @@ public abstract class BaseActivity } private void setContainer() { View root = findViewById(R.id.coordinator_layout); View root = findViewById(getRes(R.id.coordinator_layout)); root.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); root.setOnApplyWindowInsetsListener( Loading @@ -602,10 +603,10 @@ public abstract class BaseActivity .getPackageManager() .hasSystemFeature( PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT)) { View saveContainer = findViewById(R.id.container_save); View saveContainer = findViewById(getRes(R.id.container_save)); saveContainer.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); View rootsContainer = findViewById(R.id.container_roots); View rootsContainer = findViewById(getRes(R.id.container_roots)); rootsContainer.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); } Loading Loading @@ -681,31 +682,31 @@ public abstract class BaseActivity if (id == android.R.id.home) { onBackPressed(); return true; } else if (id == R.id.option_menu_create_dir) { } else if (id == getRes(R.id.option_menu_create_dir)) { getInjector().actions.showCreateDirectoryDialog(); return true; } else if (id == R.id.option_menu_search) { } else if (id == getRes(R.id.option_menu_search)) { // SearchViewManager listens for this directly. return false; } else if (id == R.id.option_menu_select_all) { } else if (id == getRes(R.id.option_menu_select_all)) { getInjector().actions.selectAllFiles(); return true; } else if (id == R.id.option_menu_debug) { } else if (id == getRes(R.id.option_menu_debug)) { getInjector().actions.showDebugMessage(); return true; } else if (id == R.id.option_menu_sort) { } else if (id == getRes(R.id.option_menu_sort)) { getInjector().actions.showSortDialog(); return true; } else if (id == R.id.option_menu_launcher) { } else if (id == getRes(R.id.option_menu_launcher)) { getInjector().actions.switchLauncherIcon(); return true; } else if (id == R.id.option_menu_show_hidden_files) { } else if (id == getRes(R.id.option_menu_show_hidden_files)) { onClickedShowHiddenFiles(); return true; } else if (id == R.id.sub_menu_grid) { } else if (id == getRes(R.id.sub_menu_grid)) { setViewMode(MODE_GRID); return true; } else if (id == R.id.sub_menu_list) { } else if (id == getRes(R.id.sub_menu_list)) { setViewMode(State.MODE_LIST); return true; } Loading Loading @@ -788,7 +789,7 @@ public abstract class BaseActivity } } String appName = getString(R.string.files_label); String appName = getString(getRes(R.string.files_label)); String currentTitle = getTitle() != null ? getTitle().toString() : ""; if (currentTitle.equals(appName)) { // First launch, TalkBack announces app name. Loading Loading @@ -867,7 +868,7 @@ public abstract class BaseActivity if (isUseMaterial3FlagEnabled()) { mInjector.menuManager.updateSubMenu(null); } else { final ActionMenuView subMenuView = findViewById(R.id.sub_menu); final ActionMenuView subMenuView = findViewById(getRes(R.id.sub_menu)); mInjector.menuManager.updateSubMenu(subMenuView.getMenu()); } Loading @@ -890,7 +891,7 @@ public abstract class BaseActivity } public void expandAppBar() { final AppBarLayout appBarLayout = findViewById(R.id.app_bar); final AppBarLayout appBarLayout = findViewById(getRes(R.id.app_bar)); if (appBarLayout != null) { appBarLayout.setExpanded(true); } Loading @@ -903,7 +904,7 @@ public abstract class BaseActivity */ public void updateHeader(boolean shouldHideHeader) { // Remove headContainer when material3 is launched. b/379776735. View headerContainer = findViewById(R.id.header_container); View headerContainer = findViewById(getRes(R.id.header_container)); if (headerContainer == null) { updateHeaderTitle(); return; Loading Loading @@ -951,7 +952,7 @@ public abstract class BaseActivity } // Remove the headerTitle when material3 is launched b/379776735. TextView headerTitle = findViewById(R.id.header_title); TextView headerTitle = findViewById(getRes(R.id.header_title)); if (headerTitle != null) { headerTitle.setText(result); } Loading @@ -962,44 +963,55 @@ public abstract class BaseActivity // is not expanded on that time. boolean isGlobalSearch = mSearchManager.isSearching() || mState.stack.size() > 1; if (mState.isPhotoPicking()) { final int resId = isGlobalSearch ? R.string.root_info_header_image_global_search : R.string.root_info_header_image_recent; final int resId = isGlobalSearch ? getRes(R.string.root_info_header_image_global_search) : getRes(R.string.root_info_header_image_recent); return getString(resId); } else { final int resId = isGlobalSearch ? R.string.root_info_header_global_search : R.string.root_info_header_recent; final int resId = isGlobalSearch ? getRes(R.string.root_info_header_global_search) : getRes(R.string.root_info_header_recent); return getString(resId); } } private String getHeaderDownloadsTitle() { return getString(mState.isPhotoPicking() ? R.string.root_info_header_image_downloads : R.string.root_info_header_downloads); return getString( mState.isPhotoPicking() ? getRes(R.string.root_info_header_image_downloads) : getRes(R.string.root_info_header_downloads)); } private String getHeaderStorageTitle(String rootTitle) { if (mState.stack.size() > 1) { final int resId = mState.isPhotoPicking() ? R.string.root_info_header_image_folder : R.string.root_info_header_folder; final int resId = mState.isPhotoPicking() ? getRes(R.string.root_info_header_image_folder) : getRes(R.string.root_info_header_folder); return getString(resId, getCurrentTitle()); } else { final int resId = mState.isPhotoPicking() ? R.string.root_info_header_image_storage : R.string.root_info_header_storage; final int resId = mState.isPhotoPicking() ? getRes(R.string.root_info_header_image_storage) : getRes(R.string.root_info_header_storage); return getString(resId, rootTitle); } } private String getHeaderDefaultTitle(String rootTitle, String summary) { if (TextUtils.isEmpty(summary)) { final int resId = mState.isPhotoPicking() ? R.string.root_info_header_image_app : R.string.root_info_header_app; final int resId = mState.isPhotoPicking() ? getRes(R.string.root_info_header_image_app) : getRes(R.string.root_info_header_app); return getString(resId, rootTitle); } else { final int resId = mState.isPhotoPicking() ? R.string.root_info_header_image_app_with_summary : R.string.root_info_header_app_with_summary; final int resId = mState.isPhotoPicking() ? getRes(R.string.root_info_header_image_app_with_summary) : getRes(R.string.root_info_header_app_with_summary); return getString(resId, rootTitle, summary); } } Loading Loading @@ -1205,8 +1217,8 @@ public abstract class BaseActivity private void onBurgerMenuFocusChange(View v, boolean hasFocus) { MaterialButton burgerMenu = (MaterialButton) v; if (hasFocus) { final int focusRingWidth = getResources() .getDimensionPixelSize(R.dimen.focus_ring_width); final int focusRingWidth = getResources().getDimensionPixelSize(getRes(R.dimen.focus_ring_width)); burgerMenu.setStrokeWidth(focusRingWidth); } else { burgerMenu.setStrokeWidth(0); Loading src/com/android/documentsui/BreadcrumbHolder.java +4 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.documentsui; import static com.android.documentsui.util.Material3Config.getRes; import android.view.View; import android.widget.ImageView; import android.widget.TextView; Loading @@ -31,8 +33,8 @@ public final class BreadcrumbHolder extends RecyclerView.ViewHolder { public BreadcrumbHolder(View itemView) { super(itemView); mTitle = itemView.findViewById(R.id.breadcrumb_text); mArrow = itemView.findViewById(R.id.breadcrumb_arrow); mTitle = itemView.findViewById(getRes(R.id.breadcrumb_text)); mArrow = itemView.findViewById(getRes(R.id.breadcrumb_arrow)); mLast = false; } Loading src/com/android/documentsui/CreateDirectoryFragment.java +8 −7 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.documentsui; import static android.content.ContentResolver.wrap; import static com.android.documentsui.base.SharedMinimal.TAG; import static com.android.documentsui.util.Material3Config.getRes; import android.app.Dialog; import android.content.ContentProviderClient; Loading Loading @@ -80,13 +81,13 @@ public class CreateDirectoryFragment extends DialogFragment { final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context); final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext()); final View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false); final View view = dialogInflater.inflate(getRes(R.layout.dialog_file_name), null, false); mEditText = (EditText) view.findViewById(android.R.id.text1); mInputWrapper = view.findViewById(R.id.input_wrapper); mInputWrapper.setHint(getString(R.string.input_hint_new_folder)); mInputWrapper = view.findViewById(getRes(R.id.input_wrapper)); mInputWrapper.setHint(getString(getRes(R.string.input_hint_new_folder))); builder.setTitle(R.string.menu_create_dir); builder.setTitle(getRes(R.string.menu_create_dir)); builder.setView(view); builder.setPositiveButton(android.R.string.ok, null); builder.setNegativeButton(android.R.string.cancel, null); Loading Loading @@ -125,8 +126,7 @@ public class CreateDirectoryFragment extends DialogFragment { private void createDirectory(String name) { if (name.isEmpty()) { mInputWrapper.setError(getContext().getString( R.string.add_folder_name_error)); mInputWrapper.setError(getContext().getString(getRes(R.string.add_folder_name_error))); } else { final BaseActivity activity = (BaseActivity) getActivity(); final DocumentInfo cwd = activity.getCurrentDirectory(); Loading Loading @@ -175,7 +175,8 @@ public class CreateDirectoryFragment extends DialogFragment { mActivity.onDirectoryCreated(result); Metrics.logCreateDirOperation(); } else { Snackbars.makeSnackbar(mActivity, R.string.create_error, Snackbar.LENGTH_LONG) Snackbars.makeSnackbar( mActivity, getRes(R.string.create_error), Snackbar.LENGTH_LONG) .show(); Metrics.logCreateDirError(); } Loading src/com/android/documentsui/DragAndDropManager.java +4 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.documentsui; import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled; import static com.android.documentsui.util.Material3Config.getRes; import android.content.ClipData; import android.content.Context; Loading Loading @@ -286,8 +287,9 @@ public interface DragAndDropManager { title = doc.displayName; icon = iconHelper.getDocumentIcon(mContext, doc); } else { title = mContext.getResources() .getQuantityString(R.plurals.elements_dragged, size, size); title = mContext.getResources() .getQuantityString(getRes(R.plurals.elements_dragged), size, size); icon = mDefaultShadowIcon; } Loading Loading
src/com/android/documentsui/ActionModeController.java +9 −7 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.documentsui; import static com.android.documentsui.base.SharedMinimal.DEBUG; import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled; import static com.android.documentsui.util.Material3Config.getRes; import android.app.Activity; import android.util.Log; Loading Loading @@ -100,8 +101,9 @@ public class ActionModeController extends SelectionObserver<String> if (mActionMode != null) { assert(!mSelected.isEmpty()); final String title = mMessages.getQuantityString( R.plurals.elements_selected, mSelected.size()); final String title = mMessages.getQuantityString( getRes(R.plurals.elements_selected), mSelected.size()); mActionMode.setTitle(title); mActivity.getWindow().setTitle(title); } Loading Loading @@ -139,8 +141,8 @@ public class ActionModeController extends SelectionObserver<String> // Re-enable TalkBack for the toolbars, as they are no longer covered by action mode. int[] toolbarIds = isUseMaterial3FlagEnabled() ? new int[] {R.id.toolbar} : new int[] {R.id.toolbar, R.id.roots_toolbar}; ? new int[] {getRes(R.id.toolbar)} : new int[] {getRes(R.id.toolbar), getRes(R.id.roots_toolbar)}; mScope.accessibilityImportanceSetter.setAccessibilityImportance( View.IMPORTANT_FOR_ACCESSIBILITY_AUTO, toolbarIds); Loading @@ -150,7 +152,7 @@ public class ActionModeController extends SelectionObserver<String> @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { int size = mSelectionMgr.getSelection().size(); mode.getMenuInflater().inflate(R.menu.action_mode_menu, menu); mode.getMenuInflater().inflate(getRes(R.menu.action_mode_menu), menu); mode.setTitle(mActivity.getResources().getQuantityString(R.plurals.selected_count, size)); if (size > 0) { Loading @@ -160,8 +162,8 @@ public class ActionModeController extends SelectionObserver<String> // these controls when using linear navigation. int[] toolbarIds = isUseMaterial3FlagEnabled() ? new int[] {R.id.toolbar} : new int[] {R.id.toolbar, R.id.roots_toolbar}; ? new int[] {getRes(R.id.toolbar)} : new int[] {getRes(R.id.toolbar), getRes(R.id.roots_toolbar)}; mScope.accessibilityImportanceSetter.setAccessibilityImportance( View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, toolbarIds); Loading
src/com/android/documentsui/BaseActivity.java +65 −53 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.documentsui.base.SharedMinimal.DEBUG; import static com.android.documentsui.base.State.MODE_GRID; import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled; import static com.android.documentsui.util.FlagUtils.isUsePeekPreviewFlagEnabled; import static com.android.documentsui.util.Material3Config.getRes; import android.content.Context; import android.content.Intent; Loading Loading @@ -184,7 +185,7 @@ public abstract class BaseActivity // ToDo Create tool to check resource version before applyStyle for the theme // If version code is not match, we should reset overlay package to default, // in case Activity continuously encounter resource not found exception. getTheme().applyStyle(R.style.DocumentsDefaultTheme, false); getTheme().applyStyle(getRes(R.style.DocumentsDefaultTheme), false); if (isUseMaterial3FlagEnabled() && SdkLevel.isAtLeastS()) { DynamicColors.applyToActivityIfAvailable(this); Loading @@ -208,10 +209,10 @@ public abstract class BaseActivity Metrics.logActivityLaunch(mState, intent); if (isUseMaterial3FlagEnabled()) { View navRailRoots = findViewById(R.id.nav_rail_container_roots); View navRailRoots = findViewById(getRes(R.id.nav_rail_container_roots)); if (navRailRoots != null) { // Bind event listener for the burger menu on nav rail. MaterialButton burgerMenu = findViewById(R.id.nav_rail_burger_menu); MaterialButton burgerMenu = findViewById(getRes(R.id.nav_rail_burger_menu)); burgerMenu.setOnClickListener(v -> mDrawer.setOpen(true)); burgerMenu.setOnFocusChangeListener(this::onBurgerMenuFocusChange); } Loading @@ -220,16 +221,16 @@ public abstract class BaseActivity mProviders = DocumentsApplication.getProvidersCache(this); mDocs = DocumentsAccess.create(this, mState); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(getRes(R.id.toolbar)); setSupportActionBar(toolbar); Breadcrumb breadcrumb = findViewById(R.id.horizontal_breadcrumb); Breadcrumb breadcrumb = findViewById(getRes(R.id.horizontal_breadcrumb)); assert (breadcrumb != null); View profileTabsContainer = findViewById(R.id.tabs_container); View profileTabsContainer = findViewById(getRes(R.id.tabs_container)); assert (profileTabsContainer != null); mNavigator = getNavigationViewManager(breadcrumb, profileTabsContainer); AppBarLayout appBarLayout = findViewById(R.id.app_bar); AppBarLayout appBarLayout = findViewById(getRes(R.id.app_bar)); if (appBarLayout != null) { appBarLayout.addOnOffsetChangedListener(mNavigator); } Loading Loading @@ -329,10 +330,10 @@ public abstract class BaseActivity mInjector.debugHelper::toggleDebugMode, cmdInterceptor); ViewGroup chipGroup = findViewById(R.id.search_chip_group); ViewGroup chipGroup = findViewById(getRes(R.id.search_chip_group)); View searchOptionsView = null; if (isUseMaterial3FlagEnabled()) { searchOptionsView = findViewById(R.id.search_options_row); searchOptionsView = findViewById(getRes(R.id.search_options_row)); } mUserIdManager = DocumentsApplication.getUserIdManager(this); Loading Loading @@ -409,7 +410,7 @@ public abstract class BaseActivity mSortController = SortController.create(this, mState.derivedMode, mState.sortModel); if (isUseMaterial3FlagEnabled()) { View previewIconPlaceholder = findViewById(R.id.preview_icon_placeholder); View previewIconPlaceholder = findViewById(getRes(R.id.preview_icon_placeholder)); if (previewIconPlaceholder != null) { previewIconPlaceholder.setVisibility( mState.shouldShowPreview() ? View.VISIBLE : View.GONE); Loading Loading @@ -504,18 +505,18 @@ public abstract class BaseActivity } boolean showMenu = super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.activity, menu); getMenuInflater().inflate(getRes(R.menu.activity), menu); mNavigator.update(); boolean fullBarSearch = getResources().getBoolean(R.bool.full_bar_search_view); boolean showSearchBar = getResources().getBoolean(R.bool.show_search_bar); mSearchManager.install(menu, fullBarSearch, showSearchBar); // Remove the subMenu when material3 is launched b/379776735. final ActionMenuView subMenuView = findViewById(R.id.sub_menu); final ActionMenuView subMenuView = findViewById(getRes(R.id.sub_menu)); // If size is 0, it means the menu has not inflated and it should only do once. if (subMenuView != null && subMenuView.getMenu().size() == 0) { subMenuView.setOnMenuItemClickListener(this::onOptionsItemSelected); getMenuInflater().inflate(R.menu.sub_menu, subMenuView.getMenu()); getMenuInflater().inflate(getRes(R.menu.sub_menu), subMenuView.getMenu()); } return showMenu; Loading @@ -532,7 +533,7 @@ public abstract class BaseActivity } } else { mSearchManager.showMenu(mState.stack); final ActionMenuView subMenuView = findViewById(R.id.sub_menu); final ActionMenuView subMenuView = findViewById(getRes(R.id.sub_menu)); mInjector.menuManager.updateSubMenu(subMenuView.getMenu()); } Loading Loading @@ -582,7 +583,7 @@ public abstract class BaseActivity } private void setContainer() { View root = findViewById(R.id.coordinator_layout); View root = findViewById(getRes(R.id.coordinator_layout)); root.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); root.setOnApplyWindowInsetsListener( Loading @@ -602,10 +603,10 @@ public abstract class BaseActivity .getPackageManager() .hasSystemFeature( PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT)) { View saveContainer = findViewById(R.id.container_save); View saveContainer = findViewById(getRes(R.id.container_save)); saveContainer.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); View rootsContainer = findViewById(R.id.container_roots); View rootsContainer = findViewById(getRes(R.id.container_roots)); rootsContainer.setPadding(0, 0, 0, insets.getSystemWindowInsetBottom()); } Loading Loading @@ -681,31 +682,31 @@ public abstract class BaseActivity if (id == android.R.id.home) { onBackPressed(); return true; } else if (id == R.id.option_menu_create_dir) { } else if (id == getRes(R.id.option_menu_create_dir)) { getInjector().actions.showCreateDirectoryDialog(); return true; } else if (id == R.id.option_menu_search) { } else if (id == getRes(R.id.option_menu_search)) { // SearchViewManager listens for this directly. return false; } else if (id == R.id.option_menu_select_all) { } else if (id == getRes(R.id.option_menu_select_all)) { getInjector().actions.selectAllFiles(); return true; } else if (id == R.id.option_menu_debug) { } else if (id == getRes(R.id.option_menu_debug)) { getInjector().actions.showDebugMessage(); return true; } else if (id == R.id.option_menu_sort) { } else if (id == getRes(R.id.option_menu_sort)) { getInjector().actions.showSortDialog(); return true; } else if (id == R.id.option_menu_launcher) { } else if (id == getRes(R.id.option_menu_launcher)) { getInjector().actions.switchLauncherIcon(); return true; } else if (id == R.id.option_menu_show_hidden_files) { } else if (id == getRes(R.id.option_menu_show_hidden_files)) { onClickedShowHiddenFiles(); return true; } else if (id == R.id.sub_menu_grid) { } else if (id == getRes(R.id.sub_menu_grid)) { setViewMode(MODE_GRID); return true; } else if (id == R.id.sub_menu_list) { } else if (id == getRes(R.id.sub_menu_list)) { setViewMode(State.MODE_LIST); return true; } Loading Loading @@ -788,7 +789,7 @@ public abstract class BaseActivity } } String appName = getString(R.string.files_label); String appName = getString(getRes(R.string.files_label)); String currentTitle = getTitle() != null ? getTitle().toString() : ""; if (currentTitle.equals(appName)) { // First launch, TalkBack announces app name. Loading Loading @@ -867,7 +868,7 @@ public abstract class BaseActivity if (isUseMaterial3FlagEnabled()) { mInjector.menuManager.updateSubMenu(null); } else { final ActionMenuView subMenuView = findViewById(R.id.sub_menu); final ActionMenuView subMenuView = findViewById(getRes(R.id.sub_menu)); mInjector.menuManager.updateSubMenu(subMenuView.getMenu()); } Loading @@ -890,7 +891,7 @@ public abstract class BaseActivity } public void expandAppBar() { final AppBarLayout appBarLayout = findViewById(R.id.app_bar); final AppBarLayout appBarLayout = findViewById(getRes(R.id.app_bar)); if (appBarLayout != null) { appBarLayout.setExpanded(true); } Loading @@ -903,7 +904,7 @@ public abstract class BaseActivity */ public void updateHeader(boolean shouldHideHeader) { // Remove headContainer when material3 is launched. b/379776735. View headerContainer = findViewById(R.id.header_container); View headerContainer = findViewById(getRes(R.id.header_container)); if (headerContainer == null) { updateHeaderTitle(); return; Loading Loading @@ -951,7 +952,7 @@ public abstract class BaseActivity } // Remove the headerTitle when material3 is launched b/379776735. TextView headerTitle = findViewById(R.id.header_title); TextView headerTitle = findViewById(getRes(R.id.header_title)); if (headerTitle != null) { headerTitle.setText(result); } Loading @@ -962,44 +963,55 @@ public abstract class BaseActivity // is not expanded on that time. boolean isGlobalSearch = mSearchManager.isSearching() || mState.stack.size() > 1; if (mState.isPhotoPicking()) { final int resId = isGlobalSearch ? R.string.root_info_header_image_global_search : R.string.root_info_header_image_recent; final int resId = isGlobalSearch ? getRes(R.string.root_info_header_image_global_search) : getRes(R.string.root_info_header_image_recent); return getString(resId); } else { final int resId = isGlobalSearch ? R.string.root_info_header_global_search : R.string.root_info_header_recent; final int resId = isGlobalSearch ? getRes(R.string.root_info_header_global_search) : getRes(R.string.root_info_header_recent); return getString(resId); } } private String getHeaderDownloadsTitle() { return getString(mState.isPhotoPicking() ? R.string.root_info_header_image_downloads : R.string.root_info_header_downloads); return getString( mState.isPhotoPicking() ? getRes(R.string.root_info_header_image_downloads) : getRes(R.string.root_info_header_downloads)); } private String getHeaderStorageTitle(String rootTitle) { if (mState.stack.size() > 1) { final int resId = mState.isPhotoPicking() ? R.string.root_info_header_image_folder : R.string.root_info_header_folder; final int resId = mState.isPhotoPicking() ? getRes(R.string.root_info_header_image_folder) : getRes(R.string.root_info_header_folder); return getString(resId, getCurrentTitle()); } else { final int resId = mState.isPhotoPicking() ? R.string.root_info_header_image_storage : R.string.root_info_header_storage; final int resId = mState.isPhotoPicking() ? getRes(R.string.root_info_header_image_storage) : getRes(R.string.root_info_header_storage); return getString(resId, rootTitle); } } private String getHeaderDefaultTitle(String rootTitle, String summary) { if (TextUtils.isEmpty(summary)) { final int resId = mState.isPhotoPicking() ? R.string.root_info_header_image_app : R.string.root_info_header_app; final int resId = mState.isPhotoPicking() ? getRes(R.string.root_info_header_image_app) : getRes(R.string.root_info_header_app); return getString(resId, rootTitle); } else { final int resId = mState.isPhotoPicking() ? R.string.root_info_header_image_app_with_summary : R.string.root_info_header_app_with_summary; final int resId = mState.isPhotoPicking() ? getRes(R.string.root_info_header_image_app_with_summary) : getRes(R.string.root_info_header_app_with_summary); return getString(resId, rootTitle, summary); } } Loading Loading @@ -1205,8 +1217,8 @@ public abstract class BaseActivity private void onBurgerMenuFocusChange(View v, boolean hasFocus) { MaterialButton burgerMenu = (MaterialButton) v; if (hasFocus) { final int focusRingWidth = getResources() .getDimensionPixelSize(R.dimen.focus_ring_width); final int focusRingWidth = getResources().getDimensionPixelSize(getRes(R.dimen.focus_ring_width)); burgerMenu.setStrokeWidth(focusRingWidth); } else { burgerMenu.setStrokeWidth(0); Loading
src/com/android/documentsui/BreadcrumbHolder.java +4 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.documentsui; import static com.android.documentsui.util.Material3Config.getRes; import android.view.View; import android.widget.ImageView; import android.widget.TextView; Loading @@ -31,8 +33,8 @@ public final class BreadcrumbHolder extends RecyclerView.ViewHolder { public BreadcrumbHolder(View itemView) { super(itemView); mTitle = itemView.findViewById(R.id.breadcrumb_text); mArrow = itemView.findViewById(R.id.breadcrumb_arrow); mTitle = itemView.findViewById(getRes(R.id.breadcrumb_text)); mArrow = itemView.findViewById(getRes(R.id.breadcrumb_arrow)); mLast = false; } Loading
src/com/android/documentsui/CreateDirectoryFragment.java +8 −7 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.documentsui; import static android.content.ContentResolver.wrap; import static com.android.documentsui.base.SharedMinimal.TAG; import static com.android.documentsui.util.Material3Config.getRes; import android.app.Dialog; import android.content.ContentProviderClient; Loading Loading @@ -80,13 +81,13 @@ public class CreateDirectoryFragment extends DialogFragment { final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context); final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext()); final View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false); final View view = dialogInflater.inflate(getRes(R.layout.dialog_file_name), null, false); mEditText = (EditText) view.findViewById(android.R.id.text1); mInputWrapper = view.findViewById(R.id.input_wrapper); mInputWrapper.setHint(getString(R.string.input_hint_new_folder)); mInputWrapper = view.findViewById(getRes(R.id.input_wrapper)); mInputWrapper.setHint(getString(getRes(R.string.input_hint_new_folder))); builder.setTitle(R.string.menu_create_dir); builder.setTitle(getRes(R.string.menu_create_dir)); builder.setView(view); builder.setPositiveButton(android.R.string.ok, null); builder.setNegativeButton(android.R.string.cancel, null); Loading Loading @@ -125,8 +126,7 @@ public class CreateDirectoryFragment extends DialogFragment { private void createDirectory(String name) { if (name.isEmpty()) { mInputWrapper.setError(getContext().getString( R.string.add_folder_name_error)); mInputWrapper.setError(getContext().getString(getRes(R.string.add_folder_name_error))); } else { final BaseActivity activity = (BaseActivity) getActivity(); final DocumentInfo cwd = activity.getCurrentDirectory(); Loading Loading @@ -175,7 +175,8 @@ public class CreateDirectoryFragment extends DialogFragment { mActivity.onDirectoryCreated(result); Metrics.logCreateDirOperation(); } else { Snackbars.makeSnackbar(mActivity, R.string.create_error, Snackbar.LENGTH_LONG) Snackbars.makeSnackbar( mActivity, getRes(R.string.create_error), Snackbar.LENGTH_LONG) .show(); Metrics.logCreateDirError(); } Loading
src/com/android/documentsui/DragAndDropManager.java +4 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.documentsui; import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled; import static com.android.documentsui.util.Material3Config.getRes; import android.content.ClipData; import android.content.Context; Loading Loading @@ -286,8 +287,9 @@ public interface DragAndDropManager { title = doc.displayName; icon = iconHelper.getDocumentIcon(mContext, doc); } else { title = mContext.getResources() .getQuantityString(R.plurals.elements_dragged, size, size); title = mContext.getResources() .getQuantityString(getRes(R.plurals.elements_dragged), size, size); icon = mDefaultShadowIcon; } Loading