Merge "DocumentsUI tablet support." into klp-dev
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
<!-- TODO: allow rotation when state saving is in better shape -->
|
<!-- TODO: allow rotation when state saving is in better shape -->
|
||||||
<activity
|
<activity
|
||||||
android:name=".DocumentsActivity"
|
android:name=".DocumentsActivity"
|
||||||
android:theme="@android:style/Theme.Holo.Light">
|
android:theme="@style/Theme">
|
||||||
<intent-filter android:priority="100">
|
<intent-filter android:priority="100">
|
||||||
<action android:name="android.intent.action.OPEN_DOCUMENT" />
|
<action android:name="android.intent.action.OPEN_DOCUMENT" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
@@ -39,8 +39,8 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".SettingsActivity"
|
android:name=".SettingsActivity"
|
||||||
android:title="@string/menu_settings"
|
android:label="@string/menu_settings"
|
||||||
android:theme="@android:style/Theme.Holo.Light"
|
android:theme="@android:style/Theme.Holo.Light.DialogWhenLarge"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
|
|||||||
@@ -18,5 +18,5 @@
|
|||||||
<item android:state_pressed="true" android:drawable="@color/item_root_activated" />
|
<item android:state_pressed="true" android:drawable="@color/item_root_activated" />
|
||||||
<item android:state_activated="true" android:drawable="@color/item_root_activated" />
|
<item android:state_activated="true" android:drawable="@color/item_root_activated" />
|
||||||
<item android:state_focused="true" android:drawable="@color/item_root_activated" />
|
<item android:state_focused="true" android:drawable="@color/item_root_activated" />
|
||||||
<item android:drawable="@android:color/white" />
|
<item android:drawable="@android:color/transparent" />
|
||||||
</selector>
|
</selector>
|
||||||
|
|||||||
115
packages/DocumentsUI/res/layout-sw720dp-land/item_doc_list.xml
Normal file
115
packages/DocumentsUI/res/layout-sw720dp-land/item_doc_list.xml
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2013 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/item_background"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||||
|
android:paddingTop="8dip"
|
||||||
|
android:paddingBottom="8dip"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@android:id/icon"
|
||||||
|
android:layout_width="@dimen/icon_size"
|
||||||
|
android:layout_height="@dimen/icon_size"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:layout_gravity="center_vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/icon_mime"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
android:contentDescription="@null" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/icon_thumb"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:contentDescription="@null" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/title"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
style="@style/TextAppearance.Medium" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@android:id/icon1"
|
||||||
|
android:layout_width="@dimen/root_icon_size"
|
||||||
|
android:layout_height="@dimen/root_icon_size"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
android:contentDescription="@null" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/summary"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.25"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
style="@style/TextAppearance.Small" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/size"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.125"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:minWidth="70dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:textAlignment="viewEnd"
|
||||||
|
style="@style/TextAppearance.Small" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/date"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.125"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:minWidth="70dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:textAlignment="viewEnd"
|
||||||
|
style="@style/TextAppearance.Small" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
60
packages/DocumentsUI/res/layout-sw720dp/activity.xml
Normal file
60
packages/DocumentsUI/res/layout-sw720dp/activity.xml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2013 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/dialog_roots">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/container_roots"
|
||||||
|
android:layout_width="250dp"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/ic_drawer_shadow_tablet" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/container_directory"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dip"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/container_save"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -121,18 +121,6 @@
|
|||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
style="@style/TextAppearance.Small" />
|
style="@style/TextAppearance.Small" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@android:id/summary"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="marquee"
|
|
||||||
android:textAlignment="viewStart"
|
|
||||||
style="@style/TextAppearance.Small" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
19
packages/DocumentsUI/res/values-sw720dp-land/dimens.xml
Normal file
19
packages/DocumentsUI/res/values-sw720dp-land/dimens.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2013 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<bool name="always_show_summary">true</bool>
|
||||||
|
</resources>
|
||||||
22
packages/DocumentsUI/res/values-sw720dp/dimens.xml
Normal file
22
packages/DocumentsUI/res/values-sw720dp/dimens.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2013 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<bool name="show_as_dialog">true</bool>
|
||||||
|
|
||||||
|
<item type="dimen" name="dialog_width">85%</item>
|
||||||
|
<item type="dimen" name="dialog_height">90%</item>
|
||||||
|
</resources>
|
||||||
23
packages/DocumentsUI/res/values-sw720dp/styles.xml
Normal file
23
packages/DocumentsUI/res/values-sw720dp/styles.xml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2013 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<style name="Theme" parent="@android:style/Theme.Holo.Light">
|
||||||
|
<item name="android:windowBackground">@*android:drawable/dialog_full_holo_light</item>
|
||||||
|
<item name="android:colorBackgroundCacheHint">@null</item>
|
||||||
|
<item name="android:windowIsTranslucent">true</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -19,4 +19,7 @@
|
|||||||
<dimen name="root_icon_size">24dp</dimen>
|
<dimen name="root_icon_size">24dp</dimen>
|
||||||
<dimen name="grid_width">180dp</dimen>
|
<dimen name="grid_width">180dp</dimen>
|
||||||
<dimen name="grid_height">180dp</dimen>
|
<dimen name="grid_height">180dp</dimen>
|
||||||
|
|
||||||
|
<bool name="show_as_dialog">false</bool>
|
||||||
|
<bool name="always_show_summary">false</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<resources>
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<style name="TextAppearance" />
|
<style name="TextAppearance" />
|
||||||
|
|
||||||
<style name="TextAppearance.Medium">
|
<style name="TextAppearance.Medium">
|
||||||
@@ -26,4 +26,8 @@
|
|||||||
<item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
|
<item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
|
||||||
<item name="android:textColor">?android:attr/textColorTertiary</item>
|
<item name="android:textColor">?android:attr/textColorTertiary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- Normally just a redirection, but this is used to make ourselves a
|
||||||
|
dialog on large tablets -->
|
||||||
|
<style name="Theme" parent="@android:style/Theme.Holo.Light" />
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -228,7 +228,9 @@ public class DirectoryFragment extends Fragment {
|
|||||||
|
|
||||||
// Push latest state up to UI
|
// Push latest state up to UI
|
||||||
// TODO: if mode change was racing with us, don't overwrite it
|
// TODO: if mode change was racing with us, don't overwrite it
|
||||||
|
if (result.mode != MODE_UNKNOWN) {
|
||||||
state.derivedMode = result.mode;
|
state.derivedMode = result.mode;
|
||||||
|
}
|
||||||
state.derivedSortOrder = result.sortOrder;
|
state.derivedSortOrder = result.sortOrder;
|
||||||
((DocumentsActivity) context).onStateChanged();
|
((DocumentsActivity) context).onStateChanged();
|
||||||
|
|
||||||
@@ -254,8 +256,8 @@ public class DirectoryFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onResume() {
|
||||||
super.onStart();
|
super.onResume();
|
||||||
updateDisplayState();
|
updateDisplayState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,6 +274,7 @@ public class DirectoryFragment extends Fragment {
|
|||||||
final RootInfo root = getArguments().getParcelable(EXTRA_ROOT);
|
final RootInfo root = getArguments().getParcelable(EXTRA_ROOT);
|
||||||
final DocumentInfo doc = getArguments().getParcelable(EXTRA_DOC);
|
final DocumentInfo doc = getArguments().getParcelable(EXTRA_DOC);
|
||||||
|
|
||||||
|
if (root != null) {
|
||||||
final Uri stateUri = RecentsProvider.buildState(
|
final Uri stateUri = RecentsProvider.buildState(
|
||||||
root.authority, root.rootId, doc.documentId);
|
root.authority, root.rootId, doc.documentId);
|
||||||
final ContentValues values = new ContentValues();
|
final ContentValues values = new ContentValues();
|
||||||
@@ -284,6 +287,7 @@ public class DirectoryFragment extends Fragment {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
|
}
|
||||||
|
|
||||||
// Mode change is just visual change; no need to kick loader, and
|
// Mode change is just visual change; no need to kick loader, and
|
||||||
// deliver change event immediately.
|
// deliver change event immediately.
|
||||||
@@ -733,6 +737,14 @@ public class DirectoryFragment extends Fragment {
|
|||||||
icon1.setVisibility(View.VISIBLE);
|
icon1.setVisibility(View.VISIBLE);
|
||||||
icon1.setImageDrawable(iconDrawable);
|
icon1.setImageDrawable(iconDrawable);
|
||||||
|
|
||||||
|
if (summary != null) {
|
||||||
|
final boolean alwaysShowSummary = getResources()
|
||||||
|
.getBoolean(R.bool.always_show_summary);
|
||||||
|
if (alwaysShowSummary) {
|
||||||
|
summary.setText(root.getDirectoryString());
|
||||||
|
summary.setVisibility(View.VISIBLE);
|
||||||
|
hasLine2 = true;
|
||||||
|
} else {
|
||||||
if (iconDrawable != null && roots.isIconUnique(root)) {
|
if (iconDrawable != null && roots.isIconUnique(root)) {
|
||||||
// No summary needed if icon speaks for itself
|
// No summary needed if icon speaks for itself
|
||||||
summary.setVisibility(View.INVISIBLE);
|
summary.setVisibility(View.INVISIBLE);
|
||||||
@@ -742,8 +754,11 @@ public class DirectoryFragment extends Fragment {
|
|||||||
summary.setTextAlignment(TextView.TEXT_ALIGNMENT_TEXT_END);
|
summary.setTextAlignment(TextView.TEXT_ALIGNMENT_TEXT_END);
|
||||||
hasLine2 = true;
|
hasLine2 = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
icon1.setVisibility(View.GONE);
|
icon1.setVisibility(View.GONE);
|
||||||
|
if (summary != null) {
|
||||||
if (docSummary != null) {
|
if (docSummary != null) {
|
||||||
summary.setText(docSummary);
|
summary.setText(docSummary);
|
||||||
summary.setVisibility(View.VISIBLE);
|
summary.setVisibility(View.VISIBLE);
|
||||||
@@ -752,6 +767,7 @@ public class DirectoryFragment extends Fragment {
|
|||||||
summary.setVisibility(View.INVISIBLE);
|
summary.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (docLastModified == -1) {
|
if (docLastModified == -1) {
|
||||||
date.setText(null);
|
date.setText(null);
|
||||||
@@ -772,7 +788,9 @@ public class DirectoryFragment extends Fragment {
|
|||||||
size.setVisibility(View.GONE);
|
size.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (line2 != null) {
|
||||||
line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE);
|
line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
final boolean enabled = Document.MIME_TYPE_DIR.equals(docMimeType)
|
final boolean enabled = Document.MIME_TYPE_DIR.equals(docMimeType)
|
||||||
|| MimePredicate.mimeMatches(state.acceptMimes, docMimeType);
|
|| MimePredicate.mimeMatches(state.acceptMimes, docMimeType);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import static com.android.documentsui.DocumentsActivity.State.ACTION_MANAGE;
|
|||||||
import static com.android.documentsui.DocumentsActivity.State.ACTION_OPEN;
|
import static com.android.documentsui.DocumentsActivity.State.ACTION_OPEN;
|
||||||
import static com.android.documentsui.DocumentsActivity.State.MODE_GRID;
|
import static com.android.documentsui.DocumentsActivity.State.MODE_GRID;
|
||||||
import static com.android.documentsui.DocumentsActivity.State.MODE_LIST;
|
import static com.android.documentsui.DocumentsActivity.State.MODE_LIST;
|
||||||
import static com.android.documentsui.DocumentsActivity.State.SORT_ORDER_LAST_MODIFIED;
|
|
||||||
|
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.app.ActionBar.OnNavigationListener;
|
import android.app.ActionBar.OnNavigationListener;
|
||||||
@@ -36,8 +35,12 @@ import android.content.ContentResolver;
|
|||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.graphics.Point;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.drawable.InsetDrawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
@@ -51,19 +54,20 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MenuItem.OnActionExpandListener;
|
import android.view.MenuItem.OnActionExpandListener;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.View.OnTouchListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.SearchView;
|
import android.widget.SearchView;
|
||||||
import android.widget.SearchView.OnCloseListener;
|
|
||||||
import android.widget.SearchView.OnQueryTextListener;
|
import android.widget.SearchView.OnQueryTextListener;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.documentsui.RecentsProvider.RecentColumns;
|
import com.android.documentsui.RecentsProvider.RecentColumns;
|
||||||
import com.android.documentsui.RecentsProvider.ResumeColumns;
|
import com.android.documentsui.RecentsProvider.ResumeColumns;
|
||||||
import com.android.documentsui.RecentsProvider.StateColumns;
|
|
||||||
import com.android.documentsui.model.DocumentInfo;
|
import com.android.documentsui.model.DocumentInfo;
|
||||||
import com.android.documentsui.model.DocumentStack;
|
import com.android.documentsui.model.DocumentStack;
|
||||||
import com.android.documentsui.model.DurableUtils;
|
import com.android.documentsui.model.DurableUtils;
|
||||||
@@ -79,15 +83,18 @@ import java.util.List;
|
|||||||
public class DocumentsActivity extends Activity {
|
public class DocumentsActivity extends Activity {
|
||||||
public static final String TAG = "Documents";
|
public static final String TAG = "Documents";
|
||||||
|
|
||||||
private SearchView mSearchView;
|
|
||||||
|
|
||||||
private View mRootsContainer;
|
|
||||||
private DrawerLayout mDrawerLayout;
|
|
||||||
private ActionBarDrawerToggle mDrawerToggle;
|
|
||||||
|
|
||||||
private static final String EXTRA_STATE = "state";
|
private static final String EXTRA_STATE = "state";
|
||||||
|
|
||||||
|
private boolean mShowAsDialog;
|
||||||
|
|
||||||
|
private SearchView mSearchView;
|
||||||
|
|
||||||
|
private DrawerLayout mDrawerLayout;
|
||||||
|
private ActionBarDrawerToggle mDrawerToggle;
|
||||||
|
private View mRootsContainer;
|
||||||
|
|
||||||
private boolean mIgnoreNextNavigation;
|
private boolean mIgnoreNextNavigation;
|
||||||
|
private boolean mIgnoreNextClose;
|
||||||
private boolean mIgnoreNextCollapse;
|
private boolean mIgnoreNextCollapse;
|
||||||
|
|
||||||
private RootsCache mRoots;
|
private RootsCache mRoots;
|
||||||
@@ -102,8 +109,50 @@ public class DocumentsActivity extends Activity {
|
|||||||
setResult(Activity.RESULT_CANCELED);
|
setResult(Activity.RESULT_CANCELED);
|
||||||
setContentView(R.layout.activity);
|
setContentView(R.layout.activity);
|
||||||
|
|
||||||
mRootsContainer = findViewById(R.id.container_roots);
|
final Resources res = getResources();
|
||||||
|
mShowAsDialog = res.getBoolean(R.bool.show_as_dialog);
|
||||||
|
|
||||||
|
if (mShowAsDialog) {
|
||||||
|
// backgroundDimAmount from theme isn't applied; do it manually
|
||||||
|
final WindowManager.LayoutParams a = getWindow().getAttributes();
|
||||||
|
a.dimAmount = 0.6f;
|
||||||
|
getWindow().setAttributes(a);
|
||||||
|
|
||||||
|
getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
|
||||||
|
getWindow().setFlags(~0, WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||||
|
|
||||||
|
// Inset ourselves to look like a dialog
|
||||||
|
final Point size = new Point();
|
||||||
|
getWindowManager().getDefaultDisplay().getSize(size);
|
||||||
|
|
||||||
|
final int width = (int) res.getFraction(R.dimen.dialog_width, size.x, size.x);
|
||||||
|
final int height = (int) res.getFraction(R.dimen.dialog_height, size.y, size.y);
|
||||||
|
final int insetX = (size.x - width) / 2;
|
||||||
|
final int insetY = (size.y - height) / 2;
|
||||||
|
|
||||||
|
final Drawable before = getWindow().getDecorView().getBackground();
|
||||||
|
final Drawable after = new InsetDrawable(before, insetX, insetY, insetX, insetY);
|
||||||
|
getWindow().getDecorView().setBackground(after);
|
||||||
|
|
||||||
|
// Dismiss when touch down in the dimmed inset area
|
||||||
|
getWindow().getDecorView().setOnTouchListener(new OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
|
final float x = event.getX();
|
||||||
|
final float y = event.getY();
|
||||||
|
if (x < insetX || x > v.getWidth() - insetX || y < insetY
|
||||||
|
|| y > v.getHeight() - insetY) {
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Non-dialog means we have a drawer
|
||||||
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||||
|
|
||||||
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
|
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
|
||||||
@@ -112,15 +161,23 @@ public class DocumentsActivity extends Activity {
|
|||||||
mDrawerLayout.setDrawerListener(mDrawerListener);
|
mDrawerLayout.setDrawerListener(mDrawerListener);
|
||||||
mDrawerLayout.setDrawerShadow(R.drawable.ic_drawer_shadow, GravityCompat.START);
|
mDrawerLayout.setDrawerShadow(R.drawable.ic_drawer_shadow, GravityCompat.START);
|
||||||
|
|
||||||
|
mRootsContainer = findViewById(R.id.container_roots);
|
||||||
|
}
|
||||||
|
|
||||||
if (icicle != null) {
|
if (icicle != null) {
|
||||||
mState = icicle.getParcelable(EXTRA_STATE);
|
mState = icicle.getParcelable(EXTRA_STATE);
|
||||||
} else {
|
} else {
|
||||||
buildDefaultState();
|
buildDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hide roots when we're managing a specific root
|
||||||
if (mState.action == ACTION_MANAGE) {
|
if (mState.action == ACTION_MANAGE) {
|
||||||
|
if (mShowAsDialog) {
|
||||||
|
findViewById(R.id.dialog_roots).setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mState.action == ACTION_CREATE) {
|
if (mState.action == ACTION_CREATE) {
|
||||||
final String mimeType = getIntent().getType();
|
final String mimeType = getIntent().getType();
|
||||||
@@ -210,14 +267,14 @@ public class DocumentsActivity extends Activity {
|
|||||||
|
|
||||||
// Only open drawer when showing recents
|
// Only open drawer when showing recents
|
||||||
if (mState.stack.isRecents()) {
|
if (mState.stack.isRecents()) {
|
||||||
mDrawerLayout.openDrawer(mRootsContainer);
|
setRootsDrawerOpen(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onResume() {
|
||||||
super.onStart();
|
super.onResume();
|
||||||
|
|
||||||
if (mState.action == ACTION_MANAGE) {
|
if (mState.action == ACTION_MANAGE) {
|
||||||
mState.showSize = true;
|
mState.showSize = true;
|
||||||
@@ -255,23 +312,41 @@ public class DocumentsActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPostCreate(Bundle savedInstanceState) {
|
protected void onPostCreate(Bundle savedInstanceState) {
|
||||||
super.onPostCreate(savedInstanceState);
|
super.onPostCreate(savedInstanceState);
|
||||||
|
if (mDrawerToggle != null) {
|
||||||
mDrawerToggle.syncState();
|
mDrawerToggle.syncState();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRootsDrawerOpen(boolean open) {
|
||||||
|
if (!mShowAsDialog) {
|
||||||
|
if (open) {
|
||||||
|
mDrawerLayout.openDrawer(mRootsContainer);
|
||||||
|
} else {
|
||||||
|
mDrawerLayout.closeDrawer(mRootsContainer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isRootsDrawerOpen() {
|
||||||
|
if (mShowAsDialog) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return mDrawerLayout.isDrawerOpen(mRootsContainer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateActionBar() {
|
public void updateActionBar() {
|
||||||
final ActionBar actionBar = getActionBar();
|
final ActionBar actionBar = getActionBar();
|
||||||
|
|
||||||
actionBar.setDisplayShowHomeEnabled(true);
|
actionBar.setDisplayShowHomeEnabled(true);
|
||||||
|
|
||||||
if (mState.action == ACTION_MANAGE) {
|
final boolean showIndicator = !mShowAsDialog && (mState.action != ACTION_MANAGE);
|
||||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
actionBar.setDisplayHomeAsUpEnabled(showIndicator);
|
||||||
mDrawerToggle.setDrawerIndicatorEnabled(false);
|
if (mDrawerToggle != null) {
|
||||||
} else {
|
mDrawerToggle.setDrawerIndicatorEnabled(showIndicator);
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
||||||
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mDrawerLayout.isDrawerOpen(mRootsContainer)) {
|
if (isRootsDrawerOpen()) {
|
||||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||||
actionBar.setIcon(new ColorDrawable());
|
actionBar.setIcon(new ColorDrawable());
|
||||||
|
|
||||||
@@ -302,12 +377,20 @@ public class DocumentsActivity extends Activity {
|
|||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
getMenuInflater().inflate(R.menu.activity, menu);
|
getMenuInflater().inflate(R.menu.activity, menu);
|
||||||
|
|
||||||
|
// Actions are always visible when showing as dialog
|
||||||
|
if (mShowAsDialog) {
|
||||||
|
for (int i = 0; i < menu.size(); i++) {
|
||||||
|
menu.getItem(i).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final MenuItem searchMenu = menu.findItem(R.id.menu_search);
|
final MenuItem searchMenu = menu.findItem(R.id.menu_search);
|
||||||
mSearchView = (SearchView) searchMenu.getActionView();
|
mSearchView = (SearchView) searchMenu.getActionView();
|
||||||
mSearchView.setOnQueryTextListener(new OnQueryTextListener() {
|
mSearchView.setOnQueryTextListener(new OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextSubmit(String query) {
|
public boolean onQueryTextSubmit(String query) {
|
||||||
mState.currentSearch = query;
|
mState.currentSearch = query;
|
||||||
|
mSearchView.clearFocus();
|
||||||
onCurrentDirectoryChanged();
|
onCurrentDirectoryChanged();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -337,6 +420,20 @@ public class DocumentsActivity extends Activity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onClose() {
|
||||||
|
if (mIgnoreNextClose) {
|
||||||
|
mIgnoreNextClose = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mState.currentSearch = null;
|
||||||
|
onCurrentDirectoryChanged();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +453,7 @@ public class DocumentsActivity extends Activity {
|
|||||||
final MenuItem settings = menu.findItem(R.id.menu_settings);
|
final MenuItem settings = menu.findItem(R.id.menu_settings);
|
||||||
|
|
||||||
// Open drawer means we hide most actions
|
// Open drawer means we hide most actions
|
||||||
if (mDrawerLayout.isDrawerOpen(mRootsContainer)) {
|
if (isRootsDrawerOpen()) {
|
||||||
createDir.setVisible(false);
|
createDir.setVisible(false);
|
||||||
search.setVisible(false);
|
search.setVisible(false);
|
||||||
sort.setVisible(false);
|
sort.setVisible(false);
|
||||||
@@ -367,23 +464,24 @@ public class DocumentsActivity extends Activity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cwd != null) {
|
sort.setVisible(cwd != null);
|
||||||
sort.setVisible(true);
|
|
||||||
grid.setVisible(mState.derivedMode != MODE_GRID);
|
grid.setVisible(mState.derivedMode != MODE_GRID);
|
||||||
list.setVisible(mState.derivedMode != MODE_LIST);
|
list.setVisible(mState.derivedMode != MODE_LIST);
|
||||||
} else {
|
|
||||||
sort.setVisible(false);
|
|
||||||
grid.setVisible(false);
|
|
||||||
list.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mState.currentSearch != null) {
|
if (mState.currentSearch != null) {
|
||||||
// Search uses backend ranking; no sorting
|
// Search uses backend ranking; no sorting
|
||||||
sort.setVisible(false);
|
sort.setVisible(false);
|
||||||
|
|
||||||
search.expandActionView();
|
search.expandActionView();
|
||||||
|
|
||||||
|
mSearchView.setIconified(false);
|
||||||
|
mSearchView.clearFocus();
|
||||||
mSearchView.setQuery(mState.currentSearch, false);
|
mSearchView.setQuery(mState.currentSearch, false);
|
||||||
} else {
|
} else {
|
||||||
|
mIgnoreNextClose = true;
|
||||||
|
mSearchView.setIconified(true);
|
||||||
|
mSearchView.clearFocus();
|
||||||
|
|
||||||
mIgnoreNextCollapse = true;
|
mIgnoreNextCollapse = true;
|
||||||
search.collapseActionView();
|
search.collapseActionView();
|
||||||
}
|
}
|
||||||
@@ -418,7 +516,7 @@ public class DocumentsActivity extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
if (mDrawerToggle.onOptionsItemSelected(item)) {
|
if (mDrawerToggle != null && mDrawerToggle.onOptionsItemSelected(item)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,7 +586,7 @@ public class DocumentsActivity extends Activity {
|
|||||||
if (size > 1) {
|
if (size > 1) {
|
||||||
mState.stack.pop();
|
mState.stack.pop();
|
||||||
onCurrentDirectoryChanged();
|
onCurrentDirectoryChanged();
|
||||||
} else if (size == 1 && !mDrawerLayout.isDrawerOpen(mRootsContainer)) {
|
} else if (size == 1 && !isRootsDrawerOpen()) {
|
||||||
// TODO: open root drawer once we can capture back key
|
// TODO: open root drawer once we can capture back key
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
} else {
|
} else {
|
||||||
@@ -614,6 +712,12 @@ public class DocumentsActivity extends Activity {
|
|||||||
RecentsCreateFragment.show(fm);
|
RecentsCreateFragment.show(fm);
|
||||||
} else {
|
} else {
|
||||||
DirectoryFragment.showRecentsOpen(fm);
|
DirectoryFragment.showRecentsOpen(fm);
|
||||||
|
|
||||||
|
// Start recents in relevant mode
|
||||||
|
final boolean acceptImages = MimePredicate.mimeMatches(
|
||||||
|
"image/*", mState.acceptMimes);
|
||||||
|
mState.userMode = acceptImages ? MODE_GRID : MODE_LIST;
|
||||||
|
mState.derivedMode = mState.userMode;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mState.currentSearch != null) {
|
if (mState.currentSearch != null) {
|
||||||
@@ -666,7 +770,7 @@ public class DocumentsActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (closeDrawer) {
|
if (closeDrawer) {
|
||||||
mDrawerLayout.closeDrawers();
|
setRootsDrawerOpen(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
package com.android.documentsui;
|
package com.android.documentsui;
|
||||||
|
|
||||||
import static com.android.documentsui.DocumentsActivity.TAG;
|
import static com.android.documentsui.DocumentsActivity.TAG;
|
||||||
import static com.android.documentsui.DocumentsActivity.State.MODE_GRID;
|
|
||||||
import static com.android.documentsui.DocumentsActivity.State.MODE_LIST;
|
|
||||||
import static com.android.documentsui.DocumentsActivity.State.SORT_ORDER_LAST_MODIFIED;
|
import static com.android.documentsui.DocumentsActivity.State.SORT_ORDER_LAST_MODIFIED;
|
||||||
|
|
||||||
import android.content.AsyncTaskLoader;
|
import android.content.AsyncTaskLoader;
|
||||||
@@ -194,9 +192,6 @@ public class RecentLoader extends AsyncTaskLoader<DirectoryResult> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final DirectoryResult result = new DirectoryResult();
|
final DirectoryResult result = new DirectoryResult();
|
||||||
|
|
||||||
final boolean acceptImages = MimePredicate.mimeMatches("image/*", mAcceptMimes);
|
|
||||||
result.mode = acceptImages ? MODE_GRID : MODE_LIST;
|
|
||||||
result.sortOrder = SORT_ORDER_LAST_MODIFIED;
|
result.sortOrder = SORT_ORDER_LAST_MODIFIED;
|
||||||
|
|
||||||
if (cursors.size() > 0) {
|
if (cursors.size() > 0) {
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ public class RootsFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onResume() {
|
||||||
super.onStart();
|
super.onResume();
|
||||||
updateRootsAdapter();
|
updateRootsAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.documentsui;
|
package com.android.documentsui;
|
||||||
|
|
||||||
|
import android.app.ActionBar;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -39,8 +40,14 @@ public class SettingsActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
getFragmentManager()
|
getFragmentManager()
|
||||||
.beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit();
|
.beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit();
|
||||||
|
|
||||||
|
final ActionBar bar = getActionBar();
|
||||||
|
if (bar != null) {
|
||||||
|
bar.setDisplayShowHomeEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SettingsFragment extends PreferenceFragment {
|
public static class SettingsFragment extends PreferenceFragment {
|
||||||
|
|||||||
Reference in New Issue
Block a user