1 /*
2  * Copyright (C) 2015 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 
17 package com.android.documentsui.ui;
18 
19 import androidx.annotation.Nullable;
20 import android.content.Context;
21 import android.util.AttributeSet;
22 import android.widget.TextView;
23 
24 import com.android.documentsui.base.DocumentInfo;
25 
26 /**
27  * Document debug info view.
28  */
29 public class DocumentDebugInfo extends TextView {
DocumentDebugInfo(Context context)30     public DocumentDebugInfo(Context context) {
31         super(context);
32 
33     }
34 
DocumentDebugInfo(Context context, @Nullable AttributeSet attrs)35     public DocumentDebugInfo(Context context, @Nullable AttributeSet attrs) {
36         super(context, attrs);
37     }
38 
update(DocumentInfo doc)39     public void update(DocumentInfo doc) {
40 
41         String dbgInfo = new StringBuilder()
42                 .append("** PROPERTIES **\n\n")
43                 .append("docid: " + doc.documentId).append("\n")
44                 .append("name: " + doc.displayName).append("\n")
45                 .append("mimetype: " + doc.mimeType).append("\n")
46                 .append("container: " + doc.isContainer()).append("\n")
47                 .append("virtual: " + doc.isVirtual()).append("\n")
48                 .append("\n")
49                 .append("** OPERATIONS **\n\n")
50                 .append("create: " + doc.isCreateSupported()).append("\n")
51                 .append("delete: " + doc.isDeleteSupported()).append("\n")
52                 .append("rename: " + doc.isRenameSupported()).append("\n\n")
53                 .append("** URI **\n\n")
54                 .append(doc.derivedUri).append("\n")
55                 .toString();
56 
57         setText(dbgInfo);
58     }
59 }
60