summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/documentsui/HorizontalBreadcrumb.java7
-rw-r--r--src/com/android/documentsui/IconUtils.java49
-rw-r--r--src/com/android/documentsui/dirlist/AnimationView.java43
-rw-r--r--src/com/android/documentsui/dirlist/DirectoryFragment.java24
-rw-r--r--src/com/android/documentsui/files/FilesActivity.java10
-rw-r--r--src/com/android/documentsui/loaders/BaseFileLoader.kt12
-rw-r--r--src/com/android/documentsui/loaders/FolderLoader.kt2
-rw-r--r--src/com/android/documentsui/picker/PickActivity.java4
8 files changed, 133 insertions, 18 deletions
diff --git a/src/com/android/documentsui/HorizontalBreadcrumb.java b/src/com/android/documentsui/HorizontalBreadcrumb.java
index f47f464c0..9d2fc723e 100644
--- a/src/com/android/documentsui/HorizontalBreadcrumb.java
+++ b/src/com/android/documentsui/HorizontalBreadcrumb.java
@@ -192,7 +192,12 @@ public final class HorizontalBreadcrumb extends RecyclerView implements Breadcru
holder.mTitle.setText(
isFirst ? mEnv.getCurrentRoot().title : mState.stack.get(position).displayName);
- holder.mTitle.setEnabled(isLast);
+ if (isUseMaterial3FlagEnabled()) {
+ // The last path part in the breadcrumb is not clickable.
+ holder.mTitle.setEnabled(!isLast);
+ } else {
+ holder.mTitle.setEnabled(isLast);
+ }
if (isUseMaterial3FlagEnabled()) {
final int paddingHorizontal =
(int)
diff --git a/src/com/android/documentsui/IconUtils.java b/src/com/android/documentsui/IconUtils.java
index ece38bb64..477209150 100644
--- a/src/com/android/documentsui/IconUtils.java
+++ b/src/com/android/documentsui/IconUtils.java
@@ -16,19 +16,56 @@
package com.android.documentsui;
+import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled;
+
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
+import android.content.res.Resources;
import android.graphics.Outline;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.widget.ImageView;
import com.android.documentsui.base.UserId;
+import com.android.documentsui.util.ColorUtils;
+
+import java.util.HashMap;
+import java.util.Map;
public class IconUtils {
+ // key: drawable resource id, value: color attribute id
+ private static final Map<Integer, Integer> sCustomIconColorMap = new HashMap<>();
+
+ static {
+ if (isUseMaterial3FlagEnabled()) {
+ // Use Resources.getSystem().getIdentifier() here instead of R.drawable.ic_doc_folder
+ // because com.android.internal.R is not public.
+ sCustomIconColorMap.put(
+ Resources.getSystem().getIdentifier("ic_doc_folder", "drawable", "android"),
+ com.google.android.material.R.attr.colorPrimaryFixedDim);
+ sCustomIconColorMap.put(
+ Resources.getSystem().getIdentifier("ic_doc_generic", "drawable", "android"),
+ com.google.android.material.R.attr.colorOutline);
+ sCustomIconColorMap.put(
+ Resources.getSystem()
+ .getIdentifier("ic_doc_certificate", "drawable", "android"),
+ com.google.android.material.R.attr.colorOutline);
+ sCustomIconColorMap.put(
+ Resources.getSystem().getIdentifier("ic_doc_codes", "drawable", "android"),
+ com.google.android.material.R.attr.colorOutline);
+ sCustomIconColorMap.put(
+ Resources.getSystem().getIdentifier("ic_doc_contact", "drawable", "android"),
+ com.google.android.material.R.attr.colorOutline);
+ sCustomIconColorMap.put(
+ Resources.getSystem().getIdentifier("ic_doc_font", "drawable", "android"),
+ com.google.android.material.R.attr.colorOutline);
+ }
+ }
+
public static Drawable loadPackageIcon(Context context, UserId userId, String authority,
int icon, boolean maybeShowBadge) {
if (icon != 0) {
@@ -65,7 +102,17 @@ public class IconUtils {
*/
public static Drawable loadMimeIcon(Context context, String mimeType) {
if (mimeType == null) return null;
- return context.getContentResolver().getTypeInfo(mimeType).getIcon().loadDrawable(context);
+ Icon icon = context.getContentResolver().getTypeInfo(mimeType).getIcon();
+ Drawable drawable = icon.loadDrawable(context);
+ // TODO(b/400263417): Remove this once RRO mime icons support dynamic colors.
+ if (isUseMaterial3FlagEnabled()
+ && drawable != null
+ && sCustomIconColorMap.containsKey(icon.getResId())) {
+ drawable.setTint(
+ ColorUtils.resolveMaterialColorAttribute(
+ context, sCustomIconColorMap.get(icon.getResId())));
+ }
+ return drawable;
}
public static Drawable applyTintColor(Context context, int drawableId, int tintColorId) {
diff --git a/src/com/android/documentsui/dirlist/AnimationView.java b/src/com/android/documentsui/dirlist/AnimationView.java
index d17bddf98..5813085b3 100644
--- a/src/com/android/documentsui/dirlist/AnimationView.java
+++ b/src/com/android/documentsui/dirlist/AnimationView.java
@@ -16,19 +16,22 @@
package com.android.documentsui.dirlist;
-import androidx.annotation.IntDef;
-import androidx.fragment.app.FragmentTransaction;
+import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled;
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.widget.LinearLayout;
+import androidx.annotation.IntDef;
+import androidx.fragment.app.FragmentTransaction;
+
import com.android.documentsui.R;
import com.android.documentsui.base.Shared;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.ArrayList;
/**
* This class exists solely to support animated transition of our directory fragment.
@@ -51,6 +54,8 @@ public class AnimationView extends LinearLayout {
public static final int ANIM_LEAVE = 3;
public static final int ANIM_ENTER = 4;
+ private final ArrayList<OnSizeChangedListener> mOnSizeChangedListeners = new ArrayList<>();
+
private float mPosition = 0f;
// The distance the animation will cover...currently matches the height of the
@@ -65,11 +70,45 @@ public class AnimationView extends LinearLayout {
super(context, attrs);
}
+ /**
+ * A listener of the onSizeChanged method.
+ */
+ public interface OnSizeChangedListener {
+ /**
+ * Called on the View's onSizeChanged.
+ */
+ void onSizeChanged();
+ }
+
+ /**
+ * Adds a listener of the onSizeChanged method.
+ */
+ public void addOnSizeChangedListener(OnSizeChangedListener listener) {
+ if (isUseMaterial3FlagEnabled()) {
+ mOnSizeChangedListeners.add(listener);
+ }
+ }
+
+ /**
+ * Removes a listener of the onSizeChanged method.
+ */
+ public void removeOnSizeChangedListener(OnSizeChangedListener listener) {
+ if (isUseMaterial3FlagEnabled()) {
+ mOnSizeChangedListeners.remove(listener);
+ }
+ }
+
+
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mSpan = h;
setPosition(mPosition);
+ if (isUseMaterial3FlagEnabled()) {
+ for (int i = mOnSizeChangedListeners.size() - 1; i >= 0; --i) {
+ mOnSizeChangedListeners.get(i).onSizeChanged();
+ }
+ }
}
public float getPosition() {
diff --git a/src/com/android/documentsui/dirlist/DirectoryFragment.java b/src/com/android/documentsui/dirlist/DirectoryFragment.java
index 2ea906a60..2911d04e9 100644
--- a/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -108,6 +108,7 @@ import com.android.documentsui.clipping.ClipStore;
import com.android.documentsui.clipping.DocumentClipper;
import com.android.documentsui.clipping.UrisSupplier;
import com.android.documentsui.dirlist.AnimationView.AnimationType;
+import com.android.documentsui.dirlist.AnimationView.OnSizeChangedListener;
import com.android.documentsui.picker.PickActivity;
import com.android.documentsui.services.FileOperation;
import com.android.documentsui.services.FileOperationService;
@@ -188,7 +189,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
private SelectionMetadata mSelectionMetadata;
private KeyInputHandler mKeyListener;
private @Nullable DragHoverListener mDragHoverListener;
- private View mRootView;
+ private AnimationView mRootView;
private IconHelper mIconHelper;
private SwipeRefreshLayout mRefreshLayout;
private RecyclerView mRecView;
@@ -416,13 +417,27 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
|| Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE.equals(action);
}
+ private OnSizeChangedListener mOnSizeChangedListener =
+ new AnimationView.OnSizeChangedListener() {
+ @Override
+ public void onSizeChanged() {
+ if (isUseMaterial3FlagEnabled() && mState.derivedMode != MODE_LIST) {
+ // Update the grid layout when the window size changes.
+ updateLayout(mState.derivedMode);
+ }
+ }
+ };
+
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mHandler = new Handler(Looper.getMainLooper());
mActivity = (BaseActivity) getActivity();
- mRootView = inflater.inflate(R.layout.fragment_directory, container, false);
+ mRootView = (AnimationView) inflater.inflate(R.layout.fragment_directory, container, false);
+ if (isUseMaterial3FlagEnabled()) {
+ mRootView.addOnSizeChangedListener(mOnSizeChangedListener);
+ }
mProgressBar = mRootView.findViewById(R.id.progressbar);
assert mProgressBar != null;
@@ -497,6 +512,10 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
mModel.removeUpdateListener(mAdapter.getModelUpdateListener());
setPreDrawListenerEnabled(false);
+ if (isUseMaterial3FlagEnabled()) {
+ mRootView.removeOnSizeChangedListener(mOnSizeChangedListener);
+ }
+
super.onDestroyView();
}
@@ -809,7 +828,6 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
if (mLayout != null) {
mLayout.setSpanCount(mColumnCount);
}
-
int pad = getDirectoryPadding(mode);
mAppBarHeight = getAppBarLayoutHeight();
mSaveLayoutHeight = getSaveLayoutHeight();
diff --git a/src/com/android/documentsui/files/FilesActivity.java b/src/com/android/documentsui/files/FilesActivity.java
index 50e266d38..cb8708f0b 100644
--- a/src/com/android/documentsui/files/FilesActivity.java
+++ b/src/com/android/documentsui/files/FilesActivity.java
@@ -210,9 +210,13 @@ public class FilesActivity extends BaseActivity implements AbstractActionHandler
updateTaskDescription(intent);
}
- // Set save container background to transparent for edge to edge nav bar.
- View saveContainer = findViewById(R.id.container_save);
- saveContainer.setBackgroundColor(Color.TRANSPARENT);
+ // When the use_material3 flag is on, the file path bar is at the bottom of the layout and
+ // hence the edge to edge nav bar is no longer required.
+ if (!isUseMaterial3FlagEnabled()) {
+ // Set save container background to transparent for edge to edge nav bar.
+ View saveContainer = findViewById(R.id.container_save);
+ saveContainer.setBackgroundColor(Color.TRANSPARENT);
+ }
presentFileErrors(icicle, intent);
}
diff --git a/src/com/android/documentsui/loaders/BaseFileLoader.kt b/src/com/android/documentsui/loaders/BaseFileLoader.kt
index dd76217ac..fcb1d4cb0 100644
--- a/src/com/android/documentsui/loaders/BaseFileLoader.kt
+++ b/src/com/android/documentsui/loaders/BaseFileLoader.kt
@@ -77,7 +77,7 @@ abstract class BaseFileLoader(
private var mResult: DirectoryResult? = null
override fun cancelLoadInBackground() {
- Log.d(TAG, "BasedFileLoader.cancelLoadInBackground")
+ Log.d(TAG, "${this::class.simpleName}.cancelLoadInBackground")
super.cancelLoadInBackground()
synchronized(this) {
@@ -86,7 +86,7 @@ abstract class BaseFileLoader(
}
override fun deliverResult(result: DirectoryResult?) {
- Log.d(TAG, "BasedFileLoader.deliverResult")
+ Log.d(TAG, "${this::class.simpleName}.deliverResult")
if (isReset) {
closeResult(result)
return
@@ -104,7 +104,7 @@ abstract class BaseFileLoader(
}
override fun onStartLoading() {
- Log.d(TAG, "BasedFileLoader.onStartLoading")
+ Log.d(TAG, "${this::class.simpleName}.onStartLoading")
val isCursorStale: Boolean = checkIfCursorStale(mResult)
if (mResult != null && !isCursorStale) {
deliverResult(mResult)
@@ -115,17 +115,17 @@ abstract class BaseFileLoader(
}
override fun onStopLoading() {
- Log.d(TAG, "BasedFileLoader.onStopLoading")
+ Log.d(TAG, "${this::class.simpleName}.onStopLoading")
cancelLoad()
}
override fun onCanceled(result: DirectoryResult?) {
- Log.d(TAG, "BasedFileLoader.onCanceled")
+ Log.d(TAG, "${this::class.simpleName}.onCanceled")
closeResult(result)
}
override fun onReset() {
- Log.d(TAG, "BasedFileLoader.onReset")
+ Log.d(TAG, "${this::class.simpleName}.onReset")
super.onReset()
// Ensure the loader is stopped
diff --git a/src/com/android/documentsui/loaders/FolderLoader.kt b/src/com/android/documentsui/loaders/FolderLoader.kt
index a166ca752..40c15dfe1 100644
--- a/src/com/android/documentsui/loaders/FolderLoader.kt
+++ b/src/com/android/documentsui/loaders/FolderLoader.kt
@@ -60,7 +60,7 @@ class FolderLoader(
mListedDir.authority,
mListedDir.documentId
)
- var cursor =
+ val cursor =
queryLocation(mRoot.rootId, folderChildrenUri, mOptions.otherQueryArgs, ALL_RESULTS)
?: emptyCursor()
cursor.registerContentObserver(mObserver)
diff --git a/src/com/android/documentsui/picker/PickActivity.java b/src/com/android/documentsui/picker/PickActivity.java
index 68a797397..4f875072e 100644
--- a/src/com/android/documentsui/picker/PickActivity.java
+++ b/src/com/android/documentsui/picker/PickActivity.java
@@ -224,9 +224,11 @@ public class PickActivity extends BaseActivity implements ActionHandler.Addons {
} else if (mState.action == ACTION_OPEN_TREE ||
mState.action == ACTION_PICK_COPY_DESTINATION) {
PickFragment.show(getSupportFragmentManager());
- } else {
+ } else if (!isUseMaterial3FlagEnabled()) {
// If PickFragment or SaveFragment does not show,
// Set save container background to transparent for edge to edge nav bar.
+ // However when the use_material3 flag is on, the file path bar is at the bottom of the
+ // layout and hence the edge to edge nav bar is no longer required.
View saveContainer = findViewById(R.id.container_save);
saveContainer.setBackgroundColor(Color.TRANSPARENT);
}