# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Keep
-keep public class androidx.core.view.accessibility.AccessibilityNodeInfoCompat {
   public static androidx.core.view.accessibility.AccessibilityNodeInfoCompat obtain();
}

# This method is marked @hide in DocumentsProvider but we need to implement it for managed mode.
-keep public class com.lemenzo.files.archives.ArchivesProvider {
   public android.database.Cursor queryChildDocumentsForManage(java.lang.String, java.lang.String[], java.lang.String);
}

# To prevent class not found exception in org.brotli.dec.Dictionary
# TODO(b/373579455): Evaluate if <init> needs to be kept.
-keep final class org.brotli.dec.DictionaryData {
  void <init>();
}

# keep rule generated after running trace references on the test app against LemenzoFilesGoogle.jar
# TODO(b/339312616): Remove after a more permanent fix is available
# On modifying or adding new test run the following command to generate new keep rules and replace
# the once listed below with the newly generated keep rules:
# $ java -cp prebuilts/r8/r8.jar com.android.tools.r8.tracereferences.TraceReferences \
# --lib out/soong/.intermediates/frameworks/base/framework/android_common/combined/framework.jar  \
# --source $OUT/testcases/LemenzoFilesGoogleTests/x86_64/LemenzoFilesGoogleTests.apk \
# --target out/soong/.intermediates/vendor/unbundled_google/packages/LemenzoFilesGoogle/LemenzoFilesGoogleInternal/android_common/turbine-combined/LemenzoFilesGoogleInternal.jar \
# --keep-rules \
# --output /tmp/keep.txt

-keep class androidx.appcompat.R$id {
  int search_src_text;
}
-keep class com.lemenzo.files.R$bool {
  int feature_notification_channel;
  int full_bar_search_view;
  int is_launcher_enabled;
  int show_media_roots;
  int show_search_bar;
  int show_apps_row;
}
-keep class com.lemenzo.files.R$color {
  int app_background_color;
  int primary;
}
-keep class com.lemenzo.files.R$dimen {
  int grid_item_radius;
}
-keep class com.lemenzo.files.R$drawable {
  int ic_briefcase;
  int ic_cab_cancel;
  int ic_eject;
  int ic_menu_copy;
  int ic_root_download;
  int ic_sd_storage;
  int root_list_selector;
  int work_off;
}
-keep class com.lemenzo.files.R$id {
  int action_menu_browse;
  int action_menu_compress;
  int action_menu_copy_to;
  int action_menu_delete;
  int action_menu_deselect_all;
  int action_menu_extract_here;
  int action_menu_extract_to;
  int action_menu_inspect;
  int action_menu_move_to;
  int action_menu_open_with;
  int action_menu_rename;
  int action_menu_restore_from_trash;
  int action_menu_select;
  int action_menu_select_all;
  int action_menu_share;
  int action_menu_sort;
  int action_menu_view_in_owner;
  int apps_group;
  int apps_row;
  int button;
  int content;
  int cross_profile;
  int cross_profile_content;
  int cross_profile_progress;
  int dir_menu_browse;
  int dir_menu_copy_to_clipboard;
  int dir_menu_create_dir;
  int dir_menu_cut_to_clipboard;
  int dir_menu_delete;
  int dir_menu_deselect_all;
  int dir_menu_extract_here;
  int dir_menu_inspect;
  int dir_menu_open;
  int dir_menu_open_in_new_window;
  int dir_menu_open_with;
  int dir_menu_paste_from_clipboard;
  int dir_menu_paste_into_folder;
  int dir_menu_rename;
  int dir_menu_select_all;
  int dir_menu_share;
  int dir_menu_view_in_owner;
  int docked_search_toolbar;
  int drawer_layout;
  int inspector_details_view;
  int job_progress_panel_title;
  int option_menu_create_dir;
  int option_menu_debug;
  int option_menu_extract_all;
  int option_menu_inspect;
  int option_menu_launcher;
  int option_menu_new_window;
  int option_menu_search;
  int option_menu_select_all;
  int option_menu_settings;
  int option_menu_show_hidden_files;
  int option_menu_sort;
  int peek_container;
  int peek_preview_container;
  int root_menu_eject_root;
  int root_menu_open_in_new_window;
  int root_menu_paste_into_folder;
  int root_menu_settings;
  int sub_menu_grid;
  int sub_menu_list;
  int table_header;
  int tabs;
  int tabs_container;
  int toolbar;
}
-keep class com.lemenzo.files.R$layout {
  int apps_row;
  int directory_header;
  int files_activity;
  int fixed_layout;
  int item_doc_list;
  int nav_rail_layout;
}
-keep class com.lemenzo.files.R$menu {
  int dir_context_menu;
  int file_context_menu;
  int mixed_context_menu;
}
-keep class com.lemenzo.files.R$plurals {
  int elements_dragged;
}
-keep class com.lemenzo.files.R$string {
  int cant_select_work_files_error_message;
  int cant_select_work_files_error_title;
  int clear_selection;
  int compress_error_notification_title;
  int copy_error_notification_title;
  int copy_notification_title;
  int copy_preparing;
  int copy_remaining;
  int debug_content_uri;
  int default_root_uri;
  int delete_error_notification_title;
  int directory_items;
  int empty;
  int extract_error_notification_title;
  int menu_copy;
  int menu_move;
  int menu_rename;
  int menu_select;
  int menu_select_all;
  int menu_sort;
  int menu_view_in_owner;
  int metadata_address;
  int metadata_album;
  int metadata_altitude;
  int metadata_aperture;
  int metadata_aperture_format;
  int metadata_artist;
  int metadata_camera;
  int metadata_camera_format;
  int metadata_composer;
  int metadata_coordinates;
  int metadata_coordinates_format;
  int metadata_date_time;
  int metadata_dimensions;
  int metadata_dimensions_format;
  int metadata_duration;
  int metadata_focal_format;
  int metadata_focal_length;
  int metadata_iso_format;
  int metadata_iso_speed_ratings;
  int metadata_shutter_speed;
  int move_error_notification_title;
  int name_conflict;
  int no_results;
  int personal_tab;
  int preferred_root_package;
  int quiet_mode_button;
  int quiet_mode_error_title;
  int rename_error;
  int search_bar_hint;
  int search_last_modified_30_days;
  int search_location_everywhere;
  int share_via;
  int sort_dimension_date;
  int sort_dimension_file_type;
  int sort_dimension_name;
  int sort_dimension_size;
  int sort_direction_ascending;
  int sort_direction_descending;
  int trusted_quick_viewer_package;
  int work_tab;
}
-keep class com.lemenzo.files.R$style {
  int DocumentsDefaultTheme;
  int DocumentsTheme;
}

# Keep Apache Commons Compress classes
-keep class org.apache.commons.compress.** { *; }

# This is used in the unit test
-keep class com.google.android.material.chip.Chip {
  public android.graphics.drawable.Drawable getChipIcon();
}

-keep class com.lemenzo.files.util.Material3Config {
  static int getRes(int);
  static void overrideMappingForTest(java.util.Map);
}

-keep class com.lemenzo.files.util.FlagUtils { *; }

-keep class com.lemenzo.files.util.VersionUtils { *; }

# The SideSheetBehavior state is not directly accessed from LemenzoFiles, but is used in tests
-keep class com.google.android.material.sidesheet.SideSheetBehavior {
  public int getState();
}

# The BottomSheetBehavior state is not directly accessed from LemenzoFiles, but is used in tests
-keep class com.google.android.material.bottomsheet.BottomSheetBehavior {
  public float getHalfExpandedRatio();
}

-keep class com.lemenzo.files.JobPanelViewModel$Companion {
  public void setDisableAutoDismiss(boolean);
}

# This is used in the unit test RecyclerRootsAdapterTest
-keep class androidx.recyclerview.widget.RecyclerView$AdapterDataObserver {
  public void onItemRangeChanged(int, int, Object);
}

# Temporarily add this here because the class is not used in the source code yet, will remove it
# after adopting the class in the follow-up CL.
-keep class com.lemenzo.files.sidebar.RecyclerRootsAdapter { *; }

-keep class com.lemenzo.files.queries.SearchOptionsState {
  *;
}

# Temporarily while use_material3 flag isn't fully rolled out.
-keep interface com.lemenzo.files.util.Config {
  public java.lang.Boolean getForceMaterial3();
}

-keep class com.lemenzo.files.peek.MetadataBottomSheetController {
  public com.google.android.material.bottomsheet.BottomSheetBehavior getSheetBehavior();
  public com.google.android.material.bottomsheet.BottomSheetBehavior$BottomSheetCallback getSheetStateListener();
}

-keep interface com.lemenzo.files.UserManagerState {
  public boolean areHiddenInQuietModeProfilesPresent();
  public static com.lemenzo.files.UserManagerState create(android.content.Context);
  public java.util.Map getCanForwardToProfileIdMap(android.content.Intent);
  public java.util.Map getCanForwardToProfileIdMapForAllowedUsers(android.content.Intent, com.lemenzo.files.base.State);
  public java.util.Map getUserIdToBadgeMap();
  public java.util.Map getUserIdToLabelMap();
  public java.util.List getUserIds();
  public void onProfileActionStatusChange(java.lang.String, com.lemenzo.files.base.UserId);
  public void setCurrentStateIntent(android.content.Intent);
}

-keep class com.lemenzo.files.Injector {
  public <init>(com.lemenzo.files.base.Features, com.lemenzo.files.ActivityConfig, com.lemenzo.files.ui.MessageBuilder, com.lemenzo.files.ui.DialogController, com.lemenzo.files.base.Lookup, java.util.function.Consumer, com.lemenzo.files.Model, com.lemenzo.files.UserManagerProvider);
  com.lemenzo.files.ActivityConfig config;
  com.lemenzo.files.ui.DialogController dialogs;
  com.lemenzo.files.FocusManager focusManager;
  com.lemenzo.files.picker.PickResult pickResult;
  com.lemenzo.files.queries.SearchViewManager searchManager;
  com.lemenzo.files.DocsSelectionHelper selectionMgr;
}

-keep interface com.lemenzo.files.UserManagerProvider {
  public java.util.List getUserIds(android.content.Context);
}

-keep class com.lemenzo.files.files.ActionHandler {
  public void restoreSelectedDocumentsFromTrash(java.util.List);
}

-keep interface androidx.drawerlayout.widget.DrawerLayout$DrawerListener {
}
-keep class androidx.drawerlayout.widget.DrawerLayout$SimpleDrawerListener {
  public <init>();
  public void onDrawerClosed(android.view.View);
  public void onDrawerStateChanged(int);
}
-keep class androidx.drawerlayout.widget.DrawerLayout {
  public void addDrawerListener(androidx.drawerlayout.widget.DrawerLayout$DrawerListener);
  public void closeDrawer(int);
  public boolean isDrawerOpen(int);
  public boolean isDrawerVisible(int);
  public void openDrawer(int);
  public void removeDrawerListener(androidx.drawerlayout.widget.DrawerLayout$DrawerListener);
}

-keep class android.provider.Flags {
  public static boolean enableDocumentsTrashApi();
}