Home | History | Annotate | Download | only in base
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.android.documentsui.base;
     17 
     18 import android.content.ContentResolver;
     19 import android.os.Bundle;
     20 
     21 import com.android.documentsui.queries.CommandInterceptor;
     22 
     23 import javax.annotation.Nullable;
     24 
     25 /**
     26  * Shared values that may be set by {@link CommandInterceptor}.
     27  */
     28 public final class DebugFlags {
     29 
     30     private DebugFlags() {}
     31 
     32     private static String mQvPackage;
     33     private static boolean sDocumentDetailsEnabled;
     34     private static int sForcedPageOffset = -1;
     35     private static int sForcedPageLimit = -1;
     36 
     37     public static void setQuickViewer(@Nullable String qvPackage) {
     38         mQvPackage = qvPackage;
     39     }
     40 
     41     public static @Nullable String getQuickViewer() {
     42         return mQvPackage;
     43     }
     44 
     45     public static void setDocumentDetailsEnabled(boolean enabled) {
     46         sDocumentDetailsEnabled = enabled;
     47     }
     48 
     49     public static boolean getDocumentDetailsEnabled() {
     50         return sDocumentDetailsEnabled;
     51     }
     52 
     53     public static void setForcedPaging(int offset, int limit) {
     54         sForcedPageOffset = offset;
     55         sForcedPageLimit = limit;
     56     }
     57 
     58     public static boolean addForcedPagingArgs(Bundle queryArgs) {
     59         boolean flagsAdded = false;
     60         if (sForcedPageOffset >= 0) {
     61             queryArgs.putInt(ContentResolver.QUERY_ARG_OFFSET, sForcedPageOffset);
     62             flagsAdded |= true;
     63         }
     64         if (sForcedPageLimit >= 0) {
     65             queryArgs.putInt(ContentResolver.QUERY_ARG_LIMIT, sForcedPageLimit);
     66             flagsAdded |= true;
     67         }
     68         return flagsAdded;
     69     }
     70 }
     71