Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8a984ca8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix a pile of error prone issues."

parents 1fddbf8f 3a24e6c1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -230,6 +230,7 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons>
        throw new UnsupportedOperationException("Can't open document.");
    }

    @Override
    public void showInspector(DocumentInfo doc) {
        throw new UnsupportedOperationException("Can't open properties.");
    }
+29 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.format.Time;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;

import com.android.documentsui.R;
@@ -265,12 +266,37 @@ public final class Shared {
        }
    }

    /**
     * This method exists solely to smooth over the fact that two different types of
     * views cannot be bound to the same id in different layouts. "What's this crazy-pants
     * stuff?", you say? Here's an example:
     *
     * The main DocumentsUI view (aka "Files app") when running on a phone has a drop-down
     * "breadcrumb" (file path representation) in both landscape and portrait orientation.
     * Larger format devices, like a tablet, use a horizontal "Dir1 > Dir2 > Dir3" format
     * breadcrumb in landscape layouts, but the regular drop-down breadcrumb in portrait
     * mode.
     *
     * Our initial inclination was to give each of those views the same ID (as they both
     * implement the same "Breadcrumb" interface). But at runtime, when rotating a device
     * from one orientation to the other, deeeeeeep within the UI toolkit a exception
     * would happen, because one view instance (drop-down) was being inflated in place of
     * another (horizontal). I'm writing this code comment significantly after the face,
     * so I don't recall all of the details, but it had to do with View type-checking the
     * Parcelable state in onRestore, or something like that. Either way, this isn't
     * allowed (my patch to fix this was rejected).
     *
     * To work around this we have this cute little method that accepts multiple
     * resource IDs, and along w/ type inference finds our view, no matter which
     * id it is wearing, and returns it.
     */
    @SuppressWarnings("TypeParameterUnusedInFormals")
    public static @Nullable <T> T findView(Activity activity, int... resources) {
        for (int id : resources) {
            @SuppressWarnings("unchecked")
            T r = (T) activity.findViewById(id);
            if (r != null) {
                return r;
            View view = activity.findViewById(id);
            if (view != null) {
                return (T) view;
            }
        }
        return null;
+2 −2
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.annotation.IntDef;
import android.content.Intent;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.DocumentsContract;
import android.util.SparseArray;

import com.android.documentsui.services.FileOperationService;
@@ -30,6 +29,7 @@ import com.android.documentsui.sorting.SortModel;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

@@ -139,7 +139,7 @@ public class State implements android.os.Parcelable {
    public String toString() {
        return "State{"
                + "action=" + action
                + ", acceptMimes=" + acceptMimes
                + ", acceptMimes=" + Arrays.toString(acceptMimes)
                + ", allowMultiple=" + allowMultiple
                + ", localOnly=" + localOnly
                + ", showDeviceStorageOption=" + showDeviceStorageOption
+1 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ public abstract class DocumentHolder
        }
    }

    @SuppressWarnings("TypeParameterUnusedInFormals")
    private static <V extends View> V inflateLayout(Context context, ViewGroup parent, int layout) {
        final LayoutInflater inflater = LayoutInflater.from(context);
        return (V) inflater.inflate(layout, parent, false);
+1 −0
Original line number Diff line number Diff line
@@ -380,6 +380,7 @@ public class ProvidersCache implements ProvidersAccess {
        }
    }

    @Override
    public RootInfo getDefaultRootBlocking(State state) {
        for (RootInfo root : ProvidersAccess.getMatchingRoots(getRootsBlocking(), state)) {
            if (root.isDownloads()) {
Loading