From fddf8b4aa8b7fa0a8f8b6605552a1a09d127d382 Mon Sep 17 00:00:00 2001 From: alexgoramo-wq Date: Sun, 3 Aug 2025 02:48:51 -0600 Subject: [PATCH] Delete ActionOpenDocument directory --- ActionOpenDocument/.google/packaging.yaml | 33 --- ActionOpenDocument/README.md | 74 ------- ActionOpenDocument/app/build.gradle | 58 ------ .../PdfRendererBasicFragmentTests.kt | 134 ------------ .../app/src/main/AndroidManifest.xml | 38 ---- .../ActionOpenDocumentFragment.kt | 190 ------------------ .../actionopendocument/MainActivity.kt | 161 --------------- .../app/src/main/res/drawable/ic_info.xml | 26 --- .../res/drawable/ic_launcher_foreground.xml | 30 --- .../res/drawable/ic_pick_file_black_24dp.xml | 26 --- .../main/res/layout/activity_main_real.xml | 81 -------- .../layout/fragment_pdf_renderer_basic.xml | 58 ------ .../app/src/main/res/menu/main.xml | 31 --- .../res/mipmap-anydpi-v26/ic_launcher.xml | 21 -- .../mipmap-anydpi-v26/ic_launcher_round.xml | 21 -- .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 3355 -> 0 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 2096 -> 0 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 4668 -> 0 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 7383 -> 0 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 10567 -> 0 bytes .../res/values/ic_launcher_background.xml | 20 -- .../app/src/main/res/values/strings.xml | 34 ---- .../app/src/main/res/values/styles.xml | 25 --- ActionOpenDocument/build.gradle | 48 ----- ActionOpenDocument/gradle.properties | 18 -- .../gradle/wrapper/gradle-wrapper.jar | Bin 49896 -> 0 bytes .../gradle/wrapper/gradle-wrapper.properties | 22 -- ActionOpenDocument/gradlew | 164 --------------- ActionOpenDocument/gradlew.bat | 90 --------- ActionOpenDocument/screenshots/icon-web.png | Bin 31731 -> 0 bytes ActionOpenDocument/screenshots/main.png | Bin 214952 -> 0 bytes ActionOpenDocument/screenshots/start.png | Bin 42119 -> 0 bytes ActionOpenDocument/settings.gradle | 17 -- 33 files changed, 1420 deletions(-) delete mode 100644 ActionOpenDocument/.google/packaging.yaml delete mode 100644 ActionOpenDocument/README.md delete mode 100644 ActionOpenDocument/app/build.gradle delete mode 100644 ActionOpenDocument/app/src/androidTest/java/com/example/android/actionopendocument/PdfRendererBasicFragmentTests.kt delete mode 100644 ActionOpenDocument/app/src/main/AndroidManifest.xml delete mode 100644 ActionOpenDocument/app/src/main/java/com/example/android/actionopendocument/ActionOpenDocumentFragment.kt delete mode 100644 ActionOpenDocument/app/src/main/java/com/example/android/actionopendocument/MainActivity.kt delete mode 100644 ActionOpenDocument/app/src/main/res/drawable/ic_info.xml delete mode 100644 ActionOpenDocument/app/src/main/res/drawable/ic_launcher_foreground.xml delete mode 100644 ActionOpenDocument/app/src/main/res/drawable/ic_pick_file_black_24dp.xml delete mode 100644 ActionOpenDocument/app/src/main/res/layout/activity_main_real.xml delete mode 100644 ActionOpenDocument/app/src/main/res/layout/fragment_pdf_renderer_basic.xml delete mode 100644 ActionOpenDocument/app/src/main/res/menu/main.xml delete mode 100644 ActionOpenDocument/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml delete mode 100644 ActionOpenDocument/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml delete mode 100644 ActionOpenDocument/app/src/main/res/mipmap-hdpi/ic_launcher.png delete mode 100644 ActionOpenDocument/app/src/main/res/mipmap-mdpi/ic_launcher.png delete mode 100644 ActionOpenDocument/app/src/main/res/mipmap-xhdpi/ic_launcher.png delete mode 100644 ActionOpenDocument/app/src/main/res/mipmap-xxhdpi/ic_launcher.png delete mode 100644 ActionOpenDocument/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png delete mode 100644 ActionOpenDocument/app/src/main/res/values/ic_launcher_background.xml delete mode 100644 ActionOpenDocument/app/src/main/res/values/strings.xml delete mode 100644 ActionOpenDocument/app/src/main/res/values/styles.xml delete mode 100644 ActionOpenDocument/build.gradle delete mode 100644 ActionOpenDocument/gradle.properties delete mode 100644 ActionOpenDocument/gradle/wrapper/gradle-wrapper.jar delete mode 100644 ActionOpenDocument/gradle/wrapper/gradle-wrapper.properties delete mode 100755 ActionOpenDocument/gradlew delete mode 100644 ActionOpenDocument/gradlew.bat delete mode 100644 ActionOpenDocument/screenshots/icon-web.png delete mode 100644 ActionOpenDocument/screenshots/main.png delete mode 100644 ActionOpenDocument/screenshots/start.png delete mode 100644 ActionOpenDocument/settings.gradle diff --git a/ActionOpenDocument/.google/packaging.yaml b/ActionOpenDocument/.google/packaging.yaml deleted file mode 100644 index 3fb62933..00000000 --- a/ActionOpenDocument/.google/packaging.yaml +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (C) 2019 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. - -# GOOGLE SAMPLE PACKAGING DATA -# -# This file is used by Google as part of our samples packaging process. -# End users may safely ignore this file. It has no relevance to other systems. ---- -status: PUBLISHED -technologies: [Android, Storage Access Framework] -categories: [Storage] -languages: [Kotlin] -solutions: [Mobile] -github: android/storage -level: INTERMEDIATE -icon: screenshots/icon-web.png -apiRefs: - - android:android.content.ContentResolver - - android:android.provider.DocumentsContract - - android:android.graphics.pdf.PdfRenderer -license: apache2 diff --git a/ActionOpenDocument/README.md b/ActionOpenDocument/README.md deleted file mode 100644 index 49e347f4..00000000 --- a/ActionOpenDocument/README.md +++ /dev/null @@ -1,74 +0,0 @@ - -Android ACTION_OPEN_DOCUMENT Sample -======================================== - -
-App Icon -
- -This sample demonstrates how to display PDF document on screen using -the PdfRenderer introduced in [Android 5.0 Lollipop][4]. - -Introduction ------------- - -This sample demonstrates how to use the [Storage Access Framework][1] and -[`ACTION_OPEN_DOCUMENT`][2] to open PDF documents without relying on `READ_EXTERNAL_STORAGE` -permission. - -The app also demonstrates how you can now render PDF document pages into bitmap images for printing -by using the [PdfRenderer][1] class introduced in Android Lollipop. - -[1]: https://developer.android.com/guide/topics/providers/document-provider -[2]: https://developer.android.com/reference/android/content/Intent.html#ACTION_OPEN_DOCUMENT -[3]: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.html -[4]: https://www.android.com/versions/lollipop-5-0/ - -Pre-requisites --------------- - -- Android SDK 28 -- Android Device/Emulator API 21+ - -Screenshots -------------- - -Screenshot -Screenshot - -Getting Started ---------------- - -This sample uses the Gradle build system. To build this project, use the -"gradlew build" command or use "Import Project" in Android Studio. - -Support -------- - -- Stack Overflow: http://stackoverflow.com/questions/tagged/android - -If you've found an error in this sample, please file an issue: -https://github.com/android/storage/issues - -Patches are encouraged, and may be submitted by forking this project and -submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details. - -License -------- - -Copyright 2017 The Android Open Source Project, Inc. - -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE file distributed with this work for -additional information regarding copyright ownership. The ASF licenses this -file to you 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. diff --git a/ActionOpenDocument/app/build.gradle b/ActionOpenDocument/app/build.gradle deleted file mode 100644 index abd4cdc5..00000000 --- a/ActionOpenDocument/app/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -android { - compileSdkVersion rootProject.ext.compileSdkVersion - defaultConfig { - applicationId "com.example.android.actionopendocument" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$rootProject.ext.kotlinVersion" - - implementation 'androidx.appcompat:appcompat:1.3.1' - implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.core:core-ktx:1.6.0' - implementation 'androidx.fragment:fragment-ktx:1.3.6' - implementation 'androidx.constraintlayout:constraintlayout:2.1.0' - - implementation 'com.google.android.material:material:1.4.0' - - // Testing dependencies - androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - androidTestImplementation 'androidx.annotation:annotation:1.2.0' - androidTestImplementation 'androidx.test:runner:1.4.0' - androidTestImplementation 'androidx.test:rules:1.4.0' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - testImplementation "junit:junit:$rootProject.ext.junitVersion" -} diff --git a/ActionOpenDocument/app/src/androidTest/java/com/example/android/actionopendocument/PdfRendererBasicFragmentTests.kt b/ActionOpenDocument/app/src/androidTest/java/com/example/android/actionopendocument/PdfRendererBasicFragmentTests.kt deleted file mode 100644 index e7743efe..00000000 --- a/ActionOpenDocument/app/src/androidTest/java/com/example/android/actionopendocument/PdfRendererBasicFragmentTests.kt +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -package com.example.android.actionopendocument - -import android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE -import android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT -import androidx.test.espresso.Espresso.onView -import androidx.test.espresso.action.ViewActions.click -import androidx.test.espresso.matcher.ViewMatchers.withId -import androidx.test.rule.ActivityTestRule -import androidx.test.ext.junit.runners.AndroidJUnit4 -import android.widget.Button -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -/** - * Tests for ActionOpenDocument sample. - */ -@RunWith(AndroidJUnit4::class) -class ActionOpenDocumentFragmentTests { - - private lateinit var fragment: ActionOpenDocumentFragment - private lateinit var btnPrevious: Button - private lateinit var btnNext: Button - - @Rule - @JvmField - val activityTestRule = ActivityTestRule(MainActivity::class.java) - - @Before - fun before() { - activityTestRule.activity.supportFragmentManager.beginTransaction() - fragment = activityTestRule.activity.supportFragmentManager - .findFragmentByTag(DOCUMENT_FRAGMENT_TAG) as ActionOpenDocumentFragment - } - - @Test - fun testActivityTitle() { - // The title of the activity should be "ActionOpenDocument (1/10)" at first - val expectedActivityTitle = activityTestRule.activity.getString( - R.string.app_name_with_index, 1, fragment.pageCount - ) - assertEquals(expectedActivityTitle, activityTestRule.activity.title) - } - - @Test - fun testButtons_previousDisabledAtFirst() { - setUpButtons() - // Check that the previous button is disabled at first - assertFalse(btnPrevious.isEnabled) - // The next button should be enabled - assertTrue(btnNext.isEnabled) - } - - @Test - fun testButtons_bothEnabledInMiddle() { - setUpButtons() - turnPages(1) - // Two buttons should be both enabled - assertTrue(btnPrevious.isEnabled) - assertTrue(btnNext.isEnabled) - } - - @Test - fun testButtons_nextDisabledLastPage() { - setUpButtons() - val pageCount = fragment.pageCount - // Click till it reaches the last page - turnPages(pageCount - 1) - // Check the page count - val expectedActivityTitle = activityTestRule.activity.getString( - R.string.app_name_with_index, pageCount, pageCount - ) - assertEquals(expectedActivityTitle, activityTestRule.activity.title) - // The previous button should be enabled - assertTrue(btnPrevious.isEnabled) - // Check that the next button is disabled - assertFalse(btnNext.isEnabled) - } - - @Test - fun testOrientationChangePreserveState() { - activityTestRule.activity.requestedOrientation = SCREEN_ORIENTATION_PORTRAIT - setUpButtons() - turnPages(1) - val pageCount = fragment.pageCount - val expectedActivityTitle = activityTestRule.activity - .getString(R.string.app_name_with_index, 2, pageCount) - assertEquals(expectedActivityTitle, activityTestRule.activity.title) - activityTestRule.activity.requestedOrientation = SCREEN_ORIENTATION_LANDSCAPE - // Check that the title is the same after orientation change - assertEquals(expectedActivityTitle, activityTestRule.activity.title) - } - - /** - * Prepares references to the buttons "Previous" and "Next". - */ - private fun setUpButtons() { - val view = fragment.view ?: return - btnPrevious = view.findViewById(R.id.previous) - btnNext = view.findViewById(R.id.next) - } - - /** - * Click the "Next" button to turn the pages. - * - * @param count The number of times to turn pages. - */ - private fun turnPages(count: Int) { - for (i in 0 until count) { - onView(withId(R.id.next)).perform(click()) - } - } - -} diff --git a/ActionOpenDocument/app/src/main/AndroidManifest.xml b/ActionOpenDocument/app/src/main/AndroidManifest.xml deleted file mode 100644 index 4b19c80b..00000000 --- a/ActionOpenDocument/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/ActionOpenDocument/app/src/main/java/com/example/android/actionopendocument/ActionOpenDocumentFragment.kt b/ActionOpenDocument/app/src/main/java/com/example/android/actionopendocument/ActionOpenDocumentFragment.kt deleted file mode 100644 index 10148e50..00000000 --- a/ActionOpenDocument/app/src/main/java/com/example/android/actionopendocument/ActionOpenDocumentFragment.kt +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -package com.example.android.actionopendocument - -import android.content.Context -import android.graphics.Bitmap -import android.graphics.Bitmap.createBitmap -import android.graphics.pdf.PdfRenderer -import android.net.Uri -import android.os.Bundle -import android.util.Log -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.Button -import android.widget.ImageView -import androidx.core.net.toUri -import androidx.fragment.app.Fragment -import java.io.FileDescriptor -import java.io.IOException - -/** - * This fragment has a big [ImageView] that shows PDF pages, and 2 [Button]s to move between pages. - * We use a [PdfRenderer] to render PDF pages as [Bitmap]s. - */ -class ActionOpenDocumentFragment : Fragment() { - - private lateinit var pdfRenderer: PdfRenderer - private lateinit var currentPage: PdfRenderer.Page - private var currentPageNumber: Int = INITIAL_PAGE_INDEX - - private lateinit var pdfPageView: ImageView - private lateinit var previousButton: Button - private lateinit var nextButton: Button - - val pageCount get() = pdfRenderer.pageCount - - companion object { - private const val DOCUMENT_URI_ARGUMENT = - "com.example.android.actionopendocument.args.DOCUMENT_URI_ARGUMENT" - - fun newInstance(documentUri: Uri): ActionOpenDocumentFragment { - - return ActionOpenDocumentFragment().apply { - arguments = Bundle().apply { - putString(DOCUMENT_URI_ARGUMENT, documentUri.toString()) - } - } - } - } - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - return inflater.inflate(R.layout.fragment_pdf_renderer_basic, container, false) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - pdfPageView = view.findViewById(R.id.image) - previousButton = view.findViewById