diff --git a/.classpath b/.classpath deleted file mode 100644 index 205aca32..00000000 --- a/.classpath +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.cproject b/.cproject deleted file mode 100644 index 1c122a09..00000000 --- a/.cproject +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.gitignore b/.gitignore index 9f7eee94..a71312e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,27 @@ +#built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files bin/ gen/ -.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder.launch -.idea/ant.xml -.idea/compiler.xml -.idea/copyright/profiles_settings.xml -.idea/encodings.xml -.idea/misc.xml -.idea/modules.xml -.idea/scopes/scope_settings.xml -.idea/uiDesigner.xml -.idea/vcs.xml -.idea/workspace.xml -.settings/org.eclipse.jdt.core.prefs -.settings/org.eclipse.ltk.core.refactoring.prefs -.idea/.name -.idea/gradle.xml + +# Local configuration file (sdk path, etc) local.properties -res/drawable-hdpi/Thumbs.db -res/values/com_crashlytics_export_strings.xml -res/values/api_keys.xml + +# Windows thumbnail db +Thumbs.db + +# OSX files +.DS_Store + +# Android Studio +.idea +.gradle +build/ \ No newline at end of file diff --git a/.gradle/1.12/taskArtifacts/cache.properties b/.gradle/1.12/taskArtifacts/cache.properties deleted file mode 100644 index 548a694f..00000000 --- a/.gradle/1.12/taskArtifacts/cache.properties +++ /dev/null @@ -1 +0,0 @@ -#Mon Aug 11 17:26:46 CEST 2014 diff --git a/.gradle/1.12/taskArtifacts/cache.properties.lock b/.gradle/1.12/taskArtifacts/cache.properties.lock deleted file mode 100644 index 2c952068..00000000 Binary files a/.gradle/1.12/taskArtifacts/cache.properties.lock and /dev/null differ diff --git a/.gradle/1.12/taskArtifacts/fileHashes.bin b/.gradle/1.12/taskArtifacts/fileHashes.bin deleted file mode 100644 index 99c78562..00000000 Binary files a/.gradle/1.12/taskArtifacts/fileHashes.bin and /dev/null differ diff --git a/.gradle/1.12/taskArtifacts/fileSnapshots.bin b/.gradle/1.12/taskArtifacts/fileSnapshots.bin deleted file mode 100644 index a1aba32b..00000000 Binary files a/.gradle/1.12/taskArtifacts/fileSnapshots.bin and /dev/null differ diff --git a/.gradle/1.12/taskArtifacts/outputFileStates.bin b/.gradle/1.12/taskArtifacts/outputFileStates.bin deleted file mode 100644 index 1ed01fb8..00000000 Binary files a/.gradle/1.12/taskArtifacts/outputFileStates.bin and /dev/null differ diff --git a/.gradle/1.12/taskArtifacts/taskArtifacts.bin b/.gradle/1.12/taskArtifacts/taskArtifacts.bin deleted file mode 100644 index bb708021..00000000 Binary files a/.gradle/1.12/taskArtifacts/taskArtifacts.bin and /dev/null differ diff --git a/.idea/libraries/Palette.xml b/.idea/libraries/Palette.xml deleted file mode 100644 index 60989368..00000000 --- a/.idea/libraries/Palette.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/YouTubeAndroidPlayerApi.xml b/.idea/libraries/YouTubeAndroidPlayerApi.xml index 2841a6dc..d85d929e 100644 --- a/.idea/libraries/YouTubeAndroidPlayerApi.xml +++ b/.idea/libraries/YouTubeAndroidPlayerApi.xml @@ -1,7 +1,7 @@ - + diff --git a/.idea/libraries/android_support_v4.xml b/.idea/libraries/android_support_v4.xml deleted file mode 100644 index 90805f27..00000000 --- a/.idea/libraries/android_support_v4.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/cling_core_1_0_5.xml b/.idea/libraries/cling_core_1_0_5.xml index 3fcb1e27..f3614701 100644 --- a/.idea/libraries/cling_core_1_0_5.xml +++ b/.idea/libraries/cling_core_1_0_5.xml @@ -1,7 +1,7 @@ - + diff --git a/.idea/libraries/cling_support_1_0_5.xml b/.idea/libraries/cling_support_1_0_5.xml index 8a7d5ae8..4a2a647e 100644 --- a/.idea/libraries/cling_support_1_0_5.xml +++ b/.idea/libraries/cling_support_1_0_5.xml @@ -1,7 +1,7 @@ - + diff --git a/.idea/libraries/guava_16_0_1.xml b/.idea/libraries/guava_16_0_1.xml index f5685645..2eb7964a 100644 --- a/.idea/libraries/guava_16_0_1.xml +++ b/.idea/libraries/guava_16_0_1.xml @@ -1,9 +1,11 @@ - + - + + + \ No newline at end of file diff --git a/.idea/libraries/jcifs.xml b/.idea/libraries/jcifs.xml index 089d6798..225a5b86 100644 --- a/.idea/libraries/jcifs.xml +++ b/.idea/libraries/jcifs.xml @@ -1,7 +1,7 @@ - + diff --git a/.idea/libraries/otto_1_3_4.xml b/.idea/libraries/otto_1_3_4.xml index 90295219..96405ef7 100644 --- a/.idea/libraries/otto_1_3_4.xml +++ b/.idea/libraries/otto_1_3_4.xml @@ -1,9 +1,11 @@ - + - + + + \ No newline at end of file diff --git a/.idea/libraries/picasso_2_3_3.xml b/.idea/libraries/picasso_2_3_3.xml deleted file mode 100644 index f4e235c1..00000000 --- a/.idea/libraries/picasso_2_3_3.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/repackaged_okhttp_2_0_0.xml b/.idea/libraries/repackaged_okhttp_2_0_0.xml deleted file mode 100644 index 7b6acd49..00000000 --- a/.idea/libraries/repackaged_okhttp_2_0_0.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/repackaged_okhttp_urlconnection_2_0_0.xml b/.idea/libraries/repackaged_okhttp_urlconnection_2_0_0.xml deleted file mode 100644 index 7897f783..00000000 --- a/.idea/libraries/repackaged_okhttp_urlconnection_2_0_0.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/repackaged_okio_1_0_0.xml b/.idea/libraries/repackaged_okio_1_0_0.xml deleted file mode 100644 index 970b1fc3..00000000 --- a/.idea/libraries/repackaged_okio_1_0_0.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/teleal_common_1_0_13.xml b/.idea/libraries/teleal_common_1_0_13.xml index be6eda9d..a7dee2cf 100644 --- a/.idea/libraries/teleal_common_1_0_13.xml +++ b/.idea/libraries/teleal_common_1_0_13.xml @@ -1,7 +1,7 @@ - + diff --git a/.project b/.project deleted file mode 100644 index 7cba7a8a..00000000 --- a/.project +++ /dev/null @@ -1,43 +0,0 @@ - - - Mizuu v2 - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 0fd3f30c..00000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/com/miz/functions/MizLib.java=UTF-8 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 9430b82e..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,45 +0,0 @@ -Contributing to Mizuu's development -============ - -#### Contributing code? - -1. [Fork Mizuu][1]. -2. `git checkout -b descriptive-branch-name dev` and make your commits. -3. When you think your code is ready, start a pull request against the dev branch. Please reference [existing issues][2] when possible. - -#### No code? -* You can [suggest features][2]. -* You can [discuss a bug][2] or [report a bug][2]! -* You can [translate strings][3]. - -Branch structure ----------------- - -The repository is made up of two main branches: master (stable) and dev (unstable / work in progress). - -* **master** has the latest stable code, its tags are released as versions of Mizuu on GitHub, www.mizuu.tv and Google Play. -* **dev** includes the latest unstable code from contributers (you!). - -Since Mizuu was just recently open-sourced, there's still some work to do with branching and the overall structure of the development, but this is on the to-do list. For now, use the tagged commits as release versions. - -Setup ------ - -Mizuu is developed using ADT. I will most likely convert the project to the upcoming Android Studio environment in the future. - -In order to use the project with the various web services, you'll need to add an `api_keys.xml` file to `/res/values/` with the following content: - -```xml - - - add_your_own - add_your_own - add_your_own - add_your_own - add_your_own - -``` - - [1]: https://github.com/MizzleDK/Mizuu/fork - [2]: https://github.com/MizzleDK/Mizuu/issues - [3]: http://translate.mizuu.tv/ diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index d6456956..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/Mizuu.iml b/Mizuu.iml new file mode 100644 index 00000000..0bb6048a --- /dev/null +++ b/Mizuu.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/README.md b/README.md deleted file mode 100644 index f18209a4..00000000 --- a/README.md +++ /dev/null @@ -1,59 +0,0 @@ -Mizuu - media indexer for Android -===== - -This GitHub repository houses the source code of the Mizuu application for Android. - -![image alt][1] - -Description ----------------------- - -Mizuu is a user friendly media center application for Android tablets and smartphones. The application helps manage all your movie and TV show video files - and automatically fetches useful information about the video content, including title, plot, cover art and actors. - -Features -- Indexing of movie and TV show files on your device or on Samba (CIFS / SMB) and UPnP / DLNA compatible devices -- View actor details for movies, including biography, filmography and photos -- Many options to customize and personalize the application -- Enjoy popular video content from YouTube, Reddit as well as the latest TED Talks -- Browse details and watch trailers for upcoming and popular movies with online search -- Different widgets for displaying your collections on the home screen -- Synchronizes indexed content with your Trakt.tv account -- Google TV support (experimental) - - -Issues and suggestions ----------------------- - -Please use this link for issue tracking and suggestions: https://github.com/MizzleDK/MizuuApp/issues - -Dependencies ------------- - -Mizuu uses a number of third-party libraries, which are all included in the lib folder of this repo. - -Additionally, you'll need the Crashlytics plugin for your IDE and make sure it's set up with Mizuu. It needs to generate a special file in your assets folder and you also need to supply an API key for Crashlytics. - -Contributing ------------- - -If you want to contribute to Mizuu's development, there's plenty of ways to do it. You can read about it in [CONTRIBUTING.md][2]. - -License -------- - - Copyright 2014 Michell Bak - - 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. - - [1]: http://i.imgur.com/mvwzN67.jpg - [2]: https://github.com/MizzleDK/Mizuu/blob/master/CONTRIBUTING.md diff --git a/TRANSLATING.md b/TRANSLATING.md deleted file mode 100644 index a0f4a4d3..00000000 --- a/TRANSLATING.md +++ /dev/null @@ -1,54 +0,0 @@ -Translating Mizuu -============ - -#### Steps - -1. [Fork Mizuu][1]. -2. Read the guidelines on how to translate strings below. -3. `git checkout -b branch-name-language dev` and commit your translations. -4. When you think your translations are done, start a pull request against the dev branch. - -#### How to translate - -1. Locate the original strings in [/res/values/strings.xml][2] -2. Check if the strings have already been translated into the language you want to translate to. You can do that by checking [/res/][3] folder and look for values-##, where ## represents the [ISO 639-1 code][4] of the language, i.e. `values-da` for Danish. -3. If the language folder exists, you can check previous translations and add missing ones. If the folder doesn't exist, you can create it and add translations. -4. See the section below for specific translation examples - -Examples of string translation -============ - -#### Regular strings - -`Movies` - -*... gets translated into this (for Danish):* - -`Film` - -Some strings have explanations / context descriptions. Please refer to these, if you have any questions or doubts, or alternatively contact me or mention it in the pull request. - -#### Plural strings - -```xml - - movie - movies - -``` - -*... gets translated into this (for Danish):* - -```xml - - film - film - -``` - -Some languages include words for many different quantities. You may add or remove these quantities to match the specific language. Valid quantities are: "zero", "one", "two", "few", "many", "other". - - [1]: https://github.com/MizzleDK/Mizuu/fork - [2]: https://github.com/MizzleDK/Mizuu/blob/master/res/values/strings.xml - [3]: https://github.com/MizzleDK/Mizuu/blob/master/res/ - [4]: http://www.loc.gov/standards/iso639-2/php/code_list.php diff --git a/app/app.iml b/app/app.iml new file mode 100644 index 00000000..af2bffdf --- /dev/null +++ b/app/app.iml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 00000000..987df988 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,70 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 21 + buildToolsVersion "21.0.2" + + defaultConfig { + applicationId "com.miz.mizuu" + minSdkVersion 15 + targetSdkVersion 21 + + testApplicationId "com.miz.test" + testInstrumentationRunner "android.test.InstrumentationTestRunner" + + renderscriptTargetApi 19 + renderscriptSupportModeEnabled true + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } +} + +repositories { + mavenCentral() + mavenLocal() + maven { + url 'http://4thline.org/m2' + } +} + +dependencies { + compile 'com.android.support:support-v4:21.0.0' + compile 'com.google.guava:guava:16.0.1' + compile 'com.android.support:support-v4:21.0.+' + compile 'com.android.support:appcompat-v7:21.0.+' + compile 'com.android.support:palette-v7:21.0.+' + compile 'com.android.support:mediarouter-v7:21.0.+' + compile 'com.android.support:recyclerview-v7:+' + compile 'com.android.support:cardview-v7:21.+' + compile 'com.squareup.picasso:picasso:2.3.4' + compile 'com.squareup.okhttp:okhttp:2.1.0' + compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0' + compile 'com.squareup.okio:okio:1.0.1' + compile 'com.squareup:otto:1.3.4' + compile 'com.jpardogo.materialtabstrip:library:1.0.4+' + compile files('libs/cling-core-1.0.5.jar') + compile files('libs/cling-support-1.0.5.jar') + compile files('libs/jcifs.jar') + compile files('libs/teleal-common-1.0.13.jar') + compile files('libs/YouTubeAndroidPlayerApi.jar') + +/** + * // Cling + compile group: 'org.fourthline.cling', name: 'cling-core', version:'2.0.1' + compile group: 'org.fourthline.cling', name: 'cling-support', version:'2.0.1' + compile group: 'org.eclipse.jetty', name: 'jetty-server', version:'8.1.12.v20130726' + compile group: 'org.eclipse.jetty', name: 'jetty-servlet', version:'8.1.12.v20130726' + compile group: 'org.eclipse.jetty', name: 'jetty-client', version:'8.1.12.v20130726' + compile group: 'org.slf4j', name: 'slf4j-jdk14', version:'1.7.5' + */ + +} diff --git a/libs/YouTubeAndroidPlayerApi.jar b/app/libs/YouTubeAndroidPlayerApi.jar similarity index 100% rename from libs/YouTubeAndroidPlayerApi.jar rename to app/libs/YouTubeAndroidPlayerApi.jar diff --git a/libs/cling-core-1.0.5.jar b/app/libs/cling-core-1.0.5.jar similarity index 100% rename from libs/cling-core-1.0.5.jar rename to app/libs/cling-core-1.0.5.jar diff --git a/libs/cling-support-1.0.5.jar b/app/libs/cling-support-1.0.5.jar similarity index 100% rename from libs/cling-support-1.0.5.jar rename to app/libs/cling-support-1.0.5.jar diff --git a/libs/jcifs.jar b/app/libs/jcifs.jar similarity index 100% rename from libs/jcifs.jar rename to app/libs/jcifs.jar diff --git a/app/libs/okhttp-2.0.0.jar b/app/libs/okhttp-2.0.0.jar new file mode 100644 index 00000000..0d00384d Binary files /dev/null and b/app/libs/okhttp-2.0.0.jar differ diff --git a/app/libs/okhttp-urlconnection-2.0.0.jar b/app/libs/okhttp-urlconnection-2.0.0.jar new file mode 100644 index 00000000..62cda9be Binary files /dev/null and b/app/libs/okhttp-urlconnection-2.0.0.jar differ diff --git a/app/libs/okio-1.0.1.jar b/app/libs/okio-1.0.1.jar new file mode 100644 index 00000000..11b709a4 Binary files /dev/null and b/app/libs/okio-1.0.1.jar differ diff --git a/libs/otto-1.3.4.jar b/app/libs/otto-1.3.4.jar similarity index 100% rename from libs/otto-1.3.4.jar rename to app/libs/otto-1.3.4.jar diff --git a/libs/picasso-2.3.4.jar b/app/libs/picasso-2.3.4.jar similarity index 100% rename from libs/picasso-2.3.4.jar rename to app/libs/picasso-2.3.4.jar diff --git a/libs/teleal-common-1.0.13.jar b/app/libs/teleal-common-1.0.13.jar similarity index 100% rename from libs/teleal-common-1.0.13.jar rename to app/libs/teleal-common-1.0.13.jar diff --git a/lint.xml b/app/lint.xml similarity index 97% rename from lint.xml rename to app/lint.xml index bcbf777d..79e3d098 100644 --- a/lint.xml +++ b/app/lint.xml @@ -1,4 +1,4 @@ - + diff --git a/app/src/androidTest/java/com/miz/test/DatabaseMovieTests.java b/app/src/androidTest/java/com/miz/test/DatabaseMovieTests.java new file mode 100644 index 00000000..a7c85c13 --- /dev/null +++ b/app/src/androidTest/java/com/miz/test/DatabaseMovieTests.java @@ -0,0 +1,999 @@ +package com.miz.test;/* + * Copyright (C) 2014 Michell Bak + * + * 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. + */ + +import android.content.Context; +import android.test.InstrumentationTestCase; + +import com.miz.db.DbAdapterCollections; +import com.miz.db.DbAdapterMovieMappings; +import com.miz.db.DbAdapterMovies; +import com.miz.mizuu.MizuuApplication; +import com.miz.utils.MovieDatabaseUtils; + +/** + * Tests various movie database queries. + * Do not use this on a non-debug build, as + * it will remove all data. + */ +public class DatabaseMovieTests extends InstrumentationTestCase { + + private Context mContext; + + /** + * Tests if it's possible to create a movie. + */ + public void testMovieCreation() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + } + + /** + * Tests if it's possible to delete a movie. + */ + public void testMovieDeletion() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + // Delete the test movie + MovieDatabaseUtils.deleteMovie(mContext, "1234"); + + // We've just deleted the movie, so there should be zero now + assertEquals(0, db.count()); + } + + /** + * Tests if it's possible to delete all movies in the database. + */ + public void testDeleteAllMovies() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create two test movies + createTwoTestMovies(db); + + // We've just created two movie, so there should be two now + assertEquals(2, db.count()); + + // Delete all movies + MovieDatabaseUtils.deleteAllMovies(mContext); + + // We've just deleted all movies, so there should be zero now + assertEquals(0, db.count()); + + // Test collection count + DbAdapterCollections dbCollections = MizuuApplication.getCollectionsAdapter(); + assertEquals(0, dbCollections.count()); + + // Test filepath mapping count + DbAdapterMovieMappings dbMovieMappings = MizuuApplication.getMovieMappingAdapter(); + assertEquals(0, dbMovieMappings.count()); + + // There should be no files left to list in the movie thumbs folder + assertEquals(0, MizuuApplication.getMovieThumbFolder(mContext).listFiles().length); + + // There should be no files left to list in the movie backdrops folder + assertEquals(0, MizuuApplication.getMovieBackdropFolder(mContext).listFiles().length); + } + + /** + * Tests if it's possible to create a movie twice. Hint: It shouldn't be. + */ + public void testMovieDuplication() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + // Create the test movie again + createTestMovie(db); + + // There should still just be one movie in the database, since it + // already existed when we tried to create the movie the second time. + assertEquals(1, db.count()); + } + + /** + * Tests if it's possible to create a movie with an invalid movie ID. + */ + public void testInvalidMovieCreation() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create a movie with an unidentified ID + db.createMovie(DbAdapterMovies.UNIDENTIFIED_ID, "title", "plot", "tt1234567", "7.9", "tagline", "1970-01-01", "PG-13", "90", "http://youtube.com", "genres", "1", "actors", "collection", "collectionId", "1", "1", "123456789"); + + // There should still be zero movies, since we tried to add + // a movie with an unidentified ID + assertEquals(0, db.count()); + } + + /** + * Tests if it's possible to create a movie collection. + */ + public void testMovieCollectionCreation() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + // We've just created a movie with a collection ID, so there should be one now + assertEquals(true, MizuuApplication.getCollectionsAdapter().collectionExists("collectionId")); + } + + /** + * Tests if it's possible to ignore a movie. + */ + public void testIgnoreMovie() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + DbAdapterMovieMappings dbMappings = MizuuApplication.getMovieMappingAdapter(); + dbMappings.createFilepathMapping("/test/lulz.mkv", "1234"); + + // We've just created a filepath mapping for the movie, so there should be one now + assertEquals(1, dbMappings.getMovieFilepaths("1234").size()); + + // Ignore the movie based on its movie ID + MovieDatabaseUtils.ignoreMovie("1234"); + + // We've just ignored the movie, hence removing it from the movie database + assertEquals(0, db.count()); + + // We've just ignored all filepath mappings for the movie, so there should be zero now + assertEquals(0, dbMappings.getMovieFilepaths("1234").size()); + } + + /** + * Tests if it's possible to update the contents of an existing movie + * while keeping favourite, watchlist and watched status data intact. + */ + public void testUpdateMovie() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + db.createOrUpdateMovie("1234", "new title", "new plot", "tt12345678", "9.7", "new tagline", "1970-01-02", "PG-17", "900", "youtube.com", "genres...", "0", "new actors", "collectionName", "collID", "0", "0", "123456"); + + // Make sure that there's still just one movie + assertEquals(1, db.count()); + + // Make sure that the title has been updated + assertEquals("new title", db.getSingleItem("1234", DbAdapterMovies.KEY_TITLE)); + + // ... plot + assertEquals("new plot", db.getSingleItem("1234", DbAdapterMovies.KEY_PLOT)); + + // ... IMDB ID + assertEquals("tt12345678", db.getSingleItem("1234", DbAdapterMovies.KEY_IMDB_ID)); + + // ... Rating + assertEquals("9.7", db.getSingleItem("1234", DbAdapterMovies.KEY_RATING)); + + // ... Tagline + assertEquals("new tagline", db.getSingleItem("1234", DbAdapterMovies.KEY_TAGLINE)); + + // ... Release date + assertEquals("1970-01-02", db.getSingleItem("1234", DbAdapterMovies.KEY_RELEASEDATE)); + + // ... Certification + assertEquals("PG-17", db.getSingleItem("1234", DbAdapterMovies.KEY_CERTIFICATION)); + + // ... Runtime + assertEquals("900", db.getSingleItem("1234", DbAdapterMovies.KEY_RUNTIME)); + + // ... Trailer + assertEquals("youtube.com", db.getSingleItem("1234", DbAdapterMovies.KEY_TRAILER)); + + // ... Genres + assertEquals("genres...", db.getSingleItem("1234", DbAdapterMovies.KEY_GENRES)); + + // ... Favorite - this should NOT be changed + assertEquals("1", db.getSingleItem("1234", DbAdapterMovies.KEY_FAVOURITE)); + + // ... Actors + assertEquals("new actors", db.getSingleItem("1234", DbAdapterMovies.KEY_ACTORS)); + + // ... Collection ID + assertEquals("collID", db.getSingleItem("1234", DbAdapterMovies.KEY_COLLECTION_ID)); + + // ... To watch - this should NOT be changed + assertEquals("0", db.getSingleItem("1234", DbAdapterMovies.KEY_TO_WATCH)); + + // ... Has watched - this should NOT be changed + assertEquals("1", db.getSingleItem("1234", DbAdapterMovies.KEY_HAS_WATCHED)); + + // ... Date added + assertEquals("123456", db.getSingleItem("1234", DbAdapterMovies.KEY_DATE_ADDED)); + + DbAdapterCollections dbCollections = MizuuApplication.getCollectionsAdapter(); + assertEquals("collectionName", dbCollections.getCollection("collID")); + } + + /** + * Tests if it's possible to edit the contents of an existing movie + * while keeping favourite, watchlist and watched status data intact. + */ + public void testEditMovie() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + db.editMovie("1234", "new title", "new tagline", "new plot", "genres...", "900", "9.7", "1970-01-02", "PG-17"); + + // Make sure that there's still just one movie + assertEquals(1, db.count()); + + // Make sure that the title has been updated + assertEquals("new title", db.getSingleItem("1234", DbAdapterMovies.KEY_TITLE)); + + // ... plot + assertEquals("new plot", db.getSingleItem("1234", DbAdapterMovies.KEY_PLOT)); + + // ... Rating + assertEquals("9.7", db.getSingleItem("1234", DbAdapterMovies.KEY_RATING)); + + // ... Tagline + assertEquals("new tagline", db.getSingleItem("1234", DbAdapterMovies.KEY_TAGLINE)); + + // ... Release date + assertEquals("1970-01-02", db.getSingleItem("1234", DbAdapterMovies.KEY_RELEASEDATE)); + + // ... Certification + assertEquals("PG-17", db.getSingleItem("1234", DbAdapterMovies.KEY_CERTIFICATION)); + + // ... Runtime + assertEquals("900", db.getSingleItem("1234", DbAdapterMovies.KEY_RUNTIME)); + + // ... Genres + assertEquals("genres...", db.getSingleItem("1234", DbAdapterMovies.KEY_GENRES)); + } + + /** + * Tests if it's possible to create a movie + * and map multiple filepaths to it. + */ + public void testMultipleFilepathMappings() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + DbAdapterMovieMappings dbMappings = MizuuApplication.getMovieMappingAdapter(); + + // We haven't added any filepaths yet, so there shouldn't be any + assertEquals(0, dbMappings.getMovieFilepaths("1234").size()); + + dbMappings.createFilepathMapping("/test/lulz.mkv", "1234"); + + // We have just added a filepath, so there should be one now + assertEquals(1, dbMappings.getMovieFilepaths("1234").size()); + + dbMappings.createFilepathMapping("/test/lulz_2.mkv", "1234"); + + // We have just added another filepath, so there should be two now + assertEquals(2, dbMappings.getMovieFilepaths("1234").size()); + } + + /** + * Tests if it's possible to create a movie + * and map the same filepath to it multiple times. + * Hint: It shouldn't be possible. + */ + public void testMultipleIdenticalFilepathMappings() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + DbAdapterMovieMappings dbMappings = MizuuApplication.getMovieMappingAdapter(); + + // We haven't added any filepaths yet, so there shouldn't be any + assertEquals(0, dbMappings.getMovieFilepaths("1234").size()); + + dbMappings.createFilepathMapping("/test/lulz.mkv", "1234"); + + // We have just added a filepath, so there should be one now + assertEquals(1, dbMappings.getMovieFilepaths("1234").size()); + + dbMappings.createFilepathMapping("/test/lulz.mkv", "1234"); + + // We have just added the exact same filepath, which should be + // ignored, so there should still just be one filepath + assertEquals(1, dbMappings.getMovieFilepaths("1234").size()); + } + + /** + * Tests if it's possible to query a collection ID + * based on a movie ID. + */ + public void testGetCollectionId() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + // Check that it's the correct collection ID + assertEquals("collectionId", db.getCollectionId("1234")); + } + + public void testMovieExists() { + DbAdapterMovies db = getAndResetDatabase(); + + // We don't expect the movie to exist + assertEquals(false, db.movieExists("1234")); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so it should exist + assertEquals(true, db.movieExists("1234")); + } + + public void testCountWatchlist() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.countWatchlist()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie that's not on + // the watchlist, so we still expect zero movies + assertEquals(0, db.countWatchlist()); + + // Create two test movies, where one + // is on the watchlist + createTwoTestMovies(db); + + // There should now be one movie on the watchlist + assertEquals(1, db.countWatchlist()); + + // ... and two movies in total + assertEquals(2, db.count()); + + // Put the first movie on the watchlist + db.updateMovieSingleItem("1234", DbAdapterMovies.KEY_TO_WATCH, "1"); + + // There should now be two movies on the watchlist + assertEquals(2, db.countWatchlist()); + } + + public void testGetCertifications() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTwoTestMovies(db); + + // We've just created two movies, so there should be two now + assertEquals(2, db.count()); + + // Each movie had a unique certification, + // so there should be a total of 2 certifications. + assertEquals(2, db.getCertifications().size()); + + // The first... PG-13 + assertEquals("PG-13", db.getCertifications().get(0)); + + // The second... PG-17 + assertEquals("PG-17", db.getCertifications().get(1)); + } + + /** + * Tests if it's possible to delete + * all movie collections. + */ + public void testDeleteAllCollections() { + DbAdapterCollections dbCollections = MizuuApplication.getCollectionsAdapter(); + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // ... and zero collections + assertEquals(0, dbCollections.count()); + + // Create test movies + createTwoTestMovies(db); + + // We've just created two movies, so there should be two now + assertEquals(2, db.count()); + + // ... and two collections + assertEquals(2, dbCollections.count()); + + // Delete all collections + dbCollections.deleteAllCollections(); + + // Back to zero + assertEquals(0, dbCollections.count()); + } + + /** + * Tests if it's possible to create a movie + * collection twice. Hint: It shouldn't be. + */ + public void testCollectionDuplication() { + DbAdapterMovies db = getAndResetDatabase(); + DbAdapterCollections dbCollections = MizuuApplication.getCollectionsAdapter(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // ... and zero collections + assertEquals(0, dbCollections.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + // ... and one collection + assertEquals(1, dbCollections.count()); + + // Create test movie again + createTestMovie(db); + + // Still one of each + assertEquals(1, db.count()); + assertEquals(1, dbCollections.count()); + + // Try to manually create a collection + // using an existing collection ID + dbCollections.createCollection("1234", "collectionId", "something, something"); + + // Nope, still just one + assertEquals(1, dbCollections.count()); + } + + public void testDeleteCollection() { + DbAdapterCollections dbCollections = MizuuApplication.getCollectionsAdapter(); + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // ... and zero collections + assertEquals(0, dbCollections.count()); + + // Create test movies + createTwoTestMovies(db); + + // We've just created two movies, so there should be two now + assertEquals(2, db.count()); + + // ... and two collections + assertEquals(2, dbCollections.count()); + + // Delete one of the collections + dbCollections.deleteCollection("collectionId"); + + // Back to one + assertEquals(1, dbCollections.count()); + + // Delete the remaining collection + dbCollections.deleteCollection("collectionId2"); + + // Back to zero + assertEquals(0, dbCollections.count()); + } + + /** + * Tests if a collection exists. + */ + public void testCollectionExists() { + DbAdapterMovies db = getAndResetDatabase(); + DbAdapterCollections dbCollections = MizuuApplication.getCollectionsAdapter(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // ... and zero collections + assertEquals(0, dbCollections.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + // ... and one collection + assertEquals(1, dbCollections.count()); + + // Check if it exists + assertEquals(true, dbCollections.collectionExists("collectionId")); + + // Make sure we're not getting a false positive + assertEquals(false, dbCollections.collectionExists("lulz")); + } + + /** + * Tests if it's possible to get the number of + * movies mapped to a given collection. + */ + public void testMovieCountForCollection() { + DbAdapterMovies db = getAndResetDatabase(); + DbAdapterCollections dbCollections = MizuuApplication.getCollectionsAdapter(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + assertEquals(0, dbCollections.getMovieCount("collectionId")); + + // Create test movie + createTestMovie(db); + + // There should be one now + assertEquals(1, db.count()); + assertEquals(1, dbCollections.getMovieCount("collectionId")); + } + + /** + * Tests if it's possible to delete all unidentified movies in the database. + */ + public void testDeleteAllUnidentified() { + getAndResetDatabase(); + + // Test filepath mapping count + DbAdapterMovieMappings dbMovieMappings = MizuuApplication.getMovieMappingAdapter(); + assertEquals(0, dbMovieMappings.count()); + + // Create an unidentified mapping + dbMovieMappings.createFilepathMapping("/yo/lulz.mkv", DbAdapterMovies.UNIDENTIFIED_ID); + + // Make sure it's created + assertEquals(1, dbMovieMappings.count()); + + // Create another unidentified mapping + dbMovieMappings.createFilepathMapping("/yo/lulzz.mkv", DbAdapterMovies.UNIDENTIFIED_ID); + + // Make sure it's created + assertEquals(2, dbMovieMappings.count()); + + // Create a third unidentified mapping + dbMovieMappings.createFilepathMapping("/yo/lulzzz.mkv", DbAdapterMovies.UNIDENTIFIED_ID); + + // Make sure it's created + assertEquals(3, dbMovieMappings.count()); + + // Finally, let's create a mapping for an actual movie ID + dbMovieMappings.createFilepathMapping("/yo/lulzzzz.mkv", "1234"); + + // Make sure it's created + assertEquals(4, dbMovieMappings.count()); + + // Delete all unidentified filepaths + dbMovieMappings.deleteAllUnidentifiedFilepaths(); + + // Since we have added three unidentified mappings and one + // correct mapping we should be back at one now. + assertEquals(1, dbMovieMappings.count()); + } + + /** + * Test if it's possible to update a filepath movie mapping. + */ + public void testUpdateTmdbId() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTwoTestMovies(db); + + // We've just created two movies, so there should be two now + assertEquals(2, db.count()); + + // Get the DB adapter for movie mappings + DbAdapterMovieMappings dbMovieMappings = MizuuApplication.getMovieMappingAdapter(); + + // Make sure that there aren't any filepaths linked to begin with + assertEquals(0, dbMovieMappings.getMovieFilepaths("1234").size()); + + // Create a filepath + dbMovieMappings.createFilepathMapping("/test/yo.mkv", "1234"); + + // We should have one now + assertEquals(1, dbMovieMappings.getMovieFilepaths("1234").size()); + + // We're going to update the filepath mapping to another movie. + // Let's make sure that other movie doesn't have any mappings to begin with. + assertEquals(0, dbMovieMappings.getMovieFilepaths("12345").size()); + + // Let's update + dbMovieMappings.updateTmdbId("/test/yo.mkv", "1234", "12345"); + + // We should have one now + assertEquals(1, dbMovieMappings.getMovieFilepaths("12345").size()); + + // ... and zero for the old one + // We should have one now + assertEquals(0, dbMovieMappings.getMovieFilepaths("1234").size()); + } + + /** + * Tests if it's possible to check if a + * movie has a filepath mapping. + */ + public void testMovieMappingExists() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTwoTestMovies(db); + + // We've just created two movies, so there should be two now + assertEquals(2, db.count()); + + // Get the DB adapter for movie mappings + DbAdapterMovieMappings dbMovieMappings = MizuuApplication.getMovieMappingAdapter(); + + // We haven't added a filepath mapping yet, so we don't expect it to exist + assertEquals(false, dbMovieMappings.exists("1234")); + + // Add the filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulz.mkv", "1234"); + + // It should exist now + assertEquals(true, dbMovieMappings.exists("1234")); + } + + /** + * Test if it's possible to determine if a a filepath + * has been mapped to a movie by its movie ID. + */ + public void testFilepathExists() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTwoTestMovies(db); + + // We've just created two movies, so there should be two now + assertEquals(2, db.count()); + + // Get the DB adapter for movie mappings + DbAdapterMovieMappings dbMovieMappings = MizuuApplication.getMovieMappingAdapter(); + + // We haven't added a filepath mapping yet, so we don't expect it to exist + assertEquals(false, dbMovieMappings.filepathExists("1234", "/test/lulz.mkv")); + + // Add the filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulz.mkv", "1234"); + + // It should exist now + assertEquals(true, dbMovieMappings.filepathExists("1234", "/test/lulz.mkv")); + } + + /** + * Test if it's possible to delete all filepaths + * mapped to a movie, including + */ + public void testDeleteAllFilepathsMappedToMovie() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create two test movies + createTwoTestMovies(db); + + // We've just created two movies, so there should be two now + assertEquals(2, db.count()); + + // Get the DB adapter for movie mappings + DbAdapterMovieMappings dbMovieMappings = MizuuApplication.getMovieMappingAdapter(); + + // We haven't added any filepath mappings for the movies yet + assertEquals(0, dbMovieMappings.count()); + + // Add a filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulz.mkv", "1234"); + + // Add another filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulzz.mkv", "1234"); + + // Add a filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulz_1.mkv", "12345"); + + // Add another filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulzz_1.mkv", "12345"); + + // We have added a total of four filepath mappings + assertEquals(4, dbMovieMappings.count()); + + // Delete all filepaths for a movie + dbMovieMappings.deleteMovie("1234"); + + // Back at 2 + assertEquals(2, dbMovieMappings.count()); + + // Delete all filepaths for the second movie + dbMovieMappings.deleteMovie("12345"); + + // Back at zero + assertEquals(0, dbMovieMappings.count()); + + // Let's make sure it works with unidentified ID as well + dbMovieMappings.createFilepathMapping("/test/wat.mkv", DbAdapterMovies.UNIDENTIFIED_ID); + + // At one + assertEquals(1, dbMovieMappings.count()); + + // Delete all unidentified filepaths + dbMovieMappings.deleteAllUnidentifiedFilepaths(); + + // Back at zero + assertEquals(0, dbMovieMappings.count()); + } + + /** + * Tests if it's possible to delete all filepaths, including those + * marked with an unidentified ID. + */ + public void testDeleteAllMovieFilepaths() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create two test movies + createTwoTestMovies(db); + + // We've just created two movies, so there should be two now + assertEquals(2, db.count()); + + // Get the DB adapter for movie mappings + DbAdapterMovieMappings dbMovieMappings = MizuuApplication.getMovieMappingAdapter(); + + // We haven't added any filepath mappings for the movies yet + assertEquals(0, dbMovieMappings.count()); + + // Add a filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulz.mkv", "1234"); + + // Add another filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulzz.mkv", "1234"); + + // Add a filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulz_1.mkv", "12345"); + + // Add another filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulzz_1.mkv", "12345"); + + // We have added a total of four filepath mappings + assertEquals(4, dbMovieMappings.count()); + + // Delete them all + dbMovieMappings.deleteAllMovies(); + + // Zero, plz! + assertEquals(0, dbMovieMappings.count()); + + // Let's make sure it works with unidentified ID as well + dbMovieMappings.createFilepathMapping("/test/wat.mkv", DbAdapterMovies.UNIDENTIFIED_ID); + + // There should be one now + assertEquals(1, dbMovieMappings.count()); + + // Delete them all (well, hopefully just one) + dbMovieMappings.deleteAllMovies(); + + // Again... Zero, plz! + assertEquals(0, dbMovieMappings.count()); + } + + /** + * Test if it's possible to get all filepaths + * mapped to a movie ID. + */ + public void testMovieFilepathsByMovieId() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + // Get the DB adapter for movie mappings + DbAdapterMovieMappings dbMovieMappings = MizuuApplication.getMovieMappingAdapter(); + + // We haven't added any filepath mappings for the movie yet + assertEquals(0, dbMovieMappings.getMovieFilepaths("1234").size()); + + // Add a filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulz.mkv", "1234"); + + // Add another filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulzz.mkv", "1234"); + + // We've added two filepath mappings + assertEquals(2, dbMovieMappings.getMovieFilepaths("1234").size()); + + // Check the first one... + assertEquals("/test/lulz.mkv", dbMovieMappings.getMovieFilepaths("1234").get(0)); + + // And the second one... + assertEquals("/test/lulzz.mkv", dbMovieMappings.getMovieFilepaths("1234").get(1)); + } + + /** + * Test if it's possible to get a movie ID based on a filepath. + */ + public void testMovieIdByFilepath() { + DbAdapterMovies db = getAndResetDatabase(); + + // We expect zero movies to begin with + assertEquals(0, db.count()); + + // Create test movie + createTestMovie(db); + + // We've just created a movie, so there should be one now + assertEquals(1, db.count()); + + // Get the DB adapter for movie mappings + DbAdapterMovieMappings dbMovieMappings = MizuuApplication.getMovieMappingAdapter(); + + // There shouldn't be any + assertEquals("", dbMovieMappings.getIdForFilepath("/test/lulz.mkv")); + + // Add the filepath mapping + dbMovieMappings.createFilepathMapping("/test/lulz.mkv", "1234"); + + // It should exist now + assertEquals("1234", dbMovieMappings.getIdForFilepath("/test/lulz.mkv")); + } + + /** + * Get a database instance and reset it before the test begins. + * @return + */ + private DbAdapterMovies getAndResetDatabase() { + // Ensures that we've got an application context, which + // is required in order to use the MizuuApplication methods. + getInstrumentation().waitForIdleSync(); + + mContext = getInstrumentation().getTargetContext().getApplicationContext(); + + DbAdapterMovies db = MizuuApplication.getMovieAdapter(); + resetDatabase(db); + return db; + } + + /** + * Resets the movie database by deleting all movies, + * collections and filepath mappings. + * @param db + */ + private void resetDatabase(DbAdapterMovies db) { + MovieDatabaseUtils.deleteAllMovies(mContext); + + // Test movie count + assertEquals(0, db.count()); + + // Test collection count + DbAdapterCollections dbCollections = MizuuApplication.getCollectionsAdapter(); + assertEquals(0, dbCollections.count()); + + // Test filepath mapping count + DbAdapterMovieMappings dbMovieMappings = MizuuApplication.getMovieMappingAdapter(); + assertEquals(0, dbMovieMappings.count()); + } + + /** + * Creates a test movie in the database. + * @param db + */ + private void createTestMovie(DbAdapterMovies db) { + // Create test movie + db.createMovie("1234", "title", "plot", "tt1234567", "7.9", "tagline", "1970-01-01", "PG-13", "90", "http://youtube.com", "genres", "1", "actors", "collection", "collectionId", "0", "1", "123456789"); + } + + /** + * Creates two test movies in the database. + * @param db + */ + private void createTwoTestMovies(DbAdapterMovies db) { + // Create test movie + db.createMovie("1234", "title", "plot", "tt1234567", "7.9", "tagline", "1970-01-01", "PG-13", "90", "http://youtube.com", "genres", "1", "actors", "collection", "collectionId", "0", "1", "123456789"); + db.createMovie("12345", "title", "plot", "tt1234567", "7.9", "tagline", "1970-01-01", "PG-17", "90", "http://youtube.com", "genres", "1", "actors", "collection2", "collectionId2", "1", "1", "123456789"); + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/miz/test/DatabaseTvShowTests.java b/app/src/androidTest/java/com/miz/test/DatabaseTvShowTests.java new file mode 100644 index 00000000..76132057 --- /dev/null +++ b/app/src/androidTest/java/com/miz/test/DatabaseTvShowTests.java @@ -0,0 +1,91 @@ +package com.miz.test;/* + * Copyright (C) 2014 Michell Bak + * + * 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. + */ + +import android.content.Context; +import android.test.InstrumentationTestCase; + +/** + * Tests various TV show database queries. + * Do not use this on a non-debug build, as + * it will remove all data. + */ +public class DatabaseTvShowTests extends InstrumentationTestCase { + + private Context mContext; + + + + /* + TV shows: + +- create show +- show exists + - TVDb ID + - TMDb ID + - Title +- get show ID by show title +- get show by show ID +- get all shows +- delete show by ID +- delete all shows +- get certifications +- edit show + + +TV show episodes: + +- create episode +- update episode +- get episode +- get all episodes by show ID +- get all episodes +- delete episode +- delete all episodes by show ID +- remove season +- delete all episodes +- get episode count by show ID +- get episode count for season +- get season count +- get seasons +- get episodes in season +- get latest episode airdate by show ID +- has unwatched episodes +- set season watched status +- set episode watched status + + +TV show episode mapping: + +- create filepath mapping +- filepath exists +- get first filepath +- get filepaths for episode +- get all unidentified filepaths +- get all filepaths +- get all info for filepath +- get all filepaths by show ID +- get all ignored filepaths +- delete filepath by filepath +- ignore filepath +- delete all filepaths by show ID +- delete all filepaths +- delete all unidentified filepaths +- has multiple filepaths +- remove season +- ignore season + */ + +} \ No newline at end of file diff --git a/src/com/miz/tests/MovieFilenameTests.java b/app/src/androidTest/java/com/miz/test/MovieFilenameTests.java similarity index 94% rename from src/com/miz/tests/MovieFilenameTests.java rename to app/src/androidTest/java/com/miz/test/MovieFilenameTests.java index 52b8f8c5..a0bcd627 100644 --- a/src/com/miz/tests/MovieFilenameTests.java +++ b/app/src/androidTest/java/com/miz/test/MovieFilenameTests.java @@ -1,4 +1,4 @@ -/* +package com.miz.test;/* * Copyright (C) 2014 Michell Bak * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +14,10 @@ * limitations under the License. */ -package com.miz.tests; +import android.test.AndroidTestCase; import com.miz.identification.MovieStructure; -import android.test.AndroidTestCase; - public class MovieFilenameTests extends AndroidTestCase { public void testCase1() { @@ -192,4 +190,15 @@ public void testCase16() { assertEquals(true, ms.hasReleaseYear()); assertEquals(2009, ms.getReleaseYear()); } + + public void testCase17() { + MovieStructure ms = new MovieStructure("/G.I. Joe Retaliation (2013).mkv"); + assertEquals("", ms.getParentFolderName()); + assertEquals("G.I. Joe Retaliation (2013).mkv", ms.getFilename()); + assertEquals(false, ms.hasImdbId()); + assertEquals("", ms.getDecryptedParentFolderName()); + assertEquals("GI Joe Retaliation", ms.getDecryptedFilename()); + assertEquals(true, ms.hasReleaseYear()); + assertEquals(2013, ms.getReleaseYear()); + } } \ No newline at end of file diff --git a/src/com/miz/tests/TvShowFileNameTests.java b/app/src/androidTest/java/com/miz/test/TvShowFilenameTests.java similarity index 99% rename from src/com/miz/tests/TvShowFileNameTests.java rename to app/src/androidTest/java/com/miz/test/TvShowFilenameTests.java index aacb5ef0..d9cd337a 100644 --- a/src/com/miz/tests/TvShowFileNameTests.java +++ b/app/src/androidTest/java/com/miz/test/TvShowFilenameTests.java @@ -1,4 +1,4 @@ -/* +package com.miz.test;/* * Copyright (C) 2014 Michell Bak * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +14,10 @@ * limitations under the License. */ -package com.miz.tests; +import android.test.AndroidTestCase; import com.miz.identification.ShowStructure; -import android.test.AndroidTestCase; - public class TvShowFilenameTests extends AndroidTestCase { public void testCase1() { diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png new file mode 100644 index 00000000..cc187cf6 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_disabled_holo_dark.png new file mode 100644 index 00000000..f097749e Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_focused_holo_dark.png new file mode 100644 index 00000000..45fe011a Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_holo_dark.png new file mode 100644 index 00000000..fbde8370 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_pressed_holo_dark.png new file mode 100644 index 00000000..2f6d7b56 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_off_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png new file mode 100644 index 00000000..33af7b77 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_disabled_holo_dark.png new file mode 100644 index 00000000..aa1e5a08 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_focused_holo_dark.png new file mode 100644 index 00000000..44fa7883 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_holo_dark.png new file mode 100644 index 00000000..bfdcdf64 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_pressed_holo_dark.png new file mode 100644 index 00000000..4d403fae Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_check_on_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png new file mode 100644 index 00000000..8608718c Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_disabled_holo_dark.png new file mode 100644 index 00000000..c2f37c29 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_focused_holo_dark.png new file mode 100644 index 00000000..87535ea2 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_holo_dark.png new file mode 100644 index 00000000..dfbe365b Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_pressed_holo_dark.png new file mode 100644 index 00000000..5c97445f Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_off_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png new file mode 100644 index 00000000..c229c011 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_disabled_holo_dark.png new file mode 100644 index 00000000..2fb254cc Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_focused_holo_dark.png new file mode 100644 index 00000000..70aa37a3 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_holo_dark.png new file mode 100644 index 00000000..6a6e6667 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_pressed_holo_dark.png new file mode 100644 index 00000000..b2597e9e Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/apptheme_btn_radio_on_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/menuicon.png b/app/src/androidTest/res/crunch/drawable-hdpi/menuicon.png new file mode 100644 index 00000000..e9389647 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/menuicon.png differ diff --git a/app/src/androidTest/res/crunch/drawable-hdpi/shadow.png b/app/src/androidTest/res/crunch/drawable-hdpi/shadow.png new file mode 100644 index 00000000..1de091f3 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-hdpi/shadow.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png new file mode 100644 index 00000000..1c9b4bd9 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_disabled_holo_dark.png new file mode 100644 index 00000000..43d6882d Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_focused_holo_dark.png new file mode 100644 index 00000000..ca200b9d Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_holo_dark.png new file mode 100644 index 00000000..23235ed8 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_pressed_holo_dark.png new file mode 100644 index 00000000..2dda6334 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_off_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png new file mode 100644 index 00000000..9e67d7f2 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_disabled_holo_dark.png new file mode 100644 index 00000000..c61c75cd Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_focused_holo_dark.png new file mode 100644 index 00000000..90c13f46 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_holo_dark.png new file mode 100644 index 00000000..bf3e7c7d Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_pressed_holo_dark.png new file mode 100644 index 00000000..77901d6a Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_check_on_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png new file mode 100644 index 00000000..3e2bdfca Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_disabled_holo_dark.png new file mode 100644 index 00000000..c445b12c Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_focused_holo_dark.png new file mode 100644 index 00000000..5338502a Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_holo_dark.png new file mode 100644 index 00000000..e42d6fca Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_pressed_holo_dark.png new file mode 100644 index 00000000..c2f90bc8 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_off_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png new file mode 100644 index 00000000..9f24b6b4 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_disabled_holo_dark.png new file mode 100644 index 00000000..f4cc32bc Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_focused_holo_dark.png new file mode 100644 index 00000000..c8bbcf9d Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_holo_dark.png new file mode 100644 index 00000000..7c3ebbff Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_pressed_holo_dark.png new file mode 100644 index 00000000..de919436 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/apptheme_btn_radio_on_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-mdpi/shadow.png b/app/src/androidTest/res/crunch/drawable-mdpi/shadow.png new file mode 100644 index 00000000..242e6f81 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-mdpi/shadow.png differ diff --git a/app/src/androidTest/res/crunch/drawable-nodpi/bg_with_border.9.png b/app/src/androidTest/res/crunch/drawable-nodpi/bg_with_border.9.png new file mode 100644 index 00000000..d6b1e403 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-nodpi/bg_with_border.9.png differ diff --git a/app/src/androidTest/res/crunch/drawable-nodpi/border.9.png b/app/src/androidTest/res/crunch/drawable-nodpi/border.9.png new file mode 100644 index 00000000..52023fee Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-nodpi/border.9.png differ diff --git a/app/src/androidTest/res/crunch/drawable-nodpi/menu_bg.png b/app/src/androidTest/res/crunch/drawable-nodpi/menu_bg.png new file mode 100644 index 00000000..1aa9c6ab Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-nodpi/menu_bg.png differ diff --git a/app/src/androidTest/res/crunch/drawable-nodpi/widget_movie_backdrop.png b/app/src/androidTest/res/crunch/drawable-nodpi/widget_movie_backdrop.png new file mode 100644 index 00000000..3b223d27 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-nodpi/widget_movie_backdrop.png differ diff --git a/app/src/androidTest/res/crunch/drawable-nodpi/widget_movie_cover.png b/app/src/androidTest/res/crunch/drawable-nodpi/widget_movie_cover.png new file mode 100644 index 00000000..a007a4e7 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-nodpi/widget_movie_cover.png differ diff --git a/app/src/androidTest/res/crunch/drawable-nodpi/widget_movie_stack.png b/app/src/androidTest/res/crunch/drawable-nodpi/widget_movie_stack.png new file mode 100644 index 00000000..7cdbaf56 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-nodpi/widget_movie_stack.png differ diff --git a/app/src/androidTest/res/crunch/drawable-nodpi/widget_show_backdrop.png b/app/src/androidTest/res/crunch/drawable-nodpi/widget_show_backdrop.png new file mode 100644 index 00000000..1a4d6166 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-nodpi/widget_show_backdrop.png differ diff --git a/app/src/androidTest/res/crunch/drawable-nodpi/widget_show_cover.png b/app/src/androidTest/res/crunch/drawable-nodpi/widget_show_cover.png new file mode 100644 index 00000000..06824f2d Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-nodpi/widget_show_cover.png differ diff --git a/app/src/androidTest/res/crunch/drawable-nodpi/widget_show_stack.png b/app/src/androidTest/res/crunch/drawable-nodpi/widget_show_stack.png new file mode 100644 index 00000000..b4ef2927 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-nodpi/widget_show_stack.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/accent_bottom_border.9.png b/app/src/androidTest/res/crunch/drawable-xhdpi/accent_bottom_border.9.png new file mode 100644 index 00000000..ce7b20d8 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/accent_bottom_border.9.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/accent_bottom_border_grey.9.png b/app/src/androidTest/res/crunch/drawable-xhdpi/accent_bottom_border_grey.9.png new file mode 100644 index 00000000..61290af1 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/accent_bottom_border_grey.9.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/add.png b/app/src/androidTest/res/crunch/drawable-xhdpi/add.png new file mode 100644 index 00000000..ba7f34c1 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/add.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png new file mode 100644 index 00000000..24975f73 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_disabled_holo_dark.png new file mode 100644 index 00000000..0e539cd5 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_focused_holo_dark.png new file mode 100644 index 00000000..7f7d8f97 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_holo_dark.png new file mode 100644 index 00000000..57b32cfd Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_pressed_holo_dark.png new file mode 100644 index 00000000..b8682fd9 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_off_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png new file mode 100644 index 00000000..dad8ead0 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_disabled_holo_dark.png new file mode 100644 index 00000000..c3883b7f Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_focused_holo_dark.png new file mode 100644 index 00000000..9229f138 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_holo_dark.png new file mode 100644 index 00000000..f73aa585 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_pressed_holo_dark.png new file mode 100644 index 00000000..411f9f6a Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_check_on_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png new file mode 100644 index 00000000..e16f7521 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_disabled_holo_dark.png new file mode 100644 index 00000000..1ea52c7a Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_focused_holo_dark.png new file mode 100644 index 00000000..1baa983d Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_holo_dark.png new file mode 100644 index 00000000..91df103a Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_pressed_holo_dark.png new file mode 100644 index 00000000..877d2505 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_off_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png new file mode 100644 index 00000000..d3be4794 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_disabled_holo_dark.png new file mode 100644 index 00000000..747d7dbe Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_focused_holo_dark.png new file mode 100644 index 00000000..384d0211 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_holo_dark.png new file mode 100644 index 00000000..2a377a79 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_pressed_holo_dark.png new file mode 100644 index 00000000..c30be5b0 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/apptheme_btn_radio_on_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/backdrops.png b/app/src/androidTest/res/crunch/drawable-xhdpi/backdrops.png new file mode 100644 index 00000000..6409464e Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/backdrops.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/buffer_size.png b/app/src/androidTest/res/crunch/drawable-xhdpi/buffer_size.png new file mode 100644 index 00000000..8032e7a1 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/buffer_size.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/delete.png b/app/src/androidTest/res/crunch/drawable-xhdpi/delete.png new file mode 100644 index 00000000..cf952f49 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/delete.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/director.png b/app/src/androidTest/res/crunch/drawable-xhdpi/director.png new file mode 100644 index 00000000..bc5f6867 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/director.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/done.png b/app/src/androidTest/res/crunch/drawable-xhdpi/done.png new file mode 100644 index 00000000..ed8dad20 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/done.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/drawer_list_shadow.9.png b/app/src/androidTest/res/crunch/drawable-xhdpi/drawer_list_shadow.9.png new file mode 100644 index 00000000..0c5e98d3 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/drawer_list_shadow.9.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/fav.png b/app/src/androidTest/res/crunch/drawable-xhdpi/fav.png new file mode 100644 index 00000000..d5f02b4b Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/fav.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/file.png b/app/src/androidTest/res/crunch/drawable-xhdpi/file.png new file mode 100644 index 00000000..0b1fcaf7 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/file.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/folder.png b/app/src/androidTest/res/crunch/drawable-xhdpi/folder.png new file mode 100644 index 00000000..eaf73a1b Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/folder.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_calendar_day.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_calendar_day.png new file mode 100644 index 00000000..a3263089 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_calendar_day.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_calendar_month.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_calendar_month.png new file mode 100644 index 00000000..e7625259 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_calendar_month.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_clock.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_clock.png new file mode 100644 index 00000000..71d39431 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_clock.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_discard.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_discard.png new file mode 100644 index 00000000..f6e1b735 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_discard.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_download.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_download.png new file mode 100644 index 00000000..680869a3 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_download.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_edit.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_edit.png new file mode 100644 index 00000000..30276d50 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_edit.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_expand.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_expand.png new file mode 100644 index 00000000..85419815 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_expand.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_filter.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_filter.png new file mode 100644 index 00000000..dc07a00d Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_filter.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_flag.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_flag.png new file mode 100644 index 00000000..2ca63ba9 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_flag.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_globe.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_globe.png new file mode 100644 index 00000000..64e770d9 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_globe.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_google_play.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_google_play.png new file mode 100644 index 00000000..e7b33b90 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_google_play.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_key.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_key.png new file mode 100644 index 00000000..f5760865 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_key.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_list_2.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_list_2.png new file mode 100644 index 00000000..c827ac3c Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_list_2.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_list_grid.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_list_grid.png new file mode 100644 index 00000000..64de9954 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_list_grid.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_lock_closed.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_lock_closed.png new file mode 100644 index 00000000..b23f9d30 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_lock_closed.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_mail.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_mail.png new file mode 100644 index 00000000..f28591e1 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_mail.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_movie.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_movie.png new file mode 100644 index 00000000..08e370bd Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_movie.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_playback_play.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_playback_play.png new file mode 100644 index 00000000..438d8d09 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_playback_play.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_puzzle.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_puzzle.png new file mode 100644 index 00000000..2b4a2411 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_puzzle.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_ratings.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_ratings.png new file mode 100644 index 00000000..e51c40fb Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_ratings.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_send.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_send.png new file mode 100644 index 00000000..3f3afec2 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_send.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_settings.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_settings.png new file mode 100644 index 00000000..d5a9f3ec Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_settings.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_show.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_show.png new file mode 100644 index 00000000..a24f3047 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_show.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_star_0.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_star_0.png new file mode 100644 index 00000000..7d677dae Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_star_0.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_subtitles.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_subtitles.png new file mode 100644 index 00000000..b4cfc4c4 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_subtitles.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_tags.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_tags.png new file mode 100644 index 00000000..2c96082e Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_tags.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_tiles_large.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_tiles_large.png new file mode 100644 index 00000000..3f1dde7a Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_tiles_large.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_tv.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_tv.png new file mode 100644 index 00000000..84c9b382 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_tv.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_users.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_users.png new file mode 100644 index 00000000..d1d98a48 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_users.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_wifi.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_wifi.png new file mode 100644 index 00000000..98eb98ee Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_action_wifi.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_arrow_back.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_arrow_back.png new file mode 100644 index 00000000..8a339d33 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_arrow_back.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ic_drawer.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_drawer.png new file mode 100644 index 00000000..f0ce3be3 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ic_drawer.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/ignoresmallfiles.png b/app/src/androidTest/res/crunch/drawable-xhdpi/ignoresmallfiles.png new file mode 100644 index 00000000..32be49db Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/ignoresmallfiles.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/loading_image.png b/app/src/androidTest/res/crunch/drawable-xhdpi/loading_image.png new file mode 100644 index 00000000..92e3224c Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/loading_image.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/localizedinfo.png b/app/src/androidTest/res/crunch/drawable-xhdpi/localizedinfo.png new file mode 100644 index 00000000..d47447f2 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/localizedinfo.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/menuicon.png b/app/src/androidTest/res/crunch/drawable-xhdpi/menuicon.png new file mode 100644 index 00000000..487baec5 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/menuicon.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/no_content_face.png b/app/src/androidTest/res/crunch/drawable-xhdpi/no_content_face.png new file mode 100644 index 00000000..166c20c3 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/no_content_face.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/noactor.png b/app/src/androidTest/res/crunch/drawable-xhdpi/noactor.png new file mode 100644 index 00000000..433fed02 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/noactor.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/nobackdrop.png b/app/src/androidTest/res/crunch/drawable-xhdpi/nobackdrop.png new file mode 100644 index 00000000..0f2c2cb9 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/nobackdrop.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/other.png b/app/src/androidTest/res/crunch/drawable-xhdpi/other.png new file mode 100644 index 00000000..2e4ced6c Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/other.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/photo.png b/app/src/androidTest/res/crunch/drawable-xhdpi/photo.png new file mode 100644 index 00000000..cfef0b63 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/photo.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/reddit.png b/app/src/androidTest/res/crunch/drawable-xhdpi/reddit.png new file mode 100644 index 00000000..f67b4417 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/reddit.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/refresh.png b/app/src/androidTest/res/crunch/drawable-xhdpi/refresh.png new file mode 100644 index 00000000..22c5c693 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/refresh.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/search.png b/app/src/androidTest/res/crunch/drawable-xhdpi/search.png new file mode 100644 index 00000000..a85390f4 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/search.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/settings_small.png b/app/src/androidTest/res/crunch/drawable-xhdpi/settings_small.png new file mode 100644 index 00000000..400cf595 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/settings_small.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/shadow.png b/app/src/androidTest/res/crunch/drawable-xhdpi/shadow.png new file mode 100644 index 00000000..56d44479 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/shadow.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/share.png b/app/src/androidTest/res/crunch/drawable-xhdpi/share.png new file mode 100644 index 00000000..e3bba05b Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/share.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/sort.png b/app/src/androidTest/res/crunch/drawable-xhdpi/sort.png new file mode 100644 index 00000000..6f7c16f8 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/sort.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/startup.png b/app/src/androidTest/res/crunch/drawable-xhdpi/startup.png new file mode 100644 index 00000000..cf9cdf21 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/startup.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/support_small.png b/app/src/androidTest/res/crunch/drawable-xhdpi/support_small.png new file mode 100644 index 00000000..a0cd7978 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/support_small.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/tedtalks.png b/app/src/androidTest/res/crunch/drawable-xhdpi/tedtalks.png new file mode 100644 index 00000000..8b0ad489 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/tedtalks.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/titles.png b/app/src/androidTest/res/crunch/drawable-xhdpi/titles.png new file mode 100644 index 00000000..23f0af26 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/titles.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/unknown_user.png b/app/src/androidTest/res/crunch/drawable-xhdpi/unknown_user.png new file mode 100644 index 00000000..f829548f Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/unknown_user.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/user_interface.png b/app/src/androidTest/res/crunch/drawable-xhdpi/user_interface.png new file mode 100644 index 00000000..be8914a6 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/user_interface.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/watchlist_add.png b/app/src/androidTest/res/crunch/drawable-xhdpi/watchlist_add.png new file mode 100644 index 00000000..4da6be5a Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/watchlist_add.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/watchlist_remove.png b/app/src/androidTest/res/crunch/drawable-xhdpi/watchlist_remove.png new file mode 100644 index 00000000..f3dd3559 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/watchlist_remove.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/white_app_icon.png b/app/src/androidTest/res/crunch/drawable-xhdpi/white_app_icon.png new file mode 100644 index 00000000..7042f7b5 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/white_app_icon.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xhdpi/youtube.png b/app/src/androidTest/res/crunch/drawable-xhdpi/youtube.png new file mode 100644 index 00000000..fee7e83f Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xhdpi/youtube.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/add.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/add.png new file mode 100644 index 00000000..af06eeef Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/add.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png new file mode 100644 index 00000000..92040bdd Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_disabled_holo_dark.png new file mode 100644 index 00000000..ea2fbe35 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_focused_holo_dark.png new file mode 100644 index 00000000..27c1df97 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_holo_dark.png new file mode 100644 index 00000000..30bdac6e Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_pressed_holo_dark.png new file mode 100644 index 00000000..35c1e44f Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_off_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png new file mode 100644 index 00000000..fea6f120 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_disabled_holo_dark.png new file mode 100644 index 00000000..8d92c7f0 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_focused_holo_dark.png new file mode 100644 index 00000000..a849804e Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_holo_dark.png new file mode 100644 index 00000000..0380a11c Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_pressed_holo_dark.png new file mode 100644 index 00000000..ee1202a4 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_check_on_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png new file mode 100644 index 00000000..daa81eb9 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_disabled_holo_dark.png new file mode 100644 index 00000000..1a3f2c3a Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_focused_holo_dark.png new file mode 100644 index 00000000..8d064acd Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_holo_dark.png new file mode 100644 index 00000000..67bf683f Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_pressed_holo_dark.png new file mode 100644 index 00000000..0650651c Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_off_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png new file mode 100644 index 00000000..b2c220f8 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_disabled_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_disabled_holo_dark.png new file mode 100644 index 00000000..9c825164 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_disabled_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_focused_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_focused_holo_dark.png new file mode 100644 index 00000000..d5bba333 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_focused_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_holo_dark.png new file mode 100644 index 00000000..ef2dd21b Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_pressed_holo_dark.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_pressed_holo_dark.png new file mode 100644 index 00000000..7922a9a0 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/apptheme_btn_radio_on_pressed_holo_dark.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/backdrops.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/backdrops.png new file mode 100644 index 00000000..e442d296 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/backdrops.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/buffer_size.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/buffer_size.png new file mode 100644 index 00000000..3c32d692 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/buffer_size.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/delete.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/delete.png new file mode 100644 index 00000000..285e490e Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/delete.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/done.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/done.png new file mode 100644 index 00000000..8b510688 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/done.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/fav.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/fav.png new file mode 100644 index 00000000..debc7971 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/fav.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/file.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/file.png new file mode 100644 index 00000000..7d788393 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/file.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/folder.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/folder.png new file mode 100644 index 00000000..59e7486a Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/folder.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_bargraph.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_bargraph.png new file mode 100644 index 00000000..be8cf845 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_bargraph.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_calendar_day.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_calendar_day.png new file mode 100644 index 00000000..ad1b4811 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_calendar_day.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_calendar_month.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_calendar_month.png new file mode 100644 index 00000000..33cabaeb Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_calendar_month.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_clock.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_clock.png new file mode 100644 index 00000000..a42bfc21 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_clock.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_discard.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_discard.png new file mode 100644 index 00000000..db550e13 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_discard.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_download.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_download.png new file mode 100644 index 00000000..27f79122 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_download.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_edit.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_edit.png new file mode 100644 index 00000000..8b4276d7 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_edit.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_expand.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_expand.png new file mode 100644 index 00000000..f757f979 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_expand.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_filter.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_filter.png new file mode 100644 index 00000000..6ea44189 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_filter.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_flag.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_flag.png new file mode 100644 index 00000000..3a637abc Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_flag.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_globe.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_globe.png new file mode 100644 index 00000000..629ebfc0 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_globe.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_google_play.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_google_play.png new file mode 100644 index 00000000..163817dc Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_google_play.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_key.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_key.png new file mode 100644 index 00000000..b43a015c Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_key.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_list_2.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_list_2.png new file mode 100644 index 00000000..70cc7663 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_list_2.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_list_grid.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_list_grid.png new file mode 100644 index 00000000..7b2e3294 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_list_grid.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_lock_closed.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_lock_closed.png new file mode 100644 index 00000000..030cfb05 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_lock_closed.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_mail.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_mail.png new file mode 100644 index 00000000..68b7be52 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_mail.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_movie.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_movie.png new file mode 100644 index 00000000..ee743625 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_movie.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_playback_play.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_playback_play.png new file mode 100644 index 00000000..7b38e1aa Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_playback_play.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_puzzle.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_puzzle.png new file mode 100644 index 00000000..82003f4b Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_puzzle.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_ratings.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_ratings.png new file mode 100644 index 00000000..3987b105 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_ratings.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_send.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_send.png new file mode 100644 index 00000000..8e0f9164 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_send.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_settings.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_settings.png new file mode 100644 index 00000000..32e2c28e Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_settings.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_show.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_show.png new file mode 100644 index 00000000..023b8923 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_show.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_star_0.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_star_0.png new file mode 100644 index 00000000..f603c1aa Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_star_0.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_subtitles.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_subtitles.png new file mode 100644 index 00000000..2d17426b Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_subtitles.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_tags.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_tags.png new file mode 100644 index 00000000..35941e3d Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_tags.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_tiles_large.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_tiles_large.png new file mode 100644 index 00000000..fadc3a04 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_tiles_large.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_tv.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_tv.png new file mode 100644 index 00000000..b73be4b4 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_tv.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_users.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_users.png new file mode 100644 index 00000000..97cc30a5 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_users.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_wifi.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_wifi.png new file mode 100644 index 00000000..26d38626 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_action_wifi.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_arrow_back.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_arrow_back.png new file mode 100644 index 00000000..0218bd8c Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_arrow_back.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_search_white_24dp.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_search_white_24dp.png new file mode 100644 index 00000000..67d33c6f Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ic_search_white_24dp.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/ignoresmallfiles.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/ignoresmallfiles.png new file mode 100644 index 00000000..bf0bb6de Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/ignoresmallfiles.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/localizedinfo.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/localizedinfo.png new file mode 100644 index 00000000..4a0ab25b Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/localizedinfo.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/menuicon.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/menuicon.png new file mode 100644 index 00000000..25981293 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/menuicon.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/other.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/other.png new file mode 100644 index 00000000..599e65f2 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/other.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/photo.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/photo.png new file mode 100644 index 00000000..9f454e04 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/photo.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/reddit.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/reddit.png new file mode 100644 index 00000000..1f8861a1 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/reddit.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/refresh.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/refresh.png new file mode 100644 index 00000000..63abd3d2 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/refresh.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/search.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/search.png new file mode 100644 index 00000000..65566dff Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/search.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/settings_small.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/settings_small.png new file mode 100644 index 00000000..99b65cc8 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/settings_small.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/shadow.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/shadow.png new file mode 100644 index 00000000..3bd46063 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/shadow.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/share.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/share.png new file mode 100644 index 00000000..8c591581 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/share.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/sort.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/sort.png new file mode 100644 index 00000000..c3d2a530 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/sort.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/startup.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/startup.png new file mode 100644 index 00000000..e4daa037 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/startup.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/support_small.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/support_small.png new file mode 100644 index 00000000..9dbe1803 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/support_small.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/tedtalks.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/tedtalks.png new file mode 100644 index 00000000..50db880b Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/tedtalks.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/titles.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/titles.png new file mode 100644 index 00000000..46ddbfa0 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/titles.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/unknown_user.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/unknown_user.png new file mode 100644 index 00000000..948189c8 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/unknown_user.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/user_interface.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/user_interface.png new file mode 100644 index 00000000..c1b4b280 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/user_interface.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/watchlist_add.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/watchlist_add.png new file mode 100644 index 00000000..e72f96b5 Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/watchlist_add.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/watchlist_remove.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/watchlist_remove.png new file mode 100644 index 00000000..65e9c0ac Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/watchlist_remove.png differ diff --git a/app/src/androidTest/res/crunch/drawable-xxhdpi/youtube.png b/app/src/androidTest/res/crunch/drawable-xxhdpi/youtube.png new file mode 100644 index 00000000..1da743ae Binary files /dev/null and b/app/src/androidTest/res/crunch/drawable-xxhdpi/youtube.png differ diff --git a/AndroidManifest.xml b/app/src/main/AndroidManifest.xml similarity index 96% rename from AndroidManifest.xml rename to app/src/main/AndroidManifest.xml index e828ba29..2dc1f7a1 100644 --- a/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,698 +1,723 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/Roboto-Bold.ttf b/app/src/main/assets/Roboto-Bold.ttf similarity index 100% rename from assets/Roboto-Bold.ttf rename to app/src/main/assets/Roboto-Bold.ttf diff --git a/assets/Roboto-BoldItalic.ttf b/app/src/main/assets/Roboto-BoldItalic.ttf similarity index 100% rename from assets/Roboto-BoldItalic.ttf rename to app/src/main/assets/Roboto-BoldItalic.ttf diff --git a/assets/Roboto-Light.ttf b/app/src/main/assets/Roboto-Light.ttf similarity index 100% rename from assets/Roboto-Light.ttf rename to app/src/main/assets/Roboto-Light.ttf diff --git a/assets/Roboto-LightItalic.ttf b/app/src/main/assets/Roboto-LightItalic.ttf similarity index 100% rename from assets/Roboto-LightItalic.ttf rename to app/src/main/assets/Roboto-LightItalic.ttf diff --git a/assets/Roboto-Medium.ttf b/app/src/main/assets/Roboto-Medium.ttf similarity index 100% rename from assets/Roboto-Medium.ttf rename to app/src/main/assets/Roboto-Medium.ttf diff --git a/app/src/main/assets/Roboto-MediumItalic.ttf b/app/src/main/assets/Roboto-MediumItalic.ttf new file mode 100644 index 00000000..b8282055 Binary files /dev/null and b/app/src/main/assets/Roboto-MediumItalic.ttf differ diff --git a/app/src/main/assets/Roboto-Regular.ttf b/app/src/main/assets/Roboto-Regular.ttf new file mode 100644 index 00000000..0e58508a Binary files /dev/null and b/app/src/main/assets/Roboto-Regular.ttf differ diff --git a/assets/Roboto-Thin.ttf b/app/src/main/assets/Roboto-Thin.ttf similarity index 100% rename from assets/Roboto-Thin.ttf rename to app/src/main/assets/Roboto-Thin.ttf diff --git a/assets/RobotoCondensed-Light.ttf b/app/src/main/assets/RobotoCondensed-Light.ttf similarity index 100% rename from assets/RobotoCondensed-Light.ttf rename to app/src/main/assets/RobotoCondensed-Light.ttf diff --git a/assets/RobotoCondensed-LightItalic.ttf b/app/src/main/assets/RobotoCondensed-LightItalic.ttf similarity index 100% rename from assets/RobotoCondensed-LightItalic.ttf rename to app/src/main/assets/RobotoCondensed-LightItalic.ttf diff --git a/assets/RobotoCondensed-Regular.ttf b/app/src/main/assets/RobotoCondensed-Regular.ttf similarity index 100% rename from assets/RobotoCondensed-Regular.ttf rename to app/src/main/assets/RobotoCondensed-Regular.ttf diff --git a/app/src/main/java/com/melnykov/fab/FloatingActionButton.java b/app/src/main/java/com/melnykov/fab/FloatingActionButton.java new file mode 100644 index 00000000..3a451cfd --- /dev/null +++ b/app/src/main/java/com/melnykov/fab/FloatingActionButton.java @@ -0,0 +1,422 @@ +package com.melnykov.fab; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.ColorStateList; +import android.content.res.TypedArray; +import android.graphics.Outline; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.LayerDrawable; +import android.graphics.drawable.RippleDrawable; +import android.graphics.drawable.ShapeDrawable; +import android.graphics.drawable.StateListDrawable; +import android.graphics.drawable.shapes.OvalShape; +import android.os.Build; +import android.support.annotation.ColorRes; +import android.support.annotation.DimenRes; +import android.support.annotation.IntDef; +import android.support.annotation.NonNull; +import android.support.v7.widget.RecyclerView; +import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewOutlineProvider; +import android.view.ViewTreeObserver; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.view.animation.Interpolator; +import android.widget.AbsListView; +import android.widget.ImageButton; +import android.widget.RelativeLayout; + +import com.miz.functions.MizLib; +import com.miz.mizuu.R; + +/** + * Android Google+ like floating action button which reacts on the attached list view scrolling events. + * + * @author Oleksandr Melnykov + */ +public class FloatingActionButton extends ImageButton { + private static final int TRANSLATE_DURATION_MILLIS = 200; + private FabOnScrollListener mOnScrollListener; + private FabRecyclerOnViewScrollListener mRecyclerViewOnScrollListener; + + @IntDef({TYPE_NORMAL, TYPE_MINI}) + public @interface TYPE { + } + + public static final int TYPE_NORMAL = 0; + public static final int TYPE_MINI = 1; + + protected AbsListView mListView; + protected RecyclerView mRecyclerView; + + private boolean mVisible; + + private int mColorNormal; + private int mColorPressed; + private int mColorRipple; + private boolean mShadow; + private int mType; + + private final Interpolator mInterpolator = new AccelerateDecelerateInterpolator(); + + public FloatingActionButton(Context context) { + this(context, null); + } + + public FloatingActionButton(Context context, AttributeSet attrs) { + super(context, attrs); + init(context, attrs); + } + + public FloatingActionButton(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + init(context, attrs); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + int size = getDimension( + mType == TYPE_NORMAL ? R.dimen.fab_size_normal : R.dimen.fab_size_mini); + if (mShadow && !hasLollipopApi()) { + int shadowSize = getDimension(R.dimen.fab_shadow_size); + size += shadowSize * 2; + } + setMeasuredDimension(size, size); + } + + private void init(Context context, AttributeSet attributeSet) { + mVisible = true; + mColorNormal = getColor(R.color.fab_default); + mColorPressed = getColor(R.color.fab_light); + mColorRipple = getColor(android.R.color.white); + mType = TYPE_NORMAL; + mShadow = true; + if (attributeSet != null) { + initAttributes(context, attributeSet); + } + updateBackground(); + } + + private void initAttributes(Context context, AttributeSet attributeSet) { + TypedArray attr = getTypedArray(context, attributeSet, R.styleable.FloatingActionButton); + if (attr != null) { + try { + mColorNormal = attr.getColor(R.styleable.FloatingActionButton_fab_colorNormal, + getColor(R.color.fab_default)); + mColorPressed = attr.getColor(R.styleable.FloatingActionButton_fab_colorPressed, + getColor(R.color.fab_light)); + mColorRipple = attr.getColor(R.styleable.FloatingActionButton_fab_colorRipple, + getColor(android.R.color.white)); + mShadow = attr.getBoolean(R.styleable.FloatingActionButton_fab_shadow, true); + mType = attr.getInt(R.styleable.FloatingActionButton_fab_type, TYPE_NORMAL); + } finally { + attr.recycle(); + } + } + } + + private void updateBackground() { + StateListDrawable drawable = new StateListDrawable(); + drawable.addState(new int[]{android.R.attr.state_pressed}, createDrawable(mColorPressed)); + drawable.addState(new int[]{}, createDrawable(mColorNormal)); + setBackgroundCompat(drawable); + } + + private Drawable createDrawable(int color) { + OvalShape ovalShape = new OvalShape(); + ShapeDrawable shapeDrawable = new ShapeDrawable(ovalShape); + shapeDrawable.getPaint().setColor(color); + + if (mShadow && !hasLollipopApi()) { + LayerDrawable layerDrawable = new LayerDrawable( + new Drawable[]{getResources().getDrawable(R.drawable.shadow), + shapeDrawable}); + int shadowSize = getDimension( + mType == TYPE_NORMAL ? R.dimen.fab_shadow_size : R.dimen.fab_mini_shadow_size); + layerDrawable.setLayerInset(1, shadowSize, shadowSize, shadowSize, shadowSize); + return layerDrawable; + } else { + return shapeDrawable; + } + } + + private TypedArray getTypedArray(Context context, AttributeSet attributeSet, int[] attr) { + return context.obtainStyledAttributes(attributeSet, attr, 0, 0); + } + + private int getColor(@ColorRes int id) { + return getResources().getColor(id); + } + + private int getDimension(@DimenRes int id) { + return getResources().getDimensionPixelSize(id); + } + + @SuppressWarnings("deprecation") + @SuppressLint("NewApi") + private void setBackgroundCompat(Drawable drawable) { + if (hasLollipopApi()) { + setElevation(mShadow ? getDimension(R.dimen.fab_elevation_lollipop) : 0.0f); + RippleDrawable rippleDrawable = new RippleDrawable(new ColorStateList(new int[][]{{}}, + new int[]{mColorRipple}), drawable, null); + setOutlineProvider(new ViewOutlineProvider() { + @Override + public void getOutline(View view, Outline outline) { + int size = getDimension(mType == TYPE_NORMAL ? R.dimen.fab_size_normal : R.dimen.fab_size_mini); + outline.setOval(0, 0, size, size); + } + }); + setClipToOutline(true); + setBackground(rippleDrawable); + } else if (hasJellyBeanApi()) { + setBackground(drawable); + } else { + setBackgroundDrawable(drawable); + } + } + + /** + * @deprecated to be removed in next release. + * Now {@link com.melnykov.fab.ScrollDirectionDetector} is used to detect scrolling direction. + */ + @Deprecated + protected int getListViewScrollY() { + View topChild = mListView.getChildAt(0); + return topChild == null ? 0 : mListView.getFirstVisiblePosition() * topChild.getHeight() - + topChild.getTop(); + } + + private int getMarginBottom() { + int marginBottom = 0; + final ViewGroup.LayoutParams layoutParams = getLayoutParams(); + if (layoutParams instanceof ViewGroup.MarginLayoutParams) { + marginBottom = ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin; + } + return marginBottom; + } + + public void setColorNormal(int color) { + if (color != mColorNormal) { + mColorNormal = color; + updateBackground(); + } + } + + public void setColorNormalResId(@ColorRes int colorResId) { + setColorNormal(getColor(colorResId)); + } + + public int getColorNormal() { + return mColorNormal; + } + + public void setColorPressed(int color) { + if (color != mColorPressed) { + mColorPressed = color; + updateBackground(); + } + } + + public void setColorPressedResId(@ColorRes int colorResId) { + setColorPressed(getColor(colorResId)); + } + + public int getColorPressed() { + return mColorPressed; + } + + public void setColorRipple(int color) { + if (color != mColorRipple) { + mColorRipple = color; + updateBackground(); + } + } + + public void setColorRippleResId(@ColorRes int colorResId) { + setColorRipple(getColor(colorResId)); + } + + public int getColorRipple() { + return mColorRipple; + } + + public void setShadow(boolean shadow) { + if (shadow != mShadow) { + mShadow = shadow; + updateBackground(); + } + } + + public boolean hasShadow() { + return mShadow; + } + + public void setType(@TYPE int type) { + if (type != mType) { + mType = type; + updateBackground(); + } + } + + @TYPE + public int getType() { + return mType; + } + + protected AbsListView.OnScrollListener getOnScrollListener() { + return mOnScrollListener; + } + + protected RecyclerView.OnScrollListener getRecyclerViewOnScrollListener() { + return mRecyclerViewOnScrollListener; + } + + public void show() { + show(true); + } + + public void hide() { + hide(true); + } + + public void show(boolean animate) { + toggle(true, animate, false); + } + + public void hide(boolean animate) { + toggle(false, animate, false); + } + + private void toggle(final boolean visible, final boolean animate, boolean force) { + if (mVisible != visible || force) { + mVisible = visible; + int height = getHeight(); + if (height == 0 && !force) { + ViewTreeObserver vto = getViewTreeObserver(); + if (vto.isAlive()) { + vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + ViewTreeObserver currentVto = getViewTreeObserver(); + if (currentVto.isAlive()) { + currentVto.removeOnPreDrawListener(this); + } + toggle(visible, animate, true); + return true; + } + }); + return; + } + } + int translationY = visible ? 0 : height + getMarginBottom(); + if (animate) { + animate().setInterpolator(mInterpolator) + .setDuration(TRANSLATE_DURATION_MILLIS) + .translationY(translationY); + } else { + setTranslationY(translationY); + } + } + } + + /** + * If need to use custom {@link android.widget.AbsListView.OnScrollListener}, + * pass it to {@link #attachToListView(android.widget.AbsListView, com.melnykov.fab.FloatingActionButton.FabOnScrollListener)} + */ + public void attachToListView(@NonNull AbsListView listView) { + attachToListView(listView, new FabOnScrollListener()); + } + + /** + * If need to use custom {@link android.widget.AbsListView.OnScrollListener}, + * pass it to {@link #attachToListView(android.widget.AbsListView, com.melnykov.fab.FloatingActionButton.FabOnScrollListener)} + */ + public void attachToRecyclerView(@NonNull RecyclerView recyclerView) { + attachToRecyclerView(recyclerView, new FabRecyclerOnViewScrollListener()); + } + + public void attachToListView(@NonNull AbsListView listView, @NonNull FabOnScrollListener onScrollListener) { + mListView = listView; + mOnScrollListener = onScrollListener; + onScrollListener.setFloatingActionButton(this); + onScrollListener.setListView(listView); + mListView.setOnScrollListener(onScrollListener); + } + + public void attachToRecyclerView(@NonNull RecyclerView recyclerView, @NonNull FabRecyclerOnViewScrollListener onScrollListener) { + mRecyclerView = recyclerView; + mRecyclerViewOnScrollListener = onScrollListener; + onScrollListener.setFloatingActionButton(this); + onScrollListener.setRecyclerView(recyclerView); + mRecyclerView.setOnScrollListener(onScrollListener); + } + + private boolean hasLollipopApi() { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; + } + + private boolean hasJellyBeanApi() { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; + } + + public static class FabOnScrollListener extends ScrollDirectionDetector { + private FloatingActionButton mFloatingActionButton; + + public FabOnScrollListener() { + setScrollDirectionListener(new ScrollDirectionListener() { + @Override + public void onScrollDown() { + mFloatingActionButton.show(); + } + + @Override + public void onScrollUp() { + mFloatingActionButton.hide(); + } + }); + } + + public void setFloatingActionButton(FloatingActionButton floatingActionButton) { + mFloatingActionButton = floatingActionButton; + } + } + + public static class FabRecyclerOnViewScrollListener extends ScrollDirectionRecyclerViewDetector { + private FloatingActionButton mFloatingActionButton; + + public FabRecyclerOnViewScrollListener() { + setScrollDirectionListener(new ScrollDirectionListener() { + @Override + public void onScrollDown() { + mFloatingActionButton.show(); + } + + @Override + public void onScrollUp() { + mFloatingActionButton.hide(); + } + }); + } + + public void setFloatingActionButton(FloatingActionButton floatingActionButton) { + mFloatingActionButton = floatingActionButton; + } + } + + @Override + public void setLayoutParams(ViewGroup.LayoutParams params) { + + // Make sure that we adjust the shadow margin when dealing with devices + // running less than Android 5.0 + if (!hasLollipopApi()) { + RelativeLayout.LayoutParams p = (RelativeLayout.LayoutParams) params; + p.setMargins(p.leftMargin, p.topMargin - MizLib.convertDpToPixels(getContext(), 8), p.rightMargin, p.bottomMargin); + params = p; + } + + super.setLayoutParams(params); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/melnykov/fab/ScrollDirectionDetector.java b/app/src/main/java/com/melnykov/fab/ScrollDirectionDetector.java new file mode 100644 index 00000000..28b4584c --- /dev/null +++ b/app/src/main/java/com/melnykov/fab/ScrollDirectionDetector.java @@ -0,0 +1,108 @@ +package com.melnykov.fab; + +import android.view.View; +import android.widget.AbsListView; + +import com.miz.mizuu.R; + +/** + * Detects which direction list view was scrolled. + *

+ * Set {@link ScrollDirectionListener} to get callbacks + * {@link ScrollDirectionListener#onScrollDown()} or + * {@link ScrollDirectionListener#onScrollUp()} + * + * @author Vilius Kraujutis + */ +public abstract class ScrollDirectionDetector implements AbsListView.OnScrollListener { + private ScrollDirectionListener mScrollDirectionListener; + private int mPreviousScrollY; + private int mPreviousFirstVisibleItem; + public int mLastChangeY; + private AbsListView mListView; + private int mMinSignificantScroll; + + @Override + public void onScrollStateChanged(AbsListView view, int scrollState) { + mMinSignificantScroll = view.getContext().getResources().getDimensionPixelOffset(R.dimen.fab_min_significant_scroll); + } + + @Override + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { + int newScrollY = estimateScrollY(); + if (mScrollDirectionListener != null && isSameRow(firstVisibleItem) && isSignificantDelta(newScrollY)) { + if (isScrollUp(newScrollY)) { + mScrollDirectionListener.onScrollUp(); + } else { + mScrollDirectionListener.onScrollDown(); + } + } + } + + public ScrollDirectionListener getScrollDirectionListener() { + return mScrollDirectionListener; + } + + public void setScrollDirectionListener(ScrollDirectionListener mScrollDirectionListener) { + this.mScrollDirectionListener = mScrollDirectionListener; + } + + /** + * @return true if scrolled up or false otherwise + * @see #isSignificantDelta(int) which ensures, that events are not fired it there was no scrolling + */ + private boolean isScrollUp(int newScrollY) { + boolean scrollUp = newScrollY > mPreviousScrollY; + mPreviousScrollY = newScrollY; + return scrollUp; + } + + /** + * Make sure wrong direction method is not called when stopping scrolling + * and finger moved a little to opposite direction. + * + * @see #isScrollUp(int) + */ + private boolean isSignificantDelta(int newScrollY) { + boolean isSignificantDelta = Math.abs(mLastChangeY - newScrollY) > mMinSignificantScroll; + if (isSignificantDelta) + mLastChangeY = newScrollY; + return isSignificantDelta; + } + + /** + * newScrollY position might not be correct if: + *

    + *
  • firstVisibleItem is different than mPreviousFirstVisibleItem
  • + *
  • list has rows of different height
  • + *
+ *

+ * It's necessary to track if row did not change, so events + * {@link ScrollDirectionListener#onScrollUp()} or {@link ScrollDirectionListener#onScrollDown()} could be fired with confidence + * + * @see #estimateScrollY() + */ + private boolean isSameRow(int firstVisibleItem) { + boolean rowsChanged = firstVisibleItem == mPreviousFirstVisibleItem; + mPreviousFirstVisibleItem = firstVisibleItem; + return rowsChanged; + } + + /** + * Will be incorrect if rows has changed and if list has rows of different heights + *

+ * So when measuring scroll direction, it's necessary to ignore this value + * if first visible row is different than previously calculated. + * + * @deprecated because it should be used with caution + */ + private int estimateScrollY() { + if (mListView == null || mListView.getChildAt(0) == null) return 0; + View topChild = mListView.getChildAt(0); + return mListView.getFirstVisiblePosition() * topChild.getHeight() - topChild.getTop(); + } + + public void setListView(AbsListView listView) { + mListView = listView; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/melnykov/fab/ScrollDirectionListener.java b/app/src/main/java/com/melnykov/fab/ScrollDirectionListener.java new file mode 100644 index 00000000..6491310a --- /dev/null +++ b/app/src/main/java/com/melnykov/fab/ScrollDirectionListener.java @@ -0,0 +1,12 @@ +package com.melnykov.fab; + +/** + * Callbacks when list was scrolled up or down. + * + * @author Vilius Kraujutis + */ +public interface ScrollDirectionListener { + void onScrollDown(); + + void onScrollUp(); +} \ No newline at end of file diff --git a/app/src/main/java/com/melnykov/fab/ScrollDirectionRecyclerViewDetector.java b/app/src/main/java/com/melnykov/fab/ScrollDirectionRecyclerViewDetector.java new file mode 100644 index 00000000..f2baf413 --- /dev/null +++ b/app/src/main/java/com/melnykov/fab/ScrollDirectionRecyclerViewDetector.java @@ -0,0 +1,122 @@ +package com.melnykov.fab; + +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.View; + +import com.miz.mizuu.R; + +/** + * Detects which direction list view was scrolled. + *

+ * Set {@link ScrollDirectionListener} to get callbacks + * {@link ScrollDirectionListener#onScrollDown()} or + * {@link ScrollDirectionListener#onScrollUp()} + * + * @author Aidan Follestad + */ +public abstract class ScrollDirectionRecyclerViewDetector extends RecyclerView.OnScrollListener { + private ScrollDirectionListener mScrollDirectionListener; + private int mPreviousScrollY; + private int mPreviousFirstVisibleItem; + public int mLastChangeY; + private RecyclerView mRecyclerView; + private int mMinSignificantScroll; + + @Override + public void onScrollStateChanged(RecyclerView recyclerView, int newState) { + super.onScrollStateChanged(recyclerView, newState); + mMinSignificantScroll = recyclerView.getContext().getResources().getDimensionPixelOffset(R.dimen.fab_min_significant_scroll); + } + + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + super.onScrolled(recyclerView, dx, dy); + int newScrollY = estimateScrollY(); + if (mScrollDirectionListener != null && isSameRow(getFirstVisibleItem()) && isSignificantDelta(newScrollY)) { + if (isScrollUp(newScrollY)) { + mScrollDirectionListener.onScrollUp(); + } else { + mScrollDirectionListener.onScrollDown(); + } + } + } + + public ScrollDirectionListener getScrollDirectionListener() { + return mScrollDirectionListener; + } + + public void setScrollDirectionListener(ScrollDirectionListener mScrollDirectionListener) { + this.mScrollDirectionListener = mScrollDirectionListener; + } + + /** + * @return true if scrolled up or false otherwise + * @see #isSignificantDelta(int) which ensures, that events are not fired it there was no scrolling + */ + private boolean isScrollUp(int newScrollY) { + boolean scrollUp = newScrollY > mPreviousScrollY; + mPreviousScrollY = newScrollY; + return scrollUp; + } + + /** + * Make sure wrong direction method is not called when stopping scrolling + * and finger moved a little to opposite direction. + * + * @see #isScrollUp(int) + */ + private boolean isSignificantDelta(int newScrollY) { + boolean isSignificantDelta = Math.abs(mLastChangeY - newScrollY) > mMinSignificantScroll; + if (isSignificantDelta) + mLastChangeY = newScrollY; + return isSignificantDelta; + } + + /** + * newScrollY position might not be correct if: + *

    + *
  • firstVisibleItem is different than mPreviousFirstVisibleItem
  • + *
  • list has rows of different height
  • + *
+ *

+ * It's necessary to track if row did not change, so events + * {@link com.melnykov.fab.ScrollDirectionListener#onScrollUp()} or {@link com.melnykov.fab.ScrollDirectionListener#onScrollDown()} could be fired with confidence + * + * @see #estimateScrollY() + */ + private boolean isSameRow(int firstVisibleItem) { + boolean rowsChanged = firstVisibleItem == mPreviousFirstVisibleItem; + mPreviousFirstVisibleItem = firstVisibleItem; + return rowsChanged; + } + + /** + * Will be incorrect if rows has changed and if list has rows of different heights + *

+ * So when measuring scroll direction, it's necessary to ignore this value + * if first visible row is different than previously calculated. + * + * @deprecated because it should be used with caution + */ + private int estimateScrollY() { + if (mRecyclerView == null || mRecyclerView.getChildAt(0) == null) return 0; + View topChild = mRecyclerView.getChildAt(0); + return getFirstVisibleItem() * topChild.getHeight() - topChild.getTop(); + } + + private int getFirstVisibleItem() { + RecyclerView.LayoutManager mLayoutManager = mRecyclerView.getLayoutManager(); + if (mLayoutManager == null) + throw new IllegalStateException("Your RecyclerView does not have a LayoutManager."); + if (mLayoutManager instanceof LinearLayoutManager) { + return ((LinearLayoutManager) mLayoutManager).findFirstVisibleItemPosition(); + } else { + throw new RuntimeException("Currently only LinearLayoutManager is supported for the RecyclerView."); + } + } + + public void setRecyclerView(RecyclerView recyclerView) { + mRecyclerView = recyclerView; + } +} \ No newline at end of file diff --git a/src/com/miz/abstractclasses/AbstractFileSource.java b/app/src/main/java/com/miz/abstractclasses/AbstractFileSource.java similarity index 92% rename from src/com/miz/abstractclasses/AbstractFileSource.java rename to app/src/main/java/com/miz/abstractclasses/AbstractFileSource.java index a4ae8e7b..81b73265 100644 --- a/src/com/miz/abstractclasses/AbstractFileSource.java +++ b/app/src/main/java/com/miz/abstractclasses/AbstractFileSource.java @@ -16,21 +16,21 @@ package com.miz.abstractclasses; -import java.util.ArrayList; -import java.util.List; -import java.util.TreeSet; - import android.content.Context; import com.miz.functions.FileSource; +import java.util.ArrayList; +import java.util.List; +import java.util.TreeSet; + public abstract class AbstractFileSource { protected List mFiles = new ArrayList(); protected T mFolder; protected FileSource mFileSource = null; protected Context mContext; - protected boolean mIgnoreRemovedFiles, mSubFolderSearch, mClearLibrary; + protected boolean mSubFolderSearch, mClearLibrary; protected int mFileSizeLimit; public void setFolder(T folder) { @@ -53,10 +53,6 @@ public Context getContext() { return mContext; } - public boolean ignoreRemovedFiles() { - return mIgnoreRemovedFiles; - } - public boolean searchSubFolders() { return mSubFolderSearch; } diff --git a/src/com/miz/abstractclasses/AbstractFileSourceBrowser.java b/app/src/main/java/com/miz/abstractclasses/AbstractFileSourceBrowser.java similarity index 100% rename from src/com/miz/abstractclasses/AbstractFileSourceBrowser.java rename to app/src/main/java/com/miz/abstractclasses/AbstractFileSourceBrowser.java index 1df483e3..816a85e6 100644 --- a/src/com/miz/abstractclasses/AbstractFileSourceBrowser.java +++ b/app/src/main/java/com/miz/abstractclasses/AbstractFileSourceBrowser.java @@ -16,11 +16,11 @@ package com.miz.abstractclasses; +import com.miz.functions.BrowserFileObject; + import java.util.ArrayList; import java.util.List; -import com.miz.functions.BrowserFileObject; - public abstract class AbstractFileSourceBrowser { private T mCurrentFolder, mParentFolder; diff --git a/src/com/miz/abstractclasses/ApiService.java b/app/src/main/java/com/miz/abstractclasses/ApiService.java similarity index 100% rename from src/com/miz/abstractclasses/ApiService.java rename to app/src/main/java/com/miz/abstractclasses/ApiService.java index dbb82292..f97a4a06 100644 --- a/src/com/miz/abstractclasses/ApiService.java +++ b/app/src/main/java/com/miz/abstractclasses/ApiService.java @@ -16,10 +16,10 @@ package com.miz.abstractclasses; -import java.util.List; - import com.miz.functions.Actor; +import java.util.List; + public abstract class ApiService { /** diff --git a/src/com/miz/abstractclasses/BaseMovie.java b/app/src/main/java/com/miz/abstractclasses/BaseMovie.java similarity index 100% rename from src/com/miz/abstractclasses/BaseMovie.java rename to app/src/main/java/com/miz/abstractclasses/BaseMovie.java index 819b387c..48acbfde 100644 --- a/src/com/miz/abstractclasses/BaseMovie.java +++ b/app/src/main/java/com/miz/abstractclasses/BaseMovie.java @@ -19,17 +19,17 @@ import android.content.Context; import android.text.TextUtils; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - import com.miz.functions.Filepath; import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; import com.miz.utils.FileUtils; import com.miz.utils.StringUtils; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + public abstract class BaseMovie implements Comparable { protected ArrayList mFilepaths = new ArrayList(); diff --git a/src/com/miz/abstractclasses/MediumBaseMovie.java b/app/src/main/java/com/miz/abstractclasses/MediumBaseMovie.java similarity index 100% rename from src/com/miz/abstractclasses/MediumBaseMovie.java rename to app/src/main/java/com/miz/abstractclasses/MediumBaseMovie.java index a7684a89..a421200c 100644 --- a/src/com/miz/abstractclasses/MediumBaseMovie.java +++ b/app/src/main/java/com/miz/abstractclasses/MediumBaseMovie.java @@ -16,8 +16,6 @@ package com.miz.abstractclasses; -import java.io.File; - import android.content.Context; import android.text.TextUtils; @@ -27,6 +25,8 @@ import com.miz.mizuu.R; import com.miz.utils.FileUtils; +import java.io.File; + public abstract class MediumBaseMovie extends BaseMovie { diff --git a/src/com/miz/abstractclasses/MovieApiService.java b/app/src/main/java/com/miz/abstractclasses/MovieApiService.java similarity index 100% rename from src/com/miz/abstractclasses/MovieApiService.java rename to app/src/main/java/com/miz/abstractclasses/MovieApiService.java index 6d6c89f0..a4993284 100644 --- a/src/com/miz/abstractclasses/MovieApiService.java +++ b/app/src/main/java/com/miz/abstractclasses/MovieApiService.java @@ -16,13 +16,13 @@ package com.miz.abstractclasses; -import java.util.List; - import android.text.TextUtils; import com.miz.apis.tmdb.Movie; import com.miz.functions.WebMovie; +import java.util.List; + public abstract class MovieApiService extends ApiService { /** diff --git a/src/com/miz/abstractclasses/MovieFileSource.java b/app/src/main/java/com/miz/abstractclasses/MovieFileSource.java similarity index 94% rename from src/com/miz/abstractclasses/MovieFileSource.java rename to app/src/main/java/com/miz/abstractclasses/MovieFileSource.java index cfa0f098..6a647702 100644 --- a/src/com/miz/abstractclasses/MovieFileSource.java +++ b/app/src/main/java/com/miz/abstractclasses/MovieFileSource.java @@ -16,31 +16,30 @@ package com.miz.abstractclasses; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import android.content.Context; import android.database.Cursor; -import com.miz.db.DbAdapterMovies; import com.miz.db.DbAdapterMovieMappings; +import com.miz.db.DbAdapterMovies; import com.miz.functions.ColumnIndexCache; import com.miz.functions.DbMovie; import com.miz.functions.FileSource; import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + public abstract class MovieFileSource extends AbstractFileSource { protected HashMap mNfoFiles = new HashMap(); protected List mDbMovies = new ArrayList(); - public MovieFileSource(Context context, FileSource fileSource, boolean ignoreRemovedFiles, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { + public MovieFileSource(Context context, FileSource fileSource, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { mContext = context; mFileSource = fileSource; - mIgnoreRemovedFiles = ignoreRemovedFiles; mSubFolderSearch = subFolderSearch; mClearLibrary = clearLibrary; @@ -56,7 +55,7 @@ private void setupDbMovies() { DbAdapterMovies db = MizuuApplication.getMovieAdapter(); ColumnIndexCache cache = new ColumnIndexCache(); - Cursor tempCursor = db.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC", ignoreRemovedFiles()); + Cursor tempCursor = db.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC"); try { while (tempCursor.moveToNext()) { mDbMovies.add(new DbMovie(getContext(), diff --git a/src/com/miz/abstractclasses/TvShowApiService.java b/app/src/main/java/com/miz/abstractclasses/TvShowApiService.java similarity index 100% rename from src/com/miz/abstractclasses/TvShowApiService.java rename to app/src/main/java/com/miz/abstractclasses/TvShowApiService.java index 64bfb137..ee4ba1e3 100644 --- a/src/com/miz/abstractclasses/TvShowApiService.java +++ b/app/src/main/java/com/miz/abstractclasses/TvShowApiService.java @@ -16,12 +16,12 @@ package com.miz.abstractclasses; -import java.util.List; - import android.text.TextUtils; import com.miz.apis.thetvdb.TvShow; +import java.util.List; + public abstract class TvShowApiService extends ApiService { /** diff --git a/src/com/miz/abstractclasses/TvShowFileSource.java b/app/src/main/java/com/miz/abstractclasses/TvShowFileSource.java similarity index 91% rename from src/com/miz/abstractclasses/TvShowFileSource.java rename to app/src/main/java/com/miz/abstractclasses/TvShowFileSource.java index 0079a90c..b83f6265 100644 --- a/src/com/miz/abstractclasses/TvShowFileSource.java +++ b/app/src/main/java/com/miz/abstractclasses/TvShowFileSource.java @@ -16,9 +16,6 @@ package com.miz.abstractclasses; -import java.util.ArrayList; -import java.util.List; - import android.content.Context; import android.database.Cursor; @@ -29,14 +26,16 @@ import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; +import java.util.ArrayList; +import java.util.List; + public abstract class TvShowFileSource extends AbstractFileSource { protected List mDbEpisode = new ArrayList(); - public TvShowFileSource(Context context, FileSource fileSource, boolean ignoreRemovedFiles, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { + public TvShowFileSource(Context context, FileSource fileSource, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { mContext = context; mFileSource = fileSource; - mIgnoreRemovedFiles = ignoreRemovedFiles; mSubFolderSearch = subFolderSearch; mClearLibrary = clearLibrary; @@ -51,7 +50,7 @@ private void setupDbEpisodes() { DbAdapterTvShowEpisodes db = MizuuApplication.getTvEpisodeDbAdapter(); ColumnIndexCache cache = new ColumnIndexCache(); - Cursor tempCursor = db.getAllEpisodesInDatabase(ignoreRemovedFiles()); + Cursor tempCursor = db.getAllEpisodesInDatabase(false); try { while (tempCursor.moveToNext()) { mDbEpisode.add(new DbEpisode(getContext(), diff --git a/src/com/miz/apis/thetvdb/Episode.java b/app/src/main/java/com/miz/apis/thetvdb/Episode.java similarity index 100% rename from src/com/miz/apis/thetvdb/Episode.java rename to app/src/main/java/com/miz/apis/thetvdb/Episode.java diff --git a/src/com/miz/apis/thetvdb/Season.java b/app/src/main/java/com/miz/apis/thetvdb/Season.java similarity index 100% rename from src/com/miz/apis/thetvdb/Season.java rename to app/src/main/java/com/miz/apis/thetvdb/Season.java diff --git a/src/com/miz/apis/thetvdb/TheTVDbService.java b/app/src/main/java/com/miz/apis/thetvdb/TheTVDbService.java similarity index 85% rename from src/com/miz/apis/thetvdb/TheTVDbService.java rename to app/src/main/java/com/miz/apis/thetvdb/TheTVDbService.java index ebca1ded..fe766d6f 100644 --- a/src/com/miz/apis/thetvdb/TheTVDbService.java +++ b/app/src/main/java/com/miz/apis/thetvdb/TheTVDbService.java @@ -16,24 +16,6 @@ package com.miz.apis.thetvdb; -import static com.miz.functions.PreferenceKeys.TVSHOWS_RATINGS_SOURCE; - -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.json.JSONObject; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import android.content.Context; import android.preference.PreferenceManager; import android.text.TextUtils; @@ -46,11 +28,30 @@ import com.miz.functions.MizLib; import com.miz.mizuu.R; +import org.json.JSONObject; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import static com.miz.functions.PreferenceKeys.DVD_ORDERING; +import static com.miz.functions.PreferenceKeys.TVSHOWS_RATINGS_SOURCE; + public class TheTVDbService extends TvShowApiService { private static TheTVDbService mService; - - private final String mRatingsProvider, mTvdbApiKey; + + private final String mTvdbApiKey; private final Context mContext; public static TheTVDbService getInstance(Context context) { @@ -61,10 +62,25 @@ public static TheTVDbService getInstance(Context context) { private TheTVDbService(Context context) { mContext = context; - mRatingsProvider = PreferenceManager.getDefaultSharedPreferences(mContext).getString(TVSHOWS_RATINGS_SOURCE, mContext.getString(R.string.ratings_option_4)); mTvdbApiKey = MizLib.getTvdbApiKey(mContext); } + /** + * Get the ratings provider. This isn't a static value, so it should be reloaded when needed. + * @return + */ + private String getRatingsProvider() { + return PreferenceManager.getDefaultSharedPreferences(mContext).getString(TVSHOWS_RATINGS_SOURCE, mContext.getString(R.string.ratings_option_4)); + } + + /** + * Get the ratings provider. This isn't a static value, so it should be reloaded when needed. + * @return + */ + private boolean useDvdOrder() { + return PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(DVD_ORDERING, false); + } + @Override public List search(String query, String language) { language = getLanguage(language); @@ -210,7 +226,7 @@ public TvShow get(String id, String language) { } // Trakt.tv - if (mRatingsProvider.equals(mContext.getString(R.string.ratings_option_2))) { + if (getRatingsProvider().equals(mContext.getString(R.string.ratings_option_2))) { try { Show showSummary = Trakt.getShowSummary(mContext, id); double rating = Double.valueOf(showSummary.getRating() / 10); @@ -221,7 +237,7 @@ public TvShow get(String id, String language) { } // OMDb API / IMDb - if (mRatingsProvider.equals(mContext.getString(R.string.ratings_option_3))) { + if (getRatingsProvider().equals(mContext.getString(R.string.ratings_option_3))) { try { JSONObject jObject = MizLib.getJSONObject(mContext, "http://www.omdbapi.com/?i=" + show.getImdbId()); double rating = Double.valueOf(MizLib.getStringFromJSONObject(jObject, "imdbRating", "0")); @@ -256,23 +272,48 @@ public TvShow get(String id, String language) { Episode episode = new Episode(); - try { - list = firstElement.getElementsByTagName("EpisodeNumber"); - element = (Element) list.item(0); - tag = element.getChildNodes(); - episode.setEpisode(MizLib.getInteger(((Node) tag.item(0)).getNodeValue())); - } catch(Exception e) { - episode.setEpisode(0); - } - - try { - list = firstElement.getElementsByTagName("SeasonNumber"); - element = (Element) list.item(0); - tag = element.getChildNodes(); - episode.setSeason(MizLib.getInteger(((Node) tag.item(0)).getNodeValue())); - } catch(Exception e) { - episode.setSeason(0); - } + if (useDvdOrder()) { + try { + list = firstElement.getElementsByTagName("DVD_episodenumber"); + element = (Element) list.item(0); + tag = element.getChildNodes(); + episode.setEpisode(MizLib.getInteger(Double.valueOf(((Node) tag.item(0)).getNodeValue()))); + } catch (Exception e) { + System.out.println("EXCEPTION: DVD_episodenumber"); + } + } + + if (episode.getEpisode() == -1) { + try { + list = firstElement.getElementsByTagName("EpisodeNumber"); + element = (Element) list.item(0); + tag = element.getChildNodes(); + episode.setEpisode(MizLib.getInteger(((Node) tag.item(0)).getNodeValue())); + } catch (Exception e) { + System.out.println("EXCEPTION: EpisodeNumber"); + episode.setEpisode(0); + } + } + + if (useDvdOrder()) { + try { + list = firstElement.getElementsByTagName("DVD_season"); + element = (Element) list.item(0); + tag = element.getChildNodes(); + episode.setSeason(MizLib.getInteger(((Node) tag.item(0)).getNodeValue())); + } catch (Exception e) {} + } + + if (episode.getSeason() == -1) { + try { + list = firstElement.getElementsByTagName("SeasonNumber"); + element = (Element) list.item(0); + tag = element.getChildNodes(); + episode.setSeason(MizLib.getInteger(((Node) tag.item(0)).getNodeValue())); + } catch (Exception e) { + episode.setSeason(0); + } + } try { list = firstElement.getElementsByTagName("EpisodeName"); diff --git a/src/com/miz/apis/thetvdb/TvShow.java b/app/src/main/java/com/miz/apis/thetvdb/TvShow.java similarity index 100% rename from src/com/miz/apis/thetvdb/TvShow.java rename to app/src/main/java/com/miz/apis/thetvdb/TvShow.java index 2e4451b4..7fcb3f4d 100644 --- a/src/com/miz/apis/thetvdb/TvShow.java +++ b/app/src/main/java/com/miz/apis/thetvdb/TvShow.java @@ -16,10 +16,10 @@ package com.miz.apis.thetvdb; -import java.util.ArrayList; - import com.miz.db.DbAdapterTvShows; +import java.util.ArrayList; + public class TvShow { private String mShowId = DbAdapterTvShows.UNIDENTIFIED_ID, diff --git a/src/com/miz/apis/tmdb/Movie.java b/app/src/main/java/com/miz/apis/tmdb/Movie.java similarity index 96% rename from src/com/miz/apis/tmdb/Movie.java rename to app/src/main/java/com/miz/apis/tmdb/Movie.java index ccf6abee..7f3bebb2 100644 --- a/src/com/miz/apis/tmdb/Movie.java +++ b/app/src/main/java/com/miz/apis/tmdb/Movie.java @@ -16,14 +16,15 @@ package com.miz.apis.tmdb; -import java.util.ArrayList; -import java.util.List; - import android.text.TextUtils; +import com.miz.db.DbAdapterMovies; import com.miz.functions.Actor; import com.miz.functions.WebMovie; +import java.util.ArrayList; +import java.util.List; + public class Movie { private String id = "", title = "", originalTitle = "", plot = "", cover = "", backdrop = "", rating = "0.0", tagline = "", releasedate = "", imdbId = "", @@ -31,7 +32,12 @@ public class Movie { private List mActors = new ArrayList(); private List mSimilarMovies = new ArrayList(); - + + public Movie() { + // Unidentified by default + setId(DbAdapterMovies.UNIDENTIFIED_ID); + } + public String getId() { if (TextUtils.isEmpty(id)) return title; diff --git a/src/com/miz/apis/tmdb/TMDbMovieService.java b/app/src/main/java/com/miz/apis/tmdb/TMDbMovieService.java similarity index 96% rename from src/com/miz/apis/tmdb/TMDbMovieService.java rename to app/src/main/java/com/miz/apis/tmdb/TMDbMovieService.java index 4b403f9a..3a1ba9a3 100644 --- a/src/com/miz/apis/tmdb/TMDbMovieService.java +++ b/app/src/main/java/com/miz/apis/tmdb/TMDbMovieService.java @@ -1,19 +1,5 @@ package com.miz.apis.tmdb; -import static com.miz.functions.PreferenceKeys.INCLUDE_ADULT_CONTENT; -import static com.miz.functions.PreferenceKeys.MOVIE_RATINGS_SOURCE; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - import android.content.Context; import android.preference.PreferenceManager; import android.text.TextUtils; @@ -27,11 +13,25 @@ import com.miz.functions.WebMovie; import com.miz.mizuu.R; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static com.miz.functions.PreferenceKeys.INCLUDE_ADULT_CONTENT; +import static com.miz.functions.PreferenceKeys.MOVIE_RATINGS_SOURCE; + public class TMDbMovieService extends MovieApiService { private static TMDbMovieService mService; - private final String mRatingsProvider, mTmdbApiKey; + private final String mTmdbApiKey; private final Context mContext; public static TMDbMovieService getInstance(Context context) { @@ -42,10 +42,17 @@ public static TMDbMovieService getInstance(Context context) { private TMDbMovieService(Context context) { mContext = context; - mRatingsProvider = PreferenceManager.getDefaultSharedPreferences(mContext).getString(MOVIE_RATINGS_SOURCE, mContext.getString(R.string.ratings_option_1)); mTmdbApiKey = MizLib.getTmdbApiKey(mContext); } + /** + * Get the ratings provider. This isn't a static value, so it should be reloaded when needed. + * @return + */ + public String getRatingsProvider() { + return PreferenceManager.getDefaultSharedPreferences(mContext).getString(MOVIE_RATINGS_SOURCE, mContext.getString(R.string.ratings_option_1)); + } + @Override public List search(String query, String language) { language = getLanguage(language); @@ -236,7 +243,7 @@ public Movie get(String id, String json, String language) { } catch (Exception e) {} // Trakt.tv - if (mRatingsProvider.equals(mContext.getString(R.string.ratings_option_2)) && json == null) { + if (getRatingsProvider().equals(mContext.getString(R.string.ratings_option_2)) && json == null) { try { com.miz.apis.trakt.Movie movieSummary = Trakt.getMovieSummary(mContext, id); double rating = Double.valueOf(movieSummary.getRating()) / 10; @@ -247,7 +254,7 @@ public Movie get(String id, String json, String language) { } // OMDb API / IMDb - if (mRatingsProvider.equals(mContext.getString(R.string.ratings_option_3)) && json == null) { + if (getRatingsProvider().equals(mContext.getString(R.string.ratings_option_3)) && json == null) { try { jObject = MizLib.getJSONObject(mContext, "http://www.omdbapi.com/?i=" + movie.getImdbId()); double rating = Double.valueOf(MizLib.getStringFromJSONObject(jObject, "imdbRating", "0")); @@ -563,6 +570,11 @@ public CompleteActor getCompleteActorDetails(final String actorId) { profilePhoto = baseUrl + "w500" + profilePhoto; actor.setProfilePhoto(profilePhoto); + String profilePhotoThumb = MizLib.getStringFromJSONObject(json, "profile_path", ""); + if (!TextUtils.isEmpty(profilePhoto)) + profilePhotoThumb = baseUrl + MizLib.getActorUrlSize(mContext) + profilePhoto; + actor.setProfilePhotoThumb(profilePhotoThumb); + // Set up movies List movies = new ArrayList(); try { diff --git a/src/com/miz/apis/tmdb/TMDbTvShowService.java b/app/src/main/java/com/miz/apis/tmdb/TMDbTvShowService.java similarity index 96% rename from src/com/miz/apis/tmdb/TMDbTvShowService.java rename to app/src/main/java/com/miz/apis/tmdb/TMDbTvShowService.java index e0ac7f8c..cdddfcf2 100644 --- a/src/com/miz/apis/tmdb/TMDbTvShowService.java +++ b/app/src/main/java/com/miz/apis/tmdb/TMDbTvShowService.java @@ -1,18 +1,5 @@ package com.miz.apis.tmdb; -import static com.miz.functions.PreferenceKeys.TVSHOWS_RATINGS_SOURCE; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - import android.content.Context; import android.preference.PreferenceManager; import android.text.TextUtils; @@ -26,11 +13,24 @@ import com.miz.functions.MizLib; import com.miz.mizuu.R; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static com.miz.functions.PreferenceKeys.TVSHOWS_RATINGS_SOURCE; + public class TMDbTvShowService extends TvShowApiService { private static TMDbTvShowService mService; - private final String mRatingsProvider, mTmdbApiKey; + private final String mTmdbApiKey; private final Context mContext; public static TMDbTvShowService getInstance(Context context) { @@ -41,10 +41,17 @@ public static TMDbTvShowService getInstance(Context context) { private TMDbTvShowService(Context context) { mContext = context; - mRatingsProvider = PreferenceManager.getDefaultSharedPreferences(mContext).getString(TVSHOWS_RATINGS_SOURCE, mContext.getString(R.string.ratings_option_4)); mTmdbApiKey = MizLib.getTmdbApiKey(mContext); } + /** + * Get the ratings provider. This isn't a static value, so it should be reloaded when needed. + * @return + */ + public String getRatingsProvider() { + return PreferenceManager.getDefaultSharedPreferences(mContext).getString(TVSHOWS_RATINGS_SOURCE, mContext.getString(R.string.ratings_option_4)); + } + @Override public List search(String query, String language) { language = getLanguage(language); @@ -174,7 +181,7 @@ public TvShow get(String id, String language) { } catch (JSONException e) {} // Trakt.tv - if (mRatingsProvider.equals(mContext.getString(R.string.ratings_option_2))) { + if (getRatingsProvider().equals(mContext.getString(R.string.ratings_option_2))) { try { com.miz.apis.trakt.Movie movieSummary = Trakt.getMovieSummary(mContext, id); double rating = Double.valueOf(movieSummary.getRating() / 10); @@ -185,7 +192,7 @@ public TvShow get(String id, String language) { } // OMDb API / IMDb - if (mRatingsProvider.equals(mContext.getString(R.string.ratings_option_3))) { + if (getRatingsProvider().equals(mContext.getString(R.string.ratings_option_3))) { try { jObject = MizLib.getJSONObject(mContext, "http://www.omdbapi.com/?i=" + show.getImdbId()); double rating = Double.valueOf(MizLib.getStringFromJSONObject(jObject, "imdbRating", "0")); diff --git a/src/com/miz/apis/trakt/Movie.java b/app/src/main/java/com/miz/apis/trakt/Movie.java similarity index 100% rename from src/com/miz/apis/trakt/Movie.java rename to app/src/main/java/com/miz/apis/trakt/Movie.java index 1bbbb235..c60ab410 100644 --- a/src/com/miz/apis/trakt/Movie.java +++ b/app/src/main/java/com/miz/apis/trakt/Movie.java @@ -16,13 +16,13 @@ package com.miz.apis.trakt; -import java.util.ArrayList; -import java.util.List; - import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import java.util.ArrayList; +import java.util.List; + public class Movie { private String mTitle, mUrl, mOverview, mTagline, mCertification, mImdbId, mPoster, mFanart; diff --git a/src/com/miz/apis/trakt/Show.java b/app/src/main/java/com/miz/apis/trakt/Show.java similarity index 100% rename from src/com/miz/apis/trakt/Show.java rename to app/src/main/java/com/miz/apis/trakt/Show.java index a93ceb41..0f7c4862 100644 --- a/src/com/miz/apis/trakt/Show.java +++ b/app/src/main/java/com/miz/apis/trakt/Show.java @@ -16,13 +16,13 @@ package com.miz.apis.trakt; -import java.util.ArrayList; -import java.util.List; - import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import java.util.ArrayList; +import java.util.List; + public class Show { private String mTitle, mUrl, mCountry, mOverview, mStatus, mNetwork, mAirDay, mAirTime, mCertification, mImdbId, mPoster, mFanart; diff --git a/src/com/miz/apis/trakt/Trakt.java b/app/src/main/java/com/miz/apis/trakt/Trakt.java similarity index 100% rename from src/com/miz/apis/trakt/Trakt.java rename to app/src/main/java/com/miz/apis/trakt/Trakt.java index eff5fa81..64b8456d 100644 --- a/src/com/miz/apis/trakt/Trakt.java +++ b/app/src/main/java/com/miz/apis/trakt/Trakt.java @@ -16,16 +16,6 @@ package com.miz.apis.trakt; -import static com.miz.functions.PreferenceKeys.SYNC_WITH_TRAKT; -import static com.miz.functions.PreferenceKeys.TRAKT_PASSWORD; -import static com.miz.functions.PreferenceKeys.TRAKT_USERNAME; - -import java.util.Collection; -import java.util.List; - -import org.json.JSONArray; -import org.json.JSONObject; - import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; @@ -40,6 +30,16 @@ import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.util.Collection; +import java.util.List; + +import static com.miz.functions.PreferenceKeys.SYNC_WITH_TRAKT; +import static com.miz.functions.PreferenceKeys.TRAKT_PASSWORD; +import static com.miz.functions.PreferenceKeys.TRAKT_USERNAME; + public class Trakt { private Trakt() {} // No instantiation diff --git a/src/com/miz/apis/trakt/TraktTvShow.java b/app/src/main/java/com/miz/apis/trakt/TraktTvShow.java similarity index 100% rename from src/com/miz/apis/trakt/TraktTvShow.java rename to app/src/main/java/com/miz/apis/trakt/TraktTvShow.java diff --git a/src/com/miz/base/MizActivity.java b/app/src/main/java/com/miz/base/MizActivity.java similarity index 72% rename from src/com/miz/base/MizActivity.java rename to app/src/main/java/com/miz/base/MizActivity.java index 2dd3349f..d075f84f 100644 --- a/src/com/miz/base/MizActivity.java +++ b/app/src/main/java/com/miz/base/MizActivity.java @@ -20,29 +20,45 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; import android.preference.PreferenceManager; -import android.support.v4.app.FragmentActivity; - -import static com.miz.functions.PreferenceKeys.FULLSCREEN_TAG; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; -public class MizActivity extends FragmentActivity implements OnSharedPreferenceChangeListener { +import static com.miz.functions.PreferenceKeys.FULLSCREEN_TAG; +public abstract class MizActivity extends ActionBarActivity implements OnSharedPreferenceChangeListener { + + public Toolbar mToolbar; private boolean mFullscreen = true; @Override - public void onCreate(Bundle savedInstanceState) { + protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mFullscreen = MizuuApplication.isFullscreen(this); - + if (isFullscreen()) setTheme(R.style.Mizuu_Theme_FullScreen); - + + if (getLayoutResource() > 0) { + setContentView(getLayoutResource()); + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + if (mToolbar != null) { + setSupportActionBar(mToolbar); + } + } + PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); } + protected abstract int getLayoutResource(); + protected boolean isFullscreen() { return mFullscreen; } diff --git a/src/com/miz/contentprovider/MovieActorContentProvider.java b/app/src/main/java/com/miz/contentprovider/MovieActorContentProvider.java similarity index 99% rename from src/com/miz/contentprovider/MovieActorContentProvider.java rename to app/src/main/java/com/miz/contentprovider/MovieActorContentProvider.java index 8c65abe3..1e7b6c53 100644 --- a/src/com/miz/contentprovider/MovieActorContentProvider.java +++ b/app/src/main/java/com/miz/contentprovider/MovieActorContentProvider.java @@ -16,12 +16,6 @@ package com.miz.contentprovider; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; - import android.app.SearchManager; import android.content.ContentResolver; import android.content.ContentValues; @@ -38,6 +32,12 @@ import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; + public class MovieActorContentProvider extends SearchRecentSuggestionsProvider { static final String TAG = MovieActorContentProvider.class.getSimpleName(); @@ -122,7 +122,7 @@ private List getSearchResults(String query) { query = query.toLowerCase(Locale.ENGLISH); - Cursor c = db.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC", false); + Cursor c = db.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC"); ColumnIndexCache cache = new ColumnIndexCache(); try { diff --git a/src/com/miz/contentprovider/MovieContentProvider.java b/app/src/main/java/com/miz/contentprovider/MovieContentProvider.java similarity index 99% rename from src/com/miz/contentprovider/MovieContentProvider.java rename to app/src/main/java/com/miz/contentprovider/MovieContentProvider.java index 7b605f27..169c81bb 100644 --- a/src/com/miz/contentprovider/MovieContentProvider.java +++ b/app/src/main/java/com/miz/contentprovider/MovieContentProvider.java @@ -16,12 +16,6 @@ package com.miz.contentprovider; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.regex.Pattern; - import android.app.SearchManager; import android.content.ContentValues; import android.content.SearchRecentSuggestionsProvider; @@ -38,6 +32,12 @@ import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.regex.Pattern; + public class MovieContentProvider extends SearchRecentSuggestionsProvider { static final String TAG = MovieContentProvider.class.getSimpleName(); @@ -115,7 +115,7 @@ private List getSearchResults(String query) { query = query.toLowerCase(Locale.ENGLISH); - Cursor c = db.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC", false); + Cursor c = db.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC"); Pattern p = Pattern.compile(MizLib.CHARACTER_REGEX); // Use a pre-compiled pattern as it's a lot faster (approx. 3x for ~700 movies) ColumnIndexCache cache = new ColumnIndexCache(); diff --git a/src/com/miz/contentprovider/TvShowActorContentProvider.java b/app/src/main/java/com/miz/contentprovider/TvShowActorContentProvider.java similarity index 100% rename from src/com/miz/contentprovider/TvShowActorContentProvider.java rename to app/src/main/java/com/miz/contentprovider/TvShowActorContentProvider.java index f33eb122..b7094271 100644 --- a/src/com/miz/contentprovider/TvShowActorContentProvider.java +++ b/app/src/main/java/com/miz/contentprovider/TvShowActorContentProvider.java @@ -16,12 +16,6 @@ package com.miz.contentprovider; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; - import android.app.SearchManager; import android.content.ContentResolver; import android.content.ContentValues; @@ -38,6 +32,12 @@ import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; + public class TvShowActorContentProvider extends SearchRecentSuggestionsProvider { static final String TAG = TvShowActorContentProvider.class.getSimpleName(); diff --git a/src/com/miz/contentprovider/TvShowContentProvider.java b/app/src/main/java/com/miz/contentprovider/TvShowContentProvider.java similarity index 100% rename from src/com/miz/contentprovider/TvShowContentProvider.java rename to app/src/main/java/com/miz/contentprovider/TvShowContentProvider.java index 7e8d2dcd..c763bf9c 100644 --- a/src/com/miz/contentprovider/TvShowContentProvider.java +++ b/app/src/main/java/com/miz/contentprovider/TvShowContentProvider.java @@ -16,12 +16,6 @@ package com.miz.contentprovider; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.regex.Pattern; - import android.app.SearchManager; import android.content.ContentValues; import android.content.SearchRecentSuggestionsProvider; @@ -38,6 +32,12 @@ import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.TvShow; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.regex.Pattern; + public class TvShowContentProvider extends SearchRecentSuggestionsProvider { static final String TAG = TvShowContentProvider.class.getSimpleName(); diff --git a/src/com/miz/db/AbstractDbAdapter.java b/app/src/main/java/com/miz/db/AbstractDbAdapter.java similarity index 100% rename from src/com/miz/db/AbstractDbAdapter.java rename to app/src/main/java/com/miz/db/AbstractDbAdapter.java diff --git a/src/com/miz/db/DatabaseHelper.java b/app/src/main/java/com/miz/db/DatabaseHelper.java similarity index 100% rename from src/com/miz/db/DatabaseHelper.java rename to app/src/main/java/com/miz/db/DatabaseHelper.java index 3f5b5a31..cb5be94f 100644 --- a/src/com/miz/db/DatabaseHelper.java +++ b/app/src/main/java/com/miz/db/DatabaseHelper.java @@ -1,9 +1,5 @@ package com.miz.db; -import java.io.File; -import java.util.ArrayList; -import java.util.HashSet; - import android.annotation.SuppressLint; import android.content.ContentValues; import android.content.Context; @@ -15,6 +11,10 @@ import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; +import java.io.File; +import java.util.ArrayList; +import java.util.HashSet; + @SuppressLint("NewApi") public class DatabaseHelper extends SQLiteOpenHelper { diff --git a/src/com/miz/db/DbAdapterCollections.java b/app/src/main/java/com/miz/db/DbAdapterCollections.java similarity index 63% rename from src/com/miz/db/DbAdapterCollections.java rename to app/src/main/java/com/miz/db/DbAdapterCollections.java index 2a447bb0..17f973e9 100644 --- a/src/com/miz/db/DbAdapterCollections.java +++ b/app/src/main/java/com/miz/db/DbAdapterCollections.java @@ -16,14 +16,15 @@ package com.miz.db; -import java.util.HashMap; - -import com.miz.functions.ColumnIndexCache; - import android.content.ContentValues; import android.content.Context; import android.database.Cursor; +import com.miz.functions.ColumnIndexCache; +import com.miz.mizuu.MizuuApplication; + +import java.util.HashMap; + public class DbAdapterCollections extends AbstractDbAdapter { public static final String KEY_COLLECTION_ID = "collection_id"; @@ -37,10 +38,31 @@ public DbAdapterCollections(Context context) { super(context); } - public long createCollection(String collectionId, String collection) { + /** + * Creates a collection mapping. This method also gets the collection ID + * of the supplied movie ID, and checks if that collection has more than + * one movie mapped to it. If it doesn't, it'll remove the old mapping, + * since it also re-maps to a new collection. + * @param tmdbId + * @param collectionId + * @param collection + * @return + */ + public long createCollection(String tmdbId, String collectionId, String collection) { + DbAdapterMovies db = MizuuApplication.getMovieAdapter(); + // We don't want to create it again if it already exists - if (collectionExists(collectionId)) + // or if the movie doesn't exist + if (collectionExists(collectionId) || !db.movieExists(tmdbId)) return -1; + + String currentCollectionId = db.getSingleItem(tmdbId, DbAdapterMovies.KEY_COLLECTION_ID); + + // If there's only a single movie mapped to the collection ID, + // we can remove the mapping, since we're about to re-map it. + if (getMovieCount(currentCollectionId) == 1) { + deleteCollection(currentCollectionId); + } // Add values to a ContentValues object ContentValues values = new ContentValues(); @@ -86,6 +108,28 @@ public String getCollection(String collectionId) { return collection; } + + /** + * Returns the number of movies mapped to the given collection ID. + * @param collectionId + * @return + */ + public int getMovieCount(String collectionId) { + int count = 0; + + Cursor cursor = mDatabase.query(DATABASE_TABLE, ALL_COLUMNS, KEY_COLLECTION_ID + " = ?", new String[]{collectionId}, null, null, null); + + if (cursor != null) { + try { + count = cursor.getCount(); + } catch (Exception e) { + } finally { + cursor.close(); + } + } + + return count; + } public HashMap getCollectionsMap() { Cursor cursor = mDatabase.query(DATABASE_TABLE, ALL_COLUMNS, null, null, null, null, null); @@ -114,4 +158,15 @@ public boolean deleteCollection(String collectionId) { public boolean deleteAllCollections() { return mDatabase.delete(DATABASE_TABLE, null, null) > 0; } + + /** + * Used for unit testing. + * @return + */ + public int count() { + Cursor c = mDatabase.query(DATABASE_TABLE, new String[]{KEY_COLLECTION_ID}, null, null, null, null, null); + int count = c.getCount(); + c.close(); + return count; + } } \ No newline at end of file diff --git a/src/com/miz/db/DbAdapterMovieMappings.java b/app/src/main/java/com/miz/db/DbAdapterMovieMappings.java similarity index 82% rename from src/com/miz/db/DbAdapterMovieMappings.java rename to app/src/main/java/com/miz/db/DbAdapterMovieMappings.java index 998e456c..42359e83 100644 --- a/src/com/miz/db/DbAdapterMovieMappings.java +++ b/app/src/main/java/com/miz/db/DbAdapterMovieMappings.java @@ -16,12 +16,12 @@ package com.miz.db; -import java.util.ArrayList; - import android.content.ContentValues; import android.content.Context; import android.database.Cursor; +import java.util.ArrayList; + public class DbAdapterMovieMappings extends AbstractDbAdapter { public static final String KEY_FILEPATH = "filepath"; @@ -37,6 +37,8 @@ public DbAdapterMovieMappings(Context context) { } public long createFilepathMapping(String filepath, String tmdbId) { + // We only want to create a filepath mapping if + // the filepath doesn't already exist if (!filepathExists(tmdbId, filepath)) { // Add values to a ContentValues object ContentValues values = new ContentValues(); @@ -45,7 +47,7 @@ public long createFilepathMapping(String filepath, String tmdbId) { values.put(KEY_IGNORED, 0); // Insert into database - return mDatabase.insert(DATABASE_TABLE, null, values); + return mDatabase.insert(DATABASE_TABLE, null, values); } return -1; } @@ -54,6 +56,10 @@ public Cursor getAllFilepaths(boolean includeRemoved) { return mDatabase.query(DATABASE_TABLE, ALL_COLUMNS, includeRemoved ? null : "NOT(" + KEY_IGNORED + " = '1')", null, null, null, null); } + public Cursor getAllIgnoredFilepaths() { + return mDatabase.query(DATABASE_TABLE, ALL_COLUMNS, KEY_IGNORED + " = '1'", null, null, null, null); + } + public Cursor getAllUnidentifiedFilepaths() { return mDatabase.query(DATABASE_TABLE, ALL_COLUMNS, "NOT(" + KEY_IGNORED + " = '1') AND " + KEY_TMDB_ID + "='" + DbAdapterMovies.UNIDENTIFIED_ID + "'", null, null, null, null); } @@ -80,11 +86,11 @@ public String getFirstFilepathForMovie(String tmdbId) { return filepath; } - public boolean updateTmdbId(String filepath, String newTmdbId) { + public boolean updateTmdbId(String filepath, String currentId, String newId) { ContentValues values = new ContentValues(); - values.put(KEY_TMDB_ID, newTmdbId); + values.put(KEY_TMDB_ID, newId); - return mDatabase.update(DATABASE_TABLE, values, KEY_FILEPATH + " = ?", new String[]{filepath}) > 0; + return mDatabase.update(DATABASE_TABLE, values, KEY_FILEPATH + " = ? AND " + KEY_TMDB_ID + " = ?", new String[]{filepath, currentId}) > 0; } public boolean exists(String tmdbId) { @@ -122,6 +128,10 @@ public boolean filepathExists(String tmdbId, String filepath) { return result; } + public boolean deleteIgnoredFilepath(String filepath) { + return mDatabase.delete(DATABASE_TABLE, KEY_FILEPATH + " = ?", new String[]{filepath}) > 0; + } + public boolean deleteMovie(String tmdbId) { return mDatabase.delete(DATABASE_TABLE, KEY_TMDB_ID + " = ?", new String[]{tmdbId}) > 0; } @@ -153,8 +163,13 @@ public boolean hasMultipleFilepaths(String tmdbId) { return result; } + /** + * Gets all un-ignored filepaths mapped to a given movie ID + * @param tmdbId + * @return + */ public ArrayList getMovieFilepaths(String tmdbId) { - Cursor cursor = mDatabase.query(DATABASE_TABLE, ALL_COLUMNS, KEY_TMDB_ID + " = ?", new String[]{tmdbId}, null, null, null); + Cursor cursor = mDatabase.query(DATABASE_TABLE, ALL_COLUMNS, KEY_TMDB_ID + " = ? AND " + KEY_IGNORED + " = '0'", new String[]{tmdbId}, null, null, null); ArrayList paths = new ArrayList(); if (cursor != null) { @@ -189,4 +204,15 @@ public String getIdForFilepath(String filepath) { return id; } + + /** + * Used for unit testing + * @return + */ + public int count() { + Cursor c = mDatabase.query(DATABASE_TABLE, new String[]{KEY_FILEPATH}, null, null, null, null, null); + int count = c.getCount(); + c.close(); + return count; + } } \ No newline at end of file diff --git a/app/src/main/java/com/miz/db/DbAdapterMovies.java b/app/src/main/java/com/miz/db/DbAdapterMovies.java new file mode 100644 index 00000000..609267ca --- /dev/null +++ b/app/src/main/java/com/miz/db/DbAdapterMovies.java @@ -0,0 +1,291 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.db; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.SQLException; +import android.database.sqlite.SQLiteException; +import android.text.TextUtils; + +import com.miz.mizuu.MizuuApplication; + +import java.util.ArrayList; + +public class DbAdapterMovies extends AbstractDbAdapter { + + // Database fields + public static final String KEY_TMDB_ID = "tmdbid"; // Unidentified movies and .nfo files without TMDb ID use the filepath + public static final String KEY_TITLE = "title"; + public static final String KEY_PLOT = "plot"; + public static final String KEY_IMDB_ID = "imdbid"; + public static final String KEY_RATING = "rating"; + public static final String KEY_TAGLINE = "tagline"; + public static final String KEY_RELEASEDATE = "release"; + public static final String KEY_CERTIFICATION = "certification"; + public static final String KEY_RUNTIME = "runtime"; + public static final String KEY_TRAILER = "trailer"; + public static final String KEY_GENRES = "genres"; + public static final String KEY_FAVOURITE = "favourite"; + public static final String KEY_ACTORS = "actors"; + public static final String KEY_COLLECTION_ID = "collection_id"; + public static final String KEY_TO_WATCH = "to_watch"; + public static final String KEY_HAS_WATCHED = "has_watched"; + public static final String KEY_DATE_ADDED = "date_added"; + + public static final String DATABASE_TABLE = "movie"; + + public static final String UNIDENTIFIED_ID = "invalid"; + + public static final String[] SELECT_ALL = new String[] {KEY_TMDB_ID, KEY_TITLE, KEY_PLOT, KEY_IMDB_ID, KEY_RATING, KEY_TAGLINE, KEY_RELEASEDATE, KEY_CERTIFICATION, + KEY_RUNTIME, KEY_TRAILER, KEY_GENRES, KEY_FAVOURITE, KEY_ACTORS, KEY_COLLECTION_ID, KEY_TO_WATCH, KEY_HAS_WATCHED, KEY_DATE_ADDED}; + + public DbAdapterMovies(Context context) { + super(context); + } + + /** + * Create a new movie + */ + public void createMovie(String tmdbid, String title, String plot, String imdbid, String rating, String tagline, String release, + String certification, String runtime, String trailer, String genres, String favourite, String actors, String collection, + String collectionId, String toWatch, String hasWatched, String date) { + + if (tmdbid.equals(UNIDENTIFIED_ID)) + return; // We're not interesting in adding this to the movie database + + if (movieExists(tmdbid)) + return; // It already exists, let's not create it again + + ContentValues initialValues = createContentValues(tmdbid, title, plot, imdbid, rating, tagline, release, certification, runtime, trailer, genres, favourite, actors, collectionId, toWatch, hasWatched, date, true); + mDatabase.insert(DATABASE_TABLE, null, initialValues); + + MizuuApplication.getCollectionsAdapter().createCollection(tmdbid, collectionId, collection); + } + + public void createOrUpdateMovie(String tmdbid, String title, String plot, String imdbid, String rating, String tagline, String release, + String certification, String runtime, String trailer, String genres, String favourite, String actors, String collection, + String collectionId, String toWatch, String hasWatched, String date) { + if (movieExists(tmdbid)) { + // It already exists - let's update it while keeping + // favourite, watchlist and watched status data intact + updateMovie(tmdbid, title, plot, imdbid, rating, tagline, release, certification, runtime, trailer, genres, + actors, collection, collectionId, date); + } else { + // It doesn't exist! Let's create it + createMovie(tmdbid, title, plot, imdbid, rating, tagline, release, certification, runtime, trailer, genres, + favourite, actors, collection, collectionId, toWatch, hasWatched, date); + } + } + + /** + * Update the movie + */ + private boolean updateMovie(String tmdbid, String title, String plot, String imdbid, String rating, String tagline, String release, + String certification, String runtime, String trailer, String genres, String actors, String collection, String collectionId, String date) { + + ContentValues updateValues = createUpdateContentValues(title, plot, imdbid, rating, tagline, release, certification, + runtime, trailer, genres, actors, collectionId, date); + + return mDatabase.update(DATABASE_TABLE, updateValues, KEY_TMDB_ID + " = ?", new String[]{tmdbid}) > 0 && + MizuuApplication.getCollectionsAdapter().createCollection(tmdbid, collectionId, collection) > 0; + } + + public boolean updateMovieSingleItem(String tmdbId, String column, String value) { + ContentValues values = new ContentValues(); + values.put(column, value); + + return mDatabase.update(DATABASE_TABLE, values, KEY_TMDB_ID + " = ?", new String[]{tmdbId}) > 0; + } + + public String getSingleItem(String tmdbId, String column) { + String singleItem = ""; + Cursor c = mDatabase.query(DATABASE_TABLE, new String[]{column}, KEY_TMDB_ID + " = ?", new String[]{tmdbId}, null, null, null); + if (c != null) { + try { + if (c.moveToFirst()) + singleItem = c.getString(c.getColumnIndex(column)); + } catch (SQLException e) {} finally { + c.close(); + } + } + return singleItem; + } + + public boolean editMovie(String movieId, String title, String tagline, String description, + String genres, String runtime, String rating, String releaseDate, String certification) { + ContentValues cv = new ContentValues(); + cv.put(KEY_TITLE, title); + cv.put(KEY_PLOT, description); + cv.put(KEY_RATING, rating); + cv.put(KEY_TAGLINE, tagline); + cv.put(KEY_RELEASEDATE, releaseDate); + cv.put(KEY_CERTIFICATION, certification); + cv.put(KEY_RUNTIME, runtime); + cv.put(KEY_GENRES, genres); + return mDatabase.update(DATABASE_TABLE, cv, KEY_TMDB_ID + " = ?", new String[]{movieId}) > 0; + } + + /** + * Deletes movie + */ + public boolean deleteMovie(String tmdbId) { + return mDatabase.delete(DATABASE_TABLE, KEY_TMDB_ID + " = ?", new String[]{tmdbId}) > 0; + } + + public boolean deleteAllMovies() { + return mDatabase.delete(DATABASE_TABLE, null, null) > 0; + } + + public String getCollectionId(String tmdbId) { + return getSingleItem(tmdbId, KEY_COLLECTION_ID); + } + + /** + * Return a Cursor over the list of all movies in the database + */ + public Cursor fetchAllMovies(String sort) { + return mDatabase.query(DATABASE_TABLE, SELECT_ALL, null, null, null, null, sort); + } + + public Cursor getAllMovies() { + return mDatabase.query(DATABASE_TABLE, SELECT_ALL, null, null, null, null, null); + } + + public Cursor getCollections() { + return mDatabase.query(DATABASE_TABLE, SELECT_ALL, null, null, KEY_COLLECTION_ID, null, null); + } + + public Cursor fetchMovie(String movieId) throws SQLException { + Cursor cursor = mDatabase.query(DATABASE_TABLE, SELECT_ALL, KEY_TMDB_ID + " = ?", new String[]{movieId}, null, null, null, null); + if (cursor != null) { + cursor.moveToFirst(); + } + return cursor; + } + + public boolean movieExists(String movieId) { + Cursor cursor = mDatabase.query(DATABASE_TABLE, SELECT_ALL, KEY_TMDB_ID + " = ?", new String[]{movieId}, null, null, null, null); + + if (cursor != null) + try { + return cursor.getCount() > 0; + } catch (SQLiteException e) {} finally { + cursor.close(); + } + + return false; + } + + private ContentValues createContentValues(String tmdbid, String title, + String plot, String imdbid, String rating, String tagline, String release, + String certification, String runtime, String trailer, String genres, String favourite, String actors, + String collectionId, String toWatch, String hasWatched, String date, boolean includeTmdbId) { + ContentValues values = new ContentValues(); + values.put(KEY_TITLE, title); + values.put(KEY_PLOT, plot); + if (includeTmdbId) + values.put(KEY_TMDB_ID, tmdbid); + values.put(KEY_IMDB_ID, imdbid); + values.put(KEY_RATING, rating); + values.put(KEY_TAGLINE, tagline); + values.put(KEY_RELEASEDATE, release); + values.put(KEY_CERTIFICATION, certification); + values.put(KEY_RUNTIME, runtime); + values.put(KEY_TRAILER, trailer); + values.put(KEY_GENRES, genres); + values.put(KEY_FAVOURITE, favourite); + values.put(KEY_ACTORS, actors); + values.put(KEY_COLLECTION_ID, collectionId); + values.put(KEY_TO_WATCH, toWatch); + values.put(KEY_HAS_WATCHED, hasWatched); + values.put(KEY_DATE_ADDED, date); + return values; + } + + private ContentValues createUpdateContentValues(String title, String plot, String imdbid, + String rating, String tagline, String release, String certification, String runtime, + String trailer, String genres, String actors, String collectionId, String date) { + ContentValues values = new ContentValues(); + values.put(KEY_TITLE, title); + values.put(KEY_PLOT, plot); + values.put(KEY_IMDB_ID, imdbid); + values.put(KEY_RATING, rating); + values.put(KEY_TAGLINE, tagline); + values.put(KEY_RELEASEDATE, release); + values.put(KEY_CERTIFICATION, certification); + values.put(KEY_RUNTIME, runtime); + values.put(KEY_TRAILER, trailer); + values.put(KEY_GENRES, genres); + values.put(KEY_ACTORS, actors); + values.put(KEY_COLLECTION_ID, collectionId); + values.put(KEY_DATE_ADDED, date); + return values; + } + + private ContentValues createEditContentValues(String title, String plot, String rating, String tagline, + String release, String certification, String runtime, String genres, String toWatch, String hasWatched, String date) { + ContentValues values = new ContentValues(); + values.put(KEY_TITLE, title); + values.put(KEY_PLOT, plot); + values.put(KEY_RATING, rating); + values.put(KEY_TAGLINE, tagline); + values.put(KEY_RELEASEDATE, release); + values.put(KEY_CERTIFICATION, certification); + values.put(KEY_RUNTIME, runtime); + values.put(KEY_GENRES, genres); + values.put(KEY_TO_WATCH, toWatch); + values.put(KEY_HAS_WATCHED, hasWatched); + values.put(KEY_DATE_ADDED, date); + return values; + } + + public int count() { + Cursor c = mDatabase.query(DATABASE_TABLE, new String[]{KEY_TITLE, KEY_TMDB_ID}, "NOT(" + KEY_TMDB_ID + " = '" + UNIDENTIFIED_ID + "')", null, null, null, null); + int count = c.getCount(); + c.close(); + return count; + } + + public int countWatchlist() { + Cursor c = mDatabase.query(DATABASE_TABLE, new String[] {KEY_TO_WATCH}, KEY_TO_WATCH + " = '1'", null, null, null, null); + int count = c.getCount(); + c.close(); + return count; + } + + public ArrayList getCertifications() { + ArrayList certifications = new ArrayList(); + Cursor cursor = mDatabase.query(DATABASE_TABLE, new String[]{KEY_CERTIFICATION}, null, null, KEY_CERTIFICATION, null, null); + + if (cursor != null) { + try { + while (cursor.moveToNext()) { + String certification = cursor.getString(cursor.getColumnIndex(KEY_CERTIFICATION)); + if (!TextUtils.isEmpty(certification)) + certifications.add(certification); + } + } catch (Exception e) { + } finally { + cursor.close(); + } + } + + return certifications; + } +} \ No newline at end of file diff --git a/src/com/miz/db/DbAdapterSources.java b/app/src/main/java/com/miz/db/DbAdapterSources.java similarity index 100% rename from src/com/miz/db/DbAdapterSources.java rename to app/src/main/java/com/miz/db/DbAdapterSources.java diff --git a/src/com/miz/db/DbAdapterTvShowEpisodeMappings.java b/app/src/main/java/com/miz/db/DbAdapterTvShowEpisodeMappings.java similarity index 100% rename from src/com/miz/db/DbAdapterTvShowEpisodeMappings.java rename to app/src/main/java/com/miz/db/DbAdapterTvShowEpisodeMappings.java index b8b4d199..9195ea4d 100644 --- a/src/com/miz/db/DbAdapterTvShowEpisodeMappings.java +++ b/app/src/main/java/com/miz/db/DbAdapterTvShowEpisodeMappings.java @@ -16,14 +16,14 @@ package com.miz.db; -import java.util.ArrayList; +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; +import java.util.ArrayList; public class DbAdapterTvShowEpisodeMappings extends AbstractDbAdapter { diff --git a/src/com/miz/db/DbAdapterTvShowEpisodes.java b/app/src/main/java/com/miz/db/DbAdapterTvShowEpisodes.java similarity index 100% rename from src/com/miz/db/DbAdapterTvShowEpisodes.java rename to app/src/main/java/com/miz/db/DbAdapterTvShowEpisodes.java index 4ed0119e..3b9a4dd4 100644 --- a/src/com/miz/db/DbAdapterTvShowEpisodes.java +++ b/app/src/main/java/com/miz/db/DbAdapterTvShowEpisodes.java @@ -16,10 +16,9 @@ package com.miz.db; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; import com.miz.functions.ColumnIndexCache; import com.miz.functions.EpisodeCounter; @@ -28,9 +27,10 @@ import com.miz.mizuu.MizuuApplication; import com.miz.utils.FileUtils; -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; public class DbAdapterTvShowEpisodes extends AbstractDbAdapter { diff --git a/src/com/miz/db/DbAdapterTvShows.java b/app/src/main/java/com/miz/db/DbAdapterTvShows.java similarity index 100% rename from src/com/miz/db/DbAdapterTvShows.java rename to app/src/main/java/com/miz/db/DbAdapterTvShows.java index 6620c9a6..953e980e 100644 --- a/src/com/miz/db/DbAdapterTvShows.java +++ b/app/src/main/java/com/miz/db/DbAdapterTvShows.java @@ -16,13 +16,13 @@ package com.miz.db; -import java.util.ArrayList; - import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.text.TextUtils; +import java.util.ArrayList; + public class DbAdapterTvShows extends AbstractDbAdapter { public static final String KEY_SHOW_ID = "show_id"; diff --git a/src/com/miz/filesources/BrowserFile.java b/app/src/main/java/com/miz/filesources/BrowserFile.java similarity index 100% rename from src/com/miz/filesources/BrowserFile.java rename to app/src/main/java/com/miz/filesources/BrowserFile.java index 8f2a8a09..bc26f966 100644 --- a/src/com/miz/filesources/BrowserFile.java +++ b/app/src/main/java/com/miz/filesources/BrowserFile.java @@ -16,6 +16,12 @@ package com.miz.filesources; +import android.util.Log; + +import com.miz.abstractclasses.AbstractFileSourceBrowser; +import com.miz.functions.BrowserFileObject; +import com.miz.functions.MizLib; + import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -23,12 +29,6 @@ import java.util.List; import java.util.Locale; -import android.util.Log; - -import com.miz.abstractclasses.AbstractFileSourceBrowser; -import com.miz.functions.BrowserFileObject; -import com.miz.functions.MizLib; - public class BrowserFile extends AbstractFileSourceBrowser { public BrowserFile(File folder) { diff --git a/src/com/miz/filesources/BrowserSmb.java b/app/src/main/java/com/miz/filesources/BrowserSmb.java similarity index 100% rename from src/com/miz/filesources/BrowserSmb.java rename to app/src/main/java/com/miz/filesources/BrowserSmb.java index 0084ccda..a48c7dd3 100644 --- a/src/com/miz/filesources/BrowserSmb.java +++ b/app/src/main/java/com/miz/filesources/BrowserSmb.java @@ -16,6 +16,12 @@ package com.miz.filesources; +import android.util.Log; + +import com.miz.abstractclasses.AbstractFileSourceBrowser; +import com.miz.functions.BrowserFileObject; +import com.miz.functions.MizLib; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -24,12 +30,6 @@ import jcifs.smb.SmbFile; -import android.util.Log; - -import com.miz.abstractclasses.AbstractFileSourceBrowser; -import com.miz.functions.BrowserFileObject; -import com.miz.functions.MizLib; - public class BrowserSmb extends AbstractFileSourceBrowser { public BrowserSmb(SmbFile folder) { diff --git a/src/com/miz/filesources/BrowserUpnp.java b/app/src/main/java/com/miz/filesources/BrowserUpnp.java similarity index 100% rename from src/com/miz/filesources/BrowserUpnp.java rename to app/src/main/java/com/miz/filesources/BrowserUpnp.java index d6857dad..e4d5c345 100644 --- a/src/com/miz/filesources/BrowserUpnp.java +++ b/app/src/main/java/com/miz/filesources/BrowserUpnp.java @@ -16,13 +16,13 @@ package com.miz.filesources; -import java.util.HashMap; +import com.miz.abstractclasses.AbstractFileSourceBrowser; import org.teleal.cling.model.meta.Device; import org.teleal.cling.model.meta.Service; import org.teleal.cling.support.model.container.Container; -import com.miz.abstractclasses.AbstractFileSourceBrowser; +import java.util.HashMap; public class BrowserUpnp extends AbstractFileSourceBrowser> { diff --git a/src/com/miz/filesources/FileMovie.java b/app/src/main/java/com/miz/filesources/FileMovie.java similarity index 85% rename from src/com/miz/filesources/FileMovie.java rename to app/src/main/java/com/miz/filesources/FileMovie.java index f72ca5a6..aa1a31a7 100644 --- a/src/com/miz/filesources/FileMovie.java +++ b/app/src/main/java/com/miz/filesources/FileMovie.java @@ -16,35 +16,36 @@ package com.miz.filesources; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.TreeSet; - import android.content.Context; import android.database.Cursor; import com.miz.abstractclasses.MovieFileSource; -import com.miz.db.DbAdapterMovies; import com.miz.db.DbAdapterMovieMappings; +import com.miz.db.DbAdapterMovies; import com.miz.functions.ColumnIndexCache; import com.miz.functions.DbMovie; import com.miz.functions.FileSource; import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; +import com.miz.utils.MovieDatabaseUtils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.TreeSet; public class FileMovie extends MovieFileSource { private HashMap existingMovies = new HashMap(); private File tempFile; - public FileMovie(Context context, FileSource fileSource, boolean ignoreRemovedFiles, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { - super(context, fileSource, ignoreRemovedFiles, subFolderSearch, clearLibrary, disableEthernetWiFiCheck); + public FileMovie(Context context, FileSource fileSource, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { + super(context, fileSource, subFolderSearch, clearLibrary, disableEthernetWiFiCheck); } @Override @@ -58,7 +59,7 @@ public void removeUnidentifiedFiles() { if (!dbMovies.get(i).isNetworkFile() && !dbMovies.get(i).isUpnpFile()) { temp = new File(dbMovies.get(i).getFilepath()); if (temp.exists() && dbMovies.get(i).isUnidentified()) - db.deleteMovie(dbMovies.get(i).getTmdbId()); + MovieDatabaseUtils.deleteMovie(mContext, dbMovies.get(i).getTmdbId()); } } } @@ -66,39 +67,25 @@ public void removeUnidentifiedFiles() { @Override public void removeUnavailableFiles() { DbAdapterMovies db = MizuuApplication.getMovieAdapter(); - List dbMovies = getDbMovies(), deletedMovies = new ArrayList(); + List dbMovies = getDbMovies(); - boolean deleted; File temp; int count = dbMovies.size(); for (int i = 0; i < count; i++) { if (!dbMovies.get(i).isNetworkFile()) { temp = new File(dbMovies.get(i).getFilepath()); if (!temp.exists()) { - deleted = db.deleteMovie(dbMovies.get(i).getTmdbId()); - if (deleted) - deletedMovies.add(dbMovies.get(i)); + MovieDatabaseUtils.deleteMovie(mContext, dbMovies.get(i).getTmdbId()); } } } - - count = deletedMovies.size(); - for (int i = 0; i < count; i++) { - if (!db.movieExists(deletedMovies.get(i).getTmdbId())) { - MizLib.deleteFile(new File(deletedMovies.get(i).getThumbnail())); - MizLib.deleteFile(new File(deletedMovies.get(i).getBackdrop())); - } - } - - // Clean up - deletedMovies.clear(); } @Override public List searchFolder() { DbAdapterMovieMappings dbHelper = MizuuApplication.getMovieMappingAdapter(); - Cursor cursor = dbHelper.getAllFilepaths(ignoreRemovedFiles()); // Query database to return all filepaths in a cursor + Cursor cursor = dbHelper.getAllFilepaths(false); // Query database to return all filepaths in a cursor ColumnIndexCache cache = new ColumnIndexCache(); try { diff --git a/src/com/miz/filesources/FileTvShow.java b/app/src/main/java/com/miz/filesources/FileTvShow.java similarity index 95% rename from src/com/miz/filesources/FileTvShow.java rename to app/src/main/java/com/miz/filesources/FileTvShow.java index a2226f88..6fafaa65 100644 --- a/src/com/miz/filesources/FileTvShow.java +++ b/app/src/main/java/com/miz/filesources/FileTvShow.java @@ -16,33 +16,33 @@ package com.miz.filesources; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.TreeSet; - import android.content.Context; import android.database.Cursor; import com.miz.abstractclasses.TvShowFileSource; import com.miz.db.DbAdapterTvShowEpisodeMappings; -import com.miz.db.DbAdapterTvShows; import com.miz.db.DbAdapterTvShowEpisodes; +import com.miz.db.DbAdapterTvShows; import com.miz.functions.ColumnIndexCache; import com.miz.functions.DbEpisode; import com.miz.functions.FileSource; import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.TreeSet; + public class FileTvShow extends TvShowFileSource { private HashMap existingEpisodes = new HashMap(); private File tempFile; - public FileTvShow(Context context, FileSource fileSource, boolean ignoreRemovedFiles, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { - super(context, fileSource, ignoreRemovedFiles, subFolderSearch, clearLibrary, disableEthernetWiFiCheck); + public FileTvShow(Context context, FileSource fileSource, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { + super(context, fileSource, subFolderSearch, clearLibrary, disableEthernetWiFiCheck); } @Override @@ -69,7 +69,7 @@ public void removeUnavailableFiles() { DbAdapterTvShowEpisodes db = MizuuApplication.getTvEpisodeDbAdapter(); ColumnIndexCache cache = new ColumnIndexCache(); - Cursor tempCursor = db.getAllEpisodesInDatabase(ignoreRemovedFiles()); + Cursor tempCursor = db.getAllEpisodesInDatabase(false); if (tempCursor == null) return; diff --git a/src/com/miz/filesources/SmbMovie.java b/app/src/main/java/com/miz/filesources/SmbMovie.java similarity index 87% rename from src/com/miz/filesources/SmbMovie.java rename to app/src/main/java/com/miz/filesources/SmbMovie.java index 505596e0..dde970c7 100644 --- a/src/com/miz/filesources/SmbMovie.java +++ b/app/src/main/java/com/miz/filesources/SmbMovie.java @@ -16,36 +16,37 @@ package com.miz.filesources; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.TreeSet; - -import jcifs.smb.SmbException; -import jcifs.smb.SmbFile; import android.content.Context; import android.database.Cursor; import com.miz.abstractclasses.MovieFileSource; -import com.miz.db.DbAdapterMovies; import com.miz.db.DbAdapterMovieMappings; +import com.miz.db.DbAdapterMovies; import com.miz.functions.ColumnIndexCache; import com.miz.functions.DbMovie; import com.miz.functions.FileSource; import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; +import com.miz.utils.MovieDatabaseUtils; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.TreeSet; + +import jcifs.smb.SmbException; +import jcifs.smb.SmbFile; public class SmbMovie extends MovieFileSource { private HashMap existingMovies = new HashMap(); private SmbFile tempSmbFile; - public SmbMovie(Context context, FileSource fileSource, boolean ignoreRemovedFiles, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { - super(context, fileSource, ignoreRemovedFiles, subFolderSearch, clearLibrary, disableEthernetWiFiCheck); + public SmbMovie(Context context, FileSource fileSource, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { + super(context, fileSource, subFolderSearch, clearLibrary, disableEthernetWiFiCheck); } @Override @@ -72,7 +73,7 @@ public void removeUnidentifiedFiles() { if (source == null) { if (dbMovies.get(i).isUnidentified()) - db.deleteMovie(dbMovies.get(i).getTmdbId()); + MovieDatabaseUtils.deleteMovie(mContext, dbMovies.get(i).getTmdbId()); continue; } @@ -86,7 +87,7 @@ public void removeUnidentifiedFiles() { )); if (temp.exists() && dbMovies.get(i).isUnidentified()) - db.deleteMovie(dbMovies.get(i).getTmdbId()); + MovieDatabaseUtils.deleteMovie(mContext, dbMovies.get(i).getTmdbId()); } catch (Exception e) {} // Do nothing - the file isn't available (either MalformedURLException or SmbException) } } @@ -96,7 +97,7 @@ public void removeUnidentifiedFiles() { @Override public void removeUnavailableFiles() { DbAdapterMovies db = MizuuApplication.getMovieAdapter(); - List dbMovies = getDbMovies(), deletedMovies = new ArrayList(); + List dbMovies = getDbMovies(); ArrayList filesources = MizLib.getFileSources(MizLib.TYPE_MOVIE, true); FileSource source; @@ -116,9 +117,7 @@ public void removeUnavailableFiles() { } if (source == null) { - deleted = db.deleteMovie(dbMovies.get(i).getTmdbId()); - if (deleted) - deletedMovies.add(dbMovies.get(i)); + MovieDatabaseUtils.deleteMovie(mContext, dbMovies.get(i).getTmdbId()); continue; } @@ -132,25 +131,14 @@ public void removeUnavailableFiles() { )); if (!temp.exists()) { - deleted = db.deleteMovie(dbMovies.get(i).getTmdbId()); - if (deleted) - deletedMovies.add(dbMovies.get(i)); + MovieDatabaseUtils.deleteMovie(mContext, dbMovies.get(i).getTmdbId()); } } catch (Exception e) {} // Do nothing - the file isn't available (either MalformedURLException or SmbException) } } } - count = deletedMovies.size(); - for (int i = 0; i < count; i++) { - if (!db.movieExists(deletedMovies.get(i).getTmdbId())) { - MizLib.deleteFile(new File(deletedMovies.get(i).getThumbnail())); - MizLib.deleteFile(new File(deletedMovies.get(i).getBackdrop())); - } - } - // Clean up - deletedMovies.clear(); filesources.clear(); } @@ -160,7 +148,7 @@ public List searchFolder() { return new ArrayList(); // Return empty List DbAdapterMovieMappings dbHelper = MizuuApplication.getMovieMappingAdapter(); - Cursor cursor = dbHelper.getAllFilepaths(ignoreRemovedFiles()); // Query database to return all filepaths in a cursor + Cursor cursor = dbHelper.getAllFilepaths(false); // Query database to return all filepaths in a cursor ColumnIndexCache cache = new ColumnIndexCache(); try { diff --git a/src/com/miz/filesources/SmbTvShow.java b/app/src/main/java/com/miz/filesources/SmbTvShow.java similarity index 96% rename from src/com/miz/filesources/SmbTvShow.java rename to app/src/main/java/com/miz/filesources/SmbTvShow.java index 3efd3908..d5692334 100644 --- a/src/com/miz/filesources/SmbTvShow.java +++ b/app/src/main/java/com/miz/filesources/SmbTvShow.java @@ -16,35 +16,36 @@ package com.miz.filesources; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.TreeSet; - -import jcifs.smb.SmbException; -import jcifs.smb.SmbFile; import android.content.Context; import android.database.Cursor; import com.miz.abstractclasses.TvShowFileSource; import com.miz.db.DbAdapterTvShowEpisodeMappings; -import com.miz.db.DbAdapterTvShows; import com.miz.db.DbAdapterTvShowEpisodes; +import com.miz.db.DbAdapterTvShows; import com.miz.functions.ColumnIndexCache; import com.miz.functions.DbEpisode; import com.miz.functions.FileSource; import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.TreeSet; + +import jcifs.smb.SmbException; +import jcifs.smb.SmbFile; + public class SmbTvShow extends TvShowFileSource { private HashMap existingEpisodes = new HashMap(); private SmbFile tempSmbFile; - public SmbTvShow(Context context, FileSource fileSource, boolean ignoreRemovedFiles, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { - super(context, fileSource, ignoreRemovedFiles, subFolderSearch, clearLibrary, disableEthernetWiFiCheck); + public SmbTvShow(Context context, FileSource fileSource, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { + super(context, fileSource, subFolderSearch, clearLibrary, disableEthernetWiFiCheck); } @Override @@ -98,7 +99,7 @@ public void removeUnavailableFiles() { DbAdapterTvShowEpisodes db = MizuuApplication.getTvEpisodeDbAdapter(); ColumnIndexCache cache = new ColumnIndexCache(); - Cursor tempCursor = db.getAllEpisodesInDatabase(ignoreRemovedFiles()); + Cursor tempCursor = db.getAllEpisodesInDatabase(false); if (tempCursor == null) return; diff --git a/src/com/miz/filesources/UpnpMovie.java b/app/src/main/java/com/miz/filesources/UpnpMovie.java similarity index 91% rename from src/com/miz/filesources/UpnpMovie.java rename to app/src/main/java/com/miz/filesources/UpnpMovie.java index 58d64380..56688dcc 100644 --- a/src/com/miz/filesources/UpnpMovie.java +++ b/app/src/main/java/com/miz/filesources/UpnpMovie.java @@ -16,15 +16,24 @@ package com.miz.filesources; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.TreeSet; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.ServiceConnection; +import android.database.Cursor; +import android.os.IBinder; +import android.text.TextUtils; + +import com.miz.abstractclasses.MovieFileSource; +import com.miz.db.DbAdapterMovieMappings; +import com.miz.db.DbAdapterMovies; +import com.miz.functions.ColumnIndexCache; +import com.miz.functions.DbMovie; +import com.miz.functions.FileSource; +import com.miz.functions.MizLib; +import com.miz.mizuu.MizuuApplication; +import com.miz.service.WireUpnpService; +import com.miz.utils.MovieDatabaseUtils; import org.teleal.cling.android.AndroidUpnpService; import org.teleal.cling.model.action.ActionInvocation; @@ -43,23 +52,14 @@ import org.teleal.cling.support.model.container.Container; import org.teleal.cling.support.model.item.Item; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.database.Cursor; -import android.os.IBinder; -import android.text.TextUtils; - -import com.miz.abstractclasses.MovieFileSource; -import com.miz.db.DbAdapterMovies; -import com.miz.db.DbAdapterMovieMappings; -import com.miz.functions.ColumnIndexCache; -import com.miz.functions.DbMovie; -import com.miz.functions.FileSource; -import com.miz.functions.MizLib; -import com.miz.mizuu.MizuuApplication; -import com.miz.service.WireUpnpService; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.TreeSet; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public class UpnpMovie extends MovieFileSource { @@ -68,8 +68,8 @@ public class UpnpMovie extends MovieFileSource { private CountDownLatch mLatch = new CountDownLatch(1); private AndroidUpnpService mUpnpService; - public UpnpMovie(Context context, FileSource fileSource, boolean ignoreRemovedFiles, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { - super(context, fileSource, ignoreRemovedFiles, subFolderSearch, clearLibrary, disableEthernetWiFiCheck); + public UpnpMovie(Context context, FileSource fileSource, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { + super(context, fileSource, subFolderSearch, clearLibrary, disableEthernetWiFiCheck); } @Override @@ -80,41 +80,27 @@ public void removeUnidentifiedFiles() { int count = dbMovies.size(); for (int i = 0; i < count; i++) { if (dbMovies.get(i).isUpnpFile() && dbMovies.get(i).isUnidentified() && MizLib.exists(dbMovies.get(i).getFilepath())) - db.deleteMovie(dbMovies.get(i).getTmdbId()); + MovieDatabaseUtils.deleteMovie(mContext, dbMovies.get(i).getTmdbId()); } } @Override public void removeUnavailableFiles() { DbAdapterMovies db = MizuuApplication.getMovieAdapter(); - List dbMovies = getDbMovies(), deletedMovies = new ArrayList(); + List dbMovies = getDbMovies(); - boolean deleted; int count = dbMovies.size(); for (int i = 0; i < count; i++) { if (dbMovies.get(i).isUpnpFile() && !MizLib.exists(dbMovies.get(i).getFilepath())) { - deleted = db.deleteMovie(dbMovies.get(i).getTmdbId()); - if (deleted) - deletedMovies.add(dbMovies.get(i)); + MovieDatabaseUtils.deleteMovie(mContext, dbMovies.get(i).getTmdbId()); } } - - count = deletedMovies.size(); - for (int i = 0; i < count; i++) { - if (!db.movieExists(deletedMovies.get(i).getTmdbId())) { - MizLib.deleteFile(new File(deletedMovies.get(i).getThumbnail())); - MizLib.deleteFile(new File(deletedMovies.get(i).getBackdrop())); - } - } - - // Clean up - deletedMovies.clear(); } @Override public List searchFolder() { DbAdapterMovieMappings dbHelper = MizuuApplication.getMovieMappingAdapter(); - Cursor cursor = dbHelper.getAllFilepaths(ignoreRemovedFiles()); // Query database to return all filepaths in a cursor + Cursor cursor = dbHelper.getAllFilepaths(false); // Query database to return all filepaths in a cursor ColumnIndexCache cache = new ColumnIndexCache(); try { diff --git a/src/com/miz/filesources/UpnpTvShow.java b/app/src/main/java/com/miz/filesources/UpnpTvShow.java similarity index 97% rename from src/com/miz/filesources/UpnpTvShow.java rename to app/src/main/java/com/miz/filesources/UpnpTvShow.java index 6a5ebf97..8a82e081 100644 --- a/src/com/miz/filesources/UpnpTvShow.java +++ b/app/src/main/java/com/miz/filesources/UpnpTvShow.java @@ -16,14 +16,24 @@ package com.miz.filesources; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.TreeSet; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.ServiceConnection; +import android.database.Cursor; +import android.os.IBinder; +import android.text.TextUtils; + +import com.miz.abstractclasses.TvShowFileSource; +import com.miz.db.DbAdapterTvShowEpisodeMappings; +import com.miz.db.DbAdapterTvShowEpisodes; +import com.miz.db.DbAdapterTvShows; +import com.miz.functions.ColumnIndexCache; +import com.miz.functions.DbEpisode; +import com.miz.functions.FileSource; +import com.miz.functions.MizLib; +import com.miz.mizuu.MizuuApplication; +import com.miz.service.WireUpnpService; import org.teleal.cling.android.AndroidUpnpService; import org.teleal.cling.model.action.ActionInvocation; @@ -42,24 +52,14 @@ import org.teleal.cling.support.model.container.Container; import org.teleal.cling.support.model.item.Item; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.database.Cursor; -import android.os.IBinder; -import android.text.TextUtils; - -import com.miz.abstractclasses.TvShowFileSource; -import com.miz.db.DbAdapterTvShowEpisodeMappings; -import com.miz.db.DbAdapterTvShows; -import com.miz.db.DbAdapterTvShowEpisodes; -import com.miz.functions.ColumnIndexCache; -import com.miz.functions.DbEpisode; -import com.miz.functions.FileSource; -import com.miz.functions.MizLib; -import com.miz.mizuu.MizuuApplication; -import com.miz.service.WireUpnpService; +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.TreeSet; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public class UpnpTvShow extends TvShowFileSource { @@ -68,8 +68,8 @@ public class UpnpTvShow extends TvShowFileSource { private CountDownLatch mLatch = new CountDownLatch(1); private AndroidUpnpService mUpnpService; - public UpnpTvShow(Context context, FileSource fileSource, boolean ignoreRemovedFiles, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { - super(context, fileSource, ignoreRemovedFiles, subFolderSearch, clearLibrary, disableEthernetWiFiCheck); + public UpnpTvShow(Context context, FileSource fileSource, boolean subFolderSearch, boolean clearLibrary, boolean disableEthernetWiFiCheck) { + super(context, fileSource, subFolderSearch, clearLibrary, disableEthernetWiFiCheck); } @Override @@ -93,7 +93,7 @@ public void removeUnavailableFiles() { DbAdapterTvShowEpisodes db = MizuuApplication.getTvEpisodeDbAdapter(); ColumnIndexCache cache = new ColumnIndexCache(); - Cursor tempCursor = db.getAllEpisodesInDatabase(ignoreRemovedFiles()); + Cursor tempCursor = db.getAllEpisodesInDatabase(false); if (tempCursor == null) return; diff --git a/src/com/miz/functions/AbstractCursorLoader.java b/app/src/main/java/com/miz/functions/AbstractCursorLoader.java similarity index 100% rename from src/com/miz/functions/AbstractCursorLoader.java rename to app/src/main/java/com/miz/functions/AbstractCursorLoader.java diff --git a/src/com/miz/functions/ActionBarSpinner.java b/app/src/main/java/com/miz/functions/ActionBarSpinner.java similarity index 99% rename from src/com/miz/functions/ActionBarSpinner.java rename to app/src/main/java/com/miz/functions/ActionBarSpinner.java index fd38f0f5..13265216 100644 --- a/src/com/miz/functions/ActionBarSpinner.java +++ b/app/src/main/java/com/miz/functions/ActionBarSpinner.java @@ -16,8 +16,6 @@ package com.miz.functions; -import java.util.ArrayList; - import android.content.Context; import android.view.LayoutInflater; import android.view.View; @@ -27,6 +25,8 @@ import com.miz.mizuu.R; +import java.util.ArrayList; + public class ActionBarSpinner extends BaseAdapter { private LayoutInflater mInflater; @@ -67,7 +67,7 @@ public View getView(int position, View convertView, ViewGroup parent) { @Override public int getViewTypeCount() { - return 0; + return 1; } @Override diff --git a/src/com/miz/functions/ActionBarSpinnerViewHolder.java b/app/src/main/java/com/miz/functions/ActionBarSpinnerViewHolder.java similarity index 100% rename from src/com/miz/functions/ActionBarSpinnerViewHolder.java rename to app/src/main/java/com/miz/functions/ActionBarSpinnerViewHolder.java diff --git a/src/com/miz/functions/Actor.java b/app/src/main/java/com/miz/functions/Actor.java similarity index 100% rename from src/com/miz/functions/Actor.java rename to app/src/main/java/com/miz/functions/Actor.java diff --git a/src/com/miz/functions/AsyncTask.java b/app/src/main/java/com/miz/functions/AsyncTask.java similarity index 98% rename from src/com/miz/functions/AsyncTask.java rename to app/src/main/java/com/miz/functions/AsyncTask.java index ec456ec8..996f30a3 100644 --- a/src/com/miz/functions/AsyncTask.java +++ b/app/src/main/java/com/miz/functions/AsyncTask.java @@ -22,7 +22,18 @@ import android.os.Process; import java.util.ArrayDeque; -import java.util.concurrent.*; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.Callable; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.concurrent.FutureTask; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; diff --git a/src/com/miz/functions/BlurTransformation.java b/app/src/main/java/com/miz/functions/BlurTransformation.java similarity index 100% rename from src/com/miz/functions/BlurTransformation.java rename to app/src/main/java/com/miz/functions/BlurTransformation.java diff --git a/src/com/miz/functions/BrowserFileObject.java b/app/src/main/java/com/miz/functions/BrowserFileObject.java similarity index 100% rename from src/com/miz/functions/BrowserFileObject.java rename to app/src/main/java/com/miz/functions/BrowserFileObject.java diff --git a/src/com/miz/functions/ColumnIndexCache.java b/app/src/main/java/com/miz/functions/ColumnIndexCache.java similarity index 100% rename from src/com/miz/functions/ColumnIndexCache.java rename to app/src/main/java/com/miz/functions/ColumnIndexCache.java index befc325e..f3b30766 100644 --- a/src/com/miz/functions/ColumnIndexCache.java +++ b/app/src/main/java/com/miz/functions/ColumnIndexCache.java @@ -16,10 +16,10 @@ package com.miz.functions; -import java.util.HashMap; - import android.database.Cursor; +import java.util.HashMap; + public class ColumnIndexCache { private HashMap mMap = new HashMap(); diff --git a/src/com/miz/functions/CompleteActor.java b/app/src/main/java/com/miz/functions/CompleteActor.java similarity index 91% rename from src/com/miz/functions/CompleteActor.java rename to app/src/main/java/com/miz/functions/CompleteActor.java index 941ec62b..ef7dd06f 100644 --- a/src/com/miz/functions/CompleteActor.java +++ b/app/src/main/java/com/miz/functions/CompleteActor.java @@ -16,17 +16,17 @@ package com.miz.functions; +import android.text.TextUtils; + import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Random; -import android.text.TextUtils; - public class CompleteActor { private final String mId; - private String mName, mBirthday, mDayOfDeath, mPlaceOfBirth, mProfilePhoto, mBiography; + private String mName, mBirthday, mDayOfDeath, mPlaceOfBirth, mProfilePhoto, mProfilePhotoThumb, mBiography; private int mKnownCreditCount; private List mMovies = new ArrayList(), mTvShows = new ArrayList(); private List mPhotos = new ArrayList(), mTaggedPhotos = new ArrayList(); @@ -92,6 +92,16 @@ public String getProfilePhoto() { return null; return mProfilePhoto; } + + public void setProfilePhotoThumb(String photo) { + mProfilePhotoThumb = photo; + } + + public String getProfilePhotoThumb() { + if (TextUtils.isEmpty(mProfilePhotoThumb)) + return getProfilePhoto(); + return mProfilePhotoThumb; + } public void setKnownCreditCount(int count) { mKnownCreditCount = count; diff --git a/src/com/miz/functions/ContentItem.java b/app/src/main/java/com/miz/functions/ContentItem.java similarity index 100% rename from src/com/miz/functions/ContentItem.java rename to app/src/main/java/com/miz/functions/ContentItem.java diff --git a/src/com/miz/functions/Cover.java b/app/src/main/java/com/miz/functions/Cover.java similarity index 100% rename from src/com/miz/functions/Cover.java rename to app/src/main/java/com/miz/functions/Cover.java diff --git a/src/com/miz/functions/CoverItem.java b/app/src/main/java/com/miz/functions/CoverItem.java similarity index 100% rename from src/com/miz/functions/CoverItem.java rename to app/src/main/java/com/miz/functions/CoverItem.java diff --git a/src/com/miz/functions/DbEpisode.java b/app/src/main/java/com/miz/functions/DbEpisode.java similarity index 100% rename from src/com/miz/functions/DbEpisode.java rename to app/src/main/java/com/miz/functions/DbEpisode.java index fae660fb..74c0a488 100644 --- a/src/com/miz/functions/DbEpisode.java +++ b/app/src/main/java/com/miz/functions/DbEpisode.java @@ -16,11 +16,11 @@ package com.miz.functions; +import android.content.Context; + import com.miz.db.DbAdapterTvShows; import com.miz.utils.FileUtils; -import android.content.Context; - public class DbEpisode { private final Context mContext; diff --git a/src/com/miz/functions/DbMovie.java b/app/src/main/java/com/miz/functions/DbMovie.java similarity index 100% rename from src/com/miz/functions/DbMovie.java rename to app/src/main/java/com/miz/functions/DbMovie.java index 5c893ad9..4c47f458 100644 --- a/src/com/miz/functions/DbMovie.java +++ b/app/src/main/java/com/miz/functions/DbMovie.java @@ -16,12 +16,12 @@ package com.miz.functions; -import java.io.File; +import android.content.Context; +import android.text.TextUtils; import com.miz.utils.FileUtils; -import android.content.Context; -import android.text.TextUtils; +import java.io.File; public class DbMovie { diff --git a/src/com/miz/functions/DeviceItem.java b/app/src/main/java/com/miz/functions/DeviceItem.java similarity index 100% rename from src/com/miz/functions/DeviceItem.java rename to app/src/main/java/com/miz/functions/DeviceItem.java index 9de4fa1d..5a7bec02 100644 --- a/src/com/miz/functions/DeviceItem.java +++ b/app/src/main/java/com/miz/functions/DeviceItem.java @@ -17,11 +17,11 @@ package com.miz.functions; +import android.graphics.drawable.Drawable; + import org.teleal.cling.model.meta.Device; import org.teleal.cling.model.types.UDN; -import android.graphics.drawable.Drawable; - /** * Wraps a Device for display with icon and label. Equality is * implemented with UDN comparison. diff --git a/src/com/miz/functions/EpisodeCounter.java b/app/src/main/java/com/miz/functions/EpisodeCounter.java similarity index 100% rename from src/com/miz/functions/EpisodeCounter.java rename to app/src/main/java/com/miz/functions/EpisodeCounter.java diff --git a/src/com/miz/functions/FileRequestTransformer.java b/app/src/main/java/com/miz/functions/FileRequestTransformer.java similarity index 94% rename from src/com/miz/functions/FileRequestTransformer.java rename to app/src/main/java/com/miz/functions/FileRequestTransformer.java index 444f5ef7..33fde9b5 100644 --- a/src/com/miz/functions/FileRequestTransformer.java +++ b/app/src/main/java/com/miz/functions/FileRequestTransformer.java @@ -30,6 +30,9 @@ public class FileRequestTransformer implements Picasso.RequestTransformer { @Override public Request transformRequest(Request arg0) { + if (arg0.resourceId > 0) + return arg0; + return arg0.buildUpon().setUri(Uri.parse(arg0.uri.toString().replace("file://", "/"))).build(); } } \ No newline at end of file diff --git a/src/com/miz/functions/FileSource.java b/app/src/main/java/com/miz/functions/FileSource.java similarity index 100% rename from src/com/miz/functions/FileSource.java rename to app/src/main/java/com/miz/functions/FileSource.java index 054846e2..47f14c35 100644 --- a/src/com/miz/functions/FileSource.java +++ b/app/src/main/java/com/miz/functions/FileSource.java @@ -16,10 +16,10 @@ package com.miz.functions; -import java.io.File; - import com.miz.db.DbAdapterSources; +import java.io.File; + public class FileSource { public static final int FILE = 0, SMB = 1, UPNP = 2; diff --git a/src/com/miz/functions/Filepath.java b/app/src/main/java/com/miz/functions/Filepath.java similarity index 100% rename from src/com/miz/functions/Filepath.java rename to app/src/main/java/com/miz/functions/Filepath.java diff --git a/src/com/miz/functions/GridEpisode.java b/app/src/main/java/com/miz/functions/GridEpisode.java similarity index 100% rename from src/com/miz/functions/GridEpisode.java rename to app/src/main/java/com/miz/functions/GridEpisode.java index 36aa8dda..f1177ef1 100644 --- a/src/com/miz/functions/GridEpisode.java +++ b/app/src/main/java/com/miz/functions/GridEpisode.java @@ -16,16 +16,16 @@ package com.miz.functions; -import static com.miz.functions.PreferenceKeys.TVSHOWS_EPISODE_ORDER; - -import java.io.File; - import android.content.Context; import android.preference.PreferenceManager; import android.text.TextUtils; import com.miz.mizuu.R; +import java.io.File; + +import static com.miz.functions.PreferenceKeys.TVSHOWS_EPISODE_ORDER; + public class GridEpisode implements Comparable { private Context mContext; diff --git a/src/com/miz/functions/GridSeason.java b/app/src/main/java/com/miz/functions/GridSeason.java similarity index 81% rename from src/com/miz/functions/GridSeason.java rename to app/src/main/java/com/miz/functions/GridSeason.java index 83f30ae1..b98c9dd9 100644 --- a/src/com/miz/functions/GridSeason.java +++ b/app/src/main/java/com/miz/functions/GridSeason.java @@ -16,12 +16,12 @@ package com.miz.functions; -import java.io.File; +import android.content.Context; +import android.preference.PreferenceManager; import com.miz.mizuu.R; -import android.content.Context; -import android.preference.PreferenceManager; +import java.io.File; import static com.miz.functions.PreferenceKeys.TVSHOWS_COLLECTION_LAYOUT; import static com.miz.functions.PreferenceKeys.TVSHOWS_SEASON_ORDER; @@ -29,20 +29,24 @@ public class GridSeason implements Comparable { private Context mContext; - private String mSubtitleText; + private String mShowId, mHeaderText, mSubtitleText, mSubtitleTextSimple; private int mSeason, mEpisodeCount, mWatchedCount; private boolean mUseGridView; private File mCover; - public GridSeason(Context context, int season, int episodeCount, int watchedCount, File cover) { + public GridSeason(Context context, String showId, int season, int episodeCount, int watchedCount, File cover) { mContext = context; + mShowId = showId; mSeason = season; mEpisodeCount = episodeCount; mWatchedCount = watchedCount; mCover = cover; mUseGridView = PreferenceManager.getDefaultSharedPreferences(mContext).getString(TVSHOWS_COLLECTION_LAYOUT, mContext.getString(R.string.gridView)).equals(mContext.getString(R.string.gridView)); - + + // Header text + mHeaderText = (mSeason == 0) ? context.getString(R.string.stringSpecials) : context.getString(R.string.showSeason) + " " + getSeasonZeroIndex(); + // Subtitle text StringBuilder sb = new StringBuilder(); sb.append(getEpisodeCount()).append(" ").append(mContext.getResources().getQuantityString(R.plurals.episodes, getEpisodeCount(), getEpisodeCount())); @@ -56,8 +60,10 @@ else if (MizLib.isTablet(mContext)) // Small tablets (23 left) else // Phones (23) sb.append(" (" + getUnwatchedCount() + ")"); } - + mSubtitleText = sb.toString(); + + mSubtitleTextSimple = getEpisodeCount() + " " + mContext.getResources().getQuantityString(R.plurals.episodes, getEpisodeCount(), getEpisodeCount()); } public int getSeason() { @@ -79,15 +85,27 @@ public int getWatchedCount() { public int getUnwatchedCount() { return mEpisodeCount - mWatchedCount; } - + + public String getHeaderText() { + return mHeaderText; + } + public String getSubtitleText() { return mSubtitleText; } + public String getSimpleSubtitleText() { + return mSubtitleTextSimple; + } + public File getCover() { return mCover; } + public String getShowId() { + return mShowId; + } + /** * Custom comparator in order to put regular seasons before specials. * The comparator takes the user's sorting preference into consideration diff --git a/app/src/main/java/com/miz/functions/IntentKeys.java b/app/src/main/java/com/miz/functions/IntentKeys.java new file mode 100644 index 00000000..cd2cb2c9 --- /dev/null +++ b/app/src/main/java/com/miz/functions/IntentKeys.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.functions; + +/** + * Simple class to hold keys for Intent keys. This should + * always be used when dealing with Intents. Scattered keys + * across the app? No thank you. + * @author Michell + * + */ +public class IntentKeys { + + private IntentKeys() {} // No instantiation + + public static final String TOOLBAR_COLOR = "toolbarColor"; + +} diff --git a/src/com/miz/functions/LibrarySectionAsyncTask.java b/app/src/main/java/com/miz/functions/LibrarySectionAsyncTask.java similarity index 98% rename from src/com/miz/functions/LibrarySectionAsyncTask.java rename to app/src/main/java/com/miz/functions/LibrarySectionAsyncTask.java index d77a6bae..c500cdeb 100644 --- a/src/com/miz/functions/LibrarySectionAsyncTask.java +++ b/app/src/main/java/com/miz/functions/LibrarySectionAsyncTask.java @@ -22,7 +22,18 @@ import android.os.Process; import java.util.ArrayDeque; -import java.util.concurrent.*; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.Callable; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.concurrent.FutureTask; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; diff --git a/src/com/miz/functions/MediumMovie.java b/app/src/main/java/com/miz/functions/MediumMovie.java similarity index 100% rename from src/com/miz/functions/MediumMovie.java rename to app/src/main/java/com/miz/functions/MediumMovie.java index b9df4985..2dc060e0 100644 --- a/src/com/miz/functions/MediumMovie.java +++ b/app/src/main/java/com/miz/functions/MediumMovie.java @@ -16,10 +16,10 @@ package com.miz.functions; -import com.miz.abstractclasses.MediumBaseMovie; - import android.content.Context; +import com.miz.abstractclasses.MediumBaseMovie; + public class MediumMovie extends MediumBaseMovie { public MediumMovie(Context context, String title, String tmdbId, String rating, String releasedate, diff --git a/src/com/miz/functions/MenuItem.java b/app/src/main/java/com/miz/functions/MenuItem.java similarity index 83% rename from src/com/miz/functions/MenuItem.java rename to app/src/main/java/com/miz/functions/MenuItem.java index d3b0483b..40b1544c 100644 --- a/src/com/miz/functions/MenuItem.java +++ b/app/src/main/java/com/miz/functions/MenuItem.java @@ -18,11 +18,15 @@ public class MenuItem { - public static final int HEADER = 0, SEPARATOR = 1000, SECTION = 2000, THIRD_PARTY_APP = 3000, SMALL_SECTION = 4000; + public static final int HEADER = 0, SEPARATOR = 1000, SEPARATOR_EXTRA_PADDING = 1100, SUB_HEADER = 1500, SECTION = 2000, THIRD_PARTY_APP = 3000, SETTINGS_AREA = 4000; private int mType, mCount, mFragment, mIcon; private String mTitle, mPackageName; - + + public MenuItem(int type) { + mType = type; + } + public MenuItem(String title, int type, int icon) { mTitle = title; mType = type; @@ -36,12 +40,13 @@ public MenuItem(String title, int count, int type, String packageName) { mPackageName = packageName; } - public MenuItem(String title, int count, int type, String packageName, int fragment) { + public MenuItem(String title, int count, int type, String packageName, int fragment, int icon) { mTitle = title; mCount = count; mType = type; mPackageName = packageName; mFragment = fragment; + mIcon = icon; } public String getTitle() { diff --git a/src/com/miz/functions/MizLib.java b/app/src/main/java/com/miz/functions/MizLib.java similarity index 97% rename from src/com/miz/functions/MizLib.java rename to app/src/main/java/com/miz/functions/MizLib.java index 208e7588..660f494d 100644 --- a/src/com/miz/functions/MizLib.java +++ b/app/src/main/java/com/miz/functions/MizLib.java @@ -16,53 +16,11 @@ package com.miz.functions; -import static com.miz.functions.PreferenceKeys.DISABLE_ETHERNET_WIFI_CHECK; -import static com.miz.functions.PreferenceKeys.IGNORE_FILE_SIZE; -import static com.miz.functions.PreferenceKeys.INCLUDE_ADULT_CONTENT; -import static com.miz.functions.PreferenceKeys.SCHEDULED_UPDATES_MOVIE; -import static com.miz.functions.PreferenceKeys.SCHEDULED_UPDATES_TVSHOWS; -import static com.miz.functions.PreferenceKeys.TMDB_BASE_URL; -import static com.miz.functions.PreferenceKeys.TMDB_BASE_URL_TIME; -import static com.miz.functions.PreferenceKeys.TRAKT_USERNAME; - -import android.support.v8.renderscript.*; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLEncoder; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.text.DateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Comparator; -import java.util.List; -import java.util.Locale; -import java.util.Random; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.smb.SmbException; -import jcifs.smb.SmbFile; - -import org.json.JSONException; -import org.json.JSONObject; - import android.annotation.SuppressLint; import android.app.ActivityManager; +import android.app.ActivityManager.RunningServiceInfo; import android.app.AlertDialog; import android.app.Dialog; -import android.app.ActivityManager.RunningServiceInfo; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; @@ -88,6 +46,10 @@ import android.os.Looper; import android.os.StatFs; import android.preference.PreferenceManager; +import android.support.v8.renderscript.Allocation; +import android.support.v8.renderscript.Element; +import android.support.v8.renderscript.RenderScript; +import android.support.v8.renderscript.ScriptIntrinsicBlur; import android.text.TextUtils; import android.util.TypedValue; import android.view.Display; @@ -110,12 +72,54 @@ import com.miz.service.MakeAvailableOffline; import com.miz.service.MovieLibraryUpdate; import com.miz.service.TvShowsLibraryUpdate; +import com.miz.utils.FileUtils; +import com.miz.utils.ViewUtils; import com.squareup.okhttp.MediaType; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; import com.squareup.okhttp.RequestBody; import com.squareup.okhttp.Response; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLEncoder; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; +import java.util.Random; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import jcifs.smb.NtlmPasswordAuthentication; +import jcifs.smb.SmbException; +import jcifs.smb.SmbFile; + +import static com.miz.functions.PreferenceKeys.DISABLE_ETHERNET_WIFI_CHECK; +import static com.miz.functions.PreferenceKeys.IGNORE_FILE_SIZE; +import static com.miz.functions.PreferenceKeys.INCLUDE_ADULT_CONTENT; +import static com.miz.functions.PreferenceKeys.SCHEDULED_UPDATES_MOVIE; +import static com.miz.functions.PreferenceKeys.SCHEDULED_UPDATES_TVSHOWS; +import static com.miz.functions.PreferenceKeys.TMDB_BASE_URL; +import static com.miz.functions.PreferenceKeys.TMDB_BASE_URL_TIME; +import static com.miz.functions.PreferenceKeys.TRAKT_USERNAME; + @SuppressLint("NewApi") public class MizLib { @@ -526,7 +530,7 @@ public static void addNavigationBarMargin(Context c, View v) { params.setMargins(0, 0, 0, getNavigationBarHeight(c)); v.setLayoutParams(params); } - + public static boolean hasICSMR1() { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1; } @@ -547,6 +551,14 @@ public static boolean hasKitKat() { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; } + public static boolean isKitKat() { + return Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT; + } + + public static boolean hasLollipop() { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; + } + public static int getThumbnailNotificationSize(Context c) { Resources r = c.getResources(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64, r.getDisplayMetrics()); @@ -557,42 +569,30 @@ public static int getLargeNotificationWidth(Context c) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 360, r.getDisplayMetrics()); } - public static int getMenuWidth(Context c) { - Resources r = c.getResources(); - if (MizLib.isTablet(c)) { - return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 320, r.getDisplayMetrics()); - } else - return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 300, r.getDisplayMetrics()); - } - public static int convertDpToPixels(Context c, int dp) { Resources r = c.getResources(); return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); } public static int getActionBarHeight(Context c) { - int mActionBarHeight = 0; + int actionBarHeight = 0; TypedValue tv = new TypedValue(); - if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) - mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); + if (c.getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) + actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); else - mActionBarHeight = 0; // No ActionBar style (pre-Honeycomb or ActionBar not in theme) + actionBarHeight = 0; // No ActionBar style (pre-Honeycomb or ActionBar not in theme) - return mActionBarHeight; + return actionBarHeight; } public static int getActionBarAndStatusBarHeight(Context c) { - int mActionBarHeight = 0, mStatusBarHeight = 0; - TypedValue tv = new TypedValue(); - if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) - mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); - else - mActionBarHeight = 0; // No ActionBar style (pre-Honeycomb or ActionBar not in theme) - - if (hasKitKat()) - mStatusBarHeight = convertDpToPixels(c, 25); + int actionBarHeight = getActionBarHeight(c); + int statusBarHeight = ViewUtils.getStatusBarHeight(c); - return mActionBarHeight + mStatusBarHeight; + // We're only interested in returning the combined + // height, if we're running on KitKat or above + return hasKitKat() ? + actionBarHeight + statusBarHeight : actionBarHeight; } public static final String md5(final String s) { @@ -825,7 +825,7 @@ public static Bitmap fastblur(Context context, Bitmap sentBitmap, int radius) { script.setInput(input); script.forEach(output); output.copyTo(sentBitmap); - + return sentBitmap; } @@ -859,7 +859,7 @@ public static boolean downloadFile(String url, String savePath) { } catch(Exception e) { // The download failed, so let's delete whatever was downloaded deleteFile(new File(savePath)); - + return false; } finally { if (fileos != null) { @@ -884,11 +884,12 @@ public static JSONObject getJSONObject(Context context, String url) { Request request = new Request.Builder() .url(url) + .get() .build(); try { Response response = client.newCall(request).execute(); - + if (response.code() >= 429) { // HTTP error 429 and above means that we've exceeded the query limit // for TMDb. Sleep for 5 seconds and try again. @@ -920,6 +921,14 @@ public static int getInteger(String number) { } } + public static int getInteger(double number) { + try { + return (int) number; + } catch (Exception e) { + return 0; + } + } + public static String removeIndexZero(String s) { if (!TextUtils.isEmpty(s)) try { @@ -1190,7 +1199,7 @@ public static boolean deleteFile(File f) { public static String createSmbLoginString(String domain, String user, String password, String server, boolean isFolder) { // Create the string to fit the following syntax: smb://[[[domain;]username[:password]@]server[:port]/ StringBuilder sb = new StringBuilder("smb://"); - + try { user = URLEncoder.encode(user, "utf-8"); } catch (UnsupportedEncodingException e) {} @@ -1859,14 +1868,16 @@ public static String getRandomBackdropPath(Context c) { ArrayList files = new ArrayList(); File[] f = MizuuApplication.getMovieBackdropFolder(c).listFiles(); - for (File file : f) { - files.add(file); - } + if (f != null) + for (File file : f) { + files.add(file); + } f = MizuuApplication.getTvShowBackdropFolder(c).listFiles(); - for (File file : f) { - files.add(file); - } + if (f != null) + for (File file : f) { + files.add(file); + } if (files.size() > 0) { Random rndm = new Random(); @@ -2141,4 +2152,12 @@ public static String getFilenameWithoutExtension(String filename) { return filename; } } + + public static void copyDatabase(Context context) { + try { + FileUtils.copyFile(context.getDatabasePath("mizuu_data"), new File(Environment.getExternalStorageDirectory(), "mizuu_data.db")); + } catch (IOException e) { + e.printStackTrace(); + } + } } \ No newline at end of file diff --git a/src/com/miz/functions/Movie.java b/app/src/main/java/com/miz/functions/Movie.java similarity index 100% rename from src/com/miz/functions/Movie.java rename to app/src/main/java/com/miz/functions/Movie.java index a902a10a..e16e852e 100644 --- a/src/com/miz/functions/Movie.java +++ b/app/src/main/java/com/miz/functions/Movie.java @@ -16,15 +16,15 @@ package com.miz.functions; -import java.io.File; -import java.util.Locale; - import android.content.Context; import android.text.TextUtils; import com.miz.abstractclasses.MediumBaseMovie; import com.miz.mizuu.R; +import java.io.File; +import java.util.Locale; + public class Movie extends MediumBaseMovie { private String PLOT, TAGLINE, IMDB_ID, TRAILER; diff --git a/src/com/miz/functions/MovieLibraryUpdateCallback.java b/app/src/main/java/com/miz/functions/MovieLibraryUpdateCallback.java similarity index 100% rename from src/com/miz/functions/MovieLibraryUpdateCallback.java rename to app/src/main/java/com/miz/functions/MovieLibraryUpdateCallback.java diff --git a/app/src/main/java/com/miz/functions/MovieLoader.java b/app/src/main/java/com/miz/functions/MovieLoader.java new file mode 100644 index 00000000..ea7b8431 --- /dev/null +++ b/app/src/main/java/com/miz/functions/MovieLoader.java @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.functions; + +import android.content.Context; +import android.database.Cursor; + +import com.miz.db.DbAdapterMovies; +import com.miz.mizuu.MizuuApplication; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class MovieLoader { + + public enum MovieLibraryType { + ALL_MOVIES, + FAVORITES, + NEW_RELEASES, + WATCHLIST, + WATCHED, + UNWATCHED, + COLLECTIONS + } + + public interface OnLoadCompletedCallback { + void onLoadCompleted(List movieList); + } + + private final Context mContext; + private final MovieLibraryType mLibraryType; + private final OnLoadCompletedCallback mCallback; + private final DbAdapterMovies mDatabase; + + private MovieLoaderAsyncTask mAsyncTask; + private boolean mIgnorePrefixes = false, + mAvailableFilesOnly = false, + mOfflineFilesOnly = false; + + public MovieLoader(Context context, MovieLibraryType libraryType, OnLoadCompletedCallback callback) { + mContext = context; + mLibraryType = libraryType; + mCallback = callback; + mDatabase = MizuuApplication.getMovieAdapter(); + } + + /** + * Determine whether the MovieLoader should ignore title prefixes. + * @param ignore + */ + public void setIgnorePrefixes(boolean ignore) { + mIgnorePrefixes = ignore; + } + + /** + * Determine whether to only show available files. + * @param showAvailableFilesOnly + */ + public void setShowAvailableFiles(boolean showAvailableFilesOnly) { + mAvailableFilesOnly = showAvailableFilesOnly; + } + + public void setShowOfflineFiles(boolean showOfflineFilesOnly) { + mOfflineFilesOnly = showOfflineFilesOnly; + } + + public void load() { + if (mAsyncTask != null) { + mAsyncTask.cancel(true); + } + + mAsyncTask = new MovieLoaderAsyncTask(); + mAsyncTask.execute(); + } + + /** + * Creates movie objects from a Cursor and adds them to a list. + * @param cursor + * @return + */ + private ArrayList listFromCursor(Cursor cursor) { + ArrayList list = new ArrayList(); + + if (cursor != null) { + HashMap collectionsMap = MizuuApplication.getCollectionsAdapter().getCollectionsMap(); + ColumnIndexCache cache = new ColumnIndexCache(); + + try { + while (cursor.moveToNext()) { + list.add(new MediumMovie(mContext, + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TITLE)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TMDB_ID)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_RATING)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_RELEASEDATE)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_GENRES)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_FAVOURITE)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_ACTORS)), + collectionsMap.get(cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_COLLECTION_ID))), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_COLLECTION_ID)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TO_WATCH)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_HAS_WATCHED)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_DATE_ADDED)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_CERTIFICATION)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_RUNTIME)), + mIgnorePrefixes + )); + } + } catch (Exception e) {} finally { + cursor.close(); + cache.clear(); + } + } + + return list; + } + + private class MovieLoaderAsyncTask extends LibrarySectionAsyncTask { + + private final ArrayList mMovieList; + + public MovieLoaderAsyncTask() { + mMovieList = new ArrayList(); + } + + @Override + protected Void doInBackground(Void... params) { + switch (mLibraryType) { + case ALL_MOVIES: + mMovieList.addAll(listFromCursor(mDatabase.getAllMovies())); + break; + case COLLECTIONS: + mMovieList.addAll(listFromCursor(mDatabase.getCollections())); + break; + case FAVORITES: + break; + case NEW_RELEASES: + break; + case UNWATCHED: + break; + case WATCHED: + break; + case WATCHLIST: + break; + default: + break; + } + return null; + } + + @Override + protected void onPostExecute(Void result) { + + if (!isCancelled()) + mCallback.onLoadCompleted(mMovieList); + else + mMovieList.clear(); + } + } +} \ No newline at end of file diff --git a/src/com/miz/functions/MovieSortHelper.java b/app/src/main/java/com/miz/functions/MovieSortHelper.java similarity index 99% rename from src/com/miz/functions/MovieSortHelper.java rename to app/src/main/java/com/miz/functions/MovieSortHelper.java index 09761136..10844438 100644 --- a/src/com/miz/functions/MovieSortHelper.java +++ b/app/src/main/java/com/miz/functions/MovieSortHelper.java @@ -16,13 +16,14 @@ package com.miz.functions; +import android.text.TextUtils; + import static com.miz.functions.SortingKeys.DATE; import static com.miz.functions.SortingKeys.DURATION; import static com.miz.functions.SortingKeys.RATING; import static com.miz.functions.SortingKeys.RELEASE; import static com.miz.functions.SortingKeys.TITLE; import static com.miz.functions.SortingKeys.WEIGHTED_RATING; -import android.text.TextUtils; public class MovieSortHelper implements Comparable { diff --git a/src/com/miz/functions/NetworkFile.java b/app/src/main/java/com/miz/functions/NetworkFile.java similarity index 100% rename from src/com/miz/functions/NetworkFile.java rename to app/src/main/java/com/miz/functions/NetworkFile.java diff --git a/src/com/miz/functions/NfoMovie.java b/app/src/main/java/com/miz/functions/NfoMovie.java similarity index 100% rename from src/com/miz/functions/NfoMovie.java rename to app/src/main/java/com/miz/functions/NfoMovie.java index fb5887ad..e0b7473e 100644 --- a/src/com/miz/functions/NfoMovie.java +++ b/app/src/main/java/com/miz/functions/NfoMovie.java @@ -16,25 +16,25 @@ package com.miz.functions; -import java.io.IOException; -import java.io.InputStream; -import java.util.Locale; +import android.content.Context; +import android.text.TextUtils; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; +import com.miz.apis.tmdb.Movie; +import com.miz.db.DbAdapterMovies; +import com.miz.mizuu.MizuuApplication; +import com.squareup.picasso.Picasso; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import android.content.Context; -import android.text.TextUtils; +import java.io.IOException; +import java.io.InputStream; +import java.util.Locale; -import com.miz.apis.tmdb.Movie; -import com.miz.db.DbAdapterMovies; -import com.miz.mizuu.MizuuApplication; -import com.squareup.picasso.Picasso; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; public class NfoMovie { diff --git a/src/com/miz/functions/OkHttpDownloader.java b/app/src/main/java/com/miz/functions/OkHttpDownloader.java similarity index 99% rename from src/com/miz/functions/OkHttpDownloader.java rename to app/src/main/java/com/miz/functions/OkHttpDownloader.java index 1a7dfa1f..0cbe8ed1 100644 --- a/src/com/miz/functions/OkHttpDownloader.java +++ b/app/src/main/java/com/miz/functions/OkHttpDownloader.java @@ -15,17 +15,6 @@ */ package com.miz.functions; -import static com.miz.functions.PreferenceKeys.IGNORED_NFO_FILES; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; - -import jcifs.smb.SmbFile; import android.content.Context; import android.net.Uri; import android.preference.PreferenceManager; @@ -38,6 +27,18 @@ import com.squareup.okhttp.OkUrlFactory; import com.squareup.picasso.Downloader; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; + +import jcifs.smb.SmbFile; + +import static com.miz.functions.PreferenceKeys.IGNORED_NFO_FILES; + /** A {@link Downloader} which uses OkHttp to download images. */ public class OkHttpDownloader implements Downloader { diff --git a/app/src/main/java/com/miz/functions/PaletteLoader.java b/app/src/main/java/com/miz/functions/PaletteLoader.java new file mode 100644 index 00000000..e25cdfb2 --- /dev/null +++ b/app/src/main/java/com/miz/functions/PaletteLoader.java @@ -0,0 +1,132 @@ +package com.miz.functions; + +import android.animation.ArgbEvaluator; +import android.animation.ObjectAnimator; +import android.graphics.Color; +import android.net.Uri; +import android.support.v7.graphics.Palette; +import android.view.View; + +import com.melnykov.fab.FloatingActionButton; +import com.miz.mizuu.MizuuApplication; +import com.squareup.picasso.Picasso; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class PaletteLoader extends AsyncTask { + + private final Picasso mPicasso; + private final String mKey; + private final Uri mImage; + private final List mViews; + private final OnPaletteLoadedCallback mOnPaletteLoadedCallback; + + private FloatingActionButton mFab; + private int mSwatchColor; + + public PaletteLoader(Picasso picasso, Uri image, OnPaletteLoadedCallback callback) { + mPicasso = picasso; + mImage = image; + mKey = image.toString(); + mViews = new ArrayList(); + mOnPaletteLoadedCallback = callback; + } + + private String getPaletteKey() { + return mKey; + } + + private Uri getImage() { + return mImage; + } + + public void addView(View view) { + mViews.add(view); + } + + private List getViews() { + return mViews; + } + + public void setFab(FloatingActionButton fab) { + mFab = fab; + } + + private FloatingActionButton getFab() { + return mFab; + } + + public void clearViews() { + mViews.clear(); + mFab = null; + } + + @Override + protected Palette doInBackground(Void... params) { + Palette palette = MizuuApplication.getPalette(getPaletteKey()); + + if (palette == null) { + try { + palette = Palette.generate(mPicasso.load(getImage()).get()); + } catch (IOException e) {} + } + + return palette; + } + + @Override + protected void onPostExecute(Palette result) { + if (result != null) { + // Add it to the Palette cache + MizuuApplication.addToPaletteCache(getPaletteKey(), result); + + Palette.Swatch sw = result.getDarkVibrantSwatch(); + + if (sw == null) + sw = result.getDarkMutedSwatch(); + + if (sw == null) + sw = result.getVibrantSwatch(); + + if (sw != null) { + // Set the found color + mSwatchColor = sw.getRgb(); + + // Color the views + colorViews(); + + mOnPaletteLoadedCallback.onPaletteLoaded(getSwatchColor()); + } + } + } + + public void colorViews() { + // Animate the color change for all set views + for (View v : getViews()) + animate(v); + + // Set the FAB color, if a FAB has been set + if (getFab() != null) { + mFab.setColorNormal(getSwatchColor()); + mFab.setColorPressed(getSwatchColor()); + mFab.setColorRipple(Color.parseColor("#80ffffff")); + } + } + + private void animate(View v) { + ObjectAnimator backgroundColorAnimator = ObjectAnimator.ofObject(v, "backgroundColor", new ArgbEvaluator(), 0xFF666666, getSwatchColor()); + backgroundColorAnimator.setDuration(500); + backgroundColorAnimator.start(); + } + + public int getSwatchColor() { + return mSwatchColor; + } + + public interface OnPaletteLoadedCallback { + void onPaletteLoaded(int swatchColor); + } + +} \ No newline at end of file diff --git a/src/com/miz/functions/PaletteTransformation.java b/app/src/main/java/com/miz/functions/PaletteTransformation.java similarity index 83% rename from src/com/miz/functions/PaletteTransformation.java rename to app/src/main/java/com/miz/functions/PaletteTransformation.java index c9c7dbb0..cd65d33e 100644 --- a/src/com/miz/functions/PaletteTransformation.java +++ b/app/src/main/java/com/miz/functions/PaletteTransformation.java @@ -5,7 +5,7 @@ import android.graphics.Bitmap; import android.support.v7.graphics.Palette; import android.support.v7.graphics.Palette.PaletteAsyncListener; -import android.support.v7.graphics.PaletteItem; +import android.support.v7.graphics.Palette.Swatch; import android.view.View; import com.miz.mizuu.MizuuApplication; @@ -52,19 +52,19 @@ private void setBackgroundColor(Palette p, boolean animate) { if (mViews == null || mHasSetBackground) return; - PaletteItem pi = p.getDarkVibrantColor(); + Swatch sw = p.getDarkVibrantSwatch(); - if (pi == null) - pi = p.getDarkMutedColor(); + if (sw == null) + sw = p.getDarkMutedSwatch(); - if (pi == null) - pi = p.getVibrantColor(); + if (sw == null) + sw = p.getVibrantSwatch(); - if (pi != null) { + if (sw != null) { if (animate) { for (View v : mViews) { if (v != null) { - ObjectAnimator backgroundColorAnimator = ObjectAnimator.ofObject(v, "backgroundColor", new ArgbEvaluator(), 0xFF666666, pi.getRgb()); + ObjectAnimator backgroundColorAnimator = ObjectAnimator.ofObject(v, "backgroundColor", new ArgbEvaluator(), 0xFF666666, sw.getRgb()); backgroundColorAnimator.setDuration(500); backgroundColorAnimator.start(); } @@ -72,7 +72,7 @@ private void setBackgroundColor(Palette p, boolean animate) { } else { for (View v : mViews) if (v != null) - v.setBackgroundColor(pi.getRgb()); + v.setBackgroundColor(sw.getRgb()); } } diff --git a/src/com/miz/functions/PreferenceKeys.java b/app/src/main/java/com/miz/functions/PreferenceKeys.java similarity index 96% rename from src/com/miz/functions/PreferenceKeys.java rename to app/src/main/java/com/miz/functions/PreferenceKeys.java index 06a79337..bc3dd97c 100644 --- a/src/com/miz/functions/PreferenceKeys.java +++ b/app/src/main/java/com/miz/functions/PreferenceKeys.java @@ -76,5 +76,7 @@ private PreferenceKeys() {} // No instantiation public static final String LANGUAGE_PREFERENCE = "prefsLanguagePreference"; public static final String TV_SHOW_DATA_SOURCE = "prefsShowsDataSource"; public static final String BLUR_BACKDROPS = "prefsBlurBackdrops"; - + public static final String DVD_ORDERING = "prefsDvdOrdering"; + public static final String CHROMECAST_BETA_SUPPORT = "prefsChromecastBeta"; + } diff --git a/src/com/miz/functions/SQLiteCursorLoader.java b/app/src/main/java/com/miz/functions/SQLiteCursorLoader.java similarity index 100% rename from src/com/miz/functions/SQLiteCursorLoader.java rename to app/src/main/java/com/miz/functions/SQLiteCursorLoader.java diff --git a/src/com/miz/functions/ScheduledUpdatesAlarmManager.java b/app/src/main/java/com/miz/functions/ScheduledUpdatesAlarmManager.java similarity index 100% rename from src/com/miz/functions/ScheduledUpdatesAlarmManager.java rename to app/src/main/java/com/miz/functions/ScheduledUpdatesAlarmManager.java diff --git a/src/com/miz/functions/SmallMovie.java b/app/src/main/java/com/miz/functions/SmallMovie.java similarity index 100% rename from src/com/miz/functions/SmallMovie.java rename to app/src/main/java/com/miz/functions/SmallMovie.java index 98e1b901..2a177da4 100644 --- a/src/com/miz/functions/SmallMovie.java +++ b/app/src/main/java/com/miz/functions/SmallMovie.java @@ -16,10 +16,10 @@ package com.miz.functions; -import com.miz.abstractclasses.BaseMovie; - import android.content.Context; +import com.miz.abstractclasses.BaseMovie; + public class SmallMovie extends BaseMovie { public SmallMovie(Context context, String title, String tmdbId, boolean ignorePrefixes) { diff --git a/src/com/miz/functions/SortingKeys.java b/app/src/main/java/com/miz/functions/SortingKeys.java similarity index 100% rename from src/com/miz/functions/SortingKeys.java rename to app/src/main/java/com/miz/functions/SortingKeys.java diff --git a/src/com/miz/functions/SpinnerItem.java b/app/src/main/java/com/miz/functions/SpinnerItem.java similarity index 100% rename from src/com/miz/functions/SpinnerItem.java rename to app/src/main/java/com/miz/functions/SpinnerItem.java diff --git a/src/com/miz/functions/StartScheduledUpdatesService.java b/app/src/main/java/com/miz/functions/StartScheduledUpdatesService.java similarity index 100% rename from src/com/miz/functions/StartScheduledUpdatesService.java rename to app/src/main/java/com/miz/functions/StartScheduledUpdatesService.java diff --git a/src/com/miz/functions/TmdbTrailerSearch.java b/app/src/main/java/com/miz/functions/TmdbTrailerSearch.java similarity index 100% rename from src/com/miz/functions/TmdbTrailerSearch.java rename to app/src/main/java/com/miz/functions/TmdbTrailerSearch.java index d0d912b5..06c24d73 100644 --- a/src/com/miz/functions/TmdbTrailerSearch.java +++ b/app/src/main/java/com/miz/functions/TmdbTrailerSearch.java @@ -16,19 +16,19 @@ package com.miz.functions; -import org.json.JSONArray; -import org.json.JSONObject; +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.os.AsyncTask; +import android.widget.Toast; import com.google.android.youtube.player.YouTubeApiServiceUtil; import com.google.android.youtube.player.YouTubeInitializationResult; import com.google.android.youtube.player.YouTubeStandalonePlayer; import com.miz.mizuu.R; -import android.app.Activity; -import android.content.Intent; -import android.net.Uri; -import android.os.AsyncTask; -import android.widget.Toast; +import org.json.JSONArray; +import org.json.JSONObject; /** * Looks for trailers on TMDb for a given movie and starts playback of the first found trailer. diff --git a/src/com/miz/functions/TvShowEpisode.java b/app/src/main/java/com/miz/functions/TvShowEpisode.java similarity index 100% rename from src/com/miz/functions/TvShowEpisode.java rename to app/src/main/java/com/miz/functions/TvShowEpisode.java diff --git a/src/com/miz/functions/TvShowLibraryUpdateCallback.java b/app/src/main/java/com/miz/functions/TvShowLibraryUpdateCallback.java similarity index 100% rename from src/com/miz/functions/TvShowLibraryUpdateCallback.java rename to app/src/main/java/com/miz/functions/TvShowLibraryUpdateCallback.java diff --git a/src/com/miz/functions/TvShowSortHelper.java b/app/src/main/java/com/miz/functions/TvShowSortHelper.java similarity index 100% rename from src/com/miz/functions/TvShowSortHelper.java rename to app/src/main/java/com/miz/functions/TvShowSortHelper.java index daf36df2..29c764a0 100644 --- a/src/com/miz/functions/TvShowSortHelper.java +++ b/app/src/main/java/com/miz/functions/TvShowSortHelper.java @@ -16,15 +16,15 @@ package com.miz.functions; -import static com.miz.functions.SortingKeys.NEWEST_EPISODE; +import com.miz.mizuu.TvShow; + import static com.miz.functions.SortingKeys.DURATION; +import static com.miz.functions.SortingKeys.NEWEST_EPISODE; import static com.miz.functions.SortingKeys.RATING; import static com.miz.functions.SortingKeys.RELEASE; import static com.miz.functions.SortingKeys.TITLE; import static com.miz.functions.SortingKeys.WEIGHTED_RATING; -import com.miz.mizuu.TvShow; - public class TvShowSortHelper implements Comparable { private TvShow mTvShow; diff --git a/src/com/miz/functions/WebMovie.java b/app/src/main/java/com/miz/functions/WebMovie.java similarity index 100% rename from src/com/miz/functions/WebMovie.java rename to app/src/main/java/com/miz/functions/WebMovie.java diff --git a/src/com/miz/functions/YoutubeTrailerSearch.java b/app/src/main/java/com/miz/functions/YoutubeTrailerSearch.java similarity index 100% rename from src/com/miz/functions/YoutubeTrailerSearch.java rename to app/src/main/java/com/miz/functions/YoutubeTrailerSearch.java index 5342c923..e270c6b6 100644 --- a/src/com/miz/functions/YoutubeTrailerSearch.java +++ b/app/src/main/java/com/miz/functions/YoutubeTrailerSearch.java @@ -16,9 +16,6 @@ package com.miz.functions; -import org.json.JSONArray; -import org.json.JSONObject; - import android.app.Activity; import android.content.Intent; import android.net.Uri; @@ -30,6 +27,9 @@ import com.google.android.youtube.player.YouTubeStandalonePlayer; import com.miz.mizuu.R; +import org.json.JSONArray; +import org.json.JSONObject; + /** * Searches YouTube for a given query and starts playback of the given * @author Michell diff --git a/src/com/miz/identification/Episode.java b/app/src/main/java/com/miz/identification/Episode.java similarity index 100% rename from src/com/miz/identification/Episode.java rename to app/src/main/java/com/miz/identification/Episode.java diff --git a/src/com/miz/identification/MovieIdentification.java b/app/src/main/java/com/miz/identification/MovieIdentification.java similarity index 82% rename from src/com/miz/identification/MovieIdentification.java rename to app/src/main/java/com/miz/identification/MovieIdentification.java index 6aa3ee84..9e384b0e 100644 --- a/src/com/miz/identification/MovieIdentification.java +++ b/app/src/main/java/com/miz/identification/MovieIdentification.java @@ -16,16 +16,6 @@ package com.miz.identification; -import static com.miz.functions.PreferenceKeys.IGNORED_FILENAME_TAGS; -import static com.miz.functions.PreferenceKeys.IGNORED_NFO_FILES; -import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; - -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import android.content.Context; import android.preference.PreferenceManager; import android.text.TextUtils; @@ -41,9 +31,20 @@ import com.miz.mizuu.MizuuApplication; import com.miz.utils.FileUtils; import com.miz.utils.LocalBroadcastUtils; +import com.miz.utils.MovieDatabaseUtils; import com.miz.utils.WidgetUtils; import com.squareup.picasso.Picasso; +import java.io.File; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import static com.miz.functions.PreferenceKeys.IGNORED_FILENAME_TAGS; +import static com.miz.functions.PreferenceKeys.IGNORED_NFO_FILES; +import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; + public class MovieIdentification { private final Picasso mPicasso; @@ -54,7 +55,7 @@ public class MovieIdentification { private final HashMap mNfoFiles; private SparseBooleanArray mImdbMap = new SparseBooleanArray(); - private String mMovieId = null, mLocale = null; + private String mMovieId = null, mCurrentMovieId = null, mLocale = null; private boolean mCancel = false, mIgnoreNfoFiles = true; private int mCount = 0; @@ -85,12 +86,16 @@ private void getLanguagePreference() { * Use this to disable movie searching * and attempt identification based on the * provided movie ID. - * @param showId + * @param movieId */ public void setMovieId(String movieId) { mMovieId = movieId; } + public void setCurrentMovieId(String oldMovieId) { + mCurrentMovieId = oldMovieId; + } + private boolean overrideMovieId() { return null != getMovieId(); } @@ -99,6 +104,10 @@ private String getMovieId() { return mMovieId; } + private String getCurrentMovieId() { + return mCurrentMovieId; + } + /** * Accepts two-letter ISO 639-1 language codes, i.e. "en". * @param language @@ -187,12 +196,14 @@ public void start() { movie = service.get(getMovieId(), mLocale); } - if (movie == null && results.size() > 0) { - movie = service.get(results.get(0).getId(), mLocale); - } else { - movie = new Movie(); - movie.setId(DbAdapterMovies.UNIDENTIFIED_ID); - } + if (!overrideMovieId() && results.size() > 0) { + // Automatic library update + movie = service.get(results.get(0).getId(), mLocale); + } + + // Last check - is movie still null? + if (movie == null) + movie = new Movie(); createMovie(ms, movie); } @@ -239,74 +250,34 @@ private void addToDatabase(MovieStructure ms, Movie movie) { // Check if this is manual identification by the user if (overrideMovieId()) { - - - - - - - - - - - - - - - /** - * - * - * - * - * - * - * - * TODO FIX THIS SHIT TODO - * - * - * - * - * - * - */ - - - - - - - - - - - - - - - + + // How many filepaths are mapped to the current movie ID? + int currentCount = dbHelperMovieMapping.getMovieFilepaths(getCurrentMovieId()).size(); + + if (currentCount > 1) { + // This movie has more than one filepath mapping, so we don't want + // to remove the movie entry nor any images, etc. + + // Update the ID currently used to map the filepath to the movie + dbHelperMovieMapping.updateTmdbId(ms.getFilepath(), getCurrentMovieId(), getMovieId()); + } else { + // This movie only has one filepath mapping, i.e. the one we're + // currently re-assigning. It's safe to delete all movie data and + // create the filepath mapping for the new movie ID. + + // Delete the old movie and everything related to it + MovieDatabaseUtils.deleteMovie(mContext, getCurrentMovieId()); + + // Create the new filepath mapping + dbHelperMovieMapping.createFilepathMapping(ms.getFilepath(), getMovieId()); + } } else { // This is Mizuu's automatic library update... - - // Check if movie already exists - if (dbHelper.movieExists(movie.getId())) { - - // Get the old filepath ID before updating the mapping - String oldId = dbHelperMovieMapping.getIdForFilepath(ms.getFilepath()); - - // Update the mapping TMDb ID to the new one - dbHelperMovieMapping.updateTmdbId(ms.getFilepath(), movie.getId()); - - // Let's check if the old TMDb ID is mapped to - // any other file paths - if not, remove the movie - // entry in the movie database - if (!dbHelperMovieMapping.exists(oldId)) - dbHelper.deleteMovie(oldId); - - } else { - // The movie mapping doesn't exist - so let's create it - dbHelperMovieMapping.createFilepathMapping(ms.getFilepath(), movie.getId()); - } + + // Just create the filepath mapping - if the filepath / movie + // combination already exists, it won't do anything + dbHelperMovieMapping.createFilepathMapping(ms.getFilepath(), movie.getId()); } // Finally, create or update the movie diff --git a/src/com/miz/identification/MovieStructure.java b/app/src/main/java/com/miz/identification/MovieStructure.java similarity index 93% rename from src/com/miz/identification/MovieStructure.java rename to app/src/main/java/com/miz/identification/MovieStructure.java index 85c2500f..c86740d5 100644 --- a/src/com/miz/identification/MovieStructure.java +++ b/app/src/main/java/com/miz/identification/MovieStructure.java @@ -16,11 +16,11 @@ package com.miz.identification; +import com.miz.functions.MizLib; + import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.miz.functions.MizLib; - public class MovieStructure { private final String mFilepath; @@ -32,9 +32,10 @@ public MovieStructure(String filepath) { checkImdbId(); } - public void split() { + public void split() { Pattern splitPattern = Pattern.compile("/"); // Pre-compiled pattern to speed things up - String[] split = splitPattern.split(mFilepath.contains("") ? mFilepath.split("")[0] : mFilepath); + // UPnP files don't have an extension, so we add one in those cases in order to make everything work with titles like "G.I. Joe" + String[] split = splitPattern.split(mFilepath.contains("") ? (mFilepath.split("")[0] + ".mkv") : mFilepath); if (split.length >= 2) { mFilename = split[split.length - 1]; mParentFolder = split[split.length - 2].trim(); diff --git a/src/com/miz/identification/ShowStructure.java b/app/src/main/java/com/miz/identification/ShowStructure.java similarity index 100% rename from src/com/miz/identification/ShowStructure.java rename to app/src/main/java/com/miz/identification/ShowStructure.java index a824b611..33e70a97 100644 --- a/src/com/miz/identification/ShowStructure.java +++ b/app/src/main/java/com/miz/identification/ShowStructure.java @@ -16,14 +16,14 @@ package com.miz.identification; -import java.util.ArrayList; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import android.text.TextUtils; import com.miz.functions.MizLib; +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class ShowStructure { private final String mFilepath; diff --git a/src/com/miz/identification/TvShowIdentification.java b/app/src/main/java/com/miz/identification/TvShowIdentification.java similarity index 100% rename from src/com/miz/identification/TvShowIdentification.java rename to app/src/main/java/com/miz/identification/TvShowIdentification.java index 96e5d4a2..a56ac99e 100644 --- a/src/com/miz/identification/TvShowIdentification.java +++ b/app/src/main/java/com/miz/identification/TvShowIdentification.java @@ -16,21 +16,19 @@ package com.miz.identification; -import static com.miz.functions.PreferenceKeys.IGNORED_FILENAME_TAGS; -import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; +import android.content.Context; +import android.database.Cursor; +import android.preference.PreferenceManager; +import android.text.TextUtils; +import android.util.SparseBooleanArray; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.Multimap; import com.miz.abstractclasses.TvShowApiService; -import com.miz.apis.thetvdb.TvShow; import com.miz.apis.thetvdb.Episode; -import com.miz.db.DbAdapterTvShows; +import com.miz.apis.thetvdb.TvShow; import com.miz.db.DbAdapterTvShowEpisodes; +import com.miz.db.DbAdapterTvShows; import com.miz.functions.MizLib; import com.miz.functions.TvShowLibraryUpdateCallback; import com.miz.mizuu.MizuuApplication; @@ -39,11 +37,13 @@ import com.miz.utils.WidgetUtils; import com.squareup.picasso.Picasso; -import android.content.Context; -import android.database.Cursor; -import android.preference.PreferenceManager; -import android.text.TextUtils; -import android.util.SparseBooleanArray; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static com.miz.functions.PreferenceKeys.IGNORED_FILENAME_TAGS; +import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; public class TvShowIdentification { diff --git a/src/com/miz/mizuu/ActorBrowser.java b/app/src/main/java/com/miz/mizuu/ActorBrowser.java similarity index 71% rename from src/com/miz/mizuu/ActorBrowser.java rename to app/src/main/java/com/miz/mizuu/ActorBrowser.java index b81218e6..37e26b5d 100644 --- a/src/com/miz/mizuu/ActorBrowser.java +++ b/app/src/main/java/com/miz/mizuu/ActorBrowser.java @@ -16,17 +16,23 @@ package com.miz.mizuu; +import android.graphics.drawable.ColorDrawable; import android.os.Bundle; +import android.preference.Preference; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.view.MenuItem; import com.miz.base.MizActivity; +import com.miz.functions.IntentKeys; +import com.miz.functions.MizLib; import com.miz.mizuu.fragments.ActorBrowserFragment; +import com.miz.utils.ViewUtils; public class ActorBrowser extends MizActivity { private static String TAG = "ActorBrowserFragment"; + private int mToolbarColor; @Override public void onCreate(Bundle savedInstanceState) { @@ -34,13 +40,14 @@ public void onCreate(Bundle savedInstanceState) { String movieId = getIntent().getExtras().getString("movieId"); String title = getIntent().getExtras().getString("title"); - - getActionBar().setSubtitle(title); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); + + getSupportActionBar().setSubtitle(title); Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); if (frag == null && savedInstanceState == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(android.R.id.content, ActorBrowserFragment.newInstance(movieId), TAG); + ft.replace(R.id.content, ActorBrowserFragment.newInstance(movieId), TAG); ft.commit(); } } @@ -59,6 +66,13 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); + } + + @Override + protected int getLayoutResource() { + return R.layout.empty_layout_with_toolbar; } } diff --git a/src/com/miz/mizuu/ActorBrowserTv.java b/app/src/main/java/com/miz/mizuu/ActorBrowserTv.java similarity index 66% rename from src/com/miz/mizuu/ActorBrowserTv.java rename to app/src/main/java/com/miz/mizuu/ActorBrowserTv.java index 17d51569..98d4bdaf 100644 --- a/src/com/miz/mizuu/ActorBrowserTv.java +++ b/app/src/main/java/com/miz/mizuu/ActorBrowserTv.java @@ -6,11 +6,14 @@ import android.view.MenuItem; import com.miz.base.MizActivity; +import com.miz.functions.IntentKeys; import com.miz.mizuu.fragments.ActorBrowserTvFragment; +import com.miz.utils.ViewUtils; public class ActorBrowserTv extends MizActivity { private static String TAG = "ActorBrowserTvFragment"; + private int mToolbarColor; @Override public void onCreate(Bundle savedInstanceState) { @@ -18,13 +21,14 @@ public void onCreate(Bundle savedInstanceState) { String showId = getIntent().getExtras().getString("showId"); String title = getIntent().getExtras().getString("title"); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); - getActionBar().setSubtitle(title); + getSupportActionBar().setSubtitle(title); Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); if (frag == null && savedInstanceState == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(android.R.id.content, ActorBrowserTvFragment.newInstance(showId), TAG); + ft.replace(R.id.content, ActorBrowserTvFragment.newInstance(showId), TAG); ft.commit(); } } @@ -43,6 +47,13 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); + } + + @Override + protected int getLayoutResource() { + return R.layout.empty_layout_with_toolbar; } } diff --git a/src/com/miz/mizuu/ActorDetails.java b/app/src/main/java/com/miz/mizuu/ActorDetails.java similarity index 79% rename from src/com/miz/mizuu/ActorDetails.java rename to app/src/main/java/com/miz/mizuu/ActorDetails.java index 9abca0e1..d1a26721 100644 --- a/src/com/miz/mizuu/ActorDetails.java +++ b/app/src/main/java/com/miz/mizuu/ActorDetails.java @@ -20,11 +20,10 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.view.MenuItem; -import android.view.Window; import com.miz.base.MizActivity; -import com.miz.functions.MizLib; import com.miz.mizuu.fragments.ActorDetailsFragment; +import com.miz.utils.ViewUtils; public class ActorDetails extends MizActivity { @@ -34,17 +33,12 @@ public class ActorDetails extends MizActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (isFullscreen()) - setTheme(R.style.Mizuu_Theme_Transparent_NoBackGround_FullScreen); - else - setTheme(R.style.Mizuu_Theme_NoBackGround_Transparent); + // Set theme + setTheme(R.style.Mizuu_Theme_NoBackground); - if (MizLib.isPortrait(this)) - getWindow().setBackgroundDrawableResource(R.drawable.bg); + ViewUtils.setupWindowFlagsForStatusbarOverlay(getWindow(), isFullscreen(), true); - getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); - - setTitle(null); + setTitle(null); String actorId = getIntent().getExtras().getString("actorID"); @@ -70,6 +64,11 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } + + @Override + protected int getLayoutResource() { + return 0; } } \ No newline at end of file diff --git a/src/com/miz/mizuu/ActorMovies.java b/app/src/main/java/com/miz/mizuu/ActorMovies.java similarity index 75% rename from src/com/miz/mizuu/ActorMovies.java rename to app/src/main/java/com/miz/mizuu/ActorMovies.java index 60523eae..4614f8d1 100644 --- a/src/com/miz/mizuu/ActorMovies.java +++ b/app/src/main/java/com/miz/mizuu/ActorMovies.java @@ -22,11 +22,14 @@ import android.view.MenuItem; import com.miz.base.MizActivity; +import com.miz.functions.IntentKeys; import com.miz.mizuu.fragments.ActorMoviesFragment; +import com.miz.utils.ViewUtils; public class ActorMovies extends MizActivity { private static String TAG = "ActorMoviesFragment"; + private int mToolbarColor; @Override public void onCreate(Bundle savedInstanceState) { @@ -34,13 +37,14 @@ public void onCreate(Bundle savedInstanceState) { String actorId = getIntent().getExtras().getString("actorId"); String actorName = getIntent().getExtras().getString("actorName"); - - getActionBar().setSubtitle(actorName); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); + + getSupportActionBar().setSubtitle(actorName); Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); if (frag == null && savedInstanceState == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(android.R.id.content, ActorMoviesFragment.newInstance(actorId), TAG); + ft.replace(R.id.content, ActorMoviesFragment.newInstance(actorId), TAG); ft.commit(); } } @@ -59,6 +63,13 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); + } + + @Override + protected int getLayoutResource() { + return R.layout.empty_layout_with_toolbar; } } \ No newline at end of file diff --git a/src/com/miz/mizuu/ActorPhotos.java b/app/src/main/java/com/miz/mizuu/ActorPhotos.java similarity index 75% rename from src/com/miz/mizuu/ActorPhotos.java rename to app/src/main/java/com/miz/mizuu/ActorPhotos.java index 783568dd..e9886f2b 100644 --- a/src/com/miz/mizuu/ActorPhotos.java +++ b/app/src/main/java/com/miz/mizuu/ActorPhotos.java @@ -22,11 +22,14 @@ import android.view.MenuItem; import com.miz.base.MizActivity; +import com.miz.functions.IntentKeys; import com.miz.mizuu.fragments.ActorPhotosFragment; +import com.miz.utils.ViewUtils; public class ActorPhotos extends MizActivity { private static String TAG = "ActorPhotosFragment"; + private int mToolbarColor; @Override public void onCreate(Bundle savedInstanceState) { @@ -34,13 +37,14 @@ public void onCreate(Bundle savedInstanceState) { String actorId = getIntent().getExtras().getString("actorId"); String actorName = getIntent().getExtras().getString("actorName"); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); - getActionBar().setSubtitle(actorName); + getSupportActionBar().setSubtitle(actorName); Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); if (frag == null && savedInstanceState == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(android.R.id.content, ActorPhotosFragment.newInstance(actorId), TAG); + ft.replace(R.id.content, ActorPhotosFragment.newInstance(actorId), TAG); ft.commit(); } } @@ -59,6 +63,13 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); + } + + @Override + protected int getLayoutResource() { + return R.layout.empty_layout_with_toolbar; } } \ No newline at end of file diff --git a/src/com/miz/mizuu/ActorTaggedPhotos.java b/app/src/main/java/com/miz/mizuu/ActorTaggedPhotos.java similarity index 75% rename from src/com/miz/mizuu/ActorTaggedPhotos.java rename to app/src/main/java/com/miz/mizuu/ActorTaggedPhotos.java index 3bad6e35..feb525ba 100644 --- a/src/com/miz/mizuu/ActorTaggedPhotos.java +++ b/app/src/main/java/com/miz/mizuu/ActorTaggedPhotos.java @@ -22,11 +22,14 @@ import android.view.MenuItem; import com.miz.base.MizActivity; +import com.miz.functions.IntentKeys; import com.miz.mizuu.fragments.ActorTaggedPhotosFragment; +import com.miz.utils.ViewUtils; public class ActorTaggedPhotos extends MizActivity { private static String TAG = "ActorTaggedPhotosFragment"; + private int mToolbarColor; @Override public void onCreate(Bundle savedInstanceState) { @@ -34,13 +37,14 @@ public void onCreate(Bundle savedInstanceState) { String actorId = getIntent().getExtras().getString("actorId"); String actorName = getIntent().getExtras().getString("actorName"); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); - getActionBar().setSubtitle(actorName); + getSupportActionBar().setSubtitle(actorName); Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); if (frag == null && savedInstanceState == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(android.R.id.content, ActorTaggedPhotosFragment.newInstance(actorId), TAG); + ft.replace(R.id.content, ActorTaggedPhotosFragment.newInstance(actorId), TAG); ft.commit(); } } @@ -59,6 +63,13 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); + } + + @Override + protected int getLayoutResource() { + return R.layout.empty_layout_with_toolbar; } } \ No newline at end of file diff --git a/src/com/miz/mizuu/ActorTvShows.java b/app/src/main/java/com/miz/mizuu/ActorTvShows.java similarity index 75% rename from src/com/miz/mizuu/ActorTvShows.java rename to app/src/main/java/com/miz/mizuu/ActorTvShows.java index 7543c32c..46421aca 100644 --- a/src/com/miz/mizuu/ActorTvShows.java +++ b/app/src/main/java/com/miz/mizuu/ActorTvShows.java @@ -22,11 +22,14 @@ import android.view.MenuItem; import com.miz.base.MizActivity; +import com.miz.functions.IntentKeys; import com.miz.mizuu.fragments.ActorTvShowsFragment; +import com.miz.utils.ViewUtils; public class ActorTvShows extends MizActivity { private static String TAG = "ActorTvShowsFragment"; + private int mToolbarColor; @Override public void onCreate(Bundle savedInstanceState) { @@ -34,13 +37,14 @@ public void onCreate(Bundle savedInstanceState) { String actorId = getIntent().getExtras().getString("actorId"); String actorName = getIntent().getExtras().getString("actorName"); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); - getActionBar().setSubtitle(actorName); + getSupportActionBar().setSubtitle(actorName); Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); if (frag == null && savedInstanceState == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(android.R.id.content, ActorTvShowsFragment.newInstance(actorId), TAG); + ft.replace(R.id.content, ActorTvShowsFragment.newInstance(actorId), TAG); ft.commit(); } } @@ -59,6 +63,13 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); + } + + @Override + protected int getLayoutResource() { + return R.layout.empty_layout_with_toolbar; } } \ No newline at end of file diff --git a/src/com/miz/mizuu/AddFileSource.java b/app/src/main/java/com/miz/mizuu/AddFileSource.java similarity index 92% rename from src/com/miz/mizuu/AddFileSource.java rename to app/src/main/java/com/miz/mizuu/AddFileSource.java index 6b8c24e5..310b9e1d 100644 --- a/src/com/miz/mizuu/AddFileSource.java +++ b/app/src/main/java/com/miz/mizuu/AddFileSource.java @@ -16,11 +16,6 @@ package com.miz.mizuu; -import static com.miz.functions.MizLib.TYPE; -import static com.miz.functions.MizLib.MOVIE; -import static com.miz.functions.MizLib.TV_SHOW; -import static com.miz.functions.MizLib.FILESOURCE; - import android.content.Intent; import android.graphics.Typeface; import android.os.Bundle; @@ -33,6 +28,12 @@ import com.miz.base.MizActivity; import com.miz.functions.FileSource; +import com.miz.utils.TypefaceUtils; + +import static com.miz.functions.MizLib.FILESOURCE; +import static com.miz.functions.MizLib.MOVIE; +import static com.miz.functions.MizLib.TV_SHOW; +import static com.miz.functions.MizLib.TYPE; public class AddFileSource extends MizActivity { @@ -45,11 +46,9 @@ public class AddFileSource extends MizActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.add_file_source); - setTitle(R.string.addFileSourceTitle); - mTypeface = MizuuApplication.getOrCreateTypeface(this, "RobotoCondensed-Regular.ttf"); + mTypeface = TypefaceUtils.getRobotoCondensedRegular(this); mContentType = (TextView) findViewById(R.id.contentType); mContentType.setTypeface(mTypeface); @@ -79,11 +78,16 @@ public void onClick(View v) { } }); } + + @Override + protected int getLayoutResource() { + return R.layout.add_file_source; + } @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override diff --git a/src/com/miz/mizuu/AddNetworkFilesourceDialog.java b/app/src/main/java/com/miz/mizuu/AddNetworkFilesourceDialog.java similarity index 100% rename from src/com/miz/mizuu/AddNetworkFilesourceDialog.java rename to app/src/main/java/com/miz/mizuu/AddNetworkFilesourceDialog.java index 1142cde5..3f0bb26c 100644 --- a/src/com/miz/mizuu/AddNetworkFilesourceDialog.java +++ b/app/src/main/java/com/miz/mizuu/AddNetworkFilesourceDialog.java @@ -16,11 +16,6 @@ package com.miz.mizuu; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.TreeSet; - import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; @@ -47,14 +42,19 @@ import com.miz.functions.FileSource; import com.miz.functions.MizLib; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.TreeSet; + import static com.miz.functions.MizLib.DOMAIN; -import static com.miz.functions.MizLib.USER; +import static com.miz.functions.MizLib.FILESOURCE; +import static com.miz.functions.MizLib.MOVIE; import static com.miz.functions.MizLib.PASSWORD; import static com.miz.functions.MizLib.SERVER; -import static com.miz.functions.MizLib.TYPE; import static com.miz.functions.MizLib.TV_SHOW; -import static com.miz.functions.MizLib.MOVIE; -import static com.miz.functions.MizLib.FILESOURCE; +import static com.miz.functions.MizLib.TYPE; +import static com.miz.functions.MizLib.USER; import static com.miz.functions.PreferenceKeys.FULLSCREEN_TAG; public class AddNetworkFilesourceDialog extends Activity { diff --git a/src/com/miz/mizuu/AddUpnpFilesourceDialog.java b/app/src/main/java/com/miz/mizuu/AddUpnpFilesourceDialog.java similarity index 100% rename from src/com/miz/mizuu/AddUpnpFilesourceDialog.java rename to app/src/main/java/com/miz/mizuu/AddUpnpFilesourceDialog.java index d7db1cba..70cf21cc 100644 --- a/src/com/miz/mizuu/AddUpnpFilesourceDialog.java +++ b/app/src/main/java/com/miz/mizuu/AddUpnpFilesourceDialog.java @@ -16,20 +16,6 @@ package com.miz.mizuu; -import static com.miz.functions.MizLib.FILESOURCE; -import static com.miz.functions.MizLib.MOVIE; -import static com.miz.functions.MizLib.SERIAL_NUMBER; -import static com.miz.functions.MizLib.SERVER; -import static com.miz.functions.MizLib.TV_SHOW; -import static com.miz.functions.MizLib.TYPE; - -import org.teleal.cling.android.AndroidUpnpService; -import org.teleal.cling.model.meta.Device; -import org.teleal.cling.model.meta.LocalDevice; -import org.teleal.cling.model.meta.RemoteDevice; -import org.teleal.cling.registry.DefaultRegistryListener; -import org.teleal.cling.registry.Registry; - import android.app.Activity; import android.content.ComponentName; import android.content.Context; @@ -46,6 +32,20 @@ import com.miz.functions.FileSource; import com.miz.service.WireUpnpService; +import org.teleal.cling.android.AndroidUpnpService; +import org.teleal.cling.model.meta.Device; +import org.teleal.cling.model.meta.LocalDevice; +import org.teleal.cling.model.meta.RemoteDevice; +import org.teleal.cling.registry.DefaultRegistryListener; +import org.teleal.cling.registry.Registry; + +import static com.miz.functions.MizLib.FILESOURCE; +import static com.miz.functions.MizLib.MOVIE; +import static com.miz.functions.MizLib.SERIAL_NUMBER; +import static com.miz.functions.MizLib.SERVER; +import static com.miz.functions.MizLib.TV_SHOW; +import static com.miz.functions.MizLib.TYPE; + public class AddUpnpFilesourceDialog extends Activity { private ListView mListView; diff --git a/src/com/miz/mizuu/CancelLibraryUpdate.java b/app/src/main/java/com/miz/mizuu/CancelLibraryUpdate.java similarity index 98% rename from src/com/miz/mizuu/CancelLibraryUpdate.java rename to app/src/main/java/com/miz/mizuu/CancelLibraryUpdate.java index b7284ff5..ea958f55 100644 --- a/src/com/miz/mizuu/CancelLibraryUpdate.java +++ b/app/src/main/java/com/miz/mizuu/CancelLibraryUpdate.java @@ -32,8 +32,6 @@ public class CancelLibraryUpdate extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - setContentView(R.layout.empty_layout); final boolean isMovie = getIntent().getExtras().getBoolean("isMovie"); diff --git a/src/com/miz/mizuu/CancelOfflineDownload.java b/app/src/main/java/com/miz/mizuu/CancelOfflineDownload.java similarity index 97% rename from src/com/miz/mizuu/CancelOfflineDownload.java rename to app/src/main/java/com/miz/mizuu/CancelOfflineDownload.java index 0aa519bf..91b9e4f3 100644 --- a/src/com/miz/mizuu/CancelOfflineDownload.java +++ b/app/src/main/java/com/miz/mizuu/CancelOfflineDownload.java @@ -21,7 +21,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; - import android.support.v4.content.LocalBroadcastManager; import android.widget.Toast; @@ -31,8 +30,6 @@ public class CancelOfflineDownload extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.empty_layout); - AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(getString(R.string.areYouSure)) .setTitle(getString(R.string.stopFileDownload)) diff --git a/src/com/miz/mizuu/EditMovie.java b/app/src/main/java/com/miz/mizuu/EditMovie.java similarity index 55% rename from src/com/miz/mizuu/EditMovie.java rename to app/src/main/java/com/miz/mizuu/EditMovie.java index d679c845..5b2713d9 100644 --- a/src/com/miz/mizuu/EditMovie.java +++ b/app/src/main/java/com/miz/mizuu/EditMovie.java @@ -4,19 +4,37 @@ import android.support.v4.app.FragmentManager; import com.miz.base.MizActivity; +import com.miz.functions.IntentKeys; import com.miz.mizuu.fragments.EditMovieFragment; +import com.miz.utils.ViewUtils; public class EditMovie extends MizActivity { + private int mToolbarColor; + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String movieId = getIntent().getStringExtra("movieId"); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); + final FragmentManager fm = getSupportFragmentManager(); if (fm.findFragmentById(android.R.id.content) == null) { fm.beginTransaction().add(android.R.id.content, EditMovieFragment.newInstance(movieId)).commit(); } } + + @Override + public void onStart() { + super.onStart(); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); + } + @Override + protected int getLayoutResource() { + return 0; + } } diff --git a/src/com/miz/mizuu/EditTvShow.java b/app/src/main/java/com/miz/mizuu/EditTvShow.java similarity index 55% rename from src/com/miz/mizuu/EditTvShow.java rename to app/src/main/java/com/miz/mizuu/EditTvShow.java index 752977a8..4d37879b 100644 --- a/src/com/miz/mizuu/EditTvShow.java +++ b/app/src/main/java/com/miz/mizuu/EditTvShow.java @@ -4,19 +4,37 @@ import android.support.v4.app.FragmentManager; import com.miz.base.MizActivity; +import com.miz.functions.IntentKeys; import com.miz.mizuu.fragments.EditTvShowFragment; +import com.miz.utils.ViewUtils; public class EditTvShow extends MizActivity { + private int mToolbarColor; + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String showId = getIntent().getStringExtra("showId"); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); + final FragmentManager fm = getSupportFragmentManager(); if (fm.findFragmentById(android.R.id.content) == null) { fm.beginTransaction().add(android.R.id.content, EditTvShowFragment.newInstance(showId)).commit(); } } + + @Override + public void onStart() { + super.onStart(); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); + } + @Override + protected int getLayoutResource() { + return 0; + } } diff --git a/src/com/miz/mizuu/EditTvShowEpisode.java b/app/src/main/java/com/miz/mizuu/EditTvShowEpisode.java similarity index 92% rename from src/com/miz/mizuu/EditTvShowEpisode.java rename to app/src/main/java/com/miz/mizuu/EditTvShowEpisode.java index b8667895..17f7653a 100644 --- a/src/com/miz/mizuu/EditTvShowEpisode.java +++ b/app/src/main/java/com/miz/mizuu/EditTvShowEpisode.java @@ -21,4 +21,8 @@ public void onCreate(Bundle savedInstanceState) { } } + @Override + protected int getLayoutResource() { + return 0; + } } diff --git a/src/com/miz/mizuu/FileSourceBrowser.java b/app/src/main/java/com/miz/mizuu/FileSourceBrowser.java similarity index 84% rename from src/com/miz/mizuu/FileSourceBrowser.java rename to app/src/main/java/com/miz/mizuu/FileSourceBrowser.java index 8eb32a60..a53bbf60 100644 --- a/src/com/miz/mizuu/FileSourceBrowser.java +++ b/app/src/main/java/com/miz/mizuu/FileSourceBrowser.java @@ -16,16 +16,6 @@ package com.miz.mizuu; -import static com.miz.functions.MizLib.DOMAIN; -import static com.miz.functions.MizLib.FILESOURCE; -import static com.miz.functions.MizLib.MOVIE; -import static com.miz.functions.MizLib.PASSWORD; -import static com.miz.functions.MizLib.SERIAL_NUMBER; -import static com.miz.functions.MizLib.SERVER; -import static com.miz.functions.MizLib.TYPE; -import static com.miz.functions.MizLib.USER; -import static com.miz.functions.PreferenceKeys.HAS_SHOWN_FILEBROWSER_MESSAGE; - import android.content.Intent; import android.content.SharedPreferences.Editor; import android.os.Bundle; @@ -40,6 +30,16 @@ import com.miz.functions.FileSource; import com.miz.mizuu.fragments.FileSourceBrowserFragment; +import static com.miz.functions.MizLib.DOMAIN; +import static com.miz.functions.MizLib.FILESOURCE; +import static com.miz.functions.MizLib.MOVIE; +import static com.miz.functions.MizLib.PASSWORD; +import static com.miz.functions.MizLib.SERIAL_NUMBER; +import static com.miz.functions.MizLib.SERVER; +import static com.miz.functions.MizLib.TYPE; +import static com.miz.functions.MizLib.USER; +import static com.miz.functions.PreferenceKeys.HAS_SHOWN_FILEBROWSER_MESSAGE; + public class FileSourceBrowser extends MizActivity { private static String TAG = ""; @@ -62,13 +62,13 @@ public void onCreate(Bundle savedInstanceState) { ft.setCustomAnimations(R.anim.fade_in, R.anim.fade_out); switch (mFilesource) { case FileSource.FILE: - ft.replace(android.R.id.content, FileSourceBrowserFragment.newInstanceFile(isMovie), TAG); + ft.replace(R.id.content, FileSourceBrowserFragment.newInstanceFile(isMovie), TAG); break; case FileSource.SMB: - ft.replace(android.R.id.content, FileSourceBrowserFragment.newInstanceSmbFile(extras.getString(SERVER), extras.getString(USER), extras.getString(PASSWORD), extras.getString(DOMAIN), isMovie), TAG); + ft.replace(R.id.content, FileSourceBrowserFragment.newInstanceSmbFile(extras.getString(SERVER), extras.getString(USER), extras.getString(PASSWORD), extras.getString(DOMAIN), isMovie), TAG); break; case FileSource.UPNP: - ft.replace(android.R.id.content, FileSourceBrowserFragment.newInstanceUpnp(extras.getString(SERVER), extras.getString(SERIAL_NUMBER), isMovie), TAG); + ft.replace(R.id.content, FileSourceBrowserFragment.newInstanceUpnp(extras.getString(SERVER), extras.getString(SERIAL_NUMBER), isMovie), TAG); break; } ft.commit(); @@ -99,11 +99,16 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override public void onBackPressed() { LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent("onBackPressed")); } + + @Override + protected int getLayoutResource() { + return R.layout.empty_layout_with_toolbar; + } } \ No newline at end of file diff --git a/src/com/miz/mizuu/FileSources.java b/app/src/main/java/com/miz/mizuu/FileSources.java similarity index 96% rename from src/com/miz/mizuu/FileSources.java rename to app/src/main/java/com/miz/mizuu/FileSources.java index 0828ae30..e828c059 100644 --- a/src/com/miz/mizuu/FileSources.java +++ b/app/src/main/java/com/miz/mizuu/FileSources.java @@ -16,17 +16,12 @@ package com.miz.mizuu; -import java.util.ArrayList; - import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.database.Cursor; import android.os.Bundle; -import com.miz.base.MizActivity; -import com.miz.db.DbAdapterSources; - import android.support.v4.content.LocalBroadcastManager; import android.view.LayoutInflater; import android.view.Menu; @@ -40,7 +35,12 @@ import android.widget.ListView; import android.widget.TextView; +import com.miz.base.MizActivity; +import com.miz.db.DbAdapterSources; import com.miz.functions.FileSource; +import com.miz.utils.TypefaceUtils; + +import java.util.ArrayList; public class FileSources extends MizActivity { @@ -54,8 +54,6 @@ public class FileSources extends MizActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.filesources_layout); - mEmptyView = (LinearLayout) findViewById(R.id.noFileSources); mListView = (ListView) findViewById(R.id.listView1); @@ -68,6 +66,11 @@ public void onCreate(Bundle savedInstanceState) { LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("mizuu-filesource-change")); } + @Override + protected int getLayoutResource() { + return R.layout.filesources_layout; + } + private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -78,7 +81,7 @@ public void onReceive(Context context, Intent intent) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override @@ -211,7 +214,7 @@ public View getView(final int position, View convertView, ViewGroup parent) { convertView = mInflater.inflate(R.layout.file_source_list_header, parent, false); TextView title = (TextView) convertView.findViewById(R.id.title); title.setText(mItems.get(position).getTitle()); - title.setTypeface(MizuuApplication.getOrCreateTypeface(getApplicationContext(), "Roboto-Light.ttf")); + title.setTypeface(TypefaceUtils.getRobotoLight(getApplicationContext())); } else { convertView = mInflater.inflate(R.layout.filesource_list, parent, false); ((TextView) convertView.findViewById(R.id.txtListTitle)).setText(mItems.get(position).getTitle()); diff --git a/src/com/miz/mizuu/IdentifyMovie.java b/app/src/main/java/com/miz/mizuu/IdentifyMovie.java similarity index 76% rename from src/com/miz/mizuu/IdentifyMovie.java rename to app/src/main/java/com/miz/mizuu/IdentifyMovie.java index f1cad7ed..ff40407e 100644 --- a/src/com/miz/mizuu/IdentifyMovie.java +++ b/app/src/main/java/com/miz/mizuu/IdentifyMovie.java @@ -22,22 +22,27 @@ import android.view.MenuItem; import com.miz.base.MizActivity; +import com.miz.functions.IntentKeys; import com.miz.mizuu.fragments.IdentifyMovieFragment; +import com.miz.utils.ViewUtils; public class IdentifyMovie extends MizActivity { private static String TAG = "IdentifyMovieFragment"; + private int mToolbarColor; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String filepath = getIntent().getExtras().getString("fileName"); + String currentMovieId = getIntent().getExtras().getString("currentMovieId"); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); if (frag == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.add(android.R.id.content, IdentifyMovieFragment.newInstance(filepath), TAG); + ft.add(android.R.id.content, IdentifyMovieFragment.newInstance(filepath, currentMovieId), TAG); ft.commit(); } } @@ -56,6 +61,13 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); + } + + @Override + protected int getLayoutResource() { + return 0; } } \ No newline at end of file diff --git a/src/com/miz/mizuu/IdentifyTvShow.java b/app/src/main/java/com/miz/mizuu/IdentifyTvShow.java similarity index 81% rename from src/com/miz/mizuu/IdentifyTvShow.java rename to app/src/main/java/com/miz/mizuu/IdentifyTvShow.java index 010bc5d4..574751b5 100644 --- a/src/com/miz/mizuu/IdentifyTvShow.java +++ b/app/src/main/java/com/miz/mizuu/IdentifyTvShow.java @@ -22,11 +22,14 @@ import android.view.MenuItem; import com.miz.base.MizActivity; +import com.miz.functions.IntentKeys; import com.miz.mizuu.fragments.IdentifyTvShowFragment; +import com.miz.utils.ViewUtils; public class IdentifyTvShow extends MizActivity { private static String TAG = "IdentifyTvShowFragment"; + private int mToolbarColor; @Override public void onCreate(Bundle savedInstanceState) { @@ -34,6 +37,7 @@ public void onCreate(Bundle savedInstanceState) { String showId = getIntent().getExtras().getString("showId"); String showTitle = getIntent().getExtras().getString("showTitle"); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); if (frag == null) { @@ -57,6 +61,13 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); + } + + @Override + protected int getLayoutResource() { + return 0; } } \ No newline at end of file diff --git a/src/com/miz/mizuu/IdentifyTvShowEpisode.java b/app/src/main/java/com/miz/mizuu/IdentifyTvShowEpisode.java similarity index 93% rename from src/com/miz/mizuu/IdentifyTvShowEpisode.java rename to app/src/main/java/com/miz/mizuu/IdentifyTvShowEpisode.java index ef9f7a0a..e24d787e 100644 --- a/src/com/miz/mizuu/IdentifyTvShowEpisode.java +++ b/app/src/main/java/com/miz/mizuu/IdentifyTvShowEpisode.java @@ -16,8 +16,6 @@ package com.miz.mizuu; -import java.util.ArrayList; - import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; @@ -26,6 +24,8 @@ import com.miz.base.MizActivity; import com.miz.mizuu.fragments.IdentifyTvShowEpisodeFragment; +import java.util.ArrayList; + public class IdentifyTvShowEpisode extends MizActivity { private static String TAG = "IdentifyTvShowEpisodeFragment"; @@ -60,6 +60,11 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } + + @Override + protected int getLayoutResource() { + return 0; } } \ No newline at end of file diff --git a/src/com/miz/mizuu/ImageViewer.java b/app/src/main/java/com/miz/mizuu/ImageViewer.java similarity index 84% rename from src/com/miz/mizuu/ImageViewer.java rename to app/src/main/java/com/miz/mizuu/ImageViewer.java index 409fe0b6..9d85a132 100644 --- a/src/com/miz/mizuu/ImageViewer.java +++ b/app/src/main/java/com/miz/mizuu/ImageViewer.java @@ -22,19 +22,18 @@ import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; -import com.miz.base.MizActivity; -import com.miz.functions.MizLib; - import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.SimpleOnPageChangeListener; +import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnSystemUiVisibilityChangeListener; -import android.view.Window; +import com.miz.base.MizActivity; +import com.miz.functions.MizLib; import com.miz.mizuu.fragments.ActorPhotoFragment; import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; @@ -46,6 +45,7 @@ public class ImageViewer extends MizActivity { private String[] mPhotos; private Bus mBus; private Handler mHandler = new Handler(); + private Toolbar mToolbar; private Runnable mHideSystemUiRunnable = new Runnable() { @Override public void run() { @@ -55,7 +55,6 @@ public void run() { @Override public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); if (MizLib.hasKitKat()) { if (isFullscreen()) @@ -69,18 +68,21 @@ public void onCreate(Bundle savedInstanceState) { setTheme(R.style.Mizuu_Theme_Transparent); } - getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); + super.onCreate(savedInstanceState); - setContentView(R.layout.viewpager); + mToolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(mToolbar); + getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.transparent_actionbar)); + mBus = MizuuApplication.getBus(); - getActionBar().setBackgroundDrawable(null); + //getSupportActionBar().setBackgroundDrawable(null); mPortraitPhotos = getIntent().getBooleanExtra("portraitPhotos", true); mPhotos = getIntent().getStringArrayExtra("photos"); - setTitle((getIntent().getIntExtra("selectedIndex", 0) + 1) + " " + getString(R.string.of) + " " + mPhotos.length); + getSupportActionBar().setTitle((getIntent().getIntExtra("selectedIndex", 0) + 1) + " " + getString(R.string.of) + " " + mPhotos.length); mViewPager = (ViewPager) findViewById(R.id.awesomepager); mViewPager.setPageMargin(MizLib.convertDpToPixels(getApplicationContext(), 16)); @@ -88,7 +90,7 @@ public void onCreate(Bundle savedInstanceState) { mViewPager.setOnPageChangeListener(new SimpleOnPageChangeListener() { @Override public void onPageSelected(int arg0) { - setTitle((arg0 + 1) + " " + getString(R.string.of) + " " + mPhotos.length); + getSupportActionBar().setTitle((arg0 + 1) + " " + getString(R.string.of) + " " + mPhotos.length); } }); @@ -105,18 +107,21 @@ public void onSystemUiVisibilityChange(int visibility) { } }); } + + @Override + protected int getLayoutResource() { + return R.layout.viewpager_with_toolbar_overlay; + } @SuppressLint("InlinedApi") @Subscribe public void tappedImage(Object event) { - boolean visible = getActionBar().isShowing(); + boolean visible = getSupportActionBar().isShowing(); if (visible) { - getActionBar().hide(); hideSystemUi(); } else { showSystemUi(); - getActionBar().show(); } } @@ -130,10 +135,14 @@ private void hideSystemUi() { | View.SYSTEM_UI_FLAG_IMMERSIVE); mHandler.removeCallbacks(mHideSystemUiRunnable); + + getSupportActionBar().hide(); } private void showSystemUi() { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); + + getSupportActionBar().show(); } @Override @@ -195,6 +204,6 @@ private void openInBrowser() { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } } \ No newline at end of file diff --git a/app/src/main/java/com/miz/mizuu/Main.java b/app/src/main/java/com/miz/mizuu/Main.java new file mode 100644 index 00000000..58cf37fa --- /dev/null +++ b/app/src/main/java/com/miz/mizuu/Main.java @@ -0,0 +1,582 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.mizuu; + +import android.annotation.SuppressLint; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.SharedPreferences; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.res.Configuration; +import android.graphics.Color; +import android.graphics.Typeface; +import android.os.Bundle; +import android.preference.PreferenceActivity; +import android.preference.PreferenceManager; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; +import android.support.v4.content.LocalBroadcastManager; +import android.support.v4.view.GravityCompat; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarDrawerToggle; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +import com.miz.base.MizActivity; +import com.miz.db.DbAdapterMovies; +import com.miz.db.DbAdapterTvShows; +import com.miz.functions.MenuItem; +import com.miz.functions.MizLib; +import com.miz.mizuu.fragments.AccountsFragment; +import com.miz.mizuu.fragments.ContactDeveloperFragment; +import com.miz.mizuu.fragments.MovieDiscoveryViewPagerFragment; +import com.miz.mizuu.fragments.MovieLibraryFragment; +import com.miz.mizuu.fragments.TvShowLibraryFragment; +import com.miz.mizuu.fragments.WebVideosViewPagerFragment; +import com.miz.utils.LocalBroadcastUtils; +import com.miz.utils.TypefaceUtils; +import com.miz.utils.ViewUtils; +import com.squareup.picasso.Callback; +import com.squareup.picasso.Picasso; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import static com.miz.functions.PreferenceKeys.CONFIRM_BACK_PRESS; +import static com.miz.functions.PreferenceKeys.STARTUP_SELECTION; +import static com.miz.functions.PreferenceKeys.TRAKT_FULL_NAME; +import static com.miz.functions.PreferenceKeys.TRAKT_USERNAME; + +@SuppressLint("NewApi") +public class Main extends MizActivity { + + public static final int MOVIES = 1, SHOWS = 2, WATCHLIST = 3, WEB_MOVIES = 4, WEB_VIDEOS = 5; + private int mNumMovies, mNumShows, mNumWatchlist, selectedIndex, mStartup; + private Typeface mTfMedium, mTfCondensed, mTfRegular; + private DrawerLayout mDrawerLayout; + protected ListView mDrawerList; + private ActionBarDrawerToggle mDrawerToggle; + private DbAdapterMovies mDbHelper; + private DbAdapterTvShows mDbHelperTv; + private boolean mConfirmExit, mTriedOnce = false; + private ArrayList mMenuItems = new ArrayList(); + private List mApplicationList; + private Picasso mPicasso; + + @Override + protected int getLayoutResource() { + return R.layout.menu_drawer; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + MizuuApplication.setupTheme(this); + + mPicasso = MizuuApplication.getPicasso(getApplicationContext()); + + SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); + mConfirmExit = settings.getBoolean(CONFIRM_BACK_PRESS, false); + mStartup = Integer.valueOf(settings.getString(STARTUP_SELECTION, "1")); + + mDbHelper = MizuuApplication.getMovieAdapter(); + mDbHelperTv = MizuuApplication.getTvDbAdapter(); + + mTfCondensed = TypefaceUtils.getRobotoCondensedRegular(getApplicationContext()); + mTfMedium = TypefaceUtils.getRobotoMedium(getApplicationContext()); + mTfRegular = TypefaceUtils.getRoboto(getApplicationContext()); + + setupMenuItems(true); + + mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); + mDrawerLayout.setDrawerShadow(R.drawable.drawer_list_shadow, GravityCompat.START); + + mDrawerList = (ListView) findViewById(R.id.listView1); + mDrawerList.setLayoutParams(new LinearLayout.LayoutParams(ViewUtils.getNavigationDrawerWidth(this), LinearLayout.LayoutParams.MATCH_PARENT)); + mDrawerList.setAdapter(new MenuAdapter()); + mDrawerList.setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { + switch (mMenuItems.get(arg2).getType()) { + case MenuItem.SECTION: + loadFragment(mMenuItems.get(arg2).getFragment()); + break; + case MenuItem.THIRD_PARTY_APP: + final PackageManager pm = getPackageManager(); + Intent i = pm.getLaunchIntentForPackage(mMenuItems.get(arg2).getPackageName()); + if (i != null) { + i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(i); + } + break; + case MenuItem.SETTINGS_AREA: + + Intent smallIntent = new Intent(getApplicationContext(), Preferences.class); + if (mMenuItems.get(arg2).getIcon() == R.drawable.ic_help_grey600_24dp) { + smallIntent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, ContactDeveloperFragment.class.getName()); + smallIntent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true); + smallIntent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE, getString(R.string.menuAboutContact)); + smallIntent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_SHORT_TITLE, getString(R.string.menuAboutContact)); + } + + startActivity(smallIntent); + + mDrawerLayout.closeDrawers(); + + break; + } + } + }); + + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + + mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close); + mDrawerLayout.setDrawerListener(mDrawerToggle); + + if (savedInstanceState != null && savedInstanceState.containsKey("selectedIndex")) { + selectedIndex = savedInstanceState.getInt("selectedIndex"); + loadFragment(selectedIndex); + } else if (getIntent().getExtras() != null && getIntent().getExtras().containsKey("startup")) { + loadFragment(Integer.parseInt(getIntent().getExtras().getString("startup"))); + } else { + loadFragment(mStartup); + } + + LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.UPDATE_MOVIE_LIBRARY)); + LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.UPDATE_TV_SHOW_LIBRARY)); + } + + private void loadFragment(int type) { + if (type == 0) + type = 1; + + setTitle(null); + + Fragment frag = getSupportFragmentManager().findFragmentByTag("frag" + type); + if (frag == null) { + final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.setCustomAnimations(R.anim.fade_in, R.anim.fade_out); + switch (type) { + case MOVIES: + ft.replace(R.id.content_frame, MovieLibraryFragment.newInstance(MovieLibraryFragment.MAIN), "frag" + type); + break; + case SHOWS: + ft.replace(R.id.content_frame, TvShowLibraryFragment.newInstance(), "frag" + type); + break; + case WATCHLIST: + ft.replace(R.id.content_frame, MovieLibraryFragment.newInstance(MovieLibraryFragment.OTHER), "frag" + type); + break; + case WEB_MOVIES: + ft.replace(R.id.content_frame, MovieDiscoveryViewPagerFragment.newInstance(), "frag" + type); + break; + case WEB_VIDEOS: + ft.replace(R.id.content_frame, WebVideosViewPagerFragment.newInstance(), "frag" + type); + break; + } + ft.commit(); + } + + selectListIndex(type); + + if (mDrawerLayout != null) + mDrawerLayout.closeDrawers(); + } + + @Override + public void onNewIntent(Intent newIntent) { + super.onNewIntent(newIntent); + + if (!newIntent.hasExtra("fromUpdate")) { + Intent i = null; + if (selectedIndex == MOVIES) + i = new Intent("mizuu-movie-actor-search"); + else // TV shows + i = new Intent("mizuu-shows-actor-search"); + i.putExtras(newIntent.getExtras()); + LocalBroadcastManager.getInstance(this).sendBroadcast(i); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + + outState.putInt("selectedIndex", selectedIndex); + } + + private void setupMenuItems(boolean refreshThirdPartyApps) { + mMenuItems.clear(); + + // Menu header + mMenuItems.add(new MenuItem(null, -1, MenuItem.HEADER, null)); + + // Regular menu items + mMenuItems.add(new MenuItem(getString(R.string.drawerMyMovies), mNumMovies, MenuItem.SECTION, null, MOVIES, R.drawable.ic_movie_grey600_24dp)); + mMenuItems.add(new MenuItem(getString(R.string.drawerMyTvShows), mNumShows, MenuItem.SECTION, null, SHOWS, R.drawable.ic_tv_grey600_24dp)); + mMenuItems.add(new MenuItem(getString(R.string.chooserWatchList), mNumWatchlist, MenuItem.SECTION, null, WATCHLIST, R.drawable.ic_video_collection_grey600_24dp)); + mMenuItems.add(new MenuItem(getString(R.string.drawerOnlineMovies), -1, MenuItem.SECTION, null, WEB_MOVIES, R.drawable.ic_local_movies_grey600_24dp)); + mMenuItems.add(new MenuItem(getString(R.string.drawerWebVideos), -1, MenuItem.SECTION, null, WEB_VIDEOS, R.drawable.ic_cloud_grey600_24dp)); + + // Third party applications + final PackageManager pm = getPackageManager(); + + if (refreshThirdPartyApps) { + mApplicationList = pm.getInstalledApplications(PackageManager.GET_META_DATA); + } + + List temp = new ArrayList(); + for (int i = 0; i < mApplicationList.size(); i++) { + if (MizLib.isMediaApp(mApplicationList.get(i))) { + temp.add(new MenuItem(pm.getApplicationLabel(mApplicationList.get(i)).toString(), -1, MenuItem.THIRD_PARTY_APP, mApplicationList.get(i).packageName)); + } + } + + if (temp.size() > 0) { + // Menu section header + mMenuItems.add(new MenuItem(MenuItem.SEPARATOR)); + mMenuItems.add(new MenuItem(getString(R.string.installed_media_apps), -1, MenuItem.SUB_HEADER, null)); + } + + Collections.sort(temp, new Comparator() { + @Override + public int compare(MenuItem lhs, MenuItem rhs) { + return lhs.getTitle().compareToIgnoreCase(rhs.getTitle()); + } + }); + + for (int i = 0; i < temp.size(); i++) { + mMenuItems.add(temp.get(i)); + } + + temp.clear(); + + mMenuItems.add(new MenuItem(MenuItem.SEPARATOR_EXTRA_PADDING)); + + mMenuItems.add(new MenuItem(getString(R.string.settings_name), MenuItem.SETTINGS_AREA, R.drawable.ic_settings_grey600_24dp)); + mMenuItems.add(new MenuItem(getString(R.string.menuAboutContact), MenuItem.SETTINGS_AREA, R.drawable.ic_help_grey600_24dp)); + } + + private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + updateLibraryCounts(); + } + }; + + protected void selectListIndex(int index) { + if (mMenuItems.get(index).getType() == MenuItem.SECTION) { + selectedIndex = mMenuItems.get(index).getFragment(); + mDrawerList.setItemChecked(index, true); + } + } + + @Override + public void onResume() { + super.onResume(); + + updateLibraryCounts(); + } + + private void updateLibraryCounts() { + new Thread() { + @Override + public void run() { + try { + mNumMovies = mDbHelper.count(); + mNumWatchlist = mDbHelper.countWatchlist(); + mNumShows = mDbHelperTv.count(); + + runOnUiThread(new Runnable() { + @Override + public void run() { + setupMenuItems(false); + ((BaseAdapter) mDrawerList.getAdapter()).notifyDataSetChanged(); + } + }); + } catch (Exception e) {} + } + }.start(); + } + + @Override + public void onDestroy() { + // Unregister since the activity is about to be closed. + LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver); + + super.onDestroy(); + } + + @Override + public boolean onOptionsItemSelected(android.view.MenuItem item) { + if (mDrawerToggle.onOptionsItemSelected(item)) { + return true; + } + + switch(item.getItemId()) { + case android.R.id.home: + if (!mDrawerLayout.isDrawerOpen(mDrawerList)) { + mDrawerLayout.openDrawer(mDrawerList); + } else { + mDrawerLayout.closeDrawer(mDrawerList); + } + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + mDrawerToggle.syncState(); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + mDrawerToggle.onConfigurationChanged(newConfig); + } + + public class MenuAdapter extends BaseAdapter { + + private String mBackdropPath; + private LayoutInflater mInflater; + + public MenuAdapter() { + mInflater = LayoutInflater.from(getApplicationContext()); + mBackdropPath = MizLib.getRandomBackdropPath(getApplicationContext()); + } + + @Override + public int getCount() { + return mMenuItems.size(); + } + + @Override + public Object getItem(int position) { + return null; + } + + @Override + public long getItemId(int position) { + return 0; + } + + @Override + public int getViewTypeCount() { + return 6; + } + + @Override + public int getItemViewType(int position) { + switch (mMenuItems.get(position).getType()) { + case MenuItem.HEADER: + return 0; + case MenuItem.SEPARATOR: + return 1; + case MenuItem.SEPARATOR_EXTRA_PADDING: + return 2; + case MenuItem.SUB_HEADER: + return 3; + case MenuItem.SECTION: + case MenuItem.THIRD_PARTY_APP: + return 4; + default: + return 5; + } + } + + @Override + public boolean isEnabled(int position) { + int type = mMenuItems.get(position).getType(); + if (type == MenuItem.SEPARATOR || type == MenuItem.SEPARATOR_EXTRA_PADDING || type == MenuItem.HEADER || type == MenuItem.SUB_HEADER) + return false; + return true; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + if (mMenuItems.get(position).getType() == MenuItem.HEADER) { + convertView = mInflater.inflate(R.layout.menu_drawer_header, parent, false); + + final String fullName = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString(TRAKT_FULL_NAME, ""); + final String userName = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString(TRAKT_USERNAME, ""); + final ImageView backgroundImage = ((ImageView) convertView.findViewById(R.id.userCover)); + final ImageView userImage = ((ImageView) convertView.findViewById(R.id.userPhoto)); + final ImageView plusIcon = ((ImageView) convertView.findViewById(R.id.plus_icon)); + final TextView realName = ((TextView) convertView.findViewById(R.id.real_name)); + final TextView userNameTextField = ((TextView) convertView.findViewById(R.id.username)); + + realName.setTypeface(mTfMedium); + userNameTextField.setTypeface(mTfRegular); + + // Full name + realName.setText(!TextUtils.isEmpty(fullName) ? fullName : ""); + + // User name + if (!TextUtils.isEmpty(userName)) { + userNameTextField.setText(String.format(getString(R.string.logged_in_as), userName)); + plusIcon.setVisibility(View.GONE); + } else { + userNameTextField.setText(R.string.sign_in_with_trakt); + plusIcon.setVisibility(View.VISIBLE); + } + + // User avatar + mPicasso.load(new File(MizuuApplication.getCacheFolder(getApplicationContext()), "avatar.jpg")) + .resize(MizLib.convertDpToPixels(getApplicationContext(), 64), MizLib.convertDpToPixels(getApplicationContext(), 64)) + .into(userImage, new Callback() { + @Override + public void onError() { + userImage.setVisibility(View.GONE); + } + + @Override + public void onSuccess() {} + }); + + // Background image + if (!TextUtils.isEmpty(mBackdropPath)) + mPicasso.load(mBackdropPath).resize(MizLib.convertDpToPixels(getApplicationContext(), 320), MizLib.convertDpToPixels(getApplicationContext(), 180)).into(backgroundImage); + else + mPicasso.load(R.drawable.default_menu_backdrop).resize(MizLib.convertDpToPixels(getApplicationContext(), 320), MizLib.convertDpToPixels(getApplicationContext(), 180)).into(backgroundImage); + + // Take the user to the Trakt login screen + convertView.findViewById(R.id.personalizedArea).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent smallIntent = new Intent(getApplicationContext(), Preferences.class); + smallIntent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, AccountsFragment.class.getName()); + smallIntent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true); + smallIntent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE, getString(R.string.social)); + smallIntent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_SHORT_TITLE, getString(R.string.social)); + + startActivity(smallIntent); + } + }); + + } else if (mMenuItems.get(position).getType() == MenuItem.SEPARATOR) { + convertView = mInflater.inflate(R.layout.menu_drawer_separator, parent, false); + } else if (mMenuItems.get(position).getType() == MenuItem.SEPARATOR_EXTRA_PADDING) { + convertView = mInflater.inflate(R.layout.menu_drawer_separator_extra_padding, parent, false); + } else if (mMenuItems.get(position).getType() == MenuItem.SUB_HEADER) { + convertView = mInflater.inflate(R.layout.menu_drawer_header_item, parent, false); + TextView title = (TextView) convertView.findViewById(R.id.title); + title.setText(mMenuItems.get(position).getTitle()); + title.setTypeface(mTfMedium); + } else if (mMenuItems.get(position).getType() == MenuItem.THIRD_PARTY_APP || mMenuItems.get(position).getType() == MenuItem.SECTION) { + convertView = mInflater.inflate(R.layout.menu_drawer_item, parent, false); + + // Icon + ImageView icon = (ImageView) convertView.findViewById(R.id.icon); + icon.setImageResource(mMenuItems.get(position).getIcon()); + + // Title + TextView title = (TextView) convertView.findViewById(R.id.title); + title.setText(mMenuItems.get(position).getTitle()); + title.setTypeface(mTfMedium); + + // Description + TextView description = (TextView) convertView.findViewById(R.id.count); + description.setTypeface(mTfRegular); + + if (mMenuItems.get(position).getType() == MenuItem.SECTION && + mMenuItems.get(position).getFragment() == selectedIndex) { + convertView.setBackgroundColor(Color.parseColor("#e8e8e8")); + + int color = Color.parseColor("#3f51b5"); + + title.setTextColor(color); + description.setTextColor(color); + icon.setColorFilter(color); + } else { + int color = Color.parseColor("#DD000000"); + + title.setTextColor(color); + description.setTextColor(color); + icon.setColorFilter(Color.parseColor("#999999")); + } + + if (mMenuItems.get(position).getCount() >= 0) + description.setText(String.valueOf(mMenuItems.get(position).getCount())); + else + description.setVisibility(View.GONE); + + } else { + convertView = mInflater.inflate(R.layout.menu_drawer_small_item, parent, false); + + // Icon + ImageView icon = (ImageView) convertView.findViewById(R.id.icon); + icon.setImageResource(mMenuItems.get(position).getIcon()); + icon.setColorFilter(Color.parseColor("#737373")); + + // Title + TextView title = (TextView) convertView.findViewById(R.id.title); + title.setText(mMenuItems.get(position).getTitle()); + title.setTypeface(mTfMedium); + + } + + return convertView; + } + } + + @Override + public void onBackPressed() { + if (mStartup == 0 && !mDrawerLayout.isDrawerOpen(findViewById(R.id.left_drawer)) && MizLib.isTablet(this)) { // Welcome screen + Intent i = new Intent(Intent.ACTION_VIEW); + i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK); + i.setClass(getApplicationContext(), Welcome.class); + startActivity(i); + finish(); + return; + } + + if (!mDrawerLayout.isDrawerOpen(findViewById(R.id.left_drawer))) { + if (mConfirmExit) { + if (mTriedOnce) { + finish(); + } else { + Toast.makeText(this, getString(R.string.pressBackToExit), Toast.LENGTH_SHORT).show(); + mTriedOnce = true; + } + } else { + finish(); + } + } else { + mDrawerLayout.closeDrawers(); + } + } +} \ No newline at end of file diff --git a/src/com/miz/mizuu/MizuuApplication.java b/app/src/main/java/com/miz/mizuu/MizuuApplication.java similarity index 98% rename from src/com/miz/mizuu/MizuuApplication.java rename to app/src/main/java/com/miz/mizuu/MizuuApplication.java index 3335abb3..8bd226f4 100644 --- a/src/com/miz/mizuu/MizuuApplication.java +++ b/app/src/main/java/com/miz/mizuu/MizuuApplication.java @@ -16,20 +16,6 @@ package com.miz.mizuu; -import static com.miz.functions.PreferenceKeys.FULLSCREEN_TAG; -import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; -import static com.miz.functions.PreferenceKeys.TV_SHOW_DATA_SOURCE; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - import android.app.ActivityManager; import android.app.Application; import android.content.Context; @@ -52,6 +38,7 @@ import com.miz.db.DbAdapterTvShowEpisodes; import com.miz.db.DbAdapterTvShows; import com.miz.functions.FileRequestTransformer; +import com.miz.functions.MizLib; import com.miz.functions.OkHttpDownloader; import com.squareup.okhttp.Cache; import com.squareup.okhttp.OkHttpClient; @@ -60,6 +47,20 @@ import com.squareup.picasso.LruCache; import com.squareup.picasso.Picasso; +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import static com.miz.functions.PreferenceKeys.FULLSCREEN_TAG; +import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; +import static com.miz.functions.PreferenceKeys.TV_SHOW_DATA_SOURCE; + public class MizuuApplication extends Application { private static DbAdapterTvShows sDbTvShow; @@ -109,7 +110,9 @@ public void onCreate() { getAvailableOfflineFolder(this); transitionLocalizationPreference(); - } + + MizLib.copyDatabase(this); + } @Override public void onTerminate() { @@ -204,7 +207,7 @@ private static FileRequestTransformer getFileRequestTransformer() { private static ThreadPoolExecutor getThreadPoolExecutor() { if (sThreadPoolExecutor == null) - sThreadPoolExecutor = new ThreadPoolExecutor(2, 2, 2, TimeUnit.SECONDS, + sThreadPoolExecutor = new ThreadPoolExecutor(3, 3, 0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new PicassoThreadFactory()); return sThreadPoolExecutor; } diff --git a/src/com/miz/mizuu/MizuuDream.java b/app/src/main/java/com/miz/mizuu/MizuuDream.java similarity index 97% rename from src/com/miz/mizuu/MizuuDream.java rename to app/src/main/java/com/miz/mizuu/MizuuDream.java index ad76a0cf..7cf6f9f3 100644 --- a/src/com/miz/mizuu/MizuuDream.java +++ b/app/src/main/java/com/miz/mizuu/MizuuDream.java @@ -16,11 +16,6 @@ package com.miz.mizuu; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Random; - import android.annotation.SuppressLint; import android.database.Cursor; import android.net.Uri; @@ -29,8 +24,8 @@ import android.view.View; import android.view.ViewGroup.LayoutParams; import android.view.animation.Animation; -import android.view.animation.AnimationUtils; import android.view.animation.Animation.AnimationListener; +import android.view.animation.AnimationUtils; import android.widget.ImageSwitcher; import android.widget.ImageView; import android.widget.TextView; @@ -39,8 +34,13 @@ import com.miz.db.DbAdapterMovies; import com.miz.db.DbAdapterTvShows; import com.miz.functions.ColumnIndexCache; -import com.miz.mizuu.R; import com.miz.utils.FileUtils; +import com.miz.utils.TypefaceUtils; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Random; @SuppressLint("NewApi") public class MizuuDream extends DreamService implements ViewFactory { @@ -73,7 +73,7 @@ public void onAttachedToWindow() { setContentView(R.layout.dream); mTitle = (TextView) findViewById(R.id.title); - mTitle.setTypeface(MizuuApplication.getOrCreateTypeface(this, "RobotoCondensed-Regular.ttf")); + mTitle.setTypeface(TypefaceUtils.getRobotoCondensedRegular(this)); mDatabaseHelper = MizuuApplication.getMovieAdapter(); mDatabaseHelperTv = MizuuApplication.getTvDbAdapter(); @@ -81,7 +81,7 @@ public void onAttachedToWindow() { File temp = null; ColumnIndexCache cache = new ColumnIndexCache(); - Cursor cursor = mDatabaseHelper.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC", false); + Cursor cursor = mDatabaseHelper.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC"); while (cursor.moveToNext()) { try { temp = FileUtils.getMovieBackdrop(this, cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TMDB_ID))); diff --git a/src/com/miz/mizuu/MovieCollection.java b/app/src/main/java/com/miz/mizuu/MovieCollection.java similarity index 84% rename from src/com/miz/mizuu/MovieCollection.java rename to app/src/main/java/com/miz/mizuu/MovieCollection.java index 1fec28eb..1b30b8a1 100644 --- a/src/com/miz/mizuu/MovieCollection.java +++ b/app/src/main/java/com/miz/mizuu/MovieCollection.java @@ -19,10 +19,10 @@ import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; -import com.miz.base.MizActivity; import android.support.v4.app.FragmentTransaction; import android.view.MenuItem; +import com.miz.base.MizActivity; import com.miz.mizuu.fragments.CollectionLibraryFragment; public class MovieCollection extends MizActivity { @@ -38,7 +38,7 @@ public void onCreate(Bundle savedInstanceState) { Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); if (frag == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.add(android.R.id.content, CollectionLibraryFragment.newInstance(getIntent().getExtras().getString("collectionId"), getIntent().getExtras().getString("collectionTitle")), TAG); + ft.add(R.id.content, CollectionLibraryFragment.newInstance(getIntent().getExtras().getString("collectionId"), getIntent().getExtras().getString("collectionTitle")), TAG); ft.commit(); } @@ -59,11 +59,16 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); } + + @Override + protected int getLayoutResource() { + return R.layout.empty_layout_with_toolbar; + } } \ No newline at end of file diff --git a/app/src/main/java/com/miz/mizuu/MovieCoverFanartBrowser.java b/app/src/main/java/com/miz/mizuu/MovieCoverFanartBrowser.java new file mode 100644 index 00000000..993b2f68 --- /dev/null +++ b/app/src/main/java/com/miz/mizuu/MovieCoverFanartBrowser.java @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.mizuu; + +import android.content.Context; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; +import android.view.View; +import android.widget.ProgressBar; +import android.widget.Toast; + +import com.astuetz.PagerSlidingTabStrip; +import com.miz.base.MizActivity; +import com.miz.functions.MizLib; +import com.miz.mizuu.fragments.CollectionCoverSearchFragment; +import com.miz.mizuu.fragments.CoverSearchFragment; +import com.miz.mizuu.fragments.FanartSearchFragment; + +public class MovieCoverFanartBrowser extends MizActivity { + + private String mTmdbId, mCollectionId, mBaseUrl = "", mJson = "", mCollection = "", mTmdbApiKey; + private ViewPager mViewPager; + private ProgressBar mProgressBar; + private PagerSlidingTabStrip mTabs; + + @Override + protected int getLayoutResource() { + return R.layout.viewpager_with_toolbar_and_tabs; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + MizuuApplication.setupTheme(this); + + if (MizLib.hasLollipop()) + getSupportActionBar().setElevation(0); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + mTmdbId = getIntent().getExtras().getString("tmdbId"); + mCollectionId = getIntent().getExtras().getString("collectionId"); + mTmdbApiKey = MizLib.getTmdbApiKey(this); + + mProgressBar = (ProgressBar) findViewById(R.id.progressbar); + mProgressBar.setVisibility(View.VISIBLE); + + mViewPager = (ViewPager) findViewById(R.id.awesomepager); + mViewPager.setOffscreenPageLimit(2); + mViewPager.setPageMargin(MizLib.convertDpToPixels(this, 16)); + + mTabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); + mTabs.setVisibility(View.GONE); + + if (savedInstanceState != null) { + mJson = savedInstanceState.getString("json", ""); + mBaseUrl = savedInstanceState.getString("baseUrl"); + mCollection = savedInstanceState.getString("collection"); + setupActionBarStuff(); + + mViewPager.setCurrentItem(savedInstanceState.getInt("tab", 0)); + } else { + new MovieLoader(getApplicationContext()).execute(mTmdbId, mCollectionId); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putInt("tab", mViewPager.getCurrentItem()); + outState.putString("json", mJson); + outState.putString("baseUrl", mBaseUrl); + outState.putString("collection", mCollection); + } + + private class PagerAdapter extends FragmentPagerAdapter { + + private final String[] TITLES = {getString(R.string.coverart), getString(R.string.backdrop), getString(R.string.collectionart)}; + + public PagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public CharSequence getPageTitle(int position) { + return TITLES[position]; + } + + @Override + public Fragment getItem(int index) { + switch (index) { + case 0: + return CoverSearchFragment.newInstance(mTmdbId, mJson, mBaseUrl); + case 1: + return FanartSearchFragment.newInstance(mTmdbId, mJson, mBaseUrl); + default: + return CollectionCoverSearchFragment.newInstance(mCollectionId, mCollection, mBaseUrl); + } + } + + @Override + public int getCount() { + if (!MizLib.isValidTmdbId(mCollectionId)) + return 2; + return 3; + } + } + + private class MovieLoader extends AsyncTask { + + private Context mContext; + + public MovieLoader(Context context) { + mContext = context; + } + + @Override + protected String doInBackground(Object... params) { + try { + mBaseUrl = MizLib.getTmdbImageBaseUrl(mContext); + + mJson = MizLib.getJSONObject(mContext, "https://api.themoviedb.org/3/movie/" + params[0] + "/images?api_key=" + mTmdbApiKey).toString(); + + if (MizLib.isValidTmdbId(mCollectionId)) { + mCollection = MizLib.getJSONObject(mContext, "https://api.themoviedb.org/3/collection/" + params[1] + "/images?api_key=" + mTmdbApiKey).toString(); + } + + return mJson; + } catch (Exception e) {} // If the fragment is no longer attached to the Activity + + return null; + } + + @Override + protected void onPostExecute(String result) { + if (result != null) { + setupActionBarStuff(); + } else { + Toast.makeText(getApplicationContext(), R.string.errorSomethingWentWrong, Toast.LENGTH_SHORT).show(); + } + } + } + + private void setupActionBarStuff() { + if (!MizLib.isPortrait(getApplicationContext())) + findViewById(R.id.layout).setBackgroundResource(0); + + mProgressBar.setVisibility(View.GONE); + mViewPager.setAdapter(new PagerAdapter(getSupportFragmentManager())); + mTabs.setViewPager(mViewPager); + mTabs.setVisibility(View.VISIBLE); + } +} \ No newline at end of file diff --git a/src/com/miz/mizuu/MovieDetails.java b/app/src/main/java/com/miz/mizuu/MovieDetails.java similarity index 78% rename from src/com/miz/mizuu/MovieDetails.java rename to app/src/main/java/com/miz/mizuu/MovieDetails.java index 2d8ea756..bf65008f 100644 --- a/src/com/miz/mizuu/MovieDetails.java +++ b/app/src/main/java/com/miz/mizuu/MovieDetails.java @@ -24,14 +24,19 @@ import android.support.v4.app.FragmentTransaction; import android.view.KeyEvent; import android.view.MenuItem; -import android.view.Window; +import android.view.View; import android.widget.Toast; import com.miz.base.MizActivity; +import com.miz.functions.MediumMovie; import com.miz.functions.MizLib; +import com.miz.functions.MovieLoader; import com.miz.mizuu.fragments.MovieDetailsFragment; +import com.miz.utils.ViewUtils; import com.miz.utils.WidgetUtils; +import java.util.List; + public class MovieDetails extends MizActivity { private static String TAG = "MovieDetailsFragment"; @@ -39,18 +44,12 @@ public class MovieDetails extends MizActivity { @Override public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - if (isFullscreen()) - setTheme(R.style.Mizuu_Theme_Transparent_NoBackGround_FullScreen); - else - setTheme(R.style.Mizuu_Theme_NoBackGround_Transparent); + super.onCreate(savedInstanceState); - if (MizLib.isPortrait(this)) { - getWindow().setBackgroundDrawableResource(R.drawable.bg); - } + // Set theme + setTheme(R.style.Mizuu_Theme_NoBackground); - getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); + ViewUtils.setupWindowFlagsForStatusbarOverlay(getWindow(), isFullscreen(), true); setTitle(null); @@ -67,8 +66,18 @@ public void onCreate(Bundle savedInstanceState) { ft.add(android.R.id.content, MovieDetailsFragment.newInstance(mMovieId), TAG); ft.commit(); } + + MovieLoader loader = new MovieLoader(this, MovieLoader.MovieLibraryType.ALL_MOVIES, callback); + loader.load(); } + private MovieLoader.OnLoadCompletedCallback callback = new MovieLoader.OnLoadCompletedCallback() { + @Override + public void onLoadCompleted(List movieList) { + System.out.println("SIZE: " + movieList.size()); + } + }; + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { @@ -83,13 +92,13 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); - + if (requestCode == 0) { if (resultCode == Activity.RESULT_OK) { finish(); @@ -126,4 +135,9 @@ public boolean onKeyDown(int keyCode, KeyEvent event) { } return super.onKeyDown(keyCode, event); } + + @Override + protected int getLayoutResource() { + return 0; + } } \ No newline at end of file diff --git a/src/com/miz/mizuu/Preferences.java b/app/src/main/java/com/miz/mizuu/Preferences.java similarity index 87% rename from src/com/miz/mizuu/Preferences.java rename to app/src/main/java/com/miz/mizuu/Preferences.java index e496022d..eef47139 100644 --- a/src/com/miz/mizuu/Preferences.java +++ b/app/src/main/java/com/miz/mizuu/Preferences.java @@ -16,26 +16,27 @@ package com.miz.mizuu; -import java.util.List; - import android.os.Bundle; import android.preference.PreferenceActivity; +import android.support.v7.widget.Toolbar; import android.view.MenuItem; +import java.util.List; + public class Preferences extends PreferenceActivity { - + + private Toolbar mToolbar; + @Override public void onCreate(Bundle savedInstanceState) { - if (MizuuApplication.isFullscreen(this)) - setTheme(R.style.Mizuu_Theme_FullScreen); - else - setTheme(R.style.Mizuu_Theme); - + + setTheme(R.style.Mizuu_Theme_Preference); + super.onCreate(savedInstanceState); - + getActionBar().setDisplayHomeAsUpEnabled(true); } - + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { @@ -46,12 +47,12 @@ public boolean onOptionsItemSelected(MenuItem item) { return super.onOptionsItemSelected(item); } } - + @Override - public void onBuildHeaders(List

target) { + public void onBuildHeaders(List
target) { loadHeadersFromResource(R.xml.preference_headers, target); } - + @Override protected boolean isValidFragment(String fragmentName) { return true; diff --git a/src/com/miz/mizuu/SearchForNetworkShares.java b/app/src/main/java/com/miz/mizuu/SearchForNetworkShares.java similarity index 100% rename from src/com/miz/mizuu/SearchForNetworkShares.java rename to app/src/main/java/com/miz/mizuu/SearchForNetworkShares.java index e391f67f..0acc565a 100644 --- a/src/com/miz/mizuu/SearchForNetworkShares.java +++ b/app/src/main/java/com/miz/mizuu/SearchForNetworkShares.java @@ -16,11 +16,6 @@ package com.miz.mizuu; -import java.util.ArrayList; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -37,6 +32,11 @@ import android.widget.ProgressBar; import android.widget.TextView; +import java.util.ArrayList; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + public class SearchForNetworkShares extends Activity { private ListView list; diff --git a/src/com/miz/mizuu/SearchWebMovies.java b/app/src/main/java/com/miz/mizuu/SearchWebMovies.java similarity index 89% rename from src/com/miz/mizuu/SearchWebMovies.java rename to app/src/main/java/com/miz/mizuu/SearchWebMovies.java index a0ee5929..29c4ab4c 100644 --- a/src/com/miz/mizuu/SearchWebMovies.java +++ b/app/src/main/java/com/miz/mizuu/SearchWebMovies.java @@ -18,10 +18,10 @@ import android.os.Bundle; import android.support.v4.app.Fragment; -import com.miz.base.MizActivity; import android.support.v4.app.FragmentTransaction; import android.view.MenuItem; +import com.miz.base.MizActivity; import com.miz.mizuu.fragments.SearchWebMoviesFragment; public class SearchWebMovies extends MizActivity { @@ -50,10 +50,15 @@ public boolean onOptionsItemSelected(MenuItem item) { return super.onOptionsItemSelected(item); } } + + @Override + public void onStart() { + super.onStart(); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } @Override - public void onStart() { - super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + protected int getLayoutResource() { + return 0; } } \ No newline at end of file diff --git a/app/src/main/java/com/miz/mizuu/ShowCoverFanartBrowser.java b/app/src/main/java/com/miz/mizuu/ShowCoverFanartBrowser.java new file mode 100644 index 00000000..2a201a9e --- /dev/null +++ b/app/src/main/java/com/miz/mizuu/ShowCoverFanartBrowser.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.mizuu; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; +import android.view.View; +import android.widget.ProgressBar; + +import com.astuetz.PagerSlidingTabStrip; +import com.miz.base.MizActivity; +import com.miz.functions.MizLib; +import com.miz.mizuu.fragments.CoverSearchFragmentTv; +import com.miz.mizuu.fragments.FanartSearchFragmentTv; + +public class ShowCoverFanartBrowser extends MizActivity { + + private String tvdbId; + private ViewPager mViewPager; + private ProgressBar mProgressBar; + private PagerSlidingTabStrip mTabs; + + @Override + protected int getLayoutResource() { + return R.layout.viewpager_with_toolbar_and_tabs; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + MizuuApplication.setupTheme(this); + + if (MizLib.hasLollipop()) + getSupportActionBar().setElevation(0); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + tvdbId = getIntent().getExtras().getString("id"); + + mProgressBar = (ProgressBar) findViewById(R.id.progressbar); + mProgressBar.setVisibility(View.VISIBLE); + + mViewPager = (ViewPager) findViewById(R.id.awesomepager); + mViewPager.setOffscreenPageLimit(2); + mViewPager.setPageMargin(MizLib.convertDpToPixels(this, 16)); + + mTabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); + mTabs.setVisibility(View.GONE); + + setupActionBarStuff(); + + if (savedInstanceState != null) { + mViewPager.setCurrentItem(savedInstanceState.getInt("tab", 0)); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putInt("tab", mViewPager.getCurrentItem()); + } + + private void setupActionBarStuff() { + if (!MizLib.isPortrait(getApplicationContext())) + findViewById(R.id.layout).setBackgroundResource(0); + + mProgressBar.setVisibility(View.GONE); + mViewPager.setAdapter(new PagerAdapter(getSupportFragmentManager())); + mTabs.setViewPager(mViewPager); + mTabs.setVisibility(View.VISIBLE); + } + + private class PagerAdapter extends FragmentPagerAdapter { + + private final String[] TITLES = {getString(R.string.coverart), getString(R.string.backdrop)}; + + public PagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public CharSequence getPageTitle(int position) { + return TITLES[position]; + } + + @Override + public Fragment getItem(int index) { + switch (index) { + case 0: + return CoverSearchFragmentTv.newInstance(tvdbId); + default: + return FanartSearchFragmentTv.newInstance(tvdbId); + } + } + + @Override + public int getCount() { + return 2; + } + } +} \ No newline at end of file diff --git a/src/com/miz/mizuu/SimilarMovies.java b/app/src/main/java/com/miz/mizuu/SimilarMovies.java similarity index 65% rename from src/com/miz/mizuu/SimilarMovies.java rename to app/src/main/java/com/miz/mizuu/SimilarMovies.java index d7652b4b..c094f7aa 100644 --- a/src/com/miz/mizuu/SimilarMovies.java +++ b/app/src/main/java/com/miz/mizuu/SimilarMovies.java @@ -6,11 +6,14 @@ import android.view.MenuItem; import com.miz.base.MizActivity; +import com.miz.functions.IntentKeys; import com.miz.mizuu.fragments.SimilarMoviesFragment; +import com.miz.utils.ViewUtils; public class SimilarMovies extends MizActivity { private static String TAG = "SimilarMoviesFragment"; + private int mToolbarColor; @Override public void onCreate(Bundle savedInstanceState) { @@ -18,13 +21,14 @@ public void onCreate(Bundle savedInstanceState) { String movieId = getIntent().getExtras().getString("movieId"); String title = getIntent().getExtras().getString("title"); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); - getActionBar().setSubtitle(title); + getSupportActionBar().setSubtitle(title); Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); if (frag == null && savedInstanceState == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(android.R.id.content, SimilarMoviesFragment.newInstance(movieId), TAG); + ft.replace(R.id.content, SimilarMoviesFragment.newInstance(movieId), TAG); ft.commit(); } } @@ -43,6 +47,13 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); + } + + @Override + protected int getLayoutResource() { + return R.layout.empty_layout_with_toolbar; } } diff --git a/src/com/miz/mizuu/SplashScreen.java b/app/src/main/java/com/miz/mizuu/SplashScreen.java similarity index 97% rename from src/com/miz/mizuu/SplashScreen.java rename to app/src/main/java/com/miz/mizuu/SplashScreen.java index 023ef6a6..083c9cc0 100644 --- a/src/com/miz/mizuu/SplashScreen.java +++ b/app/src/main/java/com/miz/mizuu/SplashScreen.java @@ -16,9 +16,7 @@ package com.miz.mizuu; -import java.io.IOException; -import java.util.Locale; - +import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; @@ -26,7 +24,6 @@ import android.preference.PreferenceManager; import android.widget.Toast; -import com.miz.base.MizActivity; import com.miz.functions.MizLib; import com.miz.mizuu.fragments.ScheduledUpdatesFragment; import com.miz.service.MoveFilesService; @@ -34,13 +31,16 @@ import com.miz.service.TvShowsLibraryUpdate; import com.miz.utils.FileUtils; +import java.io.IOException; +import java.util.Locale; + +import static com.miz.functions.PreferenceKeys.ROOT_ACCESS; import static com.miz.functions.PreferenceKeys.SCHEDULED_UPDATES_MOVIE; import static com.miz.functions.PreferenceKeys.SCHEDULED_UPDATES_TVSHOWS; -import static com.miz.functions.PreferenceKeys.ROOT_ACCESS; import static com.miz.functions.PreferenceKeys.STARTUP_SELECTION; import static com.miz.functions.PreferenceKeys.USE_ENGLISH_LANGUAGE; -public class SplashScreen extends MizActivity { +public class SplashScreen extends Activity { @Override public void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/com/miz/mizuu/TMDbMovieDetails.java b/app/src/main/java/com/miz/mizuu/TMDbMovieDetails.java new file mode 100644 index 00000000..c6856182 --- /dev/null +++ b/app/src/main/java/com/miz/mizuu/TMDbMovieDetails.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.mizuu; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; + +import com.miz.base.MizActivity; +import com.miz.mizuu.fragments.TmdbMovieDetailsFragment; +import com.miz.utils.ViewUtils; + +public class TMDbMovieDetails extends MizActivity { + + private static String TAG = "TmdbMovieDetailsFragment"; + private String mMovieId; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Set theme + setTheme(R.style.Mizuu_Theme_NoBackground); + + ViewUtils.setupWindowFlagsForStatusbarOverlay(getWindow(), isFullscreen(), true); + + setTitle(null); + + mMovieId = getIntent().getExtras().getString("tmdbId"); + + Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); + if (frag == null) { + final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.add(android.R.id.content, TmdbMovieDetailsFragment.newInstance(mMovieId), TAG); + ft.commit(); + } + } + + @Override + protected int getLayoutResource() { + return 0; + } +} \ No newline at end of file diff --git a/src/com/miz/mizuu/TvShow.java b/app/src/main/java/com/miz/mizuu/TvShow.java similarity index 100% rename from src/com/miz/mizuu/TvShow.java rename to app/src/main/java/com/miz/mizuu/TvShow.java index d28bf6a5..98816139 100644 --- a/src/com/miz/mizuu/TvShow.java +++ b/app/src/main/java/com/miz/mizuu/TvShow.java @@ -16,9 +16,6 @@ package com.miz.mizuu; -import java.io.File; -import java.util.Locale; - import android.content.Context; import android.text.TextUtils; @@ -27,6 +24,9 @@ import com.miz.utils.FileUtils; import com.miz.utils.StringUtils; +import java.io.File; +import java.util.Locale; + public class TvShow implements Comparable { private Context mContext; diff --git a/src/com/miz/mizuu/TvShowActorSearchActivity.java b/app/src/main/java/com/miz/mizuu/TvShowActorSearchActivity.java similarity index 100% rename from src/com/miz/mizuu/TvShowActorSearchActivity.java rename to app/src/main/java/com/miz/mizuu/TvShowActorSearchActivity.java diff --git a/app/src/main/java/com/miz/mizuu/TvShowDetails.java b/app/src/main/java/com/miz/mizuu/TvShowDetails.java new file mode 100644 index 00000000..e3222e6d --- /dev/null +++ b/app/src/main/java/com/miz/mizuu/TvShowDetails.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.mizuu; + +import android.app.Activity; +import android.app.SearchManager; +import android.content.Intent; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; +import android.view.MenuItem; +import android.view.View; +import android.widget.Toast; + +import com.miz.base.MizActivity; +import com.miz.functions.MizLib; +import com.miz.mizuu.fragments.TvShowDetailsFragment; +import com.miz.utils.ViewUtils; + +public class TvShowDetails extends MizActivity { + + private static String TAG = "TvShowDetailsFragment"; + private String mShowId; + + @Override + protected int getLayoutResource() { + return 0; + } + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Set theme + setTheme(R.style.Mizuu_Theme_NoBackground); + + ViewUtils.setupWindowFlagsForStatusbarOverlay(getWindow(), isFullscreen(), true); + + setTitle(null); + + // Fetch the database ID of the TV show to view + if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) { + mShowId = getIntent().getStringExtra(SearchManager.EXTRA_DATA_KEY); + } else { + mShowId = getIntent().getStringExtra("showId"); + } + + Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); + if (frag == null) { + final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.add(android.R.id.content, TvShowDetailsFragment.newInstance(mShowId), TAG); + ft.commit(); + } + } + + @Override + public void onStart() { + super.onStart(); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + onBackPressed(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == 0) { + if (resultCode == Activity.RESULT_OK) { + finish(); + } + } else if (requestCode == 1) { + if (resultCode == Activity.RESULT_OK) { + Toast.makeText(this, getString(R.string.updatedTvShow), Toast.LENGTH_SHORT).show(); + + // Create a new Intent with the Bundle + Intent intent = new Intent(); + intent.setClass(getApplicationContext(), TvShowDetails.class); + intent.putExtra("showId", mShowId); + + // Start the Intent for result + startActivity(intent); + + finish(); + return; + } + } + } +} \ No newline at end of file diff --git a/src/com/miz/mizuu/TvShowEpisode.java b/app/src/main/java/com/miz/mizuu/TvShowEpisode.java similarity index 100% rename from src/com/miz/mizuu/TvShowEpisode.java rename to app/src/main/java/com/miz/mizuu/TvShowEpisode.java index df7bb823..9dd1962d 100644 --- a/src/com/miz/mizuu/TvShowEpisode.java +++ b/app/src/main/java/com/miz/mizuu/TvShowEpisode.java @@ -16,11 +16,6 @@ package com.miz.mizuu; -import static com.miz.functions.PreferenceKeys.TVSHOWS_EPISODE_ORDER; - -import java.io.File; -import java.util.ArrayList; - import android.content.Context; import android.preference.PreferenceManager; import android.text.TextUtils; @@ -30,6 +25,11 @@ import com.miz.utils.FileUtils; import com.miz.utils.StringUtils; +import java.io.File; +import java.util.ArrayList; + +import static com.miz.functions.PreferenceKeys.TVSHOWS_EPISODE_ORDER; + public class TvShowEpisode implements Comparable { private Context mContext; diff --git a/src/com/miz/mizuu/TvShowEpisodeDetails.java b/app/src/main/java/com/miz/mizuu/TvShowEpisodeDetails.java similarity index 93% rename from src/com/miz/mizuu/TvShowEpisodeDetails.java rename to app/src/main/java/com/miz/mizuu/TvShowEpisodeDetails.java index 297e829a..20130fff 100644 --- a/src/com/miz/mizuu/TvShowEpisodeDetails.java +++ b/app/src/main/java/com/miz/mizuu/TvShowEpisodeDetails.java @@ -16,8 +16,6 @@ package com.miz.mizuu; -import java.util.ArrayList; - import android.app.ActionBar; import android.app.Activity; import android.content.Intent; @@ -33,8 +31,6 @@ import android.view.MenuItem; import android.view.View; import android.view.Window; -import android.widget.FrameLayout; -import android.widget.FrameLayout.LayoutParams; import android.widget.ImageView; import com.miz.base.MizActivity; @@ -44,6 +40,8 @@ import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; +import java.util.ArrayList; + public class TvShowEpisodeDetails extends MizActivity { private static final String SHOW_ID = "showId"; @@ -58,16 +56,19 @@ public class TvShowEpisodeDetails extends MizActivity { private ImageView mActionBarOverlay; private ActionBar mActionBar; + @Override + protected int getLayoutResource() { + return R.layout.viewpager; + } + @Override public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - mBus = MizuuApplication.getBus(); if (isFullscreen()) - setTheme(R.style.Mizuu_Theme_Transparent_NoBackGround_FullScreen); + setTheme(R.style.Mizuu_Theme_NoBackground_FullScreen); else - setTheme(R.style.Mizuu_Theme_NoBackGround_Transparent); + setTheme(R.style.Mizuu_Theme_NoBackground); if (MizLib.isPortrait(this)) { getWindow().setBackgroundDrawableResource(R.drawable.bg); @@ -75,13 +76,10 @@ public void onCreate(Bundle savedInstanceState) { getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); - setContentView(R.layout.viewpager); - + super.onCreate(savedInstanceState); + mActionBar = getActionBar(); - mActionBarOverlay = (ImageView) findViewById(R.id.actionbar_overlay); - mActionBarOverlay.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, isFullscreen() ? MizLib.getActionBarHeight(this) : MizLib.getActionBarAndStatusBarHeight(this))); - mShowId = getIntent().getExtras().getString(SHOW_ID); mSeason = getIntent().getExtras().getInt("season"); mEpisode = getIntent().getExtras().getInt("episode"); diff --git a/src/com/miz/mizuu/TvShowEpisodes.java b/app/src/main/java/com/miz/mizuu/TvShowEpisodes.java similarity index 81% rename from src/com/miz/mizuu/TvShowEpisodes.java rename to app/src/main/java/com/miz/mizuu/TvShowEpisodes.java index d079aa20..e0c47e3f 100644 --- a/src/com/miz/mizuu/TvShowEpisodes.java +++ b/app/src/main/java/com/miz/mizuu/TvShowEpisodes.java @@ -16,12 +16,6 @@ package com.miz.mizuu; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -37,9 +31,17 @@ import com.miz.base.MizActivity; import com.miz.functions.EpisodeCounter; import com.miz.functions.GridSeason; +import com.miz.functions.IntentKeys; import com.miz.functions.LibrarySectionAsyncTask; import com.miz.mizuu.fragments.TvShowEpisodesFragment; import com.miz.utils.FileUtils; +import com.miz.utils.ViewUtils; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; public class TvShowEpisodes extends MizActivity { @@ -54,16 +56,20 @@ public class TvShowEpisodes extends MizActivity { private SeasonAdapter mSeasonAdapter; private List mItems = new ArrayList(); private ProgressBar mProgressBar; + private int mToolbarColor; + + @Override + protected int getLayoutResource() { + return R.layout.viewpager_with_toolbar; + } @Override public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - MizuuApplication.setupTheme(this); - mContext = this; + super.onCreate(savedInstanceState); - setContentView(R.layout.viewpager); + mContext = this; mProgressBar = (ProgressBar) findViewById(R.id.progressbar); @@ -73,7 +79,7 @@ public void onCreate(Bundle savedInstanceState) { @Override public void onPageSelected(int position) { int episodeCount = mItems.get(position).getEpisodeCount(); - getActionBar().setSubtitle(getString(R.string.showSeason) + " " + mItems.get(position).getSeason() + " (" + episodeCount + " " + getResources().getQuantityString(R.plurals.episodes, episodeCount, episodeCount) + ")"); + getSupportActionBar().setSubtitle(getString(R.string.showSeason) + " " + mItems.get(position).getSeason() + " (" + episodeCount + " " + getResources().getQuantityString(R.plurals.episodes, episodeCount, episodeCount) + ")"); } }); @@ -81,9 +87,10 @@ public void onPageSelected(int position) { mTitle = MizuuApplication.getTvDbAdapter().getShowTitle(mShowId); mSeason = getIntent().getExtras().getInt(SEASON); mEpisodeCount = getIntent().getExtras().getInt(EPISODE_COUNT); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); setTitle(mTitle); - getActionBar().setSubtitle(getString(R.string.showSeason) + " " + mSeason + " (" + mEpisodeCount + " " + getResources().getQuantityString(R.plurals.episodes, mEpisodeCount, mEpisodeCount) + ")"); + getSupportActionBar().setSubtitle(getString(R.string.showSeason) + " " + mSeason + " (" + mEpisodeCount + " " + getResources().getQuantityString(R.plurals.episodes, mEpisodeCount, mEpisodeCount) + ")"); loadSeasons(); } @@ -102,7 +109,9 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); } public class SeasonAdapter extends FragmentPagerAdapter { @@ -141,7 +150,7 @@ protected Void doInBackground(Void... params) { File temp = null; for (String key : seasons.keySet()) { temp = FileUtils.getTvShowSeason(mContext, mShowId, key); - mItems.add(new GridSeason(mContext, Integer.valueOf(key), seasons.get(key).getEpisodeCount(), seasons.get(key).getWatchedCount(), + mItems.add(new GridSeason(mContext, mShowId, Integer.valueOf(key), seasons.get(key).getEpisodeCount(), seasons.get(key).getWatchedCount(), temp.exists() ? temp : FileUtils.getTvShowThumb(mContext, mShowId))); } diff --git a/app/src/main/java/com/miz/mizuu/TvShowSeasons.java b/app/src/main/java/com/miz/mizuu/TvShowSeasons.java new file mode 100644 index 00000000..5f7c270d --- /dev/null +++ b/app/src/main/java/com/miz/mizuu/TvShowSeasons.java @@ -0,0 +1,89 @@ +package com.miz.mizuu;/* + * Copyright (C) 2014 Michell Bak + * + * 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. + */ + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; +import android.view.MenuItem; +import android.view.View; + +import com.miz.base.MizActivity; +import com.miz.functions.IntentKeys; +import com.miz.functions.MizLib; +import com.miz.mizuu.fragments.TvShowSeasonsFragment; +import com.miz.utils.ViewUtils; + +public class TvShowSeasons extends MizActivity { + + private static String TAG = "TvShowDetailsFragment"; + private String mShowId; + private int mToolbarColor; + + @Override + protected int getLayoutResource() { + return R.layout.empty_layout_with_toolbar; + } + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + + if (isFullscreen()) + setTheme(R.style.Mizuu_Theme_NoBackground_FullScreen); + else + setTheme(R.style.Mizuu_Theme_NoBackground); + + if (MizLib.isPortrait(this)) { + getWindow().setBackgroundDrawableResource(R.drawable.bg); + } + + setTitle(getIntent().getStringExtra("showTitle")); + mShowId = getIntent().getStringExtra("showId"); + mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR); + + int count = MizuuApplication.getTvEpisodeDbAdapter().getSeasonCount(mShowId); + getSupportActionBar().setSubtitle(count + " " + getResources().getQuantityString(R.plurals.seasons, count, count)); + + Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); + if (frag == null) { + final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.add(R.id.content, TvShowSeasonsFragment.newInstance(mShowId, MizLib.isTablet(this) && !MizLib.isPortrait(this), mToolbarColor), TAG); + ft.commit(); + } + } + + @Override + public void onStart() { + super.onStart(); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + ViewUtils.setToolbarAndStatusBarColor(getSupportActionBar(), getWindow(), mToolbarColor); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + onBackPressed(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + +} diff --git a/src/com/miz/mizuu/UnidentifiedMovies.java b/app/src/main/java/com/miz/mizuu/UnidentifiedMovies.java similarity index 96% rename from src/com/miz/mizuu/UnidentifiedMovies.java rename to app/src/main/java/com/miz/mizuu/UnidentifiedMovies.java index 43a411dd..6772fb44 100644 --- a/src/com/miz/mizuu/UnidentifiedMovies.java +++ b/app/src/main/java/com/miz/mizuu/UnidentifiedMovies.java @@ -16,8 +16,6 @@ package com.miz.mizuu; -import java.util.ArrayList; - import android.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.Context; @@ -26,13 +24,8 @@ import android.content.IntentFilter; import android.database.Cursor; import android.os.Bundle; -import com.miz.base.MizActivity; -import com.miz.db.DbAdapterMovieMappings; -import com.miz.functions.Filepath; -import com.miz.utils.LocalBroadcastUtils; -import com.miz.utils.MovieDatabaseUtils; - import android.support.v4.content.LocalBroadcastManager; +import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -44,17 +37,28 @@ import android.widget.ListView; import android.widget.TextView; +import com.miz.base.MizActivity; +import com.miz.db.DbAdapterMovieMappings; +import com.miz.functions.Filepath; +import com.miz.utils.LocalBroadcastUtils; +import com.miz.utils.MovieDatabaseUtils; + +import java.util.ArrayList; + public class UnidentifiedMovies extends MizActivity { private ArrayList mFilepaths = new ArrayList(); private ListView mList; + @Override + protected int getLayoutResource() { + return R.layout.unidentified_files_layout; + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.unidentified_files_layout); - mList = (ListView) findViewById(R.id.listView1); mList.setChoiceMode(ListView.CHOICE_MODE_NONE); mList.setOnItemClickListener(new OnItemClickListener() { @@ -151,7 +155,8 @@ public void onClick(DialogInterface dialog, int id) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } static class ViewHolder { diff --git a/src/com/miz/mizuu/UnidentifiedTvShows.java b/app/src/main/java/com/miz/mizuu/UnidentifiedTvShows.java similarity index 98% rename from src/com/miz/mizuu/UnidentifiedTvShows.java rename to app/src/main/java/com/miz/mizuu/UnidentifiedTvShows.java index a6af6a66..be1f44f6 100644 --- a/src/com/miz/mizuu/UnidentifiedTvShows.java +++ b/app/src/main/java/com/miz/mizuu/UnidentifiedTvShows.java @@ -16,8 +16,6 @@ package com.miz.mizuu; -import java.util.ArrayList; - import android.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.Context; @@ -26,12 +24,6 @@ import android.content.IntentFilter; import android.database.Cursor; import android.os.Bundle; -import com.miz.base.MizActivity; -import com.miz.db.DbAdapterTvShowEpisodeMappings; -import com.miz.functions.Filepath; -import com.miz.utils.LocalBroadcastUtils; -import com.miz.utils.TvShowDatabaseUtils; - import android.support.v4.content.LocalBroadcastManager; import android.util.SparseBooleanArray; import android.view.ActionMode; @@ -48,17 +40,28 @@ import android.widget.ListView; import android.widget.TextView; +import com.miz.base.MizActivity; +import com.miz.db.DbAdapterTvShowEpisodeMappings; +import com.miz.functions.Filepath; +import com.miz.utils.LocalBroadcastUtils; +import com.miz.utils.TvShowDatabaseUtils; + +import java.util.ArrayList; + public class UnidentifiedTvShows extends MizActivity { private ArrayList mFilepaths = new ArrayList(); private ListView mList; + @Override + protected int getLayoutResource() { + return R.layout.unidentified_files_layout; + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.unidentified_files_layout); - mList = (ListView) findViewById(R.id.listView1); mList.setMultiChoiceModeListener(new MultiChoiceModeListener() { // Called when the user selects a contextual menu item @@ -221,7 +224,7 @@ public void onClick(DialogInterface dialog, int id) { @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } static class ViewHolder { diff --git a/src/com/miz/mizuu/Update.java b/app/src/main/java/com/miz/mizuu/Update.java similarity index 92% rename from src/com/miz/mizuu/Update.java rename to app/src/main/java/com/miz/mizuu/Update.java index 0a298b57..8484193d 100644 --- a/src/com/miz/mizuu/Update.java +++ b/app/src/main/java/com/miz/mizuu/Update.java @@ -16,16 +16,14 @@ package com.miz.mizuu; -import static com.miz.functions.PreferenceKeys.CLEAR_LIBRARY_MOVIES; -import static com.miz.functions.PreferenceKeys.CLEAR_LIBRARY_TVSHOWS; -import static com.miz.functions.PreferenceKeys.REMOVE_UNAVAILABLE_FILES_MOVIES; -import static com.miz.functions.PreferenceKeys.REMOVE_UNAVAILABLE_FILES_TVSHOWS; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.graphics.Typeface; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; import android.view.MenuItem; import android.view.View; import android.widget.Button; @@ -34,12 +32,17 @@ import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.TextView; -import com.miz.base.MizActivity; import com.miz.functions.MizLib; import com.miz.service.MovieLibraryUpdate; import com.miz.service.TvShowsLibraryUpdate; +import com.miz.utils.TypefaceUtils; -public class Update extends MizActivity { +import static com.miz.functions.PreferenceKeys.CLEAR_LIBRARY_MOVIES; +import static com.miz.functions.PreferenceKeys.CLEAR_LIBRARY_TVSHOWS; +import static com.miz.functions.PreferenceKeys.REMOVE_UNAVAILABLE_FILES_MOVIES; +import static com.miz.functions.PreferenceKeys.REMOVE_UNAVAILABLE_FILES_TVSHOWS; + +public class Update extends ActionBarActivity { private Button mFileSourcesButton, mUpdateLibraryButton; private TextView mFileSourcesDescription, mUpdateLibraryDescription; @@ -48,16 +51,20 @@ public class Update extends MizActivity { private SharedPreferences mSharedPreferences; private boolean mIsMovie; private Typeface mTypeface; - + private Toolbar mToolbar; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.update_layout); - + + mToolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(mToolbar); + mIsMovie = getIntent().getExtras().getBoolean("isMovie"); - mTypeface = MizuuApplication.getOrCreateTypeface(this, "Roboto-Light.ttf"); + mTypeface = TypefaceUtils.getRobotoLight(this); if (!mIsMovie) setTitle(getString(R.string.updateTvShowsTitle)); @@ -121,7 +128,7 @@ else if (!mIsMovie && !MizLib.isTvShowLibraryBeingUpdated(this)) @Override public void onStart() { super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override diff --git a/src/com/miz/mizuu/Welcome.java b/app/src/main/java/com/miz/mizuu/Welcome.java similarity index 98% rename from src/com/miz/mizuu/Welcome.java rename to app/src/main/java/com/miz/mizuu/Welcome.java index 68c33655..78419172 100644 --- a/src/com/miz/mizuu/Welcome.java +++ b/app/src/main/java/com/miz/mizuu/Welcome.java @@ -16,11 +16,6 @@ package com.miz.mizuu; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Random; - import android.annotation.SuppressLint; import android.content.Intent; import android.content.pm.ActivityInfo; @@ -30,10 +25,6 @@ import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; -import com.miz.base.MizActivity; -import com.miz.db.DbAdapterMovies; -import com.miz.db.DbAdapterTvShows; - import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; @@ -54,8 +45,17 @@ import android.widget.Toast; import android.widget.ViewSwitcher.ViewFactory; +import com.miz.base.MizActivity; +import com.miz.db.DbAdapterMovies; +import com.miz.db.DbAdapterTvShows; import com.miz.functions.MizLib; import com.miz.utils.FileUtils; +import com.miz.utils.TypefaceUtils; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Random; import static com.miz.functions.PreferenceKeys.CONFIRM_BACK_PRESS; @@ -73,10 +73,14 @@ public class Welcome extends MizActivity implements ViewFactory { private TextView title; private Handler handler; + @Override + protected int getLayoutResource() { + return R.layout.welcome; + } + @SuppressLint("InlinedApi") @Override public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); confirmExit = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(CONFIRM_BACK_PRESS, false); @@ -85,14 +89,14 @@ public void onCreate(Bundle savedInstanceState) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); // This works on API level 13 as well - setContentView(R.layout.welcome); - - tf = MizuuApplication.getOrCreateTypeface(this, "Roboto-Thin.ttf"); + super.onCreate(savedInstanceState); + + tf = TypefaceUtils.getRobotoThin(this); dbHelper = MizuuApplication.getMovieAdapter(); dbHelperTv = MizuuApplication.getTvDbAdapter(); - Cursor cursor = dbHelper.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC", false); + Cursor cursor = dbHelper.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC"); while (cursor.moveToNext()) { try { backdrops.add(new Backdrop( diff --git a/src/com/miz/mizuu/fragments/AccountsFragment.java b/app/src/main/java/com/miz/mizuu/fragments/AccountsFragment.java similarity index 100% rename from src/com/miz/mizuu/fragments/AccountsFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/AccountsFragment.java index 69289651..23d42663 100644 --- a/src/com/miz/mizuu/fragments/AccountsFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/AccountsFragment.java @@ -16,10 +16,6 @@ package com.miz.mizuu.fragments; -import java.io.File; - -import org.json.JSONObject; - import android.app.Fragment; import android.content.Intent; import android.content.SharedPreferences; @@ -51,10 +47,14 @@ import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; -import static com.miz.functions.PreferenceKeys.TRAKT_USERNAME; -import static com.miz.functions.PreferenceKeys.TRAKT_PASSWORD; -import static com.miz.functions.PreferenceKeys.TRAKT_FULL_NAME; +import org.json.JSONObject; + +import java.io.File; + import static com.miz.functions.PreferenceKeys.SYNC_WITH_TRAKT; +import static com.miz.functions.PreferenceKeys.TRAKT_FULL_NAME; +import static com.miz.functions.PreferenceKeys.TRAKT_PASSWORD; +import static com.miz.functions.PreferenceKeys.TRAKT_USERNAME; public class AccountsFragment extends Fragment { diff --git a/src/com/miz/mizuu/fragments/ActorBrowserFragment.java b/app/src/main/java/com/miz/mizuu/fragments/ActorBrowserFragment.java similarity index 93% rename from src/com/miz/mizuu/fragments/ActorBrowserFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/ActorBrowserFragment.java index 2bdae54c..0a50363f 100644 --- a/src/com/miz/mizuu/fragments/ActorBrowserFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/ActorBrowserFragment.java @@ -16,12 +16,12 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; - import android.content.Context; import android.graphics.Bitmap.Config; import android.os.AsyncTask; import android.os.Bundle; +import android.support.v4.app.ActivityCompat; +import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; @@ -42,8 +42,11 @@ import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; import com.miz.utils.IntentUtils; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; +import java.util.ArrayList; + public class ActorBrowserFragment extends Fragment { private int mImageThumbSize, mImageThumbSpacing; @@ -114,7 +117,8 @@ public void onGlobalLayout() { mGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { - startActivity(IntentUtils.getActorIntent(getActivity(), mActors.get(arg2))); + ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), arg1.findViewById(R.id.cover), "cover"); + ActivityCompat.startActivity(getActivity(), IntentUtils.getActorIntent(getActivity(), mActors.get(arg2)), options.toBundle()); } }); @@ -189,7 +193,7 @@ public View getView(int position, View convertView, ViewGroup container) { holder.subtext = (TextView) convertView.findViewById(R.id.gridCoverSubtitle); holder.subtext.setSingleLine(true); - holder.text.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf")); + holder.text.setTypeface(TypefaceUtils.getRobotoMedium(mContext)); convertView.setTag(holder); } else { diff --git a/src/com/miz/mizuu/fragments/ActorBrowserTvFragment.java b/app/src/main/java/com/miz/mizuu/fragments/ActorBrowserTvFragment.java similarity index 93% rename from src/com/miz/mizuu/fragments/ActorBrowserTvFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/ActorBrowserTvFragment.java index 954da239..884e777f 100644 --- a/src/com/miz/mizuu/fragments/ActorBrowserTvFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/ActorBrowserTvFragment.java @@ -16,13 +16,12 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; -import java.util.List; - import android.content.Context; import android.graphics.Bitmap.Config; import android.os.AsyncTask; import android.os.Bundle; +import android.support.v4.app.ActivityCompat; +import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; @@ -43,8 +42,12 @@ import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; import com.miz.utils.IntentUtils; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; +import java.util.ArrayList; +import java.util.List; + public class ActorBrowserTvFragment extends Fragment { private int mImageThumbSize, mImageThumbSpacing; @@ -116,7 +119,8 @@ public void onGlobalLayout() { mGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { - startActivity(IntentUtils.getActorIntent(getActivity(), mActors.get(arg2))); + ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), arg1.findViewById(R.id.cover), "cover"); + ActivityCompat.startActivity(getActivity(), IntentUtils.getActorIntent(getActivity(), mActors.get(arg2)), options.toBundle()); } }); @@ -192,7 +196,7 @@ public View getView(int position, View convertView, ViewGroup container) { holder.subtext = (TextView) convertView.findViewById(R.id.gridCoverSubtitle); holder.subtext.setSingleLine(true); - holder.text.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf")); + holder.text.setTypeface(TypefaceUtils.getRobotoMedium(mContext)); convertView.setTag(holder); } else { diff --git a/src/com/miz/mizuu/fragments/ActorDetailsFragment.java b/app/src/main/java/com/miz/mizuu/fragments/ActorDetailsFragment.java similarity index 63% rename from src/com/miz/mizuu/fragments/ActorDetailsFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/ActorDetailsFragment.java index f97dfec5..ac9b0f99 100644 --- a/src/com/miz/mizuu/fragments/ActorDetailsFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/ActorDetailsFragment.java @@ -16,22 +16,22 @@ package com.miz.mizuu.fragments; -import android.app.ActionBar; -import android.content.Context; +import android.app.Activity; import android.graphics.Color; import android.graphics.Typeface; -import android.graphics.drawable.Drawable; +import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v4.app.SharedElementCallback; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.ViewTreeObserver; -import android.view.View.OnClickListener; -import android.view.ViewGroup.LayoutParams; -import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ScrollView; import android.widget.TextView; @@ -40,30 +40,35 @@ import com.miz.functions.BlurTransformation; import com.miz.functions.CompleteActor; import com.miz.functions.MizLib; -import com.miz.functions.PaletteTransformation; +import com.miz.functions.PaletteLoader; import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; import com.miz.utils.IntentUtils; +import com.miz.utils.TypefaceUtils; import com.miz.utils.ViewUtils; import com.miz.views.HorizontalCardLayout; import com.miz.views.ObservableScrollView; import com.miz.views.ObservableScrollView.OnScrollChangedListener; +import com.squareup.picasso.Callback; import com.squareup.picasso.Picasso; +import java.util.List; + public class ActorDetailsFragment extends Fragment { private String mActorId; private CompleteActor mActor; - private Context mContext; + private Activity mContext; private TextView mName, mPlaceOfBirth, mBirthday, mKnownCredits, mBiography; - private ImageView mPhoto, mBackdrop, mActionBarOverlay; + private ImageView mPhoto, mBackdrop; + private ObservableScrollView mScrollView; private HorizontalCardLayout mMovieCards, mTvCards, mPhotoCards, mTaggedPhotoCards; - private int mImageThumbSize, mImageThumbBackdropSize, mImageThumbSpacing; + private int mImageThumbSize, mImageThumbBackdropSize, mImageThumbSpacing, mToolbarColor = 000000; + private Typeface mMedium, mBold, mCondensedRegular; private View mProgressLayout, mDetailsLayout; private Picasso mPicasso; - private Typeface mMedium; - private Drawable mActionBarBackgroundDrawable; - private ActionBar mActionBar; + private Toolbar mToolbar; + private PaletteLoader mPaletteLoader; public ActorDetailsFragment() {} @@ -86,24 +91,31 @@ public void onCreate(Bundle savedInstanceState) { mContext = getActivity(); - mActionBar = getActivity().getActionBar(); - mActorId = getArguments().getString("actorId"); mPicasso = MizuuApplication.getPicassoDetailsView(mContext); - mMedium = MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf"); + mMedium = TypefaceUtils.getRobotoMedium(mContext); + mBold = TypefaceUtils.getRobotoBold(mContext); + mCondensedRegular = TypefaceUtils.getRobotoCondensedRegular(mContext); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.actor_details, container, false); + return inflater.inflate(R.layout.actor_details, container, false); } @Override public void onViewCreated(final View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); + mToolbar = (Toolbar) view.findViewById(R.id.toolbar); + mToolbar.setBackgroundResource(android.R.color.transparent); + ViewUtils.setProperToolbarSize(mContext, mToolbar); + + ((ActionBarActivity) getActivity()).setSupportActionBar(mToolbar); + ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); + // This needs to be re-initialized here and not in onCreate() mImageThumbSize = getResources().getDimensionPixelSize(R.dimen.horizontal_grid_item_width); mImageThumbBackdropSize = getResources().getDimensionPixelSize(R.dimen.horizontal_grid_item_backdrop_width); @@ -116,10 +128,10 @@ public void onViewCreated(final View view, Bundle savedInstanceState) { mDetailsLayout = view.findViewById(R.id.details_area); mName = (TextView) view.findViewById(R.id.actor_name); - mName.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "RobotoCondensed-Regular.ttf")); + mName.setTypeface(mCondensedRegular); mPlaceOfBirth = (TextView) view.findViewById(R.id.place_of_birth); - mPlaceOfBirth.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-LightItalic.ttf")); + mPlaceOfBirth.setTypeface(mBold); mBirthday = (TextView) view.findViewById(R.id.actor_birthday); mBirthday.setTypeface(mMedium); @@ -135,17 +147,25 @@ public void onViewCreated(final View view, Bundle savedInstanceState) { mBiography.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - if (((Boolean) mBiography.getTag())) { - mBiography.setMaxLines(1000); - mBiography.setTag(false); - } else { - mBiography.setMaxLines(mContext.getResources().getInteger(R.integer.show_details_max_lines)); - mBiography.setTag(true); - } + if (((Boolean) mBiography.getTag())) { + // Animate + ViewUtils.animateTextViewMaxLines(mBiography, 50); // It seems highly unlikely that there would every be more than 50 lines + + // Reverse the tag + mBiography.setTag(false); + } else { + // Animate + ViewUtils.animateTextViewMaxLines(mBiography, + getResources().getInteger(R.integer.show_details_max_lines)); + + // Reverse the tag + mBiography.setTag(true); + } } }); mBiography.setEllipsize(TextUtils.TruncateAt.END); mBiography.setFocusable(true); + mBiography.setTypeface(mCondensedRegular); mPhoto = (ImageView) view.findViewById(R.id.actor_image); mBackdrop = (ImageView) view.findViewById(R.id.imageBackground); @@ -155,34 +175,28 @@ public void onClick(View v) { mPhotoCards = (HorizontalCardLayout) view.findViewById(R.id.actor_photo_cards); mTaggedPhotoCards = (HorizontalCardLayout) view.findViewById(R.id.actor_tagged_photo_cards); - mActionBarOverlay = (ImageView) view.findViewById(R.id.actionbar_overlay); - mActionBarOverlay.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, - MizuuApplication.isFullscreen(mContext) ? MizLib.getActionBarHeight(mContext) : MizLib.getActionBarAndStatusBarHeight(mContext))); - - if (MizLib.isPortrait(mContext)) { - final boolean fullscreen = MizuuApplication.isFullscreen(mContext); - final int height = fullscreen ? MizLib.getActionBarHeight(mContext) : MizLib.getActionBarAndStatusBarHeight(mContext); - - ObservableScrollView sv = (ObservableScrollView) view.findViewById(R.id.scrollView1); - sv.setOnScrollChangedListener(new OnScrollChangedListener() { - @Override - public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { - final int headerHeight = mPhoto.getHeight() - height; - final float ratio = (float) Math.min(Math.max(t, 0), headerHeight) / headerHeight; - final int newAlpha = (int) (ratio * 255); - - // We only want to update the ActionBar if it would actually make a change (times 1.2 to handle fast flings) - if (t <= headerHeight * 1.2) { - ViewUtils.updateActionBarDrawable(mContext, mActionBarOverlay, mActionBarBackgroundDrawable, mActionBar, mActor.getName(), newAlpha, true, false); - - // Such parallax, much wow - mPhoto.setPadding(0, (int) (t / 1.5), 0, 0); - } - } - }); - } - - ViewUtils.updateActionBarDrawable(mContext, mActionBarOverlay, mActionBarBackgroundDrawable, mActionBar, "", 1, true, true); + mScrollView = (ObservableScrollView) view.findViewById(R.id.observableScrollView); + + final boolean fullscreen = MizuuApplication.isFullscreen(mContext); + final int height = fullscreen ? MizLib.getActionBarHeight(mContext) : MizLib.getActionBarAndStatusBarHeight(mContext); + + mScrollView.setOnScrollChangedListener(new OnScrollChangedListener() { + @Override + public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { + ViewUtils.handleOnScrollChangedEvent( + getActivity(), view, mPhoto, mActor.getName(), + height, t, mToolbar, mToolbarColor); + } + }); + mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + ViewUtils.setLayoutParamsForDetailsEmptyView(mContext, view, + mBackdrop, mScrollView, this); + } + }); + + ViewUtils.updateToolbarBackground(getActivity(), mToolbar, 0, "", mToolbarColor); if (mActor == null) new ActorLoader(mActorId).execute(); @@ -206,14 +220,7 @@ private void fillViews() { mBirthday.setText(MizLib.getPrettyDatePrecise(mContext, mActor.getBirthday())); mKnownCredits.setText(String.valueOf(mActor.getKnownCreditCount())); - mPicasso.load(mActor.getProfilePhoto()).placeholder(R.drawable.noactor).error(R.drawable.noactor).transform(new PaletteTransformation(mActorId, mDetailsLayout, - mMovieCards.getSeeMoreView(), mTvCards.getSeeMoreView(), mPhotoCards.getSeeMoreView(), mTaggedPhotoCards.getSeeMoreView())).into(mPhoto); - - if (!MizLib.isPortrait(mContext)) { - String backdropImage = mActor.getBackdropImage(); - mPicasso.load(backdropImage).placeholder(R.drawable.bg).error(R.drawable.bg).transform(new BlurTransformation(mContext, backdropImage, 2)).into(mBackdrop); - mBackdrop.setColorFilter(Color.parseColor("#aa181818"), android.graphics.PorterDuff.Mode.SRC_OVER); - } + loadImages(); mMovieCards.setTitle(R.string.chooserMovies); mMovieCards.setSeeMoreVisibility(true); @@ -225,7 +232,7 @@ public void onGlobalLayout() { final int numColumns = (int) Math.floor(mMovieCards.getWidth() / (mImageThumbSize + mImageThumbSpacing)); mImageThumbSize = (mMovieCards.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; - mMovieCards.loadItems(mContext, mPicasso, numColumns, mImageThumbSize, mActor.getMovies(), HorizontalCardLayout.MOVIES); + mMovieCards.loadItems(mContext, mPicasso, numColumns, mImageThumbSize, mActor.getMovies(), HorizontalCardLayout.MOVIES, mToolbarColor); MizLib.removeViewTreeObserver(mMovieCards.getViewTreeObserver(), this); } } @@ -233,7 +240,7 @@ public void onGlobalLayout() { mMovieCards.setSeeMoreOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - startActivity(IntentUtils.getActorMoviesIntent(mContext, mActor.getName(), mActor.getId())); + startActivity(IntentUtils.getActorMoviesIntent(mContext, mActor.getName(), mActor.getId(), mToolbarColor)); } }); @@ -247,7 +254,7 @@ public void onGlobalLayout() { final int numColumns = (int) Math.floor(mTvCards.getWidth() / (mImageThumbSize + mImageThumbSpacing)); mImageThumbSize = (mTvCards.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; - mTvCards.loadItems(mContext, mPicasso, numColumns, mImageThumbSize, mActor.getTvShows(), HorizontalCardLayout.TV_SHOWS); + mTvCards.loadItems(mContext, mPicasso, numColumns, mImageThumbSize, mActor.getTvShows(), HorizontalCardLayout.TV_SHOWS, mToolbarColor); MizLib.removeViewTreeObserver(mTvCards.getViewTreeObserver(), this); } } @@ -255,7 +262,7 @@ public void onGlobalLayout() { mTvCards.setSeeMoreOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - startActivity(IntentUtils.getActorTvShowsIntent(mContext, mActor.getName(), mActor.getId())); + startActivity(IntentUtils.getActorTvShowsIntent(mContext, mActor.getName(), mActor.getId(), mToolbarColor)); } }); @@ -269,7 +276,7 @@ public void onGlobalLayout() { final int numColumns = (int) Math.floor(mPhotoCards.getWidth() / (mImageThumbSize + mImageThumbSpacing)); mImageThumbSize = (mPhotoCards.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; - mPhotoCards.loadItems(mContext, mPicasso, numColumns, mImageThumbSize, mActor.getPhotos(), HorizontalCardLayout.PHOTOS); + mPhotoCards.loadItems(mContext, mPicasso, numColumns, mImageThumbSize, mActor.getPhotos(), HorizontalCardLayout.PHOTOS, mToolbarColor); MizLib.removeViewTreeObserver(mPhotoCards.getViewTreeObserver(), this); } } @@ -277,7 +284,7 @@ public void onGlobalLayout() { mPhotoCards.setSeeMoreOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - startActivity(IntentUtils.getActorPhotosIntent(mContext, mActor.getName(), mActor.getId())); + startActivity(IntentUtils.getActorPhotosIntent(mContext, mActor.getName(), mActor.getId(), mToolbarColor)); } }); @@ -291,7 +298,7 @@ public void onGlobalLayout() { final int numColumns = (int) Math.floor(mTaggedPhotoCards.getWidth() / (mImageThumbBackdropSize + mImageThumbSpacing)); mImageThumbBackdropSize = (mTaggedPhotoCards.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; - mTaggedPhotoCards.loadItems(mContext, mPicasso, numColumns, mImageThumbBackdropSize, mActor.getTaggedPhotos(), HorizontalCardLayout.TAGGED_PHOTOS); + mTaggedPhotoCards.loadItems(mContext, mPicasso, numColumns, mImageThumbBackdropSize, mActor.getTaggedPhotos(), HorizontalCardLayout.TAGGED_PHOTOS, mToolbarColor); MizLib.removeViewTreeObserver(mTaggedPhotoCards.getViewTreeObserver(), this); } } @@ -299,11 +306,59 @@ public void onGlobalLayout() { mTaggedPhotoCards.setSeeMoreOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - startActivity(IntentUtils.getActorTaggedPhotosIntent(mContext, mActor.getName(), mActor.getId())); + startActivity(IntentUtils.getActorTaggedPhotosIntent(mContext, mActor.getName(), mActor.getId(), mToolbarColor)); } }); } + private void loadImages() { + mPicasso.load(mActor.getProfilePhotoThumb()).placeholder(R.drawable.noactor).error(R.drawable.noactor).into(mPhoto, new Callback() { + @Override + public void onSuccess() { + if (mPaletteLoader == null) { + mPaletteLoader = new PaletteLoader(mPicasso, Uri.parse(mActor.getProfilePhotoThumb()), new PaletteLoader.OnPaletteLoadedCallback() { + @Override + public void onPaletteLoaded(int swatchColor) { + mToolbarColor = swatchColor; + } + }); + + mPaletteLoader.addView(mDetailsLayout); + mPaletteLoader.addView(mMovieCards.getSeeMoreView()); + mPaletteLoader.addView(mTvCards.getSeeMoreView()); + mPaletteLoader.addView(mPhotoCards.getSeeMoreView()); + mPaletteLoader.addView(mTaggedPhotoCards.getSeeMoreView()); + + mPaletteLoader.execute(); + } else { + // Clear old views after configuration change + mPaletteLoader.clearViews(); + + // Add views after configuration change + mPaletteLoader.addView(mDetailsLayout); + mPaletteLoader.addView(mMovieCards.getSeeMoreView()); + mPaletteLoader.addView(mTvCards.getSeeMoreView()); + mPaletteLoader.addView(mPhotoCards.getSeeMoreView()); + mPaletteLoader.addView(mTaggedPhotoCards.getSeeMoreView()); + + // Re-color the views + mPaletteLoader.colorViews(); + } + } + + @Override + public void onError() { + + } + }); + + if (!MizLib.isPortrait(mContext)) { + String backdropImage = mActor.getBackdropImage(); + mPicasso.load(backdropImage).placeholder(R.drawable.bg).error(R.drawable.bg).transform(new BlurTransformation(mContext, backdropImage, 2)).into(mBackdrop); + mBackdrop.setColorFilter(Color.parseColor("#88181818"), android.graphics.PorterDuff.Mode.SRC_OVER); + } + } + private class ActorLoader extends AsyncTask { private final String mActorId; diff --git a/src/com/miz/mizuu/fragments/ActorMoviesFragment.java b/app/src/main/java/com/miz/mizuu/fragments/ActorMoviesFragment.java similarity index 71% rename from src/com/miz/mizuu/fragments/ActorMoviesFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/ActorMoviesFragment.java index 1649d13e..828f1359 100644 --- a/src/com/miz/mizuu/fragments/ActorMoviesFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/ActorMoviesFragment.java @@ -20,29 +20,40 @@ import android.graphics.Bitmap.Config; import android.os.AsyncTask; import android.os.Bundle; +import android.support.v4.app.ActivityCompat; +import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.app.Fragment; +import android.support.v7.widget.SwitchCompat; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; +import android.widget.CompoundButton; import android.widget.GridView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; +import android.widget.Switch; import android.widget.TextView; import com.miz.apis.tmdb.TMDbMovieService; import com.miz.functions.CompleteActor; import com.miz.functions.CoverItem; +import com.miz.functions.MizLib; import com.miz.functions.WebMovie; import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; import com.miz.utils.IntentUtils; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; +import java.util.ArrayList; + public class ActorMoviesFragment extends Fragment { private Context mContext; @@ -54,6 +65,7 @@ public class ActorMoviesFragment extends Fragment { private ProgressBar mProgressBar; private String mActorId; private CompleteActor mActor; + private boolean mChecked = false; /** * Empty constructor as per the Fragment documentation @@ -73,6 +85,7 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); + setHasOptionsMenu(true); mContext = getActivity(); @@ -85,6 +98,29 @@ public void onCreate(Bundle savedInstanceState) { mActorId = getArguments().getString("actorId"); } + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + inflater.inflate(R.menu.switch_button, menu); + + int padding = MizLib.convertDpToPixels(getActivity(), 16); + + SwitchCompat switchCompat = (SwitchCompat) menu.findItem(R.id.switch_button).getActionView(); + switchCompat.setChecked(mChecked); + switchCompat.setText(R.string.inLibrary); + switchCompat.setSwitchPadding(padding); + switchCompat.setPadding(0, 0, padding, 0); + + switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mChecked = isChecked; + mAdapter.notifyDataSetChanged(); + } + }); + + super.onCreateOptionsMenu(menu, inflater); + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.image_grid_fragment, container, false); @@ -111,7 +147,8 @@ public void onGlobalLayout() { mGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { - getActivity().startActivityForResult(IntentUtils.getTmdbMovieDetails(mContext, mActor.getMovies().get(arg2)), 0); + ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), arg1.findViewById(R.id.cover), "cover"); + ActivityCompat.startActivity(getActivity(), IntentUtils.getTmdbMovieDetails(mContext, mActor.getMovies().get(arg2)), options.toBundle()); } }); @@ -128,17 +165,19 @@ public void onResume() { private class ImageAdapter extends BaseAdapter { - private LayoutInflater inflater; + private ArrayList mMovies; + private LayoutInflater mInflater; private final Context mContext; public ImageAdapter(Context context) { mContext = context; - inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + notifyDataSetChanged(); } @Override public int getCount() { - return mActor.getMovies().size(); + return mMovies.size(); } @Override @@ -154,11 +193,11 @@ public long getItemId(int position) { @Override public View getView(int position, View convertView, ViewGroup container) { - final WebMovie movie = mActor.getMovies().get(position); + final WebMovie movie = mMovies.get(position); CoverItem holder; if (convertView == null) { - convertView = inflater.inflate(R.layout.grid_item, container, false); + convertView = mInflater.inflate(R.layout.grid_item, container, false); holder = new CoverItem(); holder.mLinearLayout = (LinearLayout) convertView.findViewById(R.id.card_layout); @@ -168,7 +207,7 @@ public View getView(int position, View convertView, ViewGroup container) { holder.subtext = (TextView) convertView.findViewById(R.id.gridCoverSubtitle); holder.subtext.setSingleLine(true); - holder.text.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf")); + holder.text.setTypeface(TypefaceUtils.getRobotoMedium(mContext)); convertView.setTag(holder); } else { @@ -187,6 +226,23 @@ public View getView(int position, View convertView, ViewGroup container) { return convertView; } + + @Override + public void notifyDataSetChanged() { + + // Initialize + mMovies = new ArrayList(); + + // Go through all movies + for (WebMovie movie : mActor.getMovies()) { + if (mChecked && !movie.isInLibrary()) + continue; + + mMovies.add(movie); + } + + super.notifyDataSetChanged(); + } } private class MovieLoader extends AsyncTask { diff --git a/src/com/miz/mizuu/fragments/ActorPhotoFragment.java b/app/src/main/java/com/miz/mizuu/fragments/ActorPhotoFragment.java similarity index 100% rename from src/com/miz/mizuu/fragments/ActorPhotoFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/ActorPhotoFragment.java diff --git a/src/com/miz/mizuu/fragments/ActorPhotosFragment.java b/app/src/main/java/com/miz/mizuu/fragments/ActorPhotosFragment.java similarity index 100% rename from src/com/miz/mizuu/fragments/ActorPhotosFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/ActorPhotosFragment.java diff --git a/src/com/miz/mizuu/fragments/ActorTaggedPhotosFragment.java b/app/src/main/java/com/miz/mizuu/fragments/ActorTaggedPhotosFragment.java similarity index 100% rename from src/com/miz/mizuu/fragments/ActorTaggedPhotosFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/ActorTaggedPhotosFragment.java diff --git a/src/com/miz/mizuu/fragments/ActorTvShowsFragment.java b/app/src/main/java/com/miz/mizuu/fragments/ActorTvShowsFragment.java similarity index 75% rename from src/com/miz/mizuu/fragments/ActorTvShowsFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/ActorTvShowsFragment.java index 4b5409c1..321e9b29 100644 --- a/src/com/miz/mizuu/fragments/ActorTvShowsFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/ActorTvShowsFragment.java @@ -21,13 +21,17 @@ import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v7.widget.SwitchCompat; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; +import android.widget.CompoundButton; import android.widget.GridView; import android.widget.ImageView; import android.widget.LinearLayout; @@ -37,12 +41,16 @@ import com.miz.apis.tmdb.TMDbMovieService; import com.miz.functions.CompleteActor; import com.miz.functions.CoverItem; +import com.miz.functions.MizLib; import com.miz.functions.WebMovie; import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; import com.miz.utils.IntentUtils; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; +import java.util.ArrayList; + public class ActorTvShowsFragment extends Fragment { private Context mContext; @@ -54,6 +62,7 @@ public class ActorTvShowsFragment extends Fragment { private ProgressBar mProgressBar; private String mActorId; private CompleteActor mActor; + private boolean mChecked = false; /** * Empty constructor as per the Fragment documentation @@ -73,6 +82,7 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); + setHasOptionsMenu(true); mContext = getActivity(); @@ -85,6 +95,29 @@ public void onCreate(Bundle savedInstanceState) { mActorId = getArguments().getString("actorId"); } + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + inflater.inflate(R.menu.switch_button, menu); + + int padding = MizLib.convertDpToPixels(getActivity(), 16); + + SwitchCompat switchCompat = (SwitchCompat) menu.findItem(R.id.switch_button).getActionView(); + switchCompat.setChecked(mChecked); + switchCompat.setText(R.string.inLibrary); + switchCompat.setSwitchPadding(padding); + switchCompat.setPadding(0, 0, padding, 0); + + switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + mChecked = isChecked; + mAdapter.notifyDataSetChanged(); + } + }); + + super.onCreateOptionsMenu(menu, inflater); + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.image_grid_fragment, container, false); @@ -128,17 +161,19 @@ public void onResume() { private class ImageAdapter extends BaseAdapter { - private LayoutInflater inflater; + private ArrayList mShows; + private LayoutInflater mInflater; private final Context mContext; public ImageAdapter(Context context) { mContext = context; - inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + notifyDataSetChanged(); } @Override public int getCount() { - return mActor.getTvShows().size(); + return mShows.size(); } @Override @@ -154,11 +189,11 @@ public long getItemId(int position) { @Override public View getView(int position, View convertView, ViewGroup container) { - final WebMovie show = mActor.getTvShows().get(position); + final WebMovie show = mShows.get(position); CoverItem holder; if (convertView == null) { - convertView = inflater.inflate(R.layout.grid_item, container, false); + convertView = mInflater.inflate(R.layout.grid_item, container, false); holder = new CoverItem(); holder.mLinearLayout = (LinearLayout) convertView.findViewById(R.id.card_layout); @@ -168,7 +203,7 @@ public View getView(int position, View convertView, ViewGroup container) { holder.subtext = (TextView) convertView.findViewById(R.id.gridCoverSubtitle); holder.subtext.setSingleLine(true); - holder.text.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf")); + holder.text.setTypeface(TypefaceUtils.getRobotoMedium(mContext)); convertView.setTag(holder); } else { @@ -187,6 +222,23 @@ public View getView(int position, View convertView, ViewGroup container) { return convertView; } + + @Override + public void notifyDataSetChanged() { + + // Initialize + mShows = new ArrayList(); + + // Go through all movies + for (WebMovie show : mActor.getTvShows()) { + if (mChecked && !show.isInLibrary()) + continue; + + mShows.add(show); + } + + super.notifyDataSetChanged(); + } } private class TvShowLoader extends AsyncTask { diff --git a/src/com/miz/mizuu/fragments/CollectionCoverSearchFragment.java b/app/src/main/java/com/miz/mizuu/fragments/CollectionCoverSearchFragment.java similarity index 98% rename from src/com/miz/mizuu/fragments/CollectionCoverSearchFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/CollectionCoverSearchFragment.java index 1593af5e..c83346c9 100644 --- a/src/com/miz/mizuu/fragments/CollectionCoverSearchFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/CollectionCoverSearchFragment.java @@ -16,13 +16,6 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.TreeSet; - -import org.json.JSONArray; -import org.json.JSONObject; - import android.content.Context; import android.content.Intent; import android.graphics.Bitmap.Config; @@ -50,6 +43,13 @@ import com.miz.service.DownloadImageService; import com.squareup.picasso.Picasso; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.TreeSet; + public class CollectionCoverSearchFragment extends Fragment { private int mImageThumbSize, mImageThumbSpacing; @@ -157,12 +157,6 @@ public void onResume() { if (mAdapter != null) mAdapter.notifyDataSetChanged(); } - @Override - public void onStart() { - super.onStart(); - getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); - } - private class ImageAdapter extends BaseAdapter { private LayoutInflater inflater; diff --git a/src/com/miz/mizuu/fragments/CollectionLibraryFragment.java b/app/src/main/java/com/miz/mizuu/fragments/CollectionLibraryFragment.java similarity index 98% rename from src/com/miz/mizuu/fragments/CollectionLibraryFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/CollectionLibraryFragment.java index 535deced..e81ae1e8 100644 --- a/src/com/miz/mizuu/fragments/CollectionLibraryFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/CollectionLibraryFragment.java @@ -16,40 +16,6 @@ package com.miz.mizuu.fragments; -import static com.miz.functions.PreferenceKeys.GRID_ITEM_SIZE; -import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; -import static com.miz.functions.PreferenceKeys.SHOW_TITLES_IN_GRID; -import static com.miz.functions.PreferenceKeys.SORTING_MOVIES; -import static com.miz.functions.SortingKeys.ALL_MOVIES; -import static com.miz.functions.SortingKeys.AVAILABLE_FILES; -import static com.miz.functions.SortingKeys.CERTIFICATION; -import static com.miz.functions.SortingKeys.DATE; -import static com.miz.functions.SortingKeys.DURATION; -import static com.miz.functions.SortingKeys.FAVORITES; -import static com.miz.functions.SortingKeys.FILE_SOURCES; -import static com.miz.functions.SortingKeys.FOLDERS; -import static com.miz.functions.SortingKeys.GENRES; -import static com.miz.functions.SortingKeys.OFFLINE_COPIES; -import static com.miz.functions.SortingKeys.RATING; -import static com.miz.functions.SortingKeys.RELEASE; -import static com.miz.functions.SortingKeys.RELEASE_YEAR; -import static com.miz.functions.SortingKeys.TITLE; -import static com.miz.functions.SortingKeys.UNWATCHED_MOVIES; -import static com.miz.functions.SortingKeys.WATCHED_MOVIES; -import static com.miz.functions.SortingKeys.WEIGHTED_RATING; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.Random; -import java.util.TreeMap; -import java.util.regex.Pattern; - -import jcifs.smb.SmbFile; -import android.app.ActionBar; -import android.app.ActionBar.OnNavigationListener; import android.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.Context; @@ -70,6 +36,9 @@ import android.support.v4.content.LocalBroadcastManager; import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat.OnActionExpandListener; +import android.support.v7.app.ActionBar; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.SearchView; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.Menu; @@ -85,8 +54,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; -import android.widget.SearchView; -import android.widget.SearchView.OnQueryTextListener; import android.widget.TextView; import com.miz.db.DatabaseHelper; @@ -109,9 +76,43 @@ import com.miz.mizuu.MovieDetails; import com.miz.mizuu.R; import com.miz.utils.LocalBroadcastUtils; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; -public class CollectionLibraryFragment extends Fragment implements OnNavigationListener, OnSharedPreferenceChangeListener { +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Random; +import java.util.TreeMap; +import java.util.regex.Pattern; + +import jcifs.smb.SmbFile; + +import static com.miz.functions.PreferenceKeys.GRID_ITEM_SIZE; +import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; +import static com.miz.functions.PreferenceKeys.SHOW_TITLES_IN_GRID; +import static com.miz.functions.PreferenceKeys.SORTING_MOVIES; +import static com.miz.functions.SortingKeys.ALL_MOVIES; +import static com.miz.functions.SortingKeys.AVAILABLE_FILES; +import static com.miz.functions.SortingKeys.CERTIFICATION; +import static com.miz.functions.SortingKeys.DATE; +import static com.miz.functions.SortingKeys.DURATION; +import static com.miz.functions.SortingKeys.FAVORITES; +import static com.miz.functions.SortingKeys.FILE_SOURCES; +import static com.miz.functions.SortingKeys.FOLDERS; +import static com.miz.functions.SortingKeys.GENRES; +import static com.miz.functions.SortingKeys.OFFLINE_COPIES; +import static com.miz.functions.SortingKeys.RATING; +import static com.miz.functions.SortingKeys.RELEASE; +import static com.miz.functions.SortingKeys.RELEASE_YEAR; +import static com.miz.functions.SortingKeys.TITLE; +import static com.miz.functions.SortingKeys.UNWATCHED_MOVIES; +import static com.miz.functions.SortingKeys.WATCHED_MOVIES; +import static com.miz.functions.SortingKeys.WEIGHTED_RATING; + +public class CollectionLibraryFragment extends Fragment implements ActionBar.OnNavigationListener, OnSharedPreferenceChangeListener { private SharedPreferences mSharedPreferences; private int mImageThumbSize, mImageThumbSpacing, mResizedWidth, mResizedHeight, mCurrentSort; @@ -195,7 +196,7 @@ public void onActivityCreated(Bundle savedInstanceState) { } private void setupActionBar() { - mActionBar = getActivity().getActionBar(); + mActionBar = ((ActionBarActivity) getActivity()).getSupportActionBar(); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); if (mSpinnerAdapter == null) mSpinnerAdapter = new ActionBarSpinner(); @@ -423,7 +424,7 @@ public View getView(int position, View convertView, ViewGroup container) { holder.subtext = (TextView) convertView.findViewById(R.id.gridCoverSubtitle); holder.subtext.setSingleLine(true); - holder.text.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf")); + holder.text.setTypeface(TypefaceUtils.getRobotoMedium(mContext)); convertView.setTag(holder); } else { @@ -648,7 +649,7 @@ public boolean onMenuItemActionCollapse(MenuItem item) { }); SearchView searchView = (SearchView) menu.findItem(R.id.search_textbox).getActionView(); - searchView.setOnQueryTextListener(new OnQueryTextListener() { + searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { if (newText.length() > 0) { diff --git a/src/com/miz/mizuu/fragments/ContactDeveloperFragment.java b/app/src/main/java/com/miz/mizuu/fragments/ContactDeveloperFragment.java similarity index 100% rename from src/com/miz/mizuu/fragments/ContactDeveloperFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/ContactDeveloperFragment.java index 6b6ebbfb..28488a6f 100644 --- a/src/com/miz/mizuu/fragments/ContactDeveloperFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/ContactDeveloperFragment.java @@ -16,9 +16,6 @@ package com.miz.mizuu.fragments; -import java.util.List; -import java.util.Locale; - import android.animation.ObjectAnimator; import android.app.Fragment; import android.content.Intent; @@ -40,6 +37,9 @@ import com.miz.functions.MizLib; import com.miz.mizuu.R; +import java.util.List; +import java.util.Locale; + public class ContactDeveloperFragment extends Fragment { private Spinner subject; diff --git a/src/com/miz/mizuu/fragments/CoverSearchFragment.java b/app/src/main/java/com/miz/mizuu/fragments/CoverSearchFragment.java similarity index 98% rename from src/com/miz/mizuu/fragments/CoverSearchFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/CoverSearchFragment.java index c337ca26..6f888079 100644 --- a/src/com/miz/mizuu/fragments/CoverSearchFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/CoverSearchFragment.java @@ -16,13 +16,6 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.TreeSet; - -import org.json.JSONArray; -import org.json.JSONObject; - import android.content.Context; import android.content.Intent; import android.graphics.Bitmap.Config; @@ -50,6 +43,13 @@ import com.miz.service.DownloadImageService; import com.squareup.picasso.Picasso; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.TreeSet; + public class CoverSearchFragment extends Fragment { private int mImageThumbSize, mImageThumbSpacing; @@ -157,12 +157,6 @@ public void onResume() { if (mAdapter != null) mAdapter.notifyDataSetChanged(); } - @Override - public void onStart() { - super.onStart(); - getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); - } - private class ImageAdapter extends BaseAdapter { private final Context mContext; @@ -218,10 +212,12 @@ private void loadJson(String baseUrl) { mImageUrls.clear(); JSONObject jObject = new JSONObject(mJson); + JSONArray array = jObject.getJSONArray("posters"); for (int i = 0; i < array.length(); i++) { JSONObject o = array.getJSONObject(i); + mCovers.add(new Cover(baseUrl + MizLib.getImageUrlSize(getActivity()) + o.getString("file_path"), o.getString("iso_639_1"))); mImageUrls.add(baseUrl + MizLib.getImageUrlSize(getActivity()) + o.getString("file_path")); } diff --git a/src/com/miz/mizuu/fragments/CoverSearchFragmentTv.java b/app/src/main/java/com/miz/mizuu/fragments/CoverSearchFragmentTv.java similarity index 97% rename from src/com/miz/mizuu/fragments/CoverSearchFragmentTv.java rename to app/src/main/java/com/miz/mizuu/fragments/CoverSearchFragmentTv.java index 2c246eab..ad5dc6fe 100644 --- a/src/com/miz/mizuu/fragments/CoverSearchFragmentTv.java +++ b/app/src/main/java/com/miz/mizuu/fragments/CoverSearchFragmentTv.java @@ -16,13 +16,12 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; - import android.content.Context; import android.content.Intent; import android.graphics.Bitmap.Config; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -45,6 +44,8 @@ import com.miz.service.DownloadImageService; import com.squareup.picasso.Picasso; +import java.util.ArrayList; + public class CoverSearchFragmentTv extends Fragment { private int mImageThumbSize, mImageThumbSpacing; @@ -141,7 +142,7 @@ public void onResume() { @Override public void onStart() { super.onStart(); - getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); + ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } private class ImageAdapter extends BaseAdapter { diff --git a/src/com/miz/mizuu/fragments/CustomTagsFragment.java b/app/src/main/java/com/miz/mizuu/fragments/CustomTagsFragment.java similarity index 100% rename from src/com/miz/mizuu/fragments/CustomTagsFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/CustomTagsFragment.java index 5e55316e..83e4d26d 100644 --- a/src/com/miz/mizuu/fragments/CustomTagsFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/CustomTagsFragment.java @@ -16,8 +16,6 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; - import android.app.Fragment; import android.content.Context; import android.content.SharedPreferences; @@ -36,6 +34,8 @@ import com.miz.mizuu.R; +import java.util.ArrayList; + import static com.miz.functions.PreferenceKeys.IGNORED_FILENAME_TAGS; public class CustomTagsFragment extends Fragment { diff --git a/src/com/miz/mizuu/fragments/EditMovieFragment.java b/app/src/main/java/com/miz/mizuu/fragments/EditMovieFragment.java similarity index 96% rename from src/com/miz/mizuu/fragments/EditMovieFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/EditMovieFragment.java index b32f8930..e9cde235 100644 --- a/src/com/miz/mizuu/fragments/EditMovieFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/EditMovieFragment.java @@ -1,8 +1,5 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; -import java.util.Calendar; - import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.DatePickerDialog; @@ -10,6 +7,8 @@ import android.database.Cursor; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.Menu; @@ -31,12 +30,16 @@ import com.miz.functions.Movie; import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; +import com.miz.utils.TypefaceUtils; + +import java.util.ArrayList; +import java.util.Calendar; @SuppressLint("InflateParams") public class EditMovieFragment extends Fragment { private Movie mMovie; - + private Toolbar mToolbar; private EditText mTitle, mTagline, mDescription, mGenres; private Button mRuntime, mRating, mReleaseDate, mCertification; @@ -73,6 +76,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); + mToolbar = (Toolbar) v.findViewById(R.id.toolbar); + ((ActionBarActivity) getActivity()).setSupportActionBar(mToolbar); + // Text fields mTitle = (EditText) v.findViewById(R.id.edit_title); mTagline = (EditText) v.findViewById(R.id.edit_tagline); @@ -92,7 +98,7 @@ private void setupValues(boolean resetTextFields) { if (resetTextFields) { // Set title mTitle.setText(mMovie.getTitle()); - mTitle.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-Bold.ttf")); + mTitle.setTypeface(TypefaceUtils.getRobotoBold(getActivity())); mTitle.setSelection(mMovie.getTitle().length()); // Set tagline @@ -331,7 +337,7 @@ private void saveChanges() { @Override public void onStart() { super.onStart(); - getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); + ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override diff --git a/src/com/miz/mizuu/fragments/EditTvShowEpisodeFragment.java b/app/src/main/java/com/miz/mizuu/fragments/EditTvShowEpisodeFragment.java similarity index 95% rename from src/com/miz/mizuu/fragments/EditTvShowEpisodeFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/EditTvShowEpisodeFragment.java index 75658363..f0e00d65 100644 --- a/src/com/miz/mizuu/fragments/EditTvShowEpisodeFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/EditTvShowEpisodeFragment.java @@ -1,7 +1,5 @@ package com.miz.mizuu.fragments; -import java.util.Calendar; - import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; @@ -10,6 +8,8 @@ import android.database.Cursor; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -30,12 +30,15 @@ import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; import com.miz.mizuu.TvShowEpisode; +import com.miz.utils.TypefaceUtils; + +import java.util.Calendar; @SuppressLint("InflateParams") public class EditTvShowEpisodeFragment extends Fragment { private TvShowEpisode mEpisode; - + private Toolbar mToolbar; private EditText mTitle, mDescription, mDirector, mWriter, mGuestStars; private Button mRating, mReleaseDate; @@ -74,6 +77,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); + mToolbar = (Toolbar) v.findViewById(R.id.toolbar); + ((ActionBarActivity) getActivity()).setSupportActionBar(mToolbar); + // Text fields mTitle = (EditText) v.findViewById(R.id.edit_title); mDescription = (EditText) v.findViewById(R.id.edit_description); @@ -92,7 +98,7 @@ private void setupValues(boolean resetTextFields) { if (resetTextFields) { // Set title mTitle.setText(mEpisode.getTitle()); - mTitle.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-Bold.ttf")); + mTitle.setTypeface(TypefaceUtils.getRobotoBold(getActivity())); mTitle.setSelection(mEpisode.getTitle().length()); // Set description @@ -229,7 +235,7 @@ private void saveChanges() { @Override public void onStart() { super.onStart(); - getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); + ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override diff --git a/src/com/miz/mizuu/fragments/EditTvShowFragment.java b/app/src/main/java/com/miz/mizuu/fragments/EditTvShowFragment.java similarity index 96% rename from src/com/miz/mizuu/fragments/EditTvShowFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/EditTvShowFragment.java index 6261325b..539c3b63 100644 --- a/src/com/miz/mizuu/fragments/EditTvShowFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/EditTvShowFragment.java @@ -1,8 +1,5 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; -import java.util.Calendar; - import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; @@ -11,6 +8,8 @@ import android.database.Cursor; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.Menu; @@ -32,12 +31,16 @@ import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; import com.miz.mizuu.TvShow; +import com.miz.utils.TypefaceUtils; + +import java.util.ArrayList; +import java.util.Calendar; @SuppressLint("InflateParams") public class EditTvShowFragment extends Fragment { private TvShow mShow; - + private Toolbar mToolbar; private EditText mTitle, mDescription, mGenres; private Button mRuntime, mRating, mReleaseDate, mCertification; @@ -74,6 +77,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); + mToolbar = (Toolbar) v.findViewById(R.id.toolbar); + ((ActionBarActivity) getActivity()).setSupportActionBar(mToolbar); + // Text fields mTitle = (EditText) v.findViewById(R.id.edit_title); mDescription = (EditText) v.findViewById(R.id.edit_description); @@ -99,7 +105,7 @@ private void setupValues(boolean resetTextFields) { if (resetTextFields) { // Set title mTitle.setText(mShow.getTitle()); - mTitle.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-Bold.ttf")); + mTitle.setTypeface(TypefaceUtils.getRobotoBold(getActivity())); mTitle.setSelection(mShow.getTitle().length()); // Set description @@ -330,7 +336,7 @@ private void saveChanges() { @Override public void onStart() { super.onStart(); - getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); + ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @Override diff --git a/src/com/miz/mizuu/fragments/FanartSearchFragment.java b/app/src/main/java/com/miz/mizuu/fragments/FanartSearchFragment.java similarity index 98% rename from src/com/miz/mizuu/fragments/FanartSearchFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/FanartSearchFragment.java index 239bcc01..e5850d2c 100644 --- a/src/com/miz/mizuu/fragments/FanartSearchFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/FanartSearchFragment.java @@ -16,13 +16,6 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.TreeSet; - -import org.json.JSONArray; -import org.json.JSONObject; - import android.content.Context; import android.content.Intent; import android.graphics.Bitmap.Config; @@ -49,6 +42,13 @@ import com.miz.service.DownloadImageService; import com.squareup.picasso.Picasso; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.TreeSet; + public class FanartSearchFragment extends Fragment { private ImageAdapter mAdapter; @@ -140,12 +140,6 @@ public void onResume() { if (mAdapter != null) mAdapter.notifyDataSetChanged(); } - @Override - public void onStart() { - super.onStart(); - getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); - } - private class ImageAdapter extends BaseAdapter { private final Context mContext; diff --git a/src/com/miz/mizuu/fragments/FanartSearchFragmentTv.java b/app/src/main/java/com/miz/mizuu/fragments/FanartSearchFragmentTv.java similarity index 97% rename from src/com/miz/mizuu/fragments/FanartSearchFragmentTv.java rename to app/src/main/java/com/miz/mizuu/fragments/FanartSearchFragmentTv.java index 273b95c7..91f501fc 100644 --- a/src/com/miz/mizuu/fragments/FanartSearchFragmentTv.java +++ b/app/src/main/java/com/miz/mizuu/fragments/FanartSearchFragmentTv.java @@ -16,14 +16,13 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; - import android.content.Context; import android.content.Intent; import android.graphics.Bitmap.Config; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -44,6 +43,8 @@ import com.miz.service.DownloadImageService; import com.squareup.picasso.Picasso; +import java.util.ArrayList; + public class FanartSearchFragmentTv extends Fragment { private ImageAdapter mAdapter; @@ -123,7 +124,7 @@ public void onResume() { @Override public void onStart() { super.onStart(); - getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); + ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } private class ImageAdapter extends BaseAdapter { diff --git a/src/com/miz/mizuu/fragments/FileSourceBrowserFragment.java b/app/src/main/java/com/miz/mizuu/fragments/FileSourceBrowserFragment.java similarity index 98% rename from src/com/miz/mizuu/fragments/FileSourceBrowserFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/FileSourceBrowserFragment.java index 8c191710..c963e916 100644 --- a/src/com/miz/mizuu/fragments/FileSourceBrowserFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/FileSourceBrowserFragment.java @@ -16,34 +16,6 @@ package com.miz.mizuu.fragments; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.util.ArrayList; -import java.util.List; - -import jcifs.smb.SmbFile; - -import static com.miz.functions.MizLib.MOVIE; -import static com.miz.functions.MizLib.TYPE; -import static com.miz.functions.MizLib.DOMAIN; -import static com.miz.functions.MizLib.USER; -import static com.miz.functions.MizLib.PASSWORD; -import static com.miz.functions.MizLib.SERVER; -import static com.miz.functions.MizLib.SERIAL_NUMBER; - -import org.teleal.cling.android.AndroidUpnpService; -import org.teleal.cling.model.action.ActionInvocation; -import org.teleal.cling.model.message.UpnpResponse; -import org.teleal.cling.model.meta.Device; -import org.teleal.cling.model.meta.Service; -import org.teleal.cling.model.types.UDAServiceType; -import org.teleal.cling.support.contentdirectory.callback.Browse; -import org.teleal.cling.support.model.BrowseFlag; -import org.teleal.cling.support.model.DIDLContent; -import org.teleal.cling.support.model.SortCriterion; -import org.teleal.cling.support.model.container.Container; -import org.teleal.cling.support.model.item.Item; - import android.app.Activity; import android.content.BroadcastReceiver; import android.content.ComponentName; @@ -57,6 +29,7 @@ import android.os.IBinder; import android.support.v4.app.Fragment; import android.support.v4.content.LocalBroadcastManager; +import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -85,6 +58,34 @@ import com.miz.mizuu.R; import com.miz.service.WireUpnpService; +import org.teleal.cling.android.AndroidUpnpService; +import org.teleal.cling.model.action.ActionInvocation; +import org.teleal.cling.model.message.UpnpResponse; +import org.teleal.cling.model.meta.Device; +import org.teleal.cling.model.meta.Service; +import org.teleal.cling.model.types.UDAServiceType; +import org.teleal.cling.support.contentdirectory.callback.Browse; +import org.teleal.cling.support.model.BrowseFlag; +import org.teleal.cling.support.model.DIDLContent; +import org.teleal.cling.support.model.SortCriterion; +import org.teleal.cling.support.model.container.Container; +import org.teleal.cling.support.model.item.Item; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.List; + +import jcifs.smb.SmbFile; + +import static com.miz.functions.MizLib.DOMAIN; +import static com.miz.functions.MizLib.MOVIE; +import static com.miz.functions.MizLib.PASSWORD; +import static com.miz.functions.MizLib.SERIAL_NUMBER; +import static com.miz.functions.MizLib.SERVER; +import static com.miz.functions.MizLib.TYPE; +import static com.miz.functions.MizLib.USER; + public class FileSourceBrowserFragment extends Fragment { public static final int INITIALIZE = -2; @@ -411,7 +412,7 @@ public View getView(int position, View convertView, ViewGroup parent) { } if (position == 0) { - holder.icon.setImageResource(R.drawable.ic_arrow_back); + holder.icon.setImageResource(R.drawable.ic_arrow_back_white_24dp); holder.name.setText("..."); holder.size.setVisibility(View.GONE); } else { @@ -430,7 +431,7 @@ public View getView(int position, View convertView, ViewGroup parent) { else if (MizLib.isSubtitleFile(browser.getName())) holder.icon.setImageResource(R.drawable.ic_action_subtitles); else - holder.icon.setImageResource(R.drawable.file); + holder.icon.setImageResource(R.drawable.ic_insert_drive_file_white_24dp); holder.size.setText(MizLib.filesizeToString(browser.getSize())); holder.size.setVisibility(View.VISIBLE); } @@ -557,7 +558,7 @@ private void notifyDataSetChanged() { } private void updateSubtitle() { - getActivity().getActionBar().setSubtitle(mBrowser.getSubtitle()); + ((ActionBarActivity) getActivity()).getSupportActionBar().setSubtitle(mBrowser.getSubtitle()); } private ServiceConnection serviceConnection = new ServiceConnection() { diff --git a/src/com/miz/mizuu/fragments/IdentifyMovieFragment.java b/app/src/main/java/com/miz/mizuu/fragments/IdentifyMovieFragment.java similarity index 94% rename from src/com/miz/mizuu/fragments/IdentifyMovieFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/IdentifyMovieFragment.java index 9e0a2b65..f06639f2 100644 --- a/src/com/miz/mizuu/fragments/IdentifyMovieFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/IdentifyMovieFragment.java @@ -16,14 +16,6 @@ package com.miz.mizuu.fragments; -import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Locale; - import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -32,6 +24,8 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.Html; import android.text.TextWatcher; @@ -39,10 +33,11 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.WindowManager; import android.view.ViewGroup.LayoutParams; +import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.BaseAdapter; import android.widget.EditText; @@ -54,9 +49,8 @@ import android.widget.Spinner; import android.widget.SpinnerAdapter; import android.widget.TextView; -import android.widget.Toast; -import android.widget.AdapterView.OnItemClickListener; import android.widget.TextView.OnEditorActionListener; +import android.widget.Toast; import com.miz.abstractclasses.MovieApiService; import com.miz.apis.tmdb.Movie; @@ -66,8 +60,17 @@ import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; import com.miz.service.IdentifyMovieService; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; + +import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; + public class IdentifyMovieFragment extends Fragment { private ListView mListView; @@ -76,21 +79,23 @@ public class IdentifyMovieFragment extends Fragment { private ProgressBar mProgress; private Picasso mPicasso; private Bitmap.Config mConfig; - private String mFilepath, mLocale; + private String mFilepath, mLocale, mCurrentMovieId; private ListAdapter mAdapter; private LanguageAdapter mSpinnerAdapter; private MovieSearch mMovieSearch; private MovieStructure mMovieStructure; + private Toolbar mToolbar; /** * Empty constructor as per the Fragment documentation */ public IdentifyMovieFragment() {} - public static IdentifyMovieFragment newInstance(String filepath) { + public static IdentifyMovieFragment newInstance(String filepath, String currentMovieId) { IdentifyMovieFragment frag = new IdentifyMovieFragment(); Bundle args = new Bundle(); args.putString("filepath", filepath); + args.putString("currentMovieId", currentMovieId); frag.setArguments(args); return frag; } @@ -105,7 +110,8 @@ public void onCreate(Bundle savedInstanceState) { getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mFilepath = getArguments().getString("filepath"); - + mCurrentMovieId = getArguments().getString("currentMovieId"); + mMovieStructure = new MovieStructure(mFilepath); mPicasso = MizuuApplication.getPicasso(getActivity()); @@ -130,6 +136,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); + mToolbar = (Toolbar) v.findViewById(R.id.toolbar); + ((ActionBarActivity) getActivity()).setSupportActionBar(mToolbar); + mListView = (ListView) v.findViewById(R.id.listView1); mQuery = (EditText) v.findViewById(R.id.editText1); mSpinner = (Spinner) v.findViewById(R.id.spinner1); @@ -217,6 +226,7 @@ private void updateMovie(int id) { Intent identifyService = new Intent(getActivity(), IdentifyMovieService.class); Bundle b = new Bundle(); b.putString("filepath", mFilepath); + b.putString("currentMovieId", mCurrentMovieId); b.putString("movieId", mAdapter.getItem(id).getId()); b.putString("language", getSelectedLanguage()); identifyService.putExtras(b); @@ -353,10 +363,10 @@ public View getView(int position, View convertView, ViewGroup parent) { holder.cover = (ImageView) convertView.findViewById(R.id.cover); holder.layout = (LinearLayout) convertView.findViewById(R.id.cover_layout); - holder.title.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "RobotoCondensed-Regular.ttf")); - holder.release.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-LightItalic.ttf")); - holder.rating.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-LightItalic.ttf")); - holder.originalTitle.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-LightItalic.ttf")); + holder.title.setTypeface(TypefaceUtils.getRobotoCondensedRegular(getActivity())); + holder.release.setTypeface(TypefaceUtils.getRobotoLightItalic(getActivity())); + holder.rating.setTypeface(TypefaceUtils.getRobotoLightItalic(getActivity())); + holder.originalTitle.setTypeface(TypefaceUtils.getRobotoLightItalic(getActivity())); // Check the height matches our calculated column width if (holder.layout.getLayoutParams().height != mItemHeight) { diff --git a/src/com/miz/mizuu/fragments/IdentifyTvShowEpisodeFragment.java b/app/src/main/java/com/miz/mizuu/fragments/IdentifyTvShowEpisodeFragment.java similarity index 96% rename from src/com/miz/mizuu/fragments/IdentifyTvShowEpisodeFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/IdentifyTvShowEpisodeFragment.java index ed8a5bd0..6d6e83bd 100644 --- a/src/com/miz/mizuu/fragments/IdentifyTvShowEpisodeFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/IdentifyTvShowEpisodeFragment.java @@ -16,15 +16,6 @@ package com.miz.mizuu.fragments; -import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; - import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -33,18 +24,21 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.Html; -import android.text.TextWatcher; import android.text.TextUtils.TruncateAt; +import android.text.TextWatcher; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.WindowManager; import android.view.ViewGroup.LayoutParams; +import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.BaseAdapter; import android.widget.EditText; @@ -56,9 +50,8 @@ import android.widget.Spinner; import android.widget.SpinnerAdapter; import android.widget.TextView; -import android.widget.Toast; -import android.widget.AdapterView.OnItemClickListener; import android.widget.TextView.OnEditorActionListener; +import android.widget.Toast; import com.miz.abstractclasses.ApiService; import com.miz.apis.thetvdb.TvShow; @@ -67,8 +60,18 @@ import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; import com.miz.service.IdentifyTvShowEpisodeService; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; + +import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; + public class IdentifyTvShowEpisodeFragment extends Fragment { private ListView mListView; @@ -82,6 +85,7 @@ public class IdentifyTvShowEpisodeFragment extends Fragment { private ListAdapter mAdapter; private LanguageAdapter mSpinnerAdapter; private TvShowSearch mTvShowSearch; + private Toolbar mToolbar; /** * Empty constructor as per the Fragment documentation @@ -133,6 +137,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); + mToolbar = (Toolbar) v.findViewById(R.id.toolbar); + ((ActionBarActivity) getActivity()).setSupportActionBar(mToolbar); + mListView = (ListView) v.findViewById(R.id.listView1); mQuery = (EditText) v.findViewById(R.id.editText1); mSpinner = (Spinner) v.findViewById(R.id.spinner1); @@ -370,9 +377,9 @@ public View getView(int position, View convertView, ViewGroup parent) { holder.cover = (ImageView) convertView.findViewById(R.id.cover); holder.layout = (LinearLayout) convertView.findViewById(R.id.cover_layout); - holder.title.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "RobotoCondensed-Regular.ttf")); - holder.release.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-LightItalic.ttf")); - holder.description.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-LightItalic.ttf")); + holder.title.setTypeface(TypefaceUtils.getRobotoCondensedRegular(getActivity())); + holder.release.setTypeface(TypefaceUtils.getRobotoLightItalic(getActivity())); + holder.description.setTypeface(TypefaceUtils.getRobotoLightItalic(getActivity())); // Check the height matches our calculated column width if (holder.layout.getLayoutParams().height != mItemHeight) { diff --git a/src/com/miz/mizuu/fragments/IdentifyTvShowFragment.java b/app/src/main/java/com/miz/mizuu/fragments/IdentifyTvShowFragment.java similarity index 96% rename from src/com/miz/mizuu/fragments/IdentifyTvShowFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/IdentifyTvShowFragment.java index 636ab125..a3f87e84 100644 --- a/src/com/miz/mizuu/fragments/IdentifyTvShowFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/IdentifyTvShowFragment.java @@ -16,15 +16,6 @@ package com.miz.mizuu.fragments; -import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; - import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -33,18 +24,21 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.Html; -import android.text.TextWatcher; import android.text.TextUtils.TruncateAt; +import android.text.TextWatcher; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.WindowManager; import android.view.ViewGroup.LayoutParams; +import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.BaseAdapter; import android.widget.EditText; @@ -56,9 +50,8 @@ import android.widget.Spinner; import android.widget.SpinnerAdapter; import android.widget.TextView; -import android.widget.Toast; -import android.widget.AdapterView.OnItemClickListener; import android.widget.TextView.OnEditorActionListener; +import android.widget.Toast; import com.miz.abstractclasses.ApiService; import com.miz.apis.thetvdb.TvShow; @@ -67,8 +60,18 @@ import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; import com.miz.service.IdentifyTvShowService; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; + +import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; + public class IdentifyTvShowFragment extends Fragment { private ListView mListView; @@ -81,6 +84,7 @@ public class IdentifyTvShowFragment extends Fragment { private ListAdapter mAdapter; private LanguageAdapter mSpinnerAdapter; private TvShowSearch mTvShowSearch; + private Toolbar mToolbar; /** * Empty constructor as per the Fragment documentation @@ -130,6 +134,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); + mToolbar = (Toolbar) v.findViewById(R.id.toolbar); + ((ActionBarActivity) getActivity()).setSupportActionBar(mToolbar); + mListView = (ListView) v.findViewById(R.id.listView1); mQuery = (EditText) v.findViewById(R.id.editText1); mSpinner = (Spinner) v.findViewById(R.id.spinner1); @@ -366,9 +373,9 @@ public View getView(int position, View convertView, ViewGroup parent) { holder.cover = (ImageView) convertView.findViewById(R.id.cover); holder.layout = (LinearLayout) convertView.findViewById(R.id.cover_layout); - holder.title.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "RobotoCondensed-Regular.ttf")); - holder.release.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-LightItalic.ttf")); - holder.description.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-LightItalic.ttf")); + holder.title.setTypeface(TypefaceUtils.getRobotoCondensedRegular(getActivity())); + holder.release.setTypeface(TypefaceUtils.getRobotoLightItalic(getActivity())); + holder.description.setTypeface(TypefaceUtils.getRobotoLightItalic(getActivity())); // Check the height matches our calculated column width if (holder.layout.getLayoutParams().height != mItemHeight) { diff --git a/src/com/miz/mizuu/fragments/IgnoredFilesFragment.java b/app/src/main/java/com/miz/mizuu/fragments/IgnoredFilesFragment.java similarity index 78% rename from src/com/miz/mizuu/fragments/IgnoredFilesFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/IgnoredFilesFragment.java index d14709df..e0093daa 100644 --- a/src/com/miz/mizuu/fragments/IgnoredFilesFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/IgnoredFilesFragment.java @@ -16,8 +16,6 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; - import android.app.Fragment; import android.content.Context; import android.database.Cursor; @@ -33,17 +31,18 @@ import android.widget.ListView; import android.widget.TextView; -import com.miz.db.DbAdapterMovies; +import com.miz.db.DbAdapterMovieMappings; import com.miz.db.DbAdapterTvShowEpisodeMappings; import com.miz.functions.ColumnIndexCache; import com.miz.functions.MizLib; -import com.miz.functions.Movie; import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; +import java.util.ArrayList; + public class IgnoredFilesFragment extends Fragment { - private ArrayList movies = new ArrayList(); + private ArrayList movies = new ArrayList(); private ArrayList mEpisodes = new ArrayList(); private ViewPager awesomePager; private IgnoredFilesAdapter mAdapter; @@ -65,31 +64,11 @@ private void refreshData() { ColumnIndexCache cache = new ColumnIndexCache(); - DbAdapterMovies db = MizuuApplication.getMovieAdapter(); - Cursor cursor = db.getAllIgnoredMovies(); + DbAdapterMovieMappings db = MizuuApplication.getMovieMappingAdapter(); + Cursor cursor = db.getAllIgnoredFilepaths(); try { while (cursor.moveToNext()) { - movies.add(new Movie(getActivity(), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TITLE)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_PLOT)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TAGLINE)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TMDB_ID)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_IMDB_ID)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_RATING)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_RELEASEDATE)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_CERTIFICATION)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_RUNTIME)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TRAILER)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_GENRES)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_FAVOURITE)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_ACTORS)), - MizuuApplication.getCollectionsAdapter().getCollection(cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_COLLECTION_ID))), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_COLLECTION_ID)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TO_WATCH)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_HAS_WATCHED)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_DATE_ADDED)), - false - )); + movies.add(cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovieMappings.KEY_FILEPATH))); } } catch (Exception e) { } finally { @@ -224,11 +203,14 @@ public View getView(final int position, View convertView, ViewGroup parent) { holder = (ViewHolder) convertView.getTag(); } - holder.folderName.setText(movies.get(position).getAllFilepaths()); + String filepath = movies.get(position); + String temp = filepath.contains("") ? filepath.split("")[1] : filepath; + + holder.folderName.setText(MizLib.transformSmbPath(temp)); holder.remove.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - removeSelectedMovie(movies.get(position).getTmdbId()); + removeSelectedMovie(movies.get(position)); } }); @@ -293,8 +275,8 @@ public void onClick(View v) { } } - private void removeSelectedMovie(String tmdbId) { - MizuuApplication.getMovieAdapter().deleteMovie(tmdbId); + private void removeSelectedMovie(String filepath) { + MizuuApplication.getMovieMappingAdapter().deleteIgnoredFilepath(filepath); refreshData(); } diff --git a/app/src/main/java/com/miz/mizuu/fragments/MovieDetailsFragment.java b/app/src/main/java/com/miz/mizuu/fragments/MovieDetailsFragment.java new file mode 100644 index 00000000..b56c696b --- /dev/null +++ b/app/src/main/java/com/miz/mizuu/fragments/MovieDetailsFragment.java @@ -0,0 +1,1185 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use mContext 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.miz.mizuu.fragments; + +import android.animation.Animator; +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.ProgressDialog; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.IntentFilter; +import android.database.Cursor; +import android.database.DataSetObserver; +import android.graphics.Color; +import android.graphics.Typeface; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.support.v4.app.Fragment; +import android.support.v4.content.LocalBroadcastManager; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; +import android.text.Html; +import android.text.TextUtils; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.widget.CheckBox; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ScrollView; +import android.widget.TextView; +import android.widget.Toast; + +import com.melnykov.fab.FloatingActionButton; +import com.miz.abstractclasses.MovieApiService; +import com.miz.apis.trakt.Trakt; +import com.miz.db.DbAdapterMovies; +import com.miz.functions.Actor; +import com.miz.functions.BlurTransformation; +import com.miz.functions.FileSource; +import com.miz.functions.Filepath; +import com.miz.functions.IntentKeys; +import com.miz.functions.MizLib; +import com.miz.functions.Movie; +import com.miz.functions.PaletteLoader; +import com.miz.functions.PreferenceKeys; +import com.miz.mizuu.EditMovie; +import com.miz.mizuu.IdentifyMovie; +import com.miz.mizuu.Main; +import com.miz.mizuu.MizuuApplication; +import com.miz.mizuu.MovieCoverFanartBrowser; +import com.miz.mizuu.R; +import com.miz.remoteplayback.RemotePlayback; +import com.miz.service.DeleteFile; +import com.miz.service.MakeAvailableOffline; +import com.miz.utils.IntentUtils; +import com.miz.utils.LocalBroadcastUtils; +import com.miz.utils.MovieDatabaseUtils; +import com.miz.utils.TypefaceUtils; +import com.miz.utils.VideoUtils; +import com.miz.utils.ViewUtils; +import com.miz.views.HorizontalCardLayout; +import com.miz.views.ObservableScrollView; +import com.miz.views.ObservableScrollView.OnScrollChangedListener; +import com.squareup.picasso.Callback; +import com.squareup.picasso.Picasso; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import static com.miz.functions.PreferenceKeys.ALWAYS_DELETE_FILE; +import static com.miz.functions.PreferenceKeys.CHROMECAST_BETA_SUPPORT; +import static com.miz.functions.PreferenceKeys.IGNORED_FILES_ENABLED; +import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; +import static com.miz.functions.PreferenceKeys.REMOVE_MOVIES_FROM_WATCHLIST; +import static com.miz.functions.PreferenceKeys.SHOW_FILE_LOCATION; + +public class MovieDetailsFragment extends Fragment { + + private Activity mContext; + private Movie mMovie; + private DbAdapterMovies mDatabase; + private TextView mTitle, mPlot, mSrc, mGenre, mRuntime, mReleaseDate, mRating, mTagline, mCertification; + private View mDetailsArea; + private ObservableScrollView mScrollView; + private HorizontalCardLayout mActorsLayout; + private boolean mIgnorePrefixes, mShowFileLocation, mIgnoreDeletedFiles, mRemoveMoviesFromWatchlist; + private ImageView mBackground, mCover; + private Picasso mPicasso; + private Typeface mLight, mMediumItalic, mMedium, mBold, mCondensedRegular; + private int mImageThumbSize, mImageThumbSpacing, mToolbarColor = 000000; + private long mVideoPlaybackStarted, mVideoPlaybackEnded; + private Toolbar mToolbar; + private FloatingActionButton mFab; + private PaletteLoader mPaletteLoader; + + /** + * Empty constructor as per the Fragment documentation + */ + public MovieDetailsFragment() {} + + public static MovieDetailsFragment newInstance(String tmdbId) { + MovieDetailsFragment pageFragment = new MovieDetailsFragment(); + Bundle bundle = new Bundle(); + bundle.putString("tmdbId", tmdbId); + pageFragment.setArguments(bundle); + return pageFragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setHasOptionsMenu(true); + setRetainInstance(true); + + mContext = getActivity(); + + mIgnorePrefixes = PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(IGNORED_TITLE_PREFIXES, false); + mShowFileLocation = PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(SHOW_FILE_LOCATION, true); + mIgnoreDeletedFiles = PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(IGNORED_FILES_ENABLED, false); + mRemoveMoviesFromWatchlist = PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(REMOVE_MOVIES_FROM_WATCHLIST, true); + + mLight = TypefaceUtils.getRobotoLight(mContext); + mMediumItalic = TypefaceUtils.getRobotoMediumItalic(mContext); + mMedium = TypefaceUtils.getRobotoMedium(mContext); + mBold = TypefaceUtils.getRobotoBold(mContext); + mCondensedRegular = TypefaceUtils.getRobotoCondensedRegular(mContext); + + mPicasso = MizuuApplication.getPicassoDetailsView(mContext); + + mDatabase = MizuuApplication.getMovieAdapter(); + + Cursor cursor = mDatabase.fetchMovie(getArguments().getString("tmdbId")); + try { + mMovie = new Movie(mContext, + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_TITLE)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_PLOT)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_TAGLINE)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_TMDB_ID)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_IMDB_ID)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_RATING)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_RELEASEDATE)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_CERTIFICATION)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_RUNTIME)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_TRAILER)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_GENRES)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_FAVOURITE)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_ACTORS)), + MizuuApplication.getCollectionsAdapter().getCollection(cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_COLLECTION_ID))), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_COLLECTION_ID)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_TO_WATCH)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_HAS_WATCHED)), + cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_DATE_ADDED)), + mIgnorePrefixes + ); + } catch (Exception e) {} finally { + if (cursor != null) { + cursor.close(); + } else { // Cursor is null, yikes! + getActivity().finish(); + return; + } + } + + LocalBroadcastManager.getInstance(mContext).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.CLEAR_IMAGE_CACHE)); + } + + @Override + public void onResume() { + super.onResume(); + + mVideoPlaybackEnded = System.currentTimeMillis(); + + if (mVideoPlaybackStarted > 0 && mVideoPlaybackEnded - mVideoPlaybackStarted > (1000 * 60 * 5)) { + if (!mMovie.hasWatched()) + watched(false); // Mark it as watched + } + } + + private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + loadImages(); + } + }; + + @Override + public void onDestroy() { + super.onDestroy(); + + // Unregister since the activity is about to be closed. + LocalBroadcastManager.getInstance(mContext).unregisterReceiver(mMessageReceiver); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return inflater.inflate(R.layout.movie_and_tv_show_details, container, false); + } + + @Override + public void onViewCreated(final View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + mToolbar = (Toolbar) view.findViewById(R.id.toolbar); + mToolbar.setBackgroundResource(android.R.color.transparent); + ViewUtils.setProperToolbarSize(mContext, mToolbar); + + ((ActionBarActivity) getActivity()).setSupportActionBar(mToolbar); + ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + // This needs to be re-initialized here and not in onCreate() + mImageThumbSize = getResources().getDimensionPixelSize(R.dimen.horizontal_grid_item_width); + mImageThumbSpacing = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); + + mDetailsArea = view.findViewById(R.id.details_area); + mBackground = (ImageView) view.findViewById(R.id.imageBackground); + mTitle = (TextView) view.findViewById(R.id.movieTitle); + mPlot = (TextView) view.findViewById(R.id.textView2); + mSrc = (TextView) view.findViewById(R.id.textView3); + mGenre = (TextView) view.findViewById(R.id.textView7); + mRuntime = (TextView) view.findViewById(R.id.textView9); + mReleaseDate = (TextView) view.findViewById(R.id.textReleaseDate); + mRating = (TextView) view.findViewById(R.id.textView12); + mTagline = (TextView) view.findViewById(R.id.textView6); + mCertification = (TextView) view.findViewById(R.id.textView11); + mCover = (ImageView) view.findViewById(R.id.traktIcon); + mActorsLayout = (HorizontalCardLayout) view.findViewById(R.id.horizontal_card_layout); + mScrollView = (ObservableScrollView) view.findViewById(R.id.observableScrollView); + mFab = (FloatingActionButton) view.findViewById(R.id.fab); + + mFab.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + ViewUtils.animateFabJump(v, new Animator.AnimatorListener() { + @Override + public void onAnimationEnd(Animator animation) { + playMovie(); + } + + @Override + public void onAnimationStart(Animator animation) {} + + @Override + public void onAnimationCancel(Animator animation) {} + + @Override + public void onAnimationRepeat(Animator animation) {} + }); + } + }); + if (MizLib.isTablet(mContext)) + mFab.setType(FloatingActionButton.TYPE_NORMAL); + + final boolean fullscreen = MizuuApplication.isFullscreen(mContext); + final int height = fullscreen ? MizLib.getActionBarHeight(mContext) : MizLib.getActionBarAndStatusBarHeight(mContext); + + mScrollView.setOnScrollChangedListener(new OnScrollChangedListener() { + @Override + public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { + ViewUtils.handleOnScrollChangedEvent( + getActivity(), view, mBackground, mMovie.getTitle(), + height, t, mToolbar, mToolbarColor); + + } + }); + mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + ViewUtils.setLayoutParamsForDetailsEmptyView(mContext, view, + mBackground, mScrollView, this); + } + }); + + // Set the movie title + mTitle.setVisibility(View.VISIBLE); + mTitle.setText(mMovie.getTitle()); + mTitle.setTypeface(mCondensedRegular); + + mPlot.setTypeface(mCondensedRegular); + mSrc.setTypeface(mLight); + + mRuntime.setTypeface(mMedium); + mCertification.setTypeface(mMedium); + mRating.setTypeface(mMedium); + + // Set the movie plot + mPlot.setBackgroundResource(R.drawable.selectable_background); + if (!mMovie.getTagline().isEmpty()) + mPlot.setMaxLines(mContext.getResources().getInteger(R.integer.movie_details_max_lines)); + else + mPlot.setMaxLines(mContext.getResources().getInteger(R.integer.show_details_max_lines)); + mPlot.setTag(true); // true = collapsed + mPlot.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (((Boolean) mPlot.getTag())) { + // Animate + ViewUtils.animateTextViewMaxLines(mPlot, 50); // It seems highly unlikely that there would every be more than 50 lines + + // Reverse the tag + mPlot.setTag(false); + } else { + // Animate + ViewUtils.animateTextViewMaxLines(mPlot, mMovie.getTagline().isEmpty() ? + getResources().getInteger(R.integer.show_details_max_lines) : getResources().getInteger(R.integer.movie_details_max_lines)); + + // Reverse the tag + mPlot.setTag(true); + } + } + }); + mPlot.setEllipsize(TextUtils.TruncateAt.END); + mPlot.setFocusable(true); + if (MizLib.isTablet(mContext)) + mPlot.setLineSpacing(0, 1.15f); + mPlot.setText(mMovie.getPlot()); + + // Set the movie file source + mSrc.setTypeface(mCondensedRegular); + if (mShowFileLocation) { + mSrc.setText(mMovie.getAllFilepaths()); + } else { + mSrc.setVisibility(View.GONE); + } + + // Set movie tag line + mTagline.setTypeface(mBold); + if (mMovie.getTagline().isEmpty()) + mTagline.setVisibility(TextView.GONE); + else + mTagline.setText(mMovie.getTagline()); + + // Set the movie genre + mGenre.setTypeface(mMediumItalic); + if (!TextUtils.isEmpty(mMovie.getGenres())) { + mGenre.setText(mMovie.getGenres()); + } else { + mGenre.setVisibility(View.GONE); + } + + // Set the movie runtime + mRuntime.setText(MizLib.getPrettyRuntime(mContext, Integer.parseInt(mMovie.getRuntime()))); + + // Set the movie release date + mReleaseDate.setTypeface(mMedium); + mReleaseDate.setText(MizLib.getPrettyDate(mContext, mMovie.getReleasedate())); + + // Set the movie rating + if (!mMovie.getRating().equals("0.0")) { + try { + int rating = (int) (Double.parseDouble(mMovie.getRating()) * 10); + mRating.setText(Html.fromHtml(+ rating + " %")); + } catch (NumberFormatException e) { + mRating.setText(mMovie.getRating()); + } + } else { + mRating.setText(R.string.stringNA); + } + + // Set the movie certification + if (!TextUtils.isEmpty(mMovie.getCertification())) { + mCertification.setText(mMovie.getCertification()); + } else { + mCertification.setText(R.string.stringNA); + } + + mActorsLayout.setTitle(R.string.detailsActors); + mActorsLayout.setSeeMoreVisibility(true); + mActorsLayout.getViewTreeObserver().addOnGlobalLayoutListener( + new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + if (mActorsLayout.getWidth() > 0) { + final int numColumns = (int) Math.floor(mActorsLayout.getWidth() / (mImageThumbSize + mImageThumbSpacing)); + mImageThumbSize = (mActorsLayout.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; + + loadActors(numColumns); + MizLib.removeViewTreeObserver(mActorsLayout.getViewTreeObserver(), this); + } + } + }); + mActorsLayout.setSeeMoreOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + startActivity(IntentUtils.getActorBrowserMovies(mContext, mMovie.getTitle(), mMovie.getTmdbId(), mToolbarColor)); + } + }); + + ViewUtils.updateToolbarBackground(getActivity(), mToolbar, 0, mMovie.getTitle(), mToolbarColor); + + loadImages(); + } + + private void loadActors(final int capacity) { + // Show ProgressBar + new AsyncTask() { + private List mActors; + + @Override + protected Void doInBackground(Void... params) { + MovieApiService service = MizuuApplication.getMovieService(mContext); + mActors = service.getActors(mMovie.getTmdbId()); + + return null; + } + + @Override + protected void onPostExecute(Void result) { + mActorsLayout.loadItems(mContext, mPicasso, capacity, mImageThumbSize, mActors, HorizontalCardLayout.ACTORS, mToolbarColor); + } + }.execute(); + } + + private void loadImages() { + // Cover image + mPicasso.load(mMovie.getThumbnail()).error(R.drawable.loading_image).placeholder(R.drawable.loading_image).into(mCover, new Callback() { + @Override + public void onSuccess() { + if (mPaletteLoader == null) { + mPaletteLoader = new PaletteLoader(mPicasso, Uri.fromFile(mMovie.getThumbnail()), new PaletteLoader.OnPaletteLoadedCallback() { + @Override + public void onPaletteLoaded(int swatchColor) { + mToolbarColor = swatchColor; + } + }); + + mPaletteLoader.addView(mDetailsArea); + mPaletteLoader.addView(mActorsLayout.getSeeMoreView()); + mPaletteLoader.setFab(mFab); + + mPaletteLoader.execute(); + } else { + // Clear old views after configuration change + mPaletteLoader.clearViews(); + + // Add views after configuration change + mPaletteLoader.addView(mDetailsArea); + mPaletteLoader.addView(mActorsLayout.getSeeMoreView()); + mPaletteLoader.setFab(mFab); + + // Re-color the views + mPaletteLoader.colorViews(); + } + } + + @Override + public void onError() {} + }); + + if (!MizLib.isPortrait(mContext)) { + if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(PreferenceKeys.BLUR_BACKDROPS, false)) { + mPicasso.load(mMovie.getBackdrop()).skipMemoryCache().error(R.drawable.bg).placeholder(R.drawable.bg).transform(new BlurTransformation(mContext, mMovie.getBackdrop().getAbsolutePath(), 8)).into(mBackground); + } else { + mPicasso.load(mMovie.getBackdrop()).skipMemoryCache().error(R.drawable.bg).placeholder(R.drawable.bg).into(mBackground); + } + } else { + mPicasso.load(mMovie.getBackdrop()).skipMemoryCache().placeholder(R.drawable.bg).into(mBackground, new Callback() { + @Override + public void onError() { + if (!isAdded()) + return; + mPicasso.load(mMovie.getThumbnail()).skipMemoryCache().placeholder(R.drawable.bg).error(R.drawable.bg).into(mBackground); + } + + @Override + public void onSuccess() {} + }); + } + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + inflater.inflate(R.menu.movie_details, menu); + + // If this is a tablet, we have more room to display icons + if (MizLib.isTablet(mContext)) { + menu.findItem(R.id.movie_fav).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + menu.findItem(R.id.share).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + menu.findItem(R.id.watch_list).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + } + + if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(CHROMECAST_BETA_SUPPORT, false)) { + + boolean add = false; + for (Filepath path : mMovie.getFilepaths()) { + if (path.isNetworkFile()) { + add = true; + break; + } + } + + if (add) { + menu.add("Remote play").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + final ArrayList networkFiles = new ArrayList(); + + for (Filepath path : mMovie.getFilepaths()) { + if (path.isNetworkFile()) { + networkFiles.add(path); + } + } + + MizLib.showSelectFileDialog(mContext, networkFiles, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + + Intent i = new Intent(mContext, RemotePlayback.class); + i.putExtra("coverUrl", ""); + i.putExtra("title", mMovie.getTitle()); + i.putExtra("id", mMovie.getTmdbId()); + + if (networkFiles.get(which).getType() == FileSource.SMB) { + String url = VideoUtils.startSmbServer(getActivity(), networkFiles.get(which).getFilepath(), mMovie); + i.putExtra("videoUrl", url); + } else { + i.putExtra("videoUrl", networkFiles.get(which).getFilepath()); + } + + startActivity(i); + } + }); + + return false; + } + }); + } + } + + // Favourite + menu.findItem(R.id.movie_fav).setIcon(mMovie.isFavourite() ? + R.drawable.ic_favorite_white_24dp : R.drawable.ic_favorite_outline_white_24dp) + .setTitle(mMovie.isFavourite() ? + R.string.menuFavouriteTitleRemove : R.string.menuFavouriteTitle); + + // Watchlist + menu.findItem(R.id.watch_list).setIcon(mMovie.toWatch() ? + R.drawable.ic_video_collection_white_24dp : R.drawable.ic_queue_white_24dp) + .setTitle(mMovie.toWatch() ? + R.string.removeFromWatchlist : R.string.watchLater); + + // Watched / unwatched + menu.findItem(R.id.watched).setTitle(mMovie.hasWatched() ? + R.string.stringMarkAsUnwatched : R.string.stringMarkAsWatched); + + // Only allow the user to browse artwork if it's a valid TMDb movie + menu.findItem(R.id.change_cover).setVisible(MizLib.isValidTmdbId(mMovie.getTmdbId())); + + // Go through filepaths and find a network file for offline watching + for (Filepath path : mMovie.getFilepaths()) { + if (path.isNetworkFile()) { + menu.findItem(R.id.watchOffline) + .setVisible(true) + .setTitle(mMovie.hasOfflineCopy(path) ? + R.string.removeOfflineCopy : R.string.watchOffline); + + break; + } + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + if (getActivity().getIntent().getExtras().getBoolean("isFromWidget")) { + Intent i = new Intent(Intent.ACTION_VIEW); + i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK); + i.putExtra("startup", String.valueOf(Main.MOVIES)); + i.setClass(mContext, Main.class); + startActivity(i); + } + + getActivity().finish(); + return true; + case R.id.share: + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_TEXT, "http://www.imdb.com/title/" + mMovie.getImdbId()); + startActivity(intent); + return true; + case R.id.imdb: + Intent imdbIntent = new Intent(Intent.ACTION_VIEW); + imdbIntent.setData(Uri.parse("http://www.imdb.com/title/" + mMovie.getImdbId())); + startActivity(imdbIntent); + return true; + case R.id.tmdb: + Intent tmdbIntent = new Intent(Intent.ACTION_VIEW); + tmdbIntent.setData(Uri.parse("http://www.themoviedb.org/movie/" + mMovie.getTmdbId())); + startActivity(tmdbIntent); + return true; + case R.id.watchOffline: + watchOffline(); + return true; + case R.id.change_cover: + searchCover(); + return true; + case R.id.editMovie: + editMovie(); + return true; + case R.id.identify: + identifyMovie(); + return true; + case R.id.watched: + watched(true); + return true; + case R.id.trailer: + VideoUtils.playTrailer(getActivity(), mMovie); + return true; + case R.id.watch_list: + watchList(); + return true; + case R.id.movie_fav: + favAction(); + return true; + case R.id.delete_movie: + deleteMovie(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + @SuppressLint("InflateParams") + public void deleteMovie() { + AlertDialog.Builder builder = new AlertDialog.Builder(mContext); + + View dialogLayout = LayoutInflater.from(mContext).inflate(R.layout.delete_file_dialog_layout, null); + final CheckBox cb = (CheckBox) dialogLayout.findViewById(R.id.deleteFile); + + + if (mMovie.getFilepaths().size() == 1 && mMovie.getFilepaths().get(0).getType() == FileSource.UPNP) + cb.setEnabled(false); + else + cb.setChecked(PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(ALWAYS_DELETE_FILE, false)); + + builder.setTitle(getString(R.string.removeMovie)) + .setView(dialogLayout) + .setCancelable(false) + .setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + + if (mIgnoreDeletedFiles) { + MovieDatabaseUtils.ignoreMovie(mMovie.getTmdbId()); + } else { + MovieDatabaseUtils.deleteMovie(getActivity(), mMovie.getTmdbId()); + } + + if (cb.isChecked()) { + for (Filepath path : mMovie.getFilepaths()) { + Intent deleteIntent = new Intent(mContext, DeleteFile.class); + deleteIntent.putExtra("filepath", path.getFilepath()); + mContext.startService(deleteIntent); + } + } + + boolean movieExists = mDatabase.movieExists(mMovie.getTmdbId()); + + // We only want to delete movie images, if there are no other versions of the same movie + if (!movieExists) { + try { // Delete cover art image + File coverArt = mMovie.getPoster(); + if (coverArt.exists() && coverArt.getAbsolutePath().contains("com.miz.mizuu")) { + MizLib.deleteFile(coverArt); + } + } catch (NullPointerException e) {} // No file to delete + + try { // Delete thumbnail image + File thumbnail = mMovie.getThumbnail(); + if (thumbnail.exists() && thumbnail.getAbsolutePath().contains("com.miz.mizuu")) { + MizLib.deleteFile(thumbnail); + } + } catch (NullPointerException e) {} // No file to delete + + try { // Delete backdrop image + File backdrop = mMovie.getBackdrop(); + if (backdrop.exists() && backdrop.getAbsolutePath().contains("com.miz.mizuu")) { + MizLib.deleteFile(backdrop); + } + } catch (NullPointerException e) {} // No file to delete + } + + notifyDatasetChanges(); + getActivity().finish(); + return; + } + }) + .setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }) + .create().show(); + } + + public void identifyMovie() { + if (mMovie.getFilepaths().size() == 1) { + getActivity().startActivityForResult(getIdentifyIntent(mMovie.getFilepaths().get(0).getFullFilepath()), 0); + } else { + MizLib.showSelectFileDialog(mContext, mMovie.getFilepaths(), new Dialog.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + startActivity(getIdentifyIntent(mMovie.getFilepaths().get(which).getFullFilepath())); + + // Dismiss the dialog + dialog.dismiss(); + } + }); + } + } + + private Intent getIdentifyIntent(String filepath) { + Intent intent = new Intent(mContext, IdentifyMovie.class); + intent.putExtra("fileName", filepath); + intent.putExtra("currentMovieId", mMovie.getTmdbId()); + intent.putExtra(IntentKeys.TOOLBAR_COLOR, mToolbarColor); + return intent; + } + + public void shareMovie(MenuItem item) { + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_TEXT, "http://www.imdb.com/title/" + mMovie.getImdbId()); + startActivity(Intent.createChooser(intent, getString(R.string.shareWith))); + } + + public void favAction() { + mMovie.setFavourite(!mMovie.isFavourite()); // Reverse the favourite boolean + + boolean success = mDatabase.updateMovieSingleItem(mMovie.getTmdbId(), DbAdapterMovies.KEY_FAVOURITE, mMovie.getFavourite()); + + if (success) { + getActivity().invalidateOptionsMenu(); + + if (mMovie.isFavourite()) { + Toast.makeText(mContext, getString(R.string.addedToFavs), Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(mContext, getString(R.string.removedFromFavs), Toast.LENGTH_SHORT).show(); + getActivity().setResult(2); // Favorite removed + } + + notifyDatasetChanges(); + + } else Toast.makeText(mContext, getString(R.string.errorOccured), Toast.LENGTH_SHORT).show(); + + new Thread() { + @Override + public void run() { + ArrayList movie = new ArrayList(); + movie.add(mMovie); + Trakt.movieFavorite(movie, mContext); + } + }.start(); + } + + private void watched(boolean showToast) { + mMovie.setHasWatched(!mMovie.hasWatched()); // Reverse the hasWatched boolean + + boolean success = mDatabase.updateMovieSingleItem(mMovie.getTmdbId(), DbAdapterMovies.KEY_HAS_WATCHED, mMovie.getHasWatched()); + + if (success) { + getActivity().invalidateOptionsMenu(); + + if (showToast) + if (mMovie.hasWatched()) { + Toast.makeText(mContext, getString(R.string.markedAsWatched), Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(mContext, getString(R.string.markedAsUnwatched), Toast.LENGTH_SHORT).show(); + } + + notifyDatasetChanges(); + + } else Toast.makeText(mContext, getString(R.string.errorOccured), Toast.LENGTH_SHORT).show(); + + if (mRemoveMoviesFromWatchlist) + removeFromWatchlist(); + + new Thread() { + @Override + public void run() { + ArrayList watchedMovies = new ArrayList(); + watchedMovies.add(mMovie); + Trakt.markMovieAsWatched(watchedMovies, mContext); + } + }.start(); + } + + public void watchList() { + mMovie.setToWatch(!mMovie.toWatch()); // Reverse the toWatch boolean + + boolean success = mDatabase.updateMovieSingleItem(mMovie.getTmdbId(), DbAdapterMovies.KEY_TO_WATCH, mMovie.getToWatch()); + + if (success) { + getActivity().invalidateOptionsMenu(); + + if (mMovie.toWatch()) { + Toast.makeText(mContext, getString(R.string.addedToWatchList), Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(mContext, getString(R.string.removedFromWatchList), Toast.LENGTH_SHORT).show(); + } + + notifyDatasetChanges(); + + } else Toast.makeText(mContext, getString(R.string.errorOccured), Toast.LENGTH_SHORT).show(); + + new Thread() { + @Override + public void run() { + ArrayList watchlist = new ArrayList(); + watchlist.add(mMovie); + Trakt.movieWatchlist(watchlist, mContext); + } + }.start(); + } + + public void removeFromWatchlist() { + mMovie.setToWatch(false); // Remove it + + boolean success = mDatabase.updateMovieSingleItem(mMovie.getTmdbId(), DbAdapterMovies.KEY_TO_WATCH, mMovie.getToWatch()); + + if (success) { + getActivity().invalidateOptionsMenu(); + notifyDatasetChanges(); + } + + new Thread() { + @Override + public void run() { + ArrayList watchlist = new ArrayList(); + watchlist.add(mMovie); + Trakt.movieWatchlist(watchlist, mContext); + } + }.start(); + } + + public void watchOffline() { + if (mMovie.getFilepaths().size() == 1) { + watchOffline(mMovie.getFilepaths().get(0)); + } else { + MizLib.showSelectFileDialog(mContext, mMovie.getFilepaths(), new Dialog.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + watchOffline(mMovie.getFilepaths().get(which)); + + // Dismiss the dialog + dialog.dismiss(); + } + }); + } + } + + public void watchOffline(final Filepath path) { + if (mMovie.hasOfflineCopy(path)) { + AlertDialog.Builder builder = new AlertDialog.Builder(mContext); + builder.setMessage(getString(R.string.areYouSure)) + .setTitle(getString(R.string.removeOfflineCopy)) + .setCancelable(false) + .setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + boolean success = mMovie.getOfflineCopyFile(path).delete(); + if (!success) + mMovie.getOfflineCopyFile(path).delete(); + getActivity().invalidateOptionsMenu(); + return; + } + }) + .setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }) + .create().show(); + } else { + AlertDialog.Builder builder = new AlertDialog.Builder(mContext); + builder.setMessage(getString(R.string.downloadOfflineCopy)) + .setTitle(getString(R.string.watchOffline)) + .setCancelable(false) + .setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + if (MizLib.isLocalCopyBeingDownloaded(mContext)) + Toast.makeText(mContext, R.string.addedToDownloadQueue, Toast.LENGTH_SHORT).show(); + + Intent i = new Intent(mContext, MakeAvailableOffline.class); + i.putExtra(MakeAvailableOffline.FILEPATH, path.getFilepath()); + i.putExtra(MakeAvailableOffline.TYPE, MizLib.TYPE_MOVIE); + i.putExtra("thumb", mMovie.getThumbnail().getAbsolutePath()); + i.putExtra("backdrop", mMovie.getBackdrop().getAbsolutePath()); + mContext.startService(i); + return; + } + }) + .setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }) + .create().show(); + } + } + + public void searchCover() { + if (MizLib.isOnline(mContext)) { // Make sure that the device is connected to the web + Intent intent = new Intent(mContext, MovieCoverFanartBrowser.class); + intent.putExtra("tmdbId", mMovie.getTmdbId()); + intent.putExtra("collectionId", mMovie.getCollectionId()); + startActivity(intent); // Start the intent for result + } else { + // No movie ID / Internet connection + Toast.makeText(mContext, getString(R.string.coverSearchFailed), Toast.LENGTH_LONG).show(); + } + } + + private void notifyDatasetChanges() { + LocalBroadcastUtils.updateMovieLibrary(mContext); + } + + private void checkIn() { + new Thread() { + @Override + public void run() { + Trakt.performMovieCheckin(mMovie, getActivity()); + } + }.start(); + } + + private void playMovie() { + ArrayList paths = mMovie.getFilepaths(); + if (paths.size() == 1) { + Filepath path = paths.get(0); + if (mMovie.hasOfflineCopy(path)) { + boolean playbackStarted = VideoUtils.playVideo(getActivity(), mMovie.getOfflineCopyUri(path), FileSource.FILE, mMovie); + if (playbackStarted) { + mVideoPlaybackStarted = System.currentTimeMillis(); + checkIn(); + } + } else { + playMovie(paths.get(0).getFilepath(), paths.get(0).getType()); + } + } else { + boolean hasOfflineCopy = false; + for (Filepath path : paths) { + if (mMovie.hasOfflineCopy(path)) { + boolean playbackStarted = VideoUtils.playVideo(getActivity(), mMovie.getOfflineCopyUri(path), FileSource.FILE, mMovie); + if (playbackStarted) { + mVideoPlaybackStarted = System.currentTimeMillis(); + checkIn(); + } + + hasOfflineCopy = true; + break; + } + } + + if (!hasOfflineCopy) { + MizLib.showSelectFileDialog(mContext, mMovie.getFilepaths(), new Dialog.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Filepath path = mMovie.getFilepaths().get(which); + playMovie(path.getFilepath(), path.getType()); + } + }); + } + } + } + + private void playMovie(String filepath, int filetype) { + if (filepath.toLowerCase(Locale.getDefault()).matches(".*(cd1|part1).*")) { + new GetSplitFiles(filepath, filetype).execute(); + } else { + mVideoPlaybackStarted = System.currentTimeMillis(); + boolean playbackStarted = VideoUtils.playVideo(getActivity(), filepath, filetype, mMovie); + if (playbackStarted) + checkIn(); + } + } + + public void editMovie() { + Intent intent = new Intent(mContext, EditMovie.class); + intent.putExtra("movieId", mMovie.getTmdbId()); + intent.putExtra(IntentKeys.TOOLBAR_COLOR, mToolbarColor); + getActivity().startActivityForResult(intent, 1); + } + + public void onKeyDown(int keyCode, KeyEvent event) { + switch (keyCode) { + case KeyEvent.KEYCODE_MEDIA_PLAY: + case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: + playMovie(); + } + } + + private class GetSplitFiles extends AsyncTask> { + + private ProgressDialog progress; + private String orig_filepath; + private int fileType; + + public GetSplitFiles(String filepath, int filetype) { + this.orig_filepath = filepath; + fileType = filetype; + } + + @Override + protected void onPreExecute() { + progress = new ProgressDialog(getActivity()); + progress.setIndeterminate(true); + progress.setTitle(getString(R.string.loading_movie_parts)); + progress.setMessage(getString(R.string.few_moments)); + progress.show(); + } + + @Override + protected List doInBackground(String... params) { + List parts = new ArrayList(); + List temp; + + try { + if (fileType == FileSource.SMB) + temp = MizLib.getSplitParts(orig_filepath, MizLib.getAuthFromFilepath(MizLib.TYPE_MOVIE, orig_filepath)); + else + temp = MizLib.getSplitParts(orig_filepath, null); + + for (int i = 0; i < temp.size(); i++) + parts.add(new SplitFile(temp.get(i))); + + } catch (Exception e) {} + + return parts; + } + + @Override + protected void onPostExecute(final List result) { + progress.dismiss(); + + if (result.size() > 0) + mVideoPlaybackStarted = System.currentTimeMillis(); + + if (result.size() > 1) { + AlertDialog.Builder builder = new AlertDialog.Builder(mContext); + builder.setTitle(getString(R.string.playPart)); + builder.setAdapter(new SplitAdapter(mContext, result), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + boolean playbackStarted = VideoUtils.playVideo(getActivity(), result.get(which).getFilepath(), fileType, mMovie); + if (playbackStarted) + checkIn(); + }}); + builder.show(); + } else if (result.size() == 1) { + boolean playbackStarted = VideoUtils.playVideo(getActivity(), result.get(0).getFilepath(), fileType, mMovie); + if (playbackStarted) + checkIn(); + } else { + Toast.makeText(mContext, getString(R.string.errorSomethingWentWrong), Toast.LENGTH_LONG).show(); + } + } + } + + private class SplitAdapter implements android.widget.ListAdapter { + + private List mFiles; + private Context mContext; + private LayoutInflater inflater; + + public SplitAdapter(Context context, List files) { + mContext = context; + inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + mFiles = files; + } + + @Override + public int getCount() { + return mFiles.size(); + } + + @Override + public Object getItem(int position) { + return null; + } + + @Override + public long getItemId(int position) { + return 0; + } + + @Override + public int getItemViewType(int position) { + return 0; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + + if (convertView == null) + convertView = inflater.inflate(R.layout.split_file_item, parent, false); + + // Don't care about the ViewHolder pattern here + ((TextView) convertView.findViewById(R.id.title)).setText(getString(R.string.part) + " " + mFiles.get(position).getPartNumber()); + ((TextView) convertView.findViewById(R.id.description)).setText(mFiles.get(position).getUserFilepath()); + + return convertView; + } + + @Override + public int getViewTypeCount() { + return 1; + } + + @Override + public boolean hasStableIds() { + return true; + } + + @Override + public boolean isEmpty() { + return mFiles.isEmpty(); + } + + @Override + public void registerDataSetObserver(DataSetObserver observer) {} + + @Override + public void unregisterDataSetObserver(DataSetObserver observer) {} + + @Override + public boolean areAllItemsEnabled() { + return true; + } + + @Override + public boolean isEnabled(int position) { + return true; + } + + } + + private class SplitFile { + + String filepath; + + public SplitFile(String filepath) { + this.filepath = filepath; + } + + public String getFilepath() { + return filepath; + } + + public String getUserFilepath() { + return MizLib.transformSmbPath(filepath); + } + + public int getPartNumber() { + return MizLib.getPartNumberFromFilepath(getUserFilepath()); + } + } +} \ No newline at end of file diff --git a/src/com/miz/mizuu/fragments/MovieDiscoveryFragment.java b/app/src/main/java/com/miz/mizuu/fragments/MovieDiscoveryFragment.java similarity index 93% rename from src/com/miz/mizuu/fragments/MovieDiscoveryFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/MovieDiscoveryFragment.java index 520121bf..31637012 100644 --- a/src/com/miz/mizuu/fragments/MovieDiscoveryFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/MovieDiscoveryFragment.java @@ -16,13 +16,6 @@ package com.miz.mizuu.fragments; -import static com.miz.functions.PreferenceKeys.GRID_ITEM_SIZE; - -import java.util.ArrayList; - -import org.json.JSONArray; -import org.json.JSONObject; - import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -30,7 +23,10 @@ import android.graphics.Bitmap.Config; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.v4.app.ActivityCompat; +import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; import android.util.SparseBooleanArray; import android.view.LayoutInflater; import android.view.View; @@ -54,8 +50,16 @@ import com.miz.mizuu.MovieDetails; import com.miz.mizuu.R; import com.miz.mizuu.TMDbMovieDetails; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.util.ArrayList; + +import static com.miz.functions.PreferenceKeys.GRID_ITEM_SIZE; + public class MovieDiscoveryFragment extends Fragment implements OnSharedPreferenceChangeListener { private int mImageThumbSize, mImageThumbSpacing; @@ -87,7 +91,7 @@ public static MovieDiscoveryFragment newInstance(String type, String json, Strin @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + mDatabase = MizuuApplication.getMovieAdapter(); String thumbnailSize = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString(GRID_ITEM_SIZE, getString(R.string.normal)); @@ -141,19 +145,19 @@ public void onGlobalLayout() { mGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { - if (mMovieMap.get(Integer.valueOf(mMovies.get(arg2).getId()))) { - Intent intent = new Intent(); - intent.setClass(getActivity(), MovieDetails.class); - intent.putExtra("tmdbId", mMovies.get(arg2).getId()); + Intent i = new Intent(); - startActivity(intent); + if (mMovieMap.get(Integer.valueOf(mMovies.get(arg2).getId()))) { + i.setClass(getActivity(), MovieDetails.class); + i.putExtra("tmdbId", mMovies.get(arg2).getId()); } else { - Intent i = new Intent(Intent.ACTION_VIEW); i.setClass(getActivity(), TMDbMovieDetails.class); i.putExtra("tmdbId", mMovies.get(arg2).getId()); i.putExtra("title", mMovies.get(arg2).getTitle()); - startActivity(i); } + + ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), arg1.findViewById(R.id.cover), "cover"); + ActivityCompat.startActivity(getActivity(), i, options.toBundle()); } }); @@ -162,19 +166,13 @@ public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { mBaseUrl = getArguments().getString("baseUrl"); loadJson(); } - } - @Override - public void onResume() { - super.onResume(); - if (mAdapter != null) - mAdapter.notifyDataSetChanged(); } @Override public void onStart() { super.onStart(); - getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); + ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } private class ImageAdapter extends BaseAdapter { @@ -208,7 +206,7 @@ public View getView(int position, View convertView, ViewGroup container) { final WebMovie mMovie = mMovies.get(position); CoverItem holder; - + if (convertView == null) { convertView = inflater.inflate(R.layout.grid_item, container, false); holder = new CoverItem(); @@ -220,7 +218,7 @@ public View getView(int position, View convertView, ViewGroup container) { holder.subtext = (TextView) convertView.findViewById(R.id.gridCoverSubtitle); holder.subtext.setSingleLine(true); - holder.text.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf")); + holder.text.setTypeface(TypefaceUtils.getRobotoMedium(mContext)); convertView.setTag(holder); } else { diff --git a/app/src/main/java/com/miz/mizuu/fragments/MovieDiscoveryViewPagerFragment.java b/app/src/main/java/com/miz/mizuu/fragments/MovieDiscoveryViewPagerFragment.java new file mode 100644 index 00000000..4def3db9 --- /dev/null +++ b/app/src/main/java/com/miz/mizuu/fragments/MovieDiscoveryViewPagerFragment.java @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.mizuu.fragments; + +import android.content.Context; +import android.content.Intent; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; +import android.support.v7.app.ActionBar; +import android.support.v7.app.ActionBarActivity; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ProgressBar; +import android.widget.Toast; + +import com.astuetz.PagerSlidingTabStrip; +import com.miz.functions.MizLib; +import com.miz.mizuu.R; +import com.miz.mizuu.SearchWebMovies; + +public class MovieDiscoveryViewPagerFragment extends Fragment { + + private ProgressBar mProgressBar; + private String mBaseUrl = "", mJson = ""; + private ViewPager mViewPager; + private PagerSlidingTabStrip mTabs; + + public MovieDiscoveryViewPagerFragment() {} + + public static MovieDiscoveryViewPagerFragment newInstance() { + return new MovieDiscoveryViewPagerFragment(); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setHasOptionsMenu(true); + setRetainInstance(true); + + getActivity().setTitle(R.string.drawerOnlineMovies); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + getActivity().setTitle(R.string.drawerOnlineMovies); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return inflater.inflate(R.layout.viewpager_with_tabs, container, false); + } + + @Override + public void onViewCreated(View v, Bundle savedInstanceState) { + super.onViewCreated(v, savedInstanceState); + + mProgressBar = (ProgressBar) v.findViewById(R.id.progressbar); + mProgressBar.setVisibility(View.VISIBLE); + + mViewPager = (ViewPager) v.findViewById(R.id.awesomepager); + mViewPager.setOffscreenPageLimit(3); + mViewPager.setPageMargin(MizLib.convertDpToPixels(getActivity(), 16)); + + mTabs = (PagerSlidingTabStrip) v.findViewById(R.id.tabs); + mTabs.setVisibility(View.GONE); + mTabs.setShouldExpand(true); + + if (savedInstanceState != null) { + mViewPager.setCurrentItem(savedInstanceState.getInt("selectedIndex", 0)); + } + + if (mJson.isEmpty()) { + new MovieLoader(getActivity()).execute(); + } else { + setupAdapterAndTabs(); + } + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + inflater.inflate(R.menu.menu_web_movies, menu); + + super.onCreateOptionsMenu(menu, inflater); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.search_textbox: + Intent i = new Intent(getActivity().getApplicationContext(), SearchWebMovies.class); + startActivity(i); + break; + } + + return super.onOptionsItemSelected(item); + } + + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putInt("selectedIndex", mViewPager.getCurrentItem()); + } + + private class WebVideosAdapter extends FragmentPagerAdapter { + + private final String[] TITLES = {getString(R.string.stringUpcoming), getString(R.string.stringNowPlaying), getString(R.string.stringPopular)}; + + public WebVideosAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public CharSequence getPageTitle(int position) { + return TITLES[position]; + } + + @Override + public Fragment getItem(int index) { + switch (index) { + case 0: return MovieDiscoveryFragment.newInstance("upcoming", mJson, mBaseUrl); + case 1: return MovieDiscoveryFragment.newInstance("now_playing", mJson, mBaseUrl); + default: return MovieDiscoveryFragment.newInstance("popular", mJson, mBaseUrl); + } + } + + @Override + public int getCount() { + return 3; + } + } + + private class MovieLoader extends AsyncTask { + + private Context mContext; + + public MovieLoader(Context context) { + mContext = context; + } + + @Override + protected String doInBackground(Object... params) { + try { + mBaseUrl = MizLib.getTmdbImageBaseUrl(mContext); + mJson = MizLib.getJSONObject(mContext, "https://api.themoviedb.org/3/movie?api_key=" + MizLib.getTmdbApiKey(mContext) + "&append_to_response=upcoming,now_playing,popular,top_rated").toString(); + + return mJson; + } catch (Exception e) {} // If the fragment is no longer attached to the Activity + + return null; + } + + @Override + protected void onPostExecute(String result) { + if (result != null) { + setupAdapterAndTabs(); + } else { + Toast.makeText(getActivity(), R.string.errorSomethingWentWrong, Toast.LENGTH_SHORT).show(); + } + } + } + + private void setupAdapterAndTabs() { + if (MizLib.hasLollipop()) + ((ActionBarActivity) getActivity()).getSupportActionBar().setElevation(0); + + mViewPager.setAdapter(new WebVideosAdapter(getChildFragmentManager())); + mTabs.setViewPager(mViewPager); + mTabs.setVisibility(View.VISIBLE); + mProgressBar.setVisibility(View.GONE); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/miz/mizuu/fragments/MovieLibraryFragment.java b/app/src/main/java/com/miz/mizuu/fragments/MovieLibraryFragment.java new file mode 100644 index 00000000..068d6f30 --- /dev/null +++ b/app/src/main/java/com/miz/mizuu/fragments/MovieLibraryFragment.java @@ -0,0 +1,1326 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.mizuu.fragments; + +import android.app.AlertDialog; +import android.app.SearchManager; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; +import android.database.Cursor; +import android.graphics.Bitmap.Config; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.support.v4.app.ActivityCompat; +import android.support.v4.app.ActivityOptionsCompat; +import android.support.v4.app.Fragment; +import android.support.v4.app.LoaderManager.LoaderCallbacks; +import android.support.v4.content.Loader; +import android.support.v4.content.LocalBroadcastManager; +import android.support.v4.view.MenuItemCompat; +import android.support.v4.view.MenuItemCompat.OnActionExpandListener; +import android.support.v7.app.ActionBar; +import android.support.v7.app.ActionBar.OnNavigationListener; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.SearchView; +import android.support.v7.widget.SearchView.OnQueryTextListener; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.BaseAdapter; +import android.widget.GridView; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.google.common.collect.ArrayListMultimap; +import com.miz.db.DatabaseHelper; +import com.miz.db.DbAdapterMovieMappings; +import com.miz.db.DbAdapterMovies; +import com.miz.db.DbAdapterSources; +import com.miz.functions.ActionBarSpinnerViewHolder; +import com.miz.functions.AsyncTask; +import com.miz.functions.ColumnIndexCache; +import com.miz.functions.CoverItem; +import com.miz.functions.FileSource; +import com.miz.functions.Filepath; +import com.miz.functions.LibrarySectionAsyncTask; +import com.miz.functions.MediumMovie; +import com.miz.functions.MizLib; +import com.miz.functions.MovieLoader; +import com.miz.functions.MovieLoader.MovieLibraryType; +import com.miz.functions.MovieLoader.OnLoadCompletedCallback; +import com.miz.functions.MovieSortHelper; +import com.miz.functions.SQLiteCursorLoader; +import com.miz.functions.SpinnerItem; +import com.miz.mizuu.MizuuApplication; +import com.miz.mizuu.MovieCollection; +import com.miz.mizuu.MovieDetails; +import com.miz.mizuu.R; +import com.miz.mizuu.UnidentifiedMovies; +import com.miz.mizuu.Update; +import com.miz.utils.LocalBroadcastUtils; +import com.miz.utils.TypefaceUtils; +import com.squareup.picasso.Picasso; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Random; +import java.util.TreeMap; +import java.util.regex.Pattern; + +import jcifs.smb.SmbFile; + +import static com.miz.functions.PreferenceKeys.GRID_ITEM_SIZE; +import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; +import static com.miz.functions.PreferenceKeys.SHOW_TITLES_IN_GRID; +import static com.miz.functions.PreferenceKeys.SORTING_COLLECTIONS_OVERVIEW; +import static com.miz.functions.PreferenceKeys.SORTING_MOVIES; +import static com.miz.functions.SortingKeys.ALL_MOVIES; +import static com.miz.functions.SortingKeys.AVAILABLE_FILES; +import static com.miz.functions.SortingKeys.CERTIFICATION; +import static com.miz.functions.SortingKeys.COLLECTIONS; +import static com.miz.functions.SortingKeys.DATE; +import static com.miz.functions.SortingKeys.DURATION; +import static com.miz.functions.SortingKeys.FAVORITES; +import static com.miz.functions.SortingKeys.FILE_SOURCES; +import static com.miz.functions.SortingKeys.FOLDERS; +import static com.miz.functions.SortingKeys.GENRES; +import static com.miz.functions.SortingKeys.OFFLINE_COPIES; +import static com.miz.functions.SortingKeys.RATING; +import static com.miz.functions.SortingKeys.RELEASE; +import static com.miz.functions.SortingKeys.RELEASE_YEAR; +import static com.miz.functions.SortingKeys.TITLE; +import static com.miz.functions.SortingKeys.UNWATCHED_MOVIES; +import static com.miz.functions.SortingKeys.WATCHED_MOVIES; +import static com.miz.functions.SortingKeys.WEIGHTED_RATING; + +public class MovieLibraryFragment extends Fragment implements OnNavigationListener, OnSharedPreferenceChangeListener { + + public static final int MAIN = 0, OTHER = 1; + + private SharedPreferences mSharedPreferences; + private int mImageThumbSize, mImageThumbSpacing, mType, mCurrentSort; + private LoaderAdapter mAdapter; + private ArrayList mMovies = new ArrayList(); + private ArrayList mMovieKeys = new ArrayList(); + private GridView mGridView = null; + private ProgressBar mProgressBar; + private boolean mIgnorePrefixes, mLoading, mShowTitles; + private ActionBar mActionBar; + private ArrayList mSpinnerItems = new ArrayList(); + private ActionBarSpinner mSpinnerAdapter; + private Picasso mPicasso; + private Config mConfig; + private MovieSectionLoader mMovieSectionLoader; + private SearchTask mSearch; + private View mEmptyLibraryLayout; + private TextView mEmptyLibraryTitle, mEmptyLibraryDescription; + + /** + * Empty constructor as per the Fragment documentation + */ + public MovieLibraryFragment() {} + + public static MovieLibraryFragment newInstance(int type) { + MovieLibraryFragment frag = new MovieLibraryFragment(); + Bundle b = new Bundle(); + b.putInt("type", type); + frag.setArguments(b); + return frag; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + mType = getArguments().getInt("type"); + + setRetainInstance(true); + setHasOptionsMenu(true); + + setupSpinnerItems(); + + // Set OnSharedPreferenceChange listener + PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this); + + // Initialize the PreferenceManager variable and preference variable(s) + mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); + + mIgnorePrefixes = mSharedPreferences.getBoolean(IGNORED_TITLE_PREFIXES, false); + mShowTitles = mSharedPreferences.getBoolean(SHOW_TITLES_IN_GRID, true); + + String thumbnailSize = mSharedPreferences.getString(GRID_ITEM_SIZE, getString(R.string.normal)); + if (thumbnailSize.equals(getString(R.string.large))) + mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 1.33); + else if (thumbnailSize.equals(getString(R.string.normal))) + mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 1); + else + mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 0.75); + mImageThumbSpacing = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); + + mPicasso = MizuuApplication.getPicasso(getActivity()); + mConfig = MizuuApplication.getBitmapConfig(); + + mAdapter = new LoaderAdapter(getActivity().getApplicationContext()); + + MovieLoader loader = new MovieLoader(getActivity(), MovieLibraryType.ALL_MOVIES, callback); + loader.load(); + } + + private OnLoadCompletedCallback callback = new OnLoadCompletedCallback() { + @Override + public void onLoadCompleted(List movieList) { + System.out.println("SIZE: " + movieList.size()); + } + }; + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + if (mType == OTHER) + getActivity().setTitle(R.string.chooserWatchList); + else + getActivity().setTitle(R.string.chooserMovies); + + // Setup ActionBar with the action list + setupActionBar(); + if (mActionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST) + mActionBar.setListNavigationCallbacks(mSpinnerAdapter, this); + + LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.UPDATE_MOVIE_LIBRARY)); + LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver, new IntentFilter("mizuu-movie-actor-search")); + } + + private void setupActionBar() { + mActionBar = ((ActionBarActivity) getActivity()).getSupportActionBar(); + if (mSpinnerAdapter == null) + mSpinnerAdapter = new ActionBarSpinner(); + } + + private void setupSpinnerItems() { + mSpinnerItems.clear(); + if (mType == MAIN) + mSpinnerItems.add(new SpinnerItem(getString(R.string.chooserMovies), getString(R.string.choiceAllMovies))); + else + mSpinnerItems.add(new SpinnerItem(getString(R.string.chooserWatchList), getString(R.string.choiceAllMovies))); + mSpinnerItems.add(new SpinnerItem(getString(R.string.choiceFavorites), getString(R.string.choiceFavorites))); + mSpinnerItems.add(new SpinnerItem(getString(R.string.choiceAvailableFiles), getString(R.string.choiceAvailableFiles))); + mSpinnerItems.add(new SpinnerItem(getString(R.string.choiceCollections), getString(R.string.choiceCollections))); + mSpinnerItems.add(new SpinnerItem(getString(R.string.choiceWatchedMovies), getString(R.string.choiceWatchedMovies))); + mSpinnerItems.add(new SpinnerItem(getString(R.string.choiceUnwatchedMovies), getString(R.string.choiceUnwatchedMovies))); + mSpinnerItems.add(new SpinnerItem(getString(R.string.choiceOffline), getString(R.string.choiceOffline))); + } + + private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (intent.filterEquals(new Intent("mizuu-movie-actor-search"))) { + search("actor: " + intent.getStringExtra("intent_extra_data_key")); + } else { + clearCaches(); + forceLoaderLoad(); + } + } + }; + + LoaderCallbacks loaderCallbacks = new LoaderCallbacks() { + @Override + public Loader onCreateLoader(int arg0, Bundle arg1) { + mLoading = true; + return new SQLiteCursorLoader(getActivity(), DatabaseHelper.getHelper(getActivity()).getWritableDatabase(), DbAdapterMovies.DATABASE_TABLE, + DbAdapterMovies.SELECT_ALL, null, null, null, null, null); + } + + @Override + public void onLoadFinished(Loader arg0, final Cursor cursor) { + new AsyncTask() { + @Override + protected void onPreExecute() { + mMovies.clear(); + mMovieKeys.clear(); + } + + @Override + protected Void doInBackground(Void... params) { + // Normally we'd have to go through each movie and add filepaths mapped to that movie + // one by one. This is a hacky approach that gets all filepaths at once and creates a + // map of them. That way it's easy to get filepaths for a specific movie - and it's + // 2-3x faster with ~750 movies. + ArrayListMultimap filepaths = ArrayListMultimap.create(); + Cursor paths = MizuuApplication.getMovieMappingAdapter().getAllFilepaths(false); + if (paths != null) { + try { + while (paths.moveToNext()) { + filepaths.put(paths.getString(paths.getColumnIndex(DbAdapterMovieMappings.KEY_TMDB_ID)), + paths.getString(paths.getColumnIndex(DbAdapterMovieMappings.KEY_FILEPATH))); + } + } catch (Exception e) {} finally { + paths.close(); + MizuuApplication.setMovieFilepaths(filepaths); + } + } + + HashMap collectionsMap = MizuuApplication.getCollectionsAdapter().getCollectionsMap(); + ColumnIndexCache cache = new ColumnIndexCache(); + + try { + while (cursor.moveToNext()) { + if (mType == OTHER && cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TO_WATCH)).equals("0")) + continue; + + mMovies.add(new MediumMovie(getActivity(), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TITLE)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TMDB_ID)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_RATING)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_RELEASEDATE)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_GENRES)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_FAVOURITE)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_ACTORS)), + collectionsMap.get(cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_COLLECTION_ID))), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_COLLECTION_ID)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TO_WATCH)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_HAS_WATCHED)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_DATE_ADDED)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_CERTIFICATION)), + cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_RUNTIME)), + mIgnorePrefixes + )); + } + } catch (Exception e) {} finally { + cursor.close(); + cache.clear(); + } + + for (int i = 0; i < mMovies.size(); i++) { + if (mType == OTHER) + if (!mMovies.get(i).toWatch()) + continue; + mMovieKeys.add(i); + } + + Log.d("MIZUU", "SIZE: " + mMovieKeys.size()); + + return null; + } + + @Override + protected void onPostExecute(Void result) { + showMovieSection(ALL_MOVIES); + + getActivity().invalidateOptionsMenu(); + + mLoading = false; + } + }.execute(); + } + + @Override + public void onLoaderReset(Loader arg0) { + mMovies.clear(); + mMovieKeys.clear(); + notifyDataSetChanged(); + } + }; + + private void clearCaches() { + if (isAdded()) + MizuuApplication.clearLruCache(getActivity()); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return inflater.inflate(R.layout.image_grid_fragment, container, false); + } + + @Override + public void onViewCreated(View v, Bundle savedInstanceState) { + super.onViewCreated(v, savedInstanceState); + + mProgressBar = (ProgressBar) v.findViewById(R.id.progress); + if (mMovieKeys.size() > 0) + mProgressBar.setVisibility(View.GONE); + + mEmptyLibraryLayout = v.findViewById(R.id.empty_library_layout); + mEmptyLibraryTitle = (TextView) v.findViewById(R.id.empty_library_title); + mEmptyLibraryTitle.setTypeface(TypefaceUtils.getRobotoCondensedRegular(getActivity())); + mEmptyLibraryDescription = (TextView) v.findViewById(R.id.empty_library_description); + if (mType == OTHER) + mEmptyLibraryDescription.setText(R.string.empty_watchlist_description); + mEmptyLibraryDescription.setTypeface(TypefaceUtils.getRobotoLight(getActivity())); + + mAdapter = new LoaderAdapter(getActivity()); + + mGridView = (GridView) v.findViewById(R.id.gridView); + mGridView.setAdapter(mAdapter); + mGridView.setEmptyView(mEmptyLibraryLayout); + mGridView.setColumnWidth(mImageThumbSize); + + // Calculate the total column width to set item heights by factor 1.5 + mGridView.getViewTreeObserver().addOnGlobalLayoutListener( + new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + if (mAdapter.getNumColumns() == 0) { + final int numColumns = (int) Math.floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing)); + if (numColumns > 0) { + mAdapter.setNumColumns(numColumns); + } + + MizLib.removeViewTreeObserver(mGridView.getViewTreeObserver(), this); + } + } + }); + mGridView.setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { + showDetails(arg2, arg1); + } + }); + } + + private void showDetails(int arg2, View view) { + Intent intent = new Intent(); + if (mActionBar.getSelectedNavigationIndex() == COLLECTIONS) { // Collection + intent.putExtra("collectionId", mMovies.get(mMovieKeys.get(arg2)).getCollectionId()); + intent.putExtra("collectionTitle", mMovies.get(mMovieKeys.get(arg2)).getCollection()); + intent.setClass(getActivity(), MovieCollection.class); + startActivity(intent); + } else { + intent.putExtra("tmdbId", mMovies.get(mMovieKeys.get(arg2)).getTmdbId()); + intent.setClass(getActivity(), MovieDetails.class); + + if (view != null) { + ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), view.findViewById(R.id.cover), "cover"); + ActivityCompat.startActivityForResult(getActivity(), intent, 0, options.toBundle()); + } else { + startActivityForResult(intent, 0); + } + } + } + + @Override + public void onResume() { + super.onResume(); + + if (mMovies.size() == 0) + forceLoaderLoad(); + } + + @Override + public void onDestroy() { + // Unregister since the activity is about to be closed. + LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mMessageReceiver); + PreferenceManager.getDefaultSharedPreferences(getActivity()).unregisterOnSharedPreferenceChangeListener(this); + + super.onDestroy(); + } + + private class LoaderAdapter extends BaseAdapter { + + private LayoutInflater mInflater; + private final Context mContext; + private int mNumColumns = 0; + private boolean mCollectionsView = false; + private ArrayList mMovieKeys = new ArrayList(); + private ArrayList mMovies = new ArrayList(); + + public LoaderAdapter(Context context) { + mContext = context; + mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + } + + // This is necessary in order to avoid random ArrayOutOfBoundsException when changing the items (i.e. during a library update) + public void setItems(ArrayList movieKeys, ArrayList movies) { + mMovieKeys = new ArrayList(movieKeys); + mMovies = new ArrayList(movies); + notifyDataSetChanged(); + } + + @Override + public boolean isEmpty() { + return !mLoading && mMovieKeys.size() == 0; + } + + @Override + public int getCount() { + return mMovieKeys.size(); + } + + @Override + public Object getItem(int position) { + return position; + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup container) { + final MediumMovie mMovie = mMovies.get(mMovieKeys.get(position)); + + CoverItem holder; + if (convertView == null) { + convertView = mInflater.inflate(R.layout.grid_item, container, false); + holder = new CoverItem(); + + holder.mLinearLayout = (LinearLayout) convertView.findViewById(R.id.card_layout); + holder.cover = (ImageView) convertView.findViewById(R.id.cover); + holder.text = (TextView) convertView.findViewById(R.id.text); + holder.subtext = (TextView) convertView.findViewById(R.id.gridCoverSubtitle); + holder.subtext.setSingleLine(true); + + holder.text.setTypeface(TypefaceUtils.getRobotoMedium(mContext)); + + convertView.setTag(holder); + } else { + holder = (CoverItem) convertView.getTag(); + } + + if (!mShowTitles) { + holder.text.setVisibility(View.GONE); + holder.subtext.setVisibility(View.GONE); + } else { + holder.text.setVisibility(View.VISIBLE); + + holder.text.setText(mCollectionsView ? mMovie.getCollection() : mMovie.getTitle()); + if (mCollectionsView) { + holder.text.setSingleLine(false); + holder.text.setLines(2); + holder.text.setMaxLines(2); + holder.subtext.setVisibility(View.GONE); + } else { + holder.text.setSingleLine(true); + holder.text.setLines(1); + holder.text.setMaxLines(1); + holder.subtext.setVisibility(View.VISIBLE); + holder.subtext.setText(mMovie.getSubText(mCurrentSort)); + } + } + + holder.cover.setImageResource(R.color.card_background_dark); + + mPicasso.load(mCollectionsView ? mMovie.getCollectionPoster() : mMovie.getThumbnail()).config(mConfig).into(holder); + + return convertView; + } + + @Override + public void notifyDataSetChanged() { + if (mActionBar != null) + mCollectionsView = mActionBar.getSelectedNavigationIndex() == COLLECTIONS; + + super.notifyDataSetChanged(); + } + + public void setNumColumns(int numColumns) { + mNumColumns = numColumns; + } + + public int getNumColumns() { + return mNumColumns; + } + } + + private void notifyDataSetChanged() { + if (mAdapter != null) + mAdapter.setItems(mMovieKeys, mMovies); + + if (mSpinnerAdapter != null) + mSpinnerAdapter.notifyDataSetChanged(); + } + + @Override + public boolean onNavigationItemSelected(int itemPosition, long itemId) { + if (!mLoading) + showMovieSection(itemPosition); + + return true; + } + + private class MovieSectionLoader extends LibrarySectionAsyncTask { + private int mPosition; + private ArrayList mTempKeys = new ArrayList(); + + public MovieSectionLoader(int position) { + mPosition = position; + } + + @Override + protected void onPreExecute() { + //setProgressBarVisible(true); + mMovieKeys.clear(); + } + + @Override + protected Boolean doInBackground(Void... params) { + if (isCancelled()) + return false; + + switch (mPosition) { + case ALL_MOVIES: + for (int i = 0; i < mMovies.size(); i++) + if (!mMovies.get(i).isUnidentified()) + mTempKeys.add(i); + break; + + case FAVORITES: + for (int i = 0; i < mMovies.size(); i++) + if (mMovies.get(i).isFavourite()) + mTempKeys.add(i); + break; + + case AVAILABLE_FILES: + ArrayList filesources = MizLib.getFileSources(MizLib.TYPE_MOVIE, true); + + for (int i = 0; i < mMovies.size(); i++) { + if (isCancelled()) + return false; + + for (Filepath path : mMovies.get(i).getFilepaths()) { + if (path.isNetworkFile()) + if (mMovies.get(i).hasOfflineCopy(path)) { + mTempKeys.add(i); + break; // break inner loop to continue to the next movie + } else { + if (path.getType() == FileSource.SMB) { + + + if (MizLib.isWifiConnected(getActivity())) { + FileSource source = null; + + for (int j = 0; j < filesources.size(); j++) + if (path.getFilepath().contains(filesources.get(j).getFilepath())) { + source = filesources.get(j); + continue; + } + + if (source == null) + continue; + + try { + final SmbFile file = new SmbFile( + MizLib.createSmbLoginString( + source.getDomain(), + source.getUser(), + source.getPassword(), + path.getFilepath(), + false + )); + if (file.exists()) { + mTempKeys.add(i); + break; // break inner loop to continue to the next movie + } + } catch (Exception e) {} // Do nothing - the file isn't available (either MalformedURLException or SmbException) + } + } else if (path.getType() == FileSource.UPNP) { + if (MizLib.exists(path.getFilepath())) { + mTempKeys.add(i); + break; // break inner loop to continue to the next movie + } + } + } else { + if (new File(path.getFilepath()).exists()) { + mTempKeys.add(i); + break; // break inner loop to continue to the next movie + } + } + } + } + break; + + case COLLECTIONS: + HashMap map = new HashMap(); + for (int i = 0; i < mMovies.size(); i++) + if (!TextUtils.isEmpty(mMovies.get(i).getCollection()) && !mMovies.get(i).getCollection().equals("null")) + if (!map.containsKey(mMovies.get(i).getCollection())) { + map.put(mMovies.get(i).getCollection(), mMovies.get(i)); + mTempKeys.add(i); + } + map.clear(); + break; + + case WATCHED_MOVIES: + for (int i = 0; i < mMovies.size(); i++) + if (mMovies.get(i).hasWatched()) + mTempKeys.add(i); + break; + + case UNWATCHED_MOVIES: + for (int i = 0; i < mMovies.size(); i++) + if (!mMovies.get(i).hasWatched()) + mTempKeys.add(i); + break; + + case OFFLINE_COPIES: + // No point in running through all movies if the folder + // doesn't contain any files at all - so let's check that first + File offlineFolder = MizuuApplication.getAvailableOfflineFolder(getActivity()); + if (offlineFolder != null && offlineFolder.listFiles().length == 0) + return true; // Return true in order to force the notifyDataSetChanged() call + + for (int i = 0; i < mMovies.size(); i++) { + if (isCancelled()) + return false; + + for (Filepath path : mMovies.get(i).getFilepaths()) + if (mMovies.get(i).hasOfflineCopy(path)) { + mTempKeys.add(i); + break; // break inner loop to continue to the next movie + } + } + break; + } + + return true; + } + + @Override + protected void onPostExecute(Boolean success) { + // Make sure that the loading was successful, that the Fragment is still added and + // that the currently selected navigation index is the same as when we started loading + if (success && isAdded()/* && mActionBar.getSelectedNavigationIndex() == mPosition*/) { + mMovieKeys.addAll(mTempKeys); + + sortMovies(); + notifyDataSetChanged(); + setProgressBarVisible(false); + } + } + } + + private void showMovieSection(int position) { + if (mSpinnerAdapter != null) + mSpinnerAdapter.notifyDataSetChanged(); // To show "0 movies" when loading + + if (mMovieSectionLoader != null) + mMovieSectionLoader.cancel(true); + mMovieSectionLoader = new MovieSectionLoader(position); + mMovieSectionLoader.execute(); + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + setupActionBar(); + inflater.inflate(R.menu.menu, menu); + if (mType == OTHER) // Don't show the Update icon if this is the Watchlist + menu.removeItem(R.id.update); + + if (mMovies.size() == 0) + menu.findItem(R.id.random).setVisible(false); + else + menu.findItem(R.id.random).setVisible(true); + + MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.search_textbox), new OnActionExpandListener() { + @Override + public boolean onMenuItemActionExpand(MenuItem item) { + return true; + } + + @Override + public boolean onMenuItemActionCollapse(MenuItem item) { + onSearchViewCollapsed(); + return true; + } + }); + + SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); + SearchView searchView = (SearchView) menu.findItem(R.id.search_textbox).getActionView(); + searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); + searchView.setOnQueryTextListener(new OnQueryTextListener() { + @Override + public boolean onQueryTextChange(String newText) { + if (newText.length() > 0) { + search(newText); + } else { + onSearchViewCollapsed(); + } + return true; + } + @Override + public boolean onQueryTextSubmit(String query) { return false; } + }); + + super.onCreateOptionsMenu(menu, inflater); + } + + private void onSearchViewCollapsed() { + if (isAdded() && mActionBar != null) { + if (mActionBar.getSelectedNavigationIndex() == ALL_MOVIES) + showMovieSection(ALL_MOVIES); + else + mActionBar.setSelectedNavigationItem(ALL_MOVIES); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + super.onOptionsItemSelected(item); + + switch (item.getItemId()) { + case R.id.update: + startActivityForResult(getUpdateIntent(), 0); + break; + case R.id.menuSortAdded: + sortBy(DATE); + break; + case R.id.menuSortRating: + sortBy(RATING); + break; + case R.id.menuSortWeightedRating: + sortBy(WEIGHTED_RATING); + break; + case R.id.menuSortRelease: + sortBy(RELEASE); + break; + case R.id.menuSortTitle: + sortBy(TITLE); + break; + case R.id.menuSortDuration: + sortBy(DURATION); + break; + case R.id.genres: + showGenres(); + break; + case R.id.certifications: + showCertifications(); + break; + case R.id.folders: + showFolders(); + break; + case R.id.fileSources: + showFileSources(); + break; + case R.id.release_year: + showReleaseYear(); + break; + case R.id.clear_filters: + showMovieSection(mActionBar.getSelectedNavigationIndex()); + break; + case R.id.random: + if (mMovieKeys.size() > 0) { + int random = new Random().nextInt(mMovieKeys.size()); + showDetails(random, null); + } + break; + case R.id.unidentifiedFiles: + startActivity(new Intent(getActivity(), UnidentifiedMovies.class)); + break; + } + + return true; + } + + private Intent getUpdateIntent() { + Intent intent = new Intent(); + intent.setClass(getActivity(), Update.class); + intent.putExtra("isMovie", true); + return intent; + } + + private void sortMovies() { + if (!isAdded()) + return; + + String SORT_TYPE = mSharedPreferences.getString((((ActionBarActivity) getActivity()).getSupportActionBar().getSelectedNavigationIndex() == COLLECTIONS) ? SORTING_COLLECTIONS_OVERVIEW : SORTING_MOVIES, "sortTitle"); + + if (SORT_TYPE.equals("sortRelease")) { + sortBy(RELEASE); + } else if (SORT_TYPE.equals("sortRating")) { + sortBy(RATING); + } else if (SORT_TYPE.equals("sortWeightedRating")) { + sortBy(WEIGHTED_RATING); + } else if (SORT_TYPE.equals("sortAdded")) { + sortBy(DATE); + } else if (SORT_TYPE.equals("sortDuration")) { + sortBy(DURATION); + } else { // if SORT_TYPE equals "sortTitle" + sortBy(TITLE); + } + } + + public void sortBy(int sort) { + if (!isAdded()) + return; + + mCurrentSort = sort; + + boolean isCollection = ((ActionBarActivity) getActivity()).getSupportActionBar().getSelectedNavigationIndex() == COLLECTIONS; + + String key = isCollection ? SORTING_COLLECTIONS_OVERVIEW : SORTING_MOVIES; + Editor editor = mSharedPreferences.edit(); + switch (mCurrentSort) { + case TITLE: + editor.putString(key, "sortTitle"); + break; + case RELEASE: + editor.putString(key, "sortRelease"); + break; + case RATING: + editor.putString(key, "sortRating"); + break; + case WEIGHTED_RATING: + editor.putString(key, "sortWeightedRating"); + break; + case DATE: + editor.putString(key, "sortAdded"); + break; + case DURATION: + editor.putString(key, "sortDuration"); + break; + } + editor.apply(); + + ArrayList tempHelper = new ArrayList(); + for (int i = 0; i < mMovieKeys.size(); i++) { + tempHelper.add(new MovieSortHelper(mMovies.get(mMovieKeys.get(i)), mMovieKeys.get(i), mCurrentSort, isCollection)); + } + + Collections.sort(tempHelper); + + mMovieKeys.clear(); + for (int i = 0; i < tempHelper.size(); i++) { + mMovieKeys.add(tempHelper.get(i).getIndex()); + } + + tempHelper.clear(); + + setProgressBarVisible(false); + notifyDataSetChanged(); + } + + private void showGenres() { + final TreeMap map = new TreeMap(); + String[] splitGenres; + for (int i = 0; i < mMovieKeys.size(); i++) { + if (!mMovies.get(mMovieKeys.get(i)).getGenres().isEmpty()) { + splitGenres = mMovies.get(mMovieKeys.get(i)).getGenres().split(","); + for (int j = 0; j < splitGenres.length; j++) { + if (map.containsKey(splitGenres[j].trim())) { + map.put(splitGenres[j].trim(), map.get(splitGenres[j].trim()) + 1); + } else { + map.put(splitGenres[j].trim(), 1); + } + } + } + } + + createAndShowAlertDialog(setupItemArray(map, R.string.allGenres), R.string.selectGenre, GENRES); + } + + private void showCertifications() { + final TreeMap map = new TreeMap(); + for (int i = 0; i < mMovieKeys.size(); i++) { + String certification = mMovies.get(mMovieKeys.get(i)).getCertification(); + if (!TextUtils.isEmpty(certification)) { + if (map.containsKey(certification.trim())) { + map.put(certification.trim(), map.get(certification.trim()) + 1); + } else { + map.put(certification.trim(), 1); + } + } + } + + createAndShowAlertDialog(setupItemArray(map, R.string.allCertifications), R.string.selectCertification, CERTIFICATION); + } + + private void showFileSources() { + ArrayList sources = new ArrayList(); + + DbAdapterSources dbHelper = MizuuApplication.getSourcesAdapter(); + Cursor cursor = dbHelper.fetchAllMovieSources(); + while (cursor.moveToNext()) { + sources.add(new FileSource( + cursor.getLong(cursor.getColumnIndex(DbAdapterSources.KEY_ROWID)), + cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_FILEPATH)), + cursor.getInt(cursor.getColumnIndex(DbAdapterSources.KEY_FILESOURCE_TYPE)), + cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_USER)), + cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_PASSWORD)), + cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_DOMAIN)), + cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_TYPE)) + )); + } + cursor.close(); + + final TreeMap map = new TreeMap(); + + for (int i = 0; i < mMovieKeys.size(); i++) { + for (Filepath path : mMovies.get(mMovieKeys.get(i)).getFilepaths()) { + for (int j = 0; j < sources.size(); j++) { + String source = sources.get(j).getFilepath(); + + if (!TextUtils.isEmpty(source) && !TextUtils.isEmpty(path.getFilepath()) && path.getFilepath().contains(source)) { + if (map.containsKey(source.trim())) { + map.put(source.trim(), map.get(source.trim()) + 1); + } else { + map.put(source.trim(), 1); + } + } + } + } + } + + createAndShowAlertDialog(setupItemArray(map, R.string.allFileSources), R.string.selectFileSource, FILE_SOURCES); + } + + private void showReleaseYear() { + final TreeMap map = new TreeMap(); + for (int i = 0; i < mMovieKeys.size(); i++) { + String year = mMovies.get(mMovieKeys.get(i)).getReleaseYear().trim(); + if (!TextUtils.isEmpty(year)) { + if (map.containsKey(year)) { + map.put(year, map.get(year) + 1); + } else { + map.put(year, 1); + } + } + } + + createAndShowAlertDialog(setupItemArray(map, R.string.allReleaseYears), R.string.selectReleaseYear, RELEASE_YEAR); + } + + private void showFolders() { + final TreeMap map = new TreeMap(); + for (int i = 0; i < mMovieKeys.size(); i++) { + for (Filepath path : mMovies.get(mMovieKeys.get(i)).getFilepaths()) { + String folder = path.getFilepath(); + if (!TextUtils.isEmpty(folder)) { + if (map.containsKey(folder.trim())) { + map.put(folder.trim(), map.get(folder.trim()) + 1); + } else { + map.put(folder.trim(), 1); + } + } + } + } + + createAndShowAlertDialog(setupItemArray(map, R.string.allFolders), R.string.selectFolder, FOLDERS); + } + + private CharSequence[] setupItemArray(TreeMap map, int stringId) { + final CharSequence[] tempArray = map.keySet().toArray(new CharSequence[map.keySet().size()]); + for (int i = 0; i < tempArray.length; i++) + tempArray[i] = tempArray[i] + " (" + map.get(tempArray[i]) + ")"; + + final CharSequence[] temp = new CharSequence[tempArray.length + 1]; + temp[0] = getString(stringId); + + for (int i = 1; i < temp.length; i++) + temp[i] = tempArray[i-1]; + + return temp; + } + + private void createAndShowAlertDialog(final CharSequence[] temp, int title, final int type) { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setTitle(title) + .setItems(temp, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + handleDialogOnClick(dialog, which, type, temp); + } + }); + builder.show(); + } + + private void handleDialogOnClick(DialogInterface dialog, int which, int type, CharSequence[] temp) { + if (which > 0) { + ArrayList currentlyShown = new ArrayList(mMovieKeys); + mMovieKeys.clear(); + + String selected = temp[which].toString(); + selected = selected.substring(0, selected.lastIndexOf("(")).trim(); + + boolean condition; + for (int i = 0; i < currentlyShown.size(); i++) { + condition = false; + + switch (type) { + case GENRES: + if (mMovies.get(currentlyShown.get(i)).getGenres().contains(selected)) { + String[] genres = mMovies.get(currentlyShown.get(i)).getGenres().split(","); + for (String genre : genres) { + if (genre.trim().equals(selected)) { + condition = true; + break; + } + } + } + break; + case CERTIFICATION: + condition = mMovies.get(currentlyShown.get(i)).getCertification().trim().contains(selected); + break; + case FILE_SOURCES: + for (Filepath path : mMovies.get(currentlyShown.get(i)).getFilepaths()) { + condition = path.getFilepath().trim().contains(selected); + if (condition) + break; + } + break; + case FOLDERS: + for (Filepath path : mMovies.get(currentlyShown.get(i)).getFilepaths()) { + condition = path.getFilepath().trim().startsWith(selected); + if (condition) + break; + } + break; + case RELEASE_YEAR: + condition = mMovies.get(currentlyShown.get(i)).getReleaseYear().trim().contains(selected); + break; + } + + if (condition) + mMovieKeys.add(currentlyShown.get(i)); + } + + sortMovies(); + notifyDataSetChanged(); + } + + dialog.dismiss(); + } + + private void search(String query) { + if (mSearch != null) + mSearch.cancel(true); + mSearch = new SearchTask(query); + mSearch.execute(); + } + + private class SearchTask extends AsyncTask { + + private String mSearchQuery = ""; + private List mTempKeys; + + public SearchTask(String query) { + mSearchQuery = query.toLowerCase(Locale.ENGLISH); + } + + @Override + protected void onPreExecute() { + setProgressBarVisible(true); + mMovieKeys.clear(); + } + + @Override + protected String doInBackground(String... params) { + mTempKeys = new ArrayList(); + + if (mSearchQuery.startsWith("actor:")) { + for (int i = 0; i < mMovies.size(); i++) { + if (isCancelled()) + return null; + + if (mMovies.get(i).getCast().toLowerCase(Locale.ENGLISH).contains(mSearchQuery.replace("actor:", "").trim())) + mTempKeys.add(i); + } + } else if (mSearchQuery.equalsIgnoreCase("missing_genres")) { + for (int i = 0; i < mMovies.size(); i++) { + if (isCancelled()) + return null; + + if (TextUtils.isEmpty(mMovies.get(i).getGenres())) + mTempKeys.add(i); + } + } else if (mSearchQuery.equalsIgnoreCase("multiple_versions")) { + DbAdapterMovieMappings db = MizuuApplication.getMovieMappingAdapter(); + + for (int i = 0; i < mMovies.size(); i++) { + if (isCancelled()) + return null; + + if (db.hasMultipleFilepaths(mMovies.get(i).getTmdbId())) + mTempKeys.add(i); + } + } else { + Pattern p = Pattern.compile(MizLib.CHARACTER_REGEX); // Use a pre-compiled pattern as it's a lot faster (approx. 3x for ~700 movies) + + for (int i = 0; i < mMovies.size(); i++) { + if (isCancelled()) + return null; + + String lowerCaseTitle = mMovies.get(i).getTitle().toLowerCase(Locale.ENGLISH); + + boolean foundInTitle = false; + + if (lowerCaseTitle.indexOf(mSearchQuery) != -1 || p.matcher(lowerCaseTitle).replaceAll("").indexOf(mSearchQuery) != -1) { + mTempKeys.add(i); + foundInTitle = true; + } + + if (!foundInTitle) { + for (Filepath path : mMovies.get(i).getFilepaths()) { + String filepath = path.getFilepath().toLowerCase(Locale.ENGLISH); + if (filepath.indexOf(mSearchQuery) != -1) { + mTempKeys.add(i); + break; // Break the loop + } + } + } + } + } + + return null; + } + + @Override + protected void onPostExecute(String result) { + mMovieKeys.addAll(mTempKeys); + + sortMovies(); + notifyDataSetChanged(); + setProgressBarVisible(false); + } + } + + private void setProgressBarVisible(boolean visible) { + mProgressBar.setVisibility(visible ? View.VISIBLE : View.GONE); + mGridView.setVisibility(visible ? View.GONE : View.VISIBLE); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + + if (resultCode == 1) { // Update + forceLoaderLoad(); + } else if (resultCode == 2 && mActionBar.getSelectedNavigationIndex() == FAVORITES) { // Favourite removed + showMovieSection(FAVORITES); + } else if (resultCode == 3) { + notifyDataSetChanged(); + } + } + + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + if (key.equals(IGNORED_TITLE_PREFIXES)) { + mIgnorePrefixes = mSharedPreferences.getBoolean(IGNORED_TITLE_PREFIXES, false); + forceLoaderLoad(); + } else if (key.equals(GRID_ITEM_SIZE)) { + String thumbnailSize = mSharedPreferences.getString(GRID_ITEM_SIZE, getString(R.string.normal)); + if (thumbnailSize.equals(getString(R.string.large))) + mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 1.33); + else if (thumbnailSize.equals(getString(R.string.normal))) + mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 1); + else + mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 0.75); + + mGridView.setColumnWidth(mImageThumbSize); + + final int numColumns = (int) Math.floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing)); + if (numColumns > 0) { + mAdapter.setNumColumns(numColumns); + } + + notifyDataSetChanged(); + } else if (key.equals(SHOW_TITLES_IN_GRID)) { + mShowTitles = sharedPreferences.getBoolean(SHOW_TITLES_IN_GRID, true); + notifyDataSetChanged(); + } + } + + private void forceLoaderLoad() { + if (isAdded()) + if (getLoaderManager().getLoader(0) == null) { + getLoaderManager().initLoader(0, null, loaderCallbacks); + } else { + getLoaderManager().restartLoader(0, null, loaderCallbacks); + } + } + + private class ActionBarSpinner extends BaseAdapter { + + private LayoutInflater mInflater; + + public ActionBarSpinner() { + mInflater = LayoutInflater.from(((ActionBarActivity) getActivity()).getSupportActionBar().getThemedContext()); + } + + @Override + public int getCount() { + return mSpinnerItems.size(); + } + + @Override + public Object getItem(int position) { + return null; + } + + @Override + public long getItemId(int position) { + return 0; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + + ActionBarSpinnerViewHolder holder; + + if (convertView == null) { + convertView = mInflater.inflate(R.layout.spinner_header, parent, false); + + holder = new ActionBarSpinnerViewHolder(); + holder.title = (TextView) convertView.findViewById(R.id.title); + holder.subtitle = (TextView) convertView.findViewById(R.id.subtitle); + + convertView.setTag(holder); + } else { + holder = (ActionBarSpinnerViewHolder) convertView.getTag(); + } + + holder.title.setText(mSpinnerItems.get(position).getTitle()); + + int size = mMovieKeys.size(); + holder.subtitle.setText(size + " " + getResources().getQuantityString((mActionBar.getSelectedNavigationIndex() == COLLECTIONS) ? + R.plurals.collectionsInLibrary : R.plurals.moviesInLibrary, size, size)); + + return convertView; + } + + @Override + public View getDropDownView(int position, View convertView, ViewGroup parent) { + + if (convertView == null) { + convertView = mInflater.inflate(android.R.layout.simple_spinner_dropdown_item, parent, false); + } + + ((TextView) convertView.findViewById(android.R.id.text1)).setText(mSpinnerItems.get(position).getSubtitle()); + + return convertView; + } + } +} \ No newline at end of file diff --git a/src/com/miz/mizuu/fragments/Prefs.java b/app/src/main/java/com/miz/mizuu/fragments/Prefs.java similarity index 100% rename from src/com/miz/mizuu/fragments/Prefs.java rename to app/src/main/java/com/miz/mizuu/fragments/Prefs.java index 3eb686e4..bcfba480 100644 --- a/src/com/miz/mizuu/fragments/Prefs.java +++ b/app/src/main/java/com/miz/mizuu/fragments/Prefs.java @@ -16,13 +16,6 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Locale; - -import com.miz.mizuu.R; - import android.app.AlertDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; @@ -34,6 +27,13 @@ import android.preference.PreferenceFragment; import android.preference.PreferenceManager; +import com.miz.mizuu.R; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Locale; + import static com.miz.functions.PreferenceKeys.IGNORED_FILES_ENABLED; import static com.miz.functions.PreferenceKeys.LANGUAGE_PREFERENCE; diff --git a/src/com/miz/mizuu/fragments/ScheduledUpdatesFragment.java b/app/src/main/java/com/miz/mizuu/fragments/ScheduledUpdatesFragment.java similarity index 100% rename from src/com/miz/mizuu/fragments/ScheduledUpdatesFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/ScheduledUpdatesFragment.java index 494df99a..f8502f80 100644 --- a/src/com/miz/mizuu/fragments/ScheduledUpdatesFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/ScheduledUpdatesFragment.java @@ -36,10 +36,10 @@ import com.miz.functions.ScheduledUpdatesAlarmManager; import com.miz.mizuu.R; -import static com.miz.functions.PreferenceKeys.SCHEDULED_UPDATES_MOVIE; -import static com.miz.functions.PreferenceKeys.SCHEDULED_UPDATES_TVSHOWS; import static com.miz.functions.PreferenceKeys.NEXT_SCHEDULED_MOVIE_UPDATE; import static com.miz.functions.PreferenceKeys.NEXT_SCHEDULED_TVSHOWS_UPDATE; +import static com.miz.functions.PreferenceKeys.SCHEDULED_UPDATES_MOVIE; +import static com.miz.functions.PreferenceKeys.SCHEDULED_UPDATES_TVSHOWS; public class ScheduledUpdatesFragment extends Fragment { diff --git a/src/com/miz/mizuu/fragments/SearchWebMoviesFragment.java b/app/src/main/java/com/miz/mizuu/fragments/SearchWebMoviesFragment.java similarity index 75% rename from src/com/miz/mizuu/fragments/SearchWebMoviesFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/SearchWebMoviesFragment.java index ac54c84e..4c76b0f3 100644 --- a/src/com/miz/mizuu/fragments/SearchWebMoviesFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/SearchWebMoviesFragment.java @@ -16,14 +16,13 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; -import java.util.List; - import android.content.Context; import android.content.Intent; import android.graphics.Bitmap.Config; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.Html; import android.text.TextWatcher; @@ -31,8 +30,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.WindowManager; import android.view.ViewGroup.LayoutParams; +import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; @@ -56,19 +55,23 @@ import com.miz.mizuu.MovieDetails; import com.miz.mizuu.R; import com.miz.mizuu.TMDbMovieDetails; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; +import java.util.ArrayList; +import java.util.List; + public class SearchWebMoviesFragment extends Fragment { - public String filename; - private ArrayList results = new ArrayList(); - private ListView lv; - private EditText searchText; - private ProgressBar pbar; - private StartSearch startSearch; + private ArrayList mResults = new ArrayList(); + private ListView mListView; + private EditText mSearchField; + private ProgressBar mProgressBar; + private SearchTask mSearchTask; private ListAdapter mAdapter; private Picasso mPicasso; private Config mConfig; + private Toolbar mToolbar; /** * Empty constructor as per the Fragment documentation @@ -92,7 +95,7 @@ public void onCreate(Bundle savedInstanceState) { mPicasso = MizuuApplication.getPicasso(getActivity()); mConfig = MizuuApplication.getBitmapConfig(); - startSearch = new StartSearch(); + mSearchTask = new SearchTask(); } @Override @@ -104,24 +107,28 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); - pbar = (ProgressBar) v.findViewById(R.id.progressBar1); - v.findViewById(R.id.spinner1).setVisibility(View.GONE); + mToolbar = (Toolbar) v.findViewById(R.id.toolbar); + ((ActionBarActivity) getActivity()).setSupportActionBar(mToolbar); - lv = (ListView) v.findViewById(R.id.listView1); - hideProgressBar(); + mProgressBar = (ProgressBar) v.findViewById(R.id.progressBar1); + v.findViewById(R.id.spinner1).setVisibility(View.GONE); - lv.setOnItemClickListener(new OnItemClickListener() { + mListView = (ListView) v.findViewById(R.id.listView1); + mListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { showMovie(arg2); } }); - lv.setEmptyView(v.findViewById(R.id.no_results)); + mListView.setEmptyView(v.findViewById(R.id.no_results)); v.findViewById(R.id.no_results).setVisibility(View.GONE); - searchText = (EditText) v.findViewById(R.id.editText1); - searchText.setSelection(searchText.length()); - searchText.addTextChangedListener(new TextWatcher() { + // Both the ProgressBar and ListView have been set, so let's hide the ProgressBar + hideProgressBar(); + + mSearchField = (EditText) v.findViewById(R.id.editText1); + mSearchField.setSelection(mSearchField.length()); + mSearchField.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @@ -133,13 +140,13 @@ public void afterTextChanged(Editable s) { if (s.toString().length() > 0) searchForMovies(); else { - startSearch.cancel(true); - results.clear(); + mSearchTask.cancel(true); + mResults.clear(); mAdapter.notifyDataSetChanged(); } } }); - searchText.setOnEditorActionListener(new OnEditorActionListener() { + mSearchField.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN || actionId == EditorInfo.IME_ACTION_SEARCH) @@ -151,18 +158,18 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { protected void showMovie(int arg2) { DbAdapterMovies db = MizuuApplication.getMovieAdapter(); - if (db.movieExists(results.get(arg2).getId())) { + if (db.movieExists(mResults.get(arg2).getId())) { Intent intent = new Intent(); intent.setClass(getActivity(), MovieDetails.class); - intent.putExtra("tmdbId", results.get(arg2).getId()); + intent.putExtra("tmdbId", mResults.get(arg2).getId()); // Start the Intent for result startActivityForResult(intent, 0); } else { Intent i = new Intent(Intent.ACTION_VIEW); i.setClass(getActivity(), TMDbMovieDetails.class); - i.putExtra("tmdbId", results.get(arg2).getId()); - i.putExtra("title", results.get(arg2).getName()); + i.putExtra("tmdbId", mResults.get(arg2).getId()); + i.putExtra("title", mResults.get(arg2).getName()); startActivity(i); } } @@ -172,12 +179,12 @@ public void searchForMovies(View v) { } private void searchForMovies() { - results.clear(); + mResults.clear(); if (MizLib.isOnline(getActivity())) { - if (!searchText.getText().toString().isEmpty()) { - startSearch.cancel(true); - startSearch = new StartSearch(); - startSearch.execute(searchText.getText().toString()); + if (!mSearchField.getText().toString().isEmpty()) { + mSearchTask.cancel(true); + mSearchTask = new SearchTask(); + mSearchTask.execute(mSearchField.getText().toString()); } else { hideProgressBar(); mAdapter.notifyDataSetChanged(); @@ -185,7 +192,7 @@ private void searchForMovies() { } else Toast.makeText(getActivity().getApplicationContext(), getString(R.string.noInternet), Toast.LENGTH_SHORT).show(); } - protected class StartSearch extends AsyncTask { + protected class SearchTask extends AsyncTask { @Override protected void onPreExecute() { @@ -206,7 +213,7 @@ protected String doInBackground(String... params) { int count = movieResults.size(); for (int i = 0; i < count; i++) { - results.add(new Result( + mResults.add(new Result( movieResults.get(i).getTitle(), movieResults.get(i).getId(), movieResults.get(i).getCover(), @@ -229,10 +236,10 @@ protected void onPostExecute(String result) { return; hideProgressBar(); - if (searchText.getText().toString().length() > 0) { - if (lv.getAdapter() == null) { + if (mSearchField.getText().toString().length() > 0) { + if (mListView.getAdapter() == null) { mAdapter = new ListAdapter(getActivity()); - lv.setAdapter(mAdapter); + mListView.setAdapter(mAdapter); } else { mAdapter.notifyDataSetChanged(); } @@ -260,7 +267,7 @@ public ListAdapter(Context context) { } public int getCount() { - return results.size(); + return mResults.size(); } // create a new ImageView for each item referenced by the Adapter @@ -279,9 +286,9 @@ public View getView(int position, View convertView, ViewGroup parent) { holder.cover = (ImageView) convertView.findViewById(R.id.cover); holder.layout = (LinearLayout) convertView.findViewById(R.id.cover_layout); - holder.title.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "RobotoCondensed-Regular.ttf")); - holder.release.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-LightItalic.ttf")); - holder.rating.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-LightItalic.ttf")); + holder.title.setTypeface(TypefaceUtils.getRobotoCondensedRegular(getActivity())); + holder.release.setTypeface(TypefaceUtils.getRobotoLightItalic(getActivity())); + holder.rating.setTypeface(TypefaceUtils.getRobotoLightItalic(getActivity())); holder.originalTitle.setVisibility(View.GONE); // Check the height matches our calculated column width @@ -294,13 +301,13 @@ public View getView(int position, View convertView, ViewGroup parent) { holder = (ViewHolder) convertView.getTag(); } - holder.title.setText(results.get(position).getName()); - holder.release.setText(results.get(position).getRelease()); + holder.title.setText(mResults.get(position).getName()); + holder.release.setText(mResults.get(position).getRelease()); holder.rating.setVisibility(View.VISIBLE); - if (!results.get(position).getRating().equals("0.0")) { + if (!mResults.get(position).getRating().equals("0.0")) { try { - int rating = (int) (Double.parseDouble(results.get(position).getRating()) * 10); + int rating = (int) (Double.parseDouble(mResults.get(position).getRating()) * 10); holder.rating.setText(Html.fromHtml(getString(R.string.detailsRating) + ": " + rating + " %")); } catch (NumberFormatException e) { holder.rating.setVisibility(View.GONE); @@ -309,7 +316,7 @@ public View getView(int position, View convertView, ViewGroup parent) { holder.rating.setVisibility(View.GONE); } - mPicasso.load(results.get(position).getImage()).placeholder(R.drawable.gray).error(R.drawable.loading_image).config(mConfig).into(holder.cover); + mPicasso.load(mResults.get(position).getImage()).placeholder(R.drawable.gray).error(R.drawable.loading_image).config(mConfig).into(holder.cover); return convertView; } @@ -367,12 +374,12 @@ public String getRelease() { } private void showProgressBar() { - lv.setVisibility(View.GONE); - pbar.setVisibility(View.VISIBLE); + mListView.setVisibility(View.GONE); + mProgressBar.setVisibility(View.VISIBLE); } private void hideProgressBar() { - lv.setVisibility(View.VISIBLE); - pbar.setVisibility(View.GONE); + mListView.setVisibility(View.VISIBLE); + mProgressBar.setVisibility(View.GONE); } } diff --git a/src/com/miz/mizuu/fragments/SimilarMoviesFragment.java b/app/src/main/java/com/miz/mizuu/fragments/SimilarMoviesFragment.java similarity index 98% rename from src/com/miz/mizuu/fragments/SimilarMoviesFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/SimilarMoviesFragment.java index 2c731398..5d6a5a92 100644 --- a/src/com/miz/mizuu/fragments/SimilarMoviesFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/SimilarMoviesFragment.java @@ -16,9 +16,6 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; -import java.util.List; - import android.content.Context; import android.content.Intent; import android.graphics.Bitmap.Config; @@ -44,8 +41,12 @@ import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; import com.miz.utils.IntentUtils; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; +import java.util.ArrayList; +import java.util.List; + public class SimilarMoviesFragment extends Fragment { private int mImageThumbSize, mImageThumbSpacing; @@ -170,7 +171,7 @@ public View getView(int position, View convertView, ViewGroup container) { holder.subtext = (TextView) convertView.findViewById(R.id.gridCoverSubtitle); holder.subtext.setSingleLine(true); - holder.text.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf")); + holder.text.setTypeface(TypefaceUtils.getRobotoMedium(mContext)); convertView.setTag(holder); } else { diff --git a/app/src/main/java/com/miz/mizuu/fragments/TmdbMovieDetailsFragment.java b/app/src/main/java/com/miz/mizuu/fragments/TmdbMovieDetailsFragment.java new file mode 100644 index 00000000..70a37e64 --- /dev/null +++ b/app/src/main/java/com/miz/mizuu/fragments/TmdbMovieDetailsFragment.java @@ -0,0 +1,509 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.mizuu.fragments; + +import android.animation.Animator; +import android.app.Activity; +import android.content.Intent; +import android.graphics.Typeface; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.Toolbar; +import android.text.Html; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.ScrollView; +import android.widget.TextView; +import android.widget.Toast; + +import com.melnykov.fab.FloatingActionButton; +import com.miz.apis.tmdb.Movie; +import com.miz.apis.tmdb.TMDbMovieService; +import com.miz.apis.trakt.Trakt; +import com.miz.functions.MizLib; +import com.miz.functions.PaletteLoader; +import com.miz.functions.TmdbTrailerSearch; +import com.miz.mizuu.MizuuApplication; +import com.miz.mizuu.R; +import com.miz.utils.IntentUtils; +import com.miz.utils.TypefaceUtils; +import com.miz.utils.ViewUtils; +import com.miz.views.HorizontalCardLayout; +import com.miz.views.ObservableScrollView; +import com.miz.views.ObservableScrollView.OnScrollChangedListener; +import com.squareup.picasso.Callback; +import com.squareup.picasso.Picasso; + +public class TmdbMovieDetailsFragment extends Fragment { + + private Activity mContext; + private TextView mTitle, mPlot, mGenre, mRuntime, mReleaseDate, mRating, mTagline, mCertification; + private ImageView mBackground, mCover; + private Movie mMovie; + private ObservableScrollView mScrollView; + private View mProgressBar, mDetailsArea; + private boolean mRetained = false; + private Picasso mPicasso; + private Typeface mMediumItalic, mMedium, mBold, mCondensedRegular; + private TMDbMovieService mMovieApiService; + private HorizontalCardLayout mActorsLayout, mSimilarMoviesLayout; + private int mImageThumbSize, mImageThumbSpacing, mToolbarColor = 000000; + private Toolbar mToolbar; + private FloatingActionButton mFab; + private PaletteLoader mPaletteLoader; + + /** + * Empty constructor as per the Fragment documentation + */ + public TmdbMovieDetailsFragment() {} + + public static TmdbMovieDetailsFragment newInstance(String movieId) { + TmdbMovieDetailsFragment pageFragment = new TmdbMovieDetailsFragment(); + Bundle bundle = new Bundle(); + bundle.putString("movieId", movieId); + pageFragment.setArguments(bundle); + return pageFragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setHasOptionsMenu(true); + setRetainInstance(true); + + mContext = getActivity(); + + mMediumItalic = TypefaceUtils.getRobotoMediumItalic(mContext); + mMedium = TypefaceUtils.getRobotoMedium(mContext); + mBold = TypefaceUtils.getRobotoBold(mContext); + mCondensedRegular = TypefaceUtils.getRobotoCondensedRegular(mContext); + + mMovieApiService = TMDbMovieService.getInstance(mContext); + + // Get the database ID of the movie in question + mMovie = new Movie(); + mMovie.setId(getArguments().getString("movieId")); + + mPicasso = MizuuApplication.getPicassoDetailsView(getActivity()); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final View v = inflater.inflate(R.layout.movie_and_tv_show_details, container, false); + + mToolbar = (Toolbar) v.findViewById(R.id.toolbar); + mToolbar.setBackgroundResource(android.R.color.transparent); + ViewUtils.setProperToolbarSize(mContext, mToolbar); + + ((ActionBarActivity) getActivity()).setSupportActionBar(mToolbar); + ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + // This needs to be re-initialized here and not in onCreate() + mImageThumbSize = getResources().getDimensionPixelSize(R.dimen.horizontal_grid_item_width); + mImageThumbSpacing = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); + + mProgressBar = v.findViewById(R.id.progress_layout); + mDetailsArea = v.findViewById(R.id.details_area); + + mBackground = (ImageView) v.findViewById(R.id.imageBackground); + mTitle = (TextView) v.findViewById(R.id.movieTitle); + mPlot = (TextView) v.findViewById(R.id.textView2); + mGenre = (TextView) v.findViewById(R.id.textView7); + mRuntime = (TextView) v.findViewById(R.id.textView9); + mReleaseDate = (TextView) v.findViewById(R.id.textReleaseDate); + mRating = (TextView) v.findViewById(R.id.textView12); + mTagline = (TextView) v.findViewById(R.id.textView6); + mCertification = (TextView) v.findViewById(R.id.textView11); + mCover = (ImageView) v.findViewById(R.id.traktIcon); + mActorsLayout = (HorizontalCardLayout) v.findViewById(R.id.horizontal_card_layout); + mSimilarMoviesLayout = (HorizontalCardLayout) v.findViewById(R.id.horizontal_card_layout_extra); + mScrollView = (ObservableScrollView) v.findViewById(R.id.observableScrollView); + mFab = (FloatingActionButton) v.findViewById(R.id.fab); + + mFab.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + ViewUtils.animateFabJump(v, new Animator.AnimatorListener() { + @Override + public void onAnimationEnd(Animator animation) { + watchTrailer(); + } + + @Override + public void onAnimationStart(Animator animation) {} + + @Override + public void onAnimationCancel(Animator animation) {} + + @Override + public void onAnimationRepeat(Animator animation) {} + }); + } + }); + if (MizLib.isTablet(mContext)) + mFab.setType(FloatingActionButton.TYPE_NORMAL); + + // Get rid of these... + v.findViewById(R.id.textView3).setVisibility(View.GONE); // File + + final boolean fullscreen = MizuuApplication.isFullscreen(mContext); + final int height = fullscreen ? MizLib.getActionBarHeight(mContext) : MizLib.getActionBarAndStatusBarHeight(mContext); + + mScrollView.setOnScrollChangedListener(new OnScrollChangedListener() { + @Override + public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { + ViewUtils.handleOnScrollChangedEvent( + getActivity(), v, mBackground, mMovie.getTitle(), + height, t, mToolbar, mToolbarColor); + } + }); + mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + ViewUtils.setLayoutParamsForDetailsEmptyView(mContext, v, + mBackground, mScrollView, this); + } + }); + + if (!mRetained) { // Nothing has been retained - load the data + setLoading(true); + new MovieLoader().execute(); + mRetained = true; + } else { + setupFields(); + } + + return v; + } + + private class MovieLoader extends AsyncTask { + @Override + protected Object doInBackground(String... params) { + mMovie = mMovieApiService.getCompleteMovie(mMovie.getId(), "en"); + + for (int i = 0; i < mMovie.getSimilarMovies().size(); i++) { + String id = mMovie.getSimilarMovies().get(i).getId(); + mMovie.getSimilarMovies().get(i).setInLibrary(MizuuApplication.getMovieAdapter().movieExists(id)); + } + + return null; + } + + @Override + protected void onPostExecute(Object result) { + getActivity().invalidateOptionsMenu(); + + setupFields(); + } + } + + private void setupFields() { + if (isAdded() && mMovie != null) { + // Set the movie title + mTitle.setVisibility(View.VISIBLE); + mTitle.setText(mMovie.getTitle()); + mTitle.setTypeface(mCondensedRegular); + + mPlot.setTypeface(mCondensedRegular); + mReleaseDate.setTypeface(mMedium); + mRuntime.setTypeface(mMedium); + mCertification.setTypeface(mMedium); + mRating.setTypeface(mMedium); + + // Set the movie plot + mPlot.setBackgroundResource(R.drawable.selectable_background); + if (!mMovie.getTagline().isEmpty()) + mPlot.setMaxLines(getActivity().getResources().getInteger(R.integer.movie_details_max_lines)); + else + mPlot.setMaxLines(getActivity().getResources().getInteger(R.integer.show_details_max_lines)); + mPlot.setTag(true); // true = collapsed + mPlot.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (((Boolean) mPlot.getTag())) { + // Animate + ViewUtils.animateTextViewMaxLines(mPlot, 50); // It seems highly unlikely that there would every be more than 50 lines + + // Reverse the tag + mPlot.setTag(false); + } else { + // Animate + ViewUtils.animateTextViewMaxLines(mPlot, mMovie.getTagline().isEmpty() ? + getResources().getInteger(R.integer.show_details_max_lines) : getResources().getInteger(R.integer.movie_details_max_lines)); + + // Reverse the tag + mPlot.setTag(true); + } + } + }); + mPlot.setEllipsize(TextUtils.TruncateAt.END); + mPlot.setFocusable(true); + + if (MizLib.isTablet(getActivity())) + mPlot.setLineSpacing(0, 1.15f); + + mPlot.setText(mMovie.getPlot()); + + // Set movie tag line + mTagline.setTypeface(mBold); + if (mMovie.getTagline().equals("NOTAGLINE") || mMovie.getTagline().isEmpty()) + mTagline.setVisibility(TextView.GONE); + else + mTagline.setText(mMovie.getTagline()); + + // Set the movie genre + mGenre.setTypeface(mMediumItalic); + if (!TextUtils.isEmpty(mMovie.getGenres())) { + mGenre.setText(mMovie.getGenres()); + } else { + mGenre.setVisibility(View.GONE); + } + + // Set the movie runtime + mRuntime.setText(MizLib.getPrettyRuntime(getActivity(), Integer.parseInt(mMovie.getRuntime()))); + + // Set the movie release date + mReleaseDate.setTypeface(mMedium); + mReleaseDate.setText(MizLib.getPrettyDate(getActivity(), mMovie.getReleasedate())); + + // Set the movie rating + if (!mMovie.getRating().equals("0.0")) { + try { + int rating = (int) (Double.parseDouble(mMovie.getRating()) * 10); + mRating.setText(Html.fromHtml(rating + " %")); + } catch (NumberFormatException e) { + mRating.setText(mMovie.getRating()); + } + } else { + mRating.setText(R.string.stringNA); + } + + // Set the movie certification + if (!TextUtils.isEmpty(mMovie.getCertification())) { + mCertification.setText(mMovie.getCertification()); + } else { + mCertification.setText(R.string.stringNA); + } + + mActorsLayout.setTitle(R.string.detailsActors); + mActorsLayout.setSeeMoreVisibility(true); + mActorsLayout.getViewTreeObserver().addOnGlobalLayoutListener( + new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + if (mActorsLayout.getWidth() > 0) { + final int numColumns = (int) Math.floor(mActorsLayout.getWidth() / (mImageThumbSize + mImageThumbSpacing)); + mImageThumbSize = (mActorsLayout.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; + + mActorsLayout.loadItems(mContext, mPicasso, numColumns, mImageThumbSize, mMovie.getActors(), HorizontalCardLayout.ACTORS, mToolbarColor); + MizLib.removeViewTreeObserver(mActorsLayout.getViewTreeObserver(), this); + } + } + }); + mActorsLayout.setSeeMoreOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + startActivity(IntentUtils.getActorBrowserMovies(mContext, mMovie.getTitle(), mMovie.getId(), mToolbarColor)); + } + }); + + mSimilarMoviesLayout.setVisibility(View.VISIBLE); + mSimilarMoviesLayout.setTitle(R.string.relatedMovies); + mSimilarMoviesLayout.setSeeMoreVisibility(true); + mSimilarMoviesLayout.getViewTreeObserver().addOnGlobalLayoutListener( + new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + if (mSimilarMoviesLayout.getWidth() > 0) { + final int numColumns = (int) Math.floor(mSimilarMoviesLayout.getWidth() / (mImageThumbSize + mImageThumbSpacing)); + mImageThumbSize = (mSimilarMoviesLayout.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; + + mSimilarMoviesLayout.loadItems(mContext, mPicasso, numColumns, mImageThumbSize, mMovie.getSimilarMovies(), HorizontalCardLayout.RELATED_MOVIES, mToolbarColor); + MizLib.removeViewTreeObserver(mSimilarMoviesLayout.getViewTreeObserver(), this); + } + } + }); + mSimilarMoviesLayout.setSeeMoreOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + startActivity(IntentUtils.getSimilarMovies(mContext, mMovie.getTitle(), mMovie.getId(), mToolbarColor)); + } + }); + + ViewUtils.updateToolbarBackground(getActivity(), mToolbar, 0, mMovie.getTitle(), mToolbarColor); + + setLoading(false); + + loadImages(); + } + } + + private void loadImages() { + if (!mMovie.getCover().isEmpty()) + mPicasso.load(mMovie.getCover()).placeholder(R.drawable.gray).error(R.drawable.loading_image).into(mCover, new Callback() { + @Override + public void onSuccess() { + if (mPaletteLoader == null) { + mPaletteLoader = new PaletteLoader(mPicasso, Uri.parse(mMovie.getCover()), new PaletteLoader.OnPaletteLoadedCallback() { + @Override + public void onPaletteLoaded(int swatchColor) { + mToolbarColor = swatchColor; + } + }); + + mPaletteLoader.addView(mDetailsArea); + mPaletteLoader.addView(mActorsLayout.getSeeMoreView()); + mPaletteLoader.addView(mSimilarMoviesLayout.getSeeMoreView()); + mPaletteLoader.setFab(mFab); + + mPaletteLoader.execute(); + } else { + // Clear old views after configuration change + mPaletteLoader.clearViews(); + + // Add views after configuration change + mPaletteLoader.addView(mDetailsArea); + mPaletteLoader.addView(mActorsLayout.getSeeMoreView()); + mPaletteLoader.addView(mSimilarMoviesLayout.getSeeMoreView()); + mPaletteLoader.setFab(mFab); + + // Re-color the views + mPaletteLoader.colorViews(); + } + } + + @Override + public void onError() {} + }); + else + mCover.setImageResource(R.drawable.gray); + + if (!mMovie.getBackdrop().isEmpty()) + mPicasso.load(mMovie.getBackdrop()).placeholder(R.drawable.gray).error(R.drawable.bg).into(mBackground, new Callback() { + @Override + public void onError() { + if (!isAdded()) + return; + + if (!mMovie.getCover().isEmpty()) + mPicasso.load(mMovie.getCover()).placeholder(R.drawable.bg).error(R.drawable.bg).into(mBackground); + else + mBackground.setImageResource(R.drawable.bg); + } + + @Override + public void onSuccess() { + } + }); + else { + if (!mMovie.getCover().isEmpty()) + mPicasso.load(mMovie.getCover()).placeholder(R.drawable.bg).error(R.drawable.bg).into(mBackground); + else + mBackground.setImageResource(R.drawable.bg); + } + } + + private void setLoading(boolean isLoading) { + mProgressBar.setVisibility(isLoading ? View.VISIBLE : View.GONE); + mScrollView.setVisibility(isLoading ? View.GONE : View.VISIBLE); + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + if (mMovie != null) { + inflater.inflate(R.menu.tmdb_details, menu); + + if (MizLib.isTablet(mContext)) { + menu.findItem(R.id.share).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + menu.findItem(R.id.checkIn).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + menu.findItem(R.id.openInBrowser).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + } + + if (!Trakt.hasTraktAccount(mContext)) + menu.findItem(R.id.checkIn).setVisible(false); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + getActivity().finish(); + break; + case R.id.share: + shareMovie(); + break; + case R.id.openInBrowser: + openInBrowser(); + break; + case R.id.checkIn: + checkIn(); + break; + } + + return super.onOptionsItemSelected(item); + } + + public void shareMovie() { + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_TEXT, "http://www.themoviedb.org/movie/" + mMovie.getId()); + startActivity(Intent.createChooser(intent, getString(R.string.shareWith))); + } + + public void openInBrowser() { + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("http://www.themoviedb.org/movie/" + mMovie.getId())); + startActivity(Intent.createChooser(intent, getString(R.string.openWith))); + } + + public void watchTrailer() { + new TmdbTrailerSearch(getActivity(), mMovie.getId(), mMovie.getTitle()).execute(); + } + + public void checkIn() { + new AsyncTask() { + @Override + protected Boolean doInBackground(Void... params) { + return Trakt.performMovieCheckin(mMovie.getId(), mContext); + } + + @Override + protected void onPostExecute(Boolean result) { + if (result) + Toast.makeText(mContext, getString(R.string.checked_in), Toast.LENGTH_SHORT).show(); + else + Toast.makeText(mContext, getString(R.string.errorSomethingWentWrong), Toast.LENGTH_SHORT).show(); + } + }.execute(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/miz/mizuu/fragments/TvShowDetailsFragment.java b/app/src/main/java/com/miz/mizuu/fragments/TvShowDetailsFragment.java new file mode 100644 index 00000000..b07f7953 --- /dev/null +++ b/app/src/main/java/com/miz/mizuu/fragments/TvShowDetailsFragment.java @@ -0,0 +1,644 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.mizuu.fragments; + +import android.animation.Animator; +import android.animation.ObjectAnimator; +import android.app.Activity; +import android.app.AlertDialog; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.IntentFilter; +import android.database.Cursor; +import android.graphics.Color; +import android.graphics.Typeface; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.support.v4.app.Fragment; +import android.support.v4.content.LocalBroadcastManager; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.graphics.Palette; +import android.support.v7.widget.Toolbar; +import android.text.Html; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.widget.ImageView; +import android.widget.ScrollView; +import android.widget.TextView; +import android.widget.Toast; + +import com.melnykov.fab.FloatingActionButton; +import com.miz.apis.tmdb.TMDbTvShowService; +import com.miz.apis.trakt.Trakt; +import com.miz.db.DbAdapterTvShowEpisodeMappings; +import com.miz.db.DbAdapterTvShows; +import com.miz.functions.Actor; +import com.miz.functions.BlurTransformation; +import com.miz.functions.EpisodeCounter; +import com.miz.functions.GridSeason; +import com.miz.functions.IntentKeys; +import com.miz.functions.MizLib; +import com.miz.functions.PaletteLoader; +import com.miz.functions.PaletteTransformation; +import com.miz.functions.PreferenceKeys; +import com.miz.mizuu.EditTvShow; +import com.miz.mizuu.IdentifyTvShow; +import com.miz.mizuu.MizuuApplication; +import com.miz.mizuu.R; +import com.miz.mizuu.ShowCoverFanartBrowser; +import com.miz.mizuu.TvShow; +import com.miz.utils.FileUtils; +import com.miz.utils.IntentUtils; +import com.miz.utils.LocalBroadcastUtils; +import com.miz.utils.TypefaceUtils; +import com.miz.utils.ViewUtils; +import com.miz.views.HorizontalCardLayout; +import com.miz.views.ObservableScrollView; +import com.miz.views.ObservableScrollView.OnScrollChangedListener; +import com.squareup.otto.Bus; +import com.squareup.picasso.Callback; +import com.squareup.picasso.Picasso; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; + +import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; + +public class TvShowDetailsFragment extends Fragment { + + private Activity mContext; + private DbAdapterTvShows dbHelper; + private TvShow thisShow; + private TextView textTitle, textPlot, textGenre, textRuntime, textReleaseDate, textRating, textCertification; + private ImageView background, cover; + private ObservableScrollView mScrollView; + private View mDetailsArea; + private boolean ignorePrefixes; + private Picasso mPicasso; + private Typeface mMediumItalic, mMedium, mBold, mCondensedRegular; + private Bus mBus; + private HorizontalCardLayout mSeasonsLayout, mActorsLayout; + private int mImageThumbSize, mImageThumbSpacing, mToolbarColor = 000000; + private Toolbar mToolbar; + private FloatingActionButton mFab; + private PaletteLoader mPaletteLoader; + + /** + * Empty constructor as per the Fragment documentation + */ + public TvShowDetailsFragment() {} + + public static TvShowDetailsFragment newInstance(String showId) { + TvShowDetailsFragment pageFragment = new TvShowDetailsFragment(); + Bundle b = new Bundle(); + b.putString("showId", showId); + pageFragment.setArguments(b); + return pageFragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setHasOptionsMenu(true); + setRetainInstance(true); + + mContext = getActivity(); + + mBus = MizuuApplication.getBus(); + + mMediumItalic = TypefaceUtils.getRobotoMediumItalic(mContext); + mMedium = TypefaceUtils.getRobotoMedium(mContext); + mBold = TypefaceUtils.getRobotoBold(mContext); + mCondensedRegular = TypefaceUtils.getRobotoCondensedRegular(mContext); + + ignorePrefixes = PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean(IGNORED_TITLE_PREFIXES, false); + + // Create and open database + dbHelper = MizuuApplication.getTvDbAdapter(); + + Cursor cursor = dbHelper.getShow(getArguments().getString("showId")); + try { + if (cursor.moveToFirst()) { + thisShow = new TvShow(getActivity(), + cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_ID)), + cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_TITLE)), + cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_PLOT)), + cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_RATING)), + cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_GENRES)), + cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_ACTORS)), + cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_CERTIFICATION)), + cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_FIRST_AIRDATE)), + cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_RUNTIME)), + ignorePrefixes, + cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_FAVOURITE)), + MizuuApplication.getTvEpisodeDbAdapter().getLatestEpisodeAirdate(cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_ID))) + ); + } + } catch (Exception e) { + } finally { + cursor.close(); + } + + mPicasso = MizuuApplication.getPicassoDetailsView(getActivity()); + + LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.CLEAR_IMAGE_CACHE)); + } + + private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + loadImages(); + } + }; + + @Override + public void onResume() { + super.onResume(); + + mBus.register(getActivity()); + } + + @Override + public void onDestroy() { + super.onDestroy(); + LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mMessageReceiver); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return inflater.inflate(R.layout.movie_and_tv_show_details, container, false); + } + + public void onViewCreated(final View v, Bundle savedInstanceState) { + super.onViewCreated(v, savedInstanceState); + + mToolbar = (Toolbar) v.findViewById(R.id.toolbar); + mToolbar.setBackgroundResource(android.R.color.transparent); + ViewUtils.setProperToolbarSize(mContext, mToolbar); + + ((ActionBarActivity) getActivity()).setSupportActionBar(mToolbar); + ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + // This needs to be re-initialized here and not in onCreate() + mImageThumbSize = getResources().getDimensionPixelSize(R.dimen.horizontal_grid_item_width); + mImageThumbSpacing = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); + + mDetailsArea = v.findViewById(R.id.details_area); + + background = (ImageView) v.findViewById(R.id.imageBackground); + textTitle = (TextView) v.findViewById(R.id.movieTitle); + textPlot = (TextView) v.findViewById(R.id.textView2); + textGenre = (TextView) v.findViewById(R.id.textView7); + textRuntime = (TextView) v.findViewById(R.id.textView9); + textReleaseDate = (TextView) v.findViewById(R.id.textReleaseDate); + textRating = (TextView) v.findViewById(R.id.textView12); + textCertification = (TextView) v.findViewById(R.id.textView11); + cover = (ImageView) v.findViewById(R.id.traktIcon); + mSeasonsLayout = (HorizontalCardLayout) v.findViewById(R.id.horizontal_card_layout); + mActorsLayout = (HorizontalCardLayout) v.findViewById(R.id.horizontal_card_layout_extra); + mActorsLayout.setVisibility(View.VISIBLE); + mScrollView = (ObservableScrollView) v.findViewById(R.id.observableScrollView); + mFab = (FloatingActionButton) v.findViewById(R.id.fab); + + mFab.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + ViewUtils.animateFabJump(v, new Animator.AnimatorListener() { + @Override + public void onAnimationEnd(Animator animation) { + // TODO + } + + @Override + public void onAnimationStart(Animator animation) {} + + @Override + public void onAnimationCancel(Animator animation) {} + + @Override + public void onAnimationRepeat(Animator animation) {} + }); + } + }); + if (MizLib.isTablet(mContext)) + mFab.setType(FloatingActionButton.TYPE_NORMAL); + + // Get rid of these... + v.findViewById(R.id.textView3).setVisibility(View.GONE); // File + v.findViewById(R.id.textView6).setVisibility(View.GONE); // Tagline + + final boolean fullscreen = MizuuApplication.isFullscreen(mContext); + final int height = fullscreen ? MizLib.getActionBarHeight(mContext) : MizLib.getActionBarAndStatusBarHeight(mContext); + + mScrollView.setOnScrollChangedListener(new OnScrollChangedListener() { + @Override + public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { + ViewUtils.handleOnScrollChangedEvent( + getActivity(), v, background, thisShow.getTitle(), + height, t, mToolbar, mToolbarColor); + } + }); + mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + ViewUtils.setLayoutParamsForDetailsEmptyView(mContext, v, + background, mScrollView, this); + } + }); + + // Set the show title + textTitle.setVisibility(View.VISIBLE); + textTitle.setText(thisShow.getTitle()); + textTitle.setTypeface(mCondensedRegular); + + textPlot.setTypeface(mCondensedRegular); + textRuntime.setTypeface(mMedium); + textRating.setTypeface(mMedium); + textCertification.setTypeface(mMedium); + + textRuntime.setTypeface(mMedium); + textCertification.setTypeface(mMedium); + textRating.setTypeface(mMedium); + + // Set the show plot + textPlot.setBackgroundResource(R.drawable.selectable_background); + textPlot.setMaxLines(getActivity().getResources().getInteger(R.integer.show_details_max_lines)); + textPlot.setTag(true); // true = collapsed + textPlot.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (((Boolean) textPlot.getTag())) { + // Animate + ViewUtils.animateTextViewMaxLines(textPlot, 50); // It seems highly unlikely that there would every be more than 50 lines + + // Reverse the tag + textPlot.setTag(false); + } else { + // Animate + ViewUtils.animateTextViewMaxLines(textPlot, getResources().getInteger(R.integer.show_details_max_lines)); + + // Reverse the tag + textPlot.setTag(true); + } + } + }); + textPlot.setEllipsize(TextUtils.TruncateAt.END); + textPlot.setFocusable(true); + + if (MizLib.isTablet(getActivity())) + textPlot.setLineSpacing(0, 1.15f); + + textPlot.setText(thisShow.getDescription()); + + // Set the show genres + textGenre.setTypeface(mMediumItalic); + if (!TextUtils.isEmpty(thisShow.getGenres())) { + textGenre.setText(thisShow.getGenres()); + } else { + textGenre.setVisibility(View.GONE); + } + + // Set the show runtime + textRuntime.setText(MizLib.getPrettyRuntime(getActivity(), Integer.parseInt(thisShow.getRuntime()))); + + // Set the show release date + textReleaseDate.setTypeface(mMedium); + textReleaseDate.setText(MizLib.getPrettyDate(getActivity(), thisShow.getFirstAirdate())); + + // Set the show rating + if (!thisShow.getRating().equals("0.0")) { + try { + int rating = (int) (Double.parseDouble(thisShow.getRating()) * 10); + textRating.setText(Html.fromHtml(rating + " %")); + } catch (NumberFormatException e) { + textRating.setText(thisShow.getRating()); + } + } else { + textRating.setText(R.string.stringNA); + } + + // Set the show certification + if (!TextUtils.isEmpty(thisShow.getCertification())) { + textCertification.setText(thisShow.getCertification()); + } else { + textCertification.setText(R.string.stringNA); + } + + mSeasonsLayout.setTitle(R.string.seasons); + mSeasonsLayout.setSeeMoreVisibility(true); + mSeasonsLayout.getViewTreeObserver().addOnGlobalLayoutListener( + new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + if (mActorsLayout.getWidth() > 0) { + final int numColumns = (int) Math.floor(mActorsLayout.getWidth() / (mImageThumbSize + mImageThumbSpacing)); + mImageThumbSize = (mActorsLayout.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; + + loadSeasons(numColumns); + MizLib.removeViewTreeObserver(mSeasonsLayout.getViewTreeObserver(), this); + } + } + }); + mSeasonsLayout.setSeeMoreOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + startActivity(IntentUtils.getTvShowSeasonsIntent(mContext, thisShow.getTitle(), thisShow.getId(), mToolbarColor)); + } + }); + + mActorsLayout.setTitle(R.string.detailsActors); + mActorsLayout.setSeeMoreVisibility(true); + mActorsLayout.getViewTreeObserver().addOnGlobalLayoutListener( + new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + if (mActorsLayout.getWidth() > 0) { + final int numColumns = (int) Math.floor(mActorsLayout.getWidth() / (mImageThumbSize + mImageThumbSpacing)); + mImageThumbSize = (mActorsLayout.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; + + loadActors(numColumns); + MizLib.removeViewTreeObserver(mActorsLayout.getViewTreeObserver(), this); + } + } + }); + mActorsLayout.setSeeMoreOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + startActivity(IntentUtils.getActorBrowserTvShows(mContext, thisShow.getTitle(), thisShow.getId(), mToolbarColor)); + } + }); + + ViewUtils.updateToolbarBackground(getActivity(), mToolbar, 0, thisShow.getTitle(), mToolbarColor); + + loadImages(); + } + + private void loadImages() { + mPicasso.load(thisShow.getCoverPhoto()).error(R.drawable.loading_image).placeholder(R.drawable.loading_image).into(cover, new Callback() { + @Override + public void onSuccess() { + if (mPaletteLoader == null) { + mPaletteLoader = new PaletteLoader(mPicasso, Uri.parse(thisShow.getCoverPhoto().toString()), new PaletteLoader.OnPaletteLoadedCallback() { + @Override + public void onPaletteLoaded(int swatchColor) { + mToolbarColor = swatchColor; + } + }); + + mPaletteLoader.addView(mDetailsArea); + mPaletteLoader.addView(mActorsLayout.getSeeMoreView()); + mPaletteLoader.addView(mSeasonsLayout.getSeeMoreView()); + mPaletteLoader.setFab(mFab); + + mPaletteLoader.execute(); + } else { + // Clear old views after configuration change + mPaletteLoader.clearViews(); + + // Add views after configuration change + mPaletteLoader.addView(mDetailsArea); + mPaletteLoader.addView(mActorsLayout.getSeeMoreView()); + mPaletteLoader.addView(mSeasonsLayout.getSeeMoreView()); + mPaletteLoader.setFab(mFab); + + // Re-color the views + mPaletteLoader.colorViews(); + } + } + + @Override + public void onError() { + } + }); + + if (!MizLib.isPortrait(getActivity())) { + if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(PreferenceKeys.BLUR_BACKDROPS, false)) { + mPicasso.load(thisShow.getBackdrop()).skipMemoryCache().error(R.drawable.bg).placeholder(R.drawable.bg).transform(new BlurTransformation(mContext, thisShow.getBackdrop(), 8)).into(background); + } else { + mPicasso.load(thisShow.getBackdrop()).skipMemoryCache().error(R.drawable.bg).placeholder(R.drawable.bg).into(background); + } + } else { + mPicasso.load(thisShow.getBackdrop()).skipMemoryCache().placeholder(R.drawable.bg).into(background, new Callback() { + @Override + public void onError() { + if (!isAdded()) + return; + + mPicasso.load(thisShow.getThumbnail()).skipMemoryCache().placeholder(R.drawable.bg).error(R.drawable.bg).into(background); + } + + @Override + public void onSuccess() {} + }); + } + } + + private void loadActors(final int capacity) { + // Show ProgressBar + new AsyncTask() { + private List mActors; + + @Override + protected Void doInBackground(Void... params) { + TMDbTvShowService service = TMDbTvShowService.getInstance(mContext); + mActors = service.getActors(thisShow.getId()); + + return null; + } + + @Override + protected void onPostExecute(Void result) { + mActorsLayout.loadItems(mContext, mPicasso, capacity, mImageThumbSize, mActors, HorizontalCardLayout.ACTORS, mToolbarColor); + } + }.execute(); + } + + private void loadSeasons(final int capacity) { + // Show ProgressBar + new AsyncTask() { + private List mSeasons = new ArrayList(); + + @Override + protected Void doInBackground(Void... params) { + + HashMap seasons = MizuuApplication.getTvEpisodeDbAdapter().getSeasons(thisShow.getId()); + + for (String key : seasons.keySet()) { + File temp = FileUtils.getTvShowSeason(mContext, thisShow.getId(), key); + mSeasons.add(new GridSeason(mContext, thisShow.getId(), Integer.valueOf(key), seasons.get(key).getEpisodeCount(), seasons.get(key).getWatchedCount(), + temp.exists() ? temp : + FileUtils.getTvShowThumb(mContext, thisShow.getId()))); + } + + seasons.clear(); + + Collections.sort(mSeasons); + + return null; + } + + @Override + protected void onPostExecute(Void result) { + mSeasonsLayout.loadItems(mContext, mPicasso, capacity, mImageThumbSize, mSeasons, HorizontalCardLayout.SEASONS, mToolbarColor); + mSeasonsLayout.setSeeMoreVisibility(true); + } + }.execute(); + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + inflater.inflate(R.menu.tv_show_details, menu); + + // If this is a tablet, we have more room to display icons + if (MizLib.isTablet(mContext)) + menu.findItem(R.id.share).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + + // Favourite + menu.findItem(R.id.show_fav).setIcon(thisShow.isFavorite() ? + R.drawable.ic_favorite_white_24dp : R.drawable.ic_favorite_outline_white_24dp) + .setTitle(thisShow.isFavorite() ? + R.string.menuFavouriteTitleRemove : R.string.menuFavouriteTitle); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.show_fav: + favAction(); + break; + case R.id.menuDeleteShow: + deleteShow(); + break; + case R.id.change_cover: + searchCover(); + break; + case R.id.identify_show: + identifyShow(); + break; + case R.id.editTvShow: + editTvShow(); + break; + case R.id.openInBrowser: + Intent browserIntent = new Intent(Intent.ACTION_VIEW); + if (thisShow.getIdType() == TvShow.TMDB) { + browserIntent.setData(Uri.parse("https://www.themoviedb.org/tv/" + thisShow.getIdWithoutHack())); + } else { + browserIntent.setData(Uri.parse("http://thetvdb.com/?tab=series&id=" + thisShow.getId())); + } + startActivity(browserIntent); + break; + case R.id.share: + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_TEXT, ((thisShow.getIdType() == TvShow.THETVDB) ? "http://thetvdb.com/?tab=series&id=" : "http://www.themoviedb.org/tv/") + thisShow.getIdWithoutHack()); + startActivity(intent); + break; + } + + return super.onOptionsItemSelected(item); + } + + private void identifyShow() { + ArrayList files = new ArrayList(); + + Cursor cursor = MizuuApplication.getTvShowEpisodeMappingsDbAdapter().getAllFilepaths(thisShow.getId()); + while (cursor.moveToNext()) + files.add(cursor.getString(cursor.getColumnIndex(DbAdapterTvShowEpisodeMappings.KEY_FILEPATH))); + + cursor.close(); + + Intent i = new Intent(); + i.setClass(mContext, IdentifyTvShow.class); + i.putExtra("showTitle", thisShow.getTitle()); + i.putExtra("showId", thisShow.getId()); + i.putExtra(IntentKeys.TOOLBAR_COLOR, mToolbarColor); + startActivityForResult(i, 0); + } + + private void editTvShow() { + Intent intent = new Intent(mContext, EditTvShow.class); + intent.putExtra("showId", thisShow.getId()); + intent.putExtra(IntentKeys.TOOLBAR_COLOR, mToolbarColor); + startActivityForResult(intent, 1); + } + + public void favAction() { + // Create and open database + thisShow.setFavorite(!thisShow.isFavorite()); // Reverse the favourite boolean + + if (dbHelper.updateShowSingleItem(thisShow.getId(), DbAdapterTvShows.KEY_SHOW_FAVOURITE, thisShow.getFavorite())) { + getActivity().invalidateOptionsMenu(); + + Toast.makeText(mContext, getString(thisShow.isFavorite() ? R.string.addedToFavs : R.string.removedFromFavs), Toast.LENGTH_SHORT).show(); + + LocalBroadcastUtils.updateTvShowLibrary(mContext); + + } else Toast.makeText(mContext, getString(R.string.errorOccured), Toast.LENGTH_SHORT).show(); + + new Thread() { + @Override + public void run() { + ArrayList show = new ArrayList(); + show.add(thisShow); + Trakt.tvShowFavorite(show, getActivity().getApplicationContext()); + } + }.start(); + } + + private void searchCover() { + Intent i = new Intent(); + i.putExtra("id", thisShow.getId()); + i.setClass(mContext, ShowCoverFanartBrowser.class); + startActivity(i); + } + + private void deleteShow() { + AlertDialog.Builder builder = new AlertDialog.Builder(mContext); + builder.setMessage(getString(R.string.areYouSure)) + .setTitle(getString(R.string.removeShow)) + .setCancelable(false) + .setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + MizLib.deleteShow(getActivity().getApplicationContext(), thisShow, true); + LocalBroadcastUtils.updateTvShowLibrary(getActivity().getApplicationContext()); + getActivity().finish(); + return; + } + }) + .setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }) + .create().show(); + } +} \ No newline at end of file diff --git a/src/com/miz/mizuu/fragments/TvShowEpisodeDetailsFragment.java b/app/src/main/java/com/miz/mizuu/fragments/TvShowEpisodeDetailsFragment.java similarity index 95% rename from src/com/miz/mizuu/fragments/TvShowEpisodeDetailsFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/TvShowEpisodeDetailsFragment.java index c937b2ec..c300c967 100644 --- a/src/com/miz/mizuu/fragments/TvShowEpisodeDetailsFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/TvShowEpisodeDetailsFragment.java @@ -16,12 +16,6 @@ package com.miz.mizuu.fragments; -import static com.miz.functions.PreferenceKeys.ALWAYS_DELETE_FILE; -import static com.miz.functions.PreferenceKeys.SHOW_FILE_LOCATION; - -import java.io.File; -import java.util.ArrayList; - import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; @@ -48,11 +42,10 @@ import android.widget.ScrollView; import android.widget.TextView; import android.widget.Toast; -import android.widget.ImageView.ScaleType; import com.miz.apis.trakt.Trakt; -import com.miz.db.DbAdapterTvShows; import com.miz.db.DbAdapterTvShowEpisodes; +import com.miz.db.DbAdapterTvShows; import com.miz.functions.BlurTransformation; import com.miz.functions.FileSource; import com.miz.functions.Filepath; @@ -67,14 +60,20 @@ import com.miz.service.MakeAvailableOffline; import com.miz.utils.FileUtils; import com.miz.utils.LocalBroadcastUtils; +import com.miz.utils.TypefaceUtils; import com.miz.utils.VideoUtils; import com.miz.views.ObservableScrollView; -import com.miz.views.PanningView; import com.miz.views.ObservableScrollView.OnScrollChangedListener; import com.squareup.otto.Bus; import com.squareup.picasso.Callback; import com.squareup.picasso.Picasso; +import java.io.File; +import java.util.ArrayList; + +import static com.miz.functions.PreferenceKeys.ALWAYS_DELETE_FILE; +import static com.miz.functions.PreferenceKeys.SHOW_FILE_LOCATION; + @SuppressLint("InflateParams") public class TvShowEpisodeDetailsFragment extends Fragment { private TvShowEpisode mEpisode; @@ -116,9 +115,9 @@ public void onCreate(Bundle savedInstanceState) { mPicasso = MizuuApplication.getPicassoDetailsView(getActivity()); - mLight = MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-Light.ttf"); - mLightItalic = MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-LightItalic.ttf"); - mMedium = MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-Medium.ttf"); + mLight = TypefaceUtils.getRobotoLight(getActivity()); + mLightItalic = TypefaceUtils.getRobotoLightItalic(getActivity()); + mMedium = TypefaceUtils.getRobotoMedium(getActivity()); mDatabaseHelper = MizuuApplication.getTvEpisodeDbAdapter(); @@ -215,29 +214,11 @@ public void onError() { return; int width = getActivity().getResources().getDimensionPixelSize(R.dimen.episode_details_background_overlay_width); int height = getActivity().getResources().getDimensionPixelSize(R.dimen.episode_details_background_overlay_height); - mPicasso.load(mEpisode.getTvShowBackdrop()).placeholder(R.drawable.bg).error(R.drawable.nobackdrop).resize(width, height).config(MizuuApplication.getBitmapConfig()).into(mEpisodePhoto, new Callback() { - @Override - public void onError() { - if (!isAdded()) - return; - setPanning(false); - } - - @Override - public void onSuccess() { - if (!isAdded()) - return; - setPanning(true); - } - }); + mPicasso.load(mEpisode.getTvShowBackdrop()).placeholder(R.drawable.bg).error(R.drawable.nobackdrop).resize(width, height).config(MizuuApplication.getBitmapConfig()).into(mEpisodePhoto); } @Override - public void onSuccess() { - if (!isAdded()) - return; - setPanning(true); - } + public void onSuccess() {} }); if (!MizLib.isPortrait(getActivity())) @@ -272,7 +253,7 @@ private void loadData() { // Set the episode title mTitle.setVisibility(View.VISIBLE); mTitle.setText(mEpisode.getTitle()); - mTitle.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "RobotoCondensed-Regular.ttf")); + mTitle.setTypeface(TypefaceUtils.getRobotoCondensedRegular(getActivity())); mTitle.setLayerType(View.LAYER_TYPE_SOFTWARE, null); mDescription.setTypeface(mLight); @@ -356,17 +337,6 @@ public void onClick(View v) { } } - private void setPanning(boolean successful) { - if (!MizLib.isPortrait(getActivity())) - return; - - if (successful) { - ((PanningView) mEpisodePhoto).startPanning(); - } else { - ((PanningView) mEpisodePhoto).setScaleType(ScaleType.CENTER_CROP); - } - } - private void play() { ArrayList paths = mEpisode.getFilepaths(); if (paths.size() == 1) { diff --git a/src/com/miz/mizuu/fragments/TvShowEpisodesFragment.java b/app/src/main/java/com/miz/mizuu/fragments/TvShowEpisodesFragment.java similarity index 99% rename from src/com/miz/mizuu/fragments/TvShowEpisodesFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/TvShowEpisodesFragment.java index 3124d958..259bdcac 100644 --- a/src/com/miz/mizuu/fragments/TvShowEpisodesFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/TvShowEpisodesFragment.java @@ -16,14 +16,6 @@ package com.miz.mizuu.fragments; -import static com.miz.functions.PreferenceKeys.TVSHOWS_COLLECTION_LAYOUT; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; @@ -41,8 +33,8 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; -import android.widget.AdapterView; import android.widget.AbsListView.MultiChoiceModeListener; +import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.BaseAdapter; @@ -66,10 +58,19 @@ import com.miz.mizuu.TvShowEpisodeDetails; import com.miz.utils.LocalBroadcastUtils; import com.miz.utils.TvShowDatabaseUtils; +import com.miz.utils.TypefaceUtils; import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; import com.squareup.picasso.Picasso; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static com.miz.functions.PreferenceKeys.TVSHOWS_COLLECTION_LAYOUT; + public class TvShowEpisodesFragment extends Fragment { private static final String SHOW_ID = "showId"; @@ -432,7 +433,7 @@ public View getView(final int position, View convertView, ViewGroup container) { holder.subtext.setSingleLine(true); holder.highlight = (ImageView) convertView.findViewById(R.id.highlight); - holder.text.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf")); + holder.text.setTypeface(TypefaceUtils.getRobotoMedium(mContext)); convertView.setTag(holder); } else { diff --git a/src/com/miz/mizuu/fragments/TvShowLibraryFragment.java b/app/src/main/java/com/miz/mizuu/fragments/TvShowLibraryFragment.java similarity index 91% rename from src/com/miz/mizuu/fragments/TvShowLibraryFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/TvShowLibraryFragment.java index a98bd5e1..543fb40d 100644 --- a/src/com/miz/mizuu/fragments/TvShowLibraryFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/TvShowLibraryFragment.java @@ -16,34 +16,7 @@ package com.miz.mizuu.fragments; -import static com.miz.functions.PreferenceKeys.GRID_ITEM_SIZE; -import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; -import static com.miz.functions.PreferenceKeys.SHOW_TITLES_IN_GRID; -import static com.miz.functions.PreferenceKeys.SORTING_TVSHOWS; -import static com.miz.functions.SortingKeys.ALL_SHOWS; -import static com.miz.functions.SortingKeys.CERTIFICATION; -import static com.miz.functions.SortingKeys.DURATION; -import static com.miz.functions.SortingKeys.FAVORITES; -import static com.miz.functions.SortingKeys.GENRES; -import static com.miz.functions.SortingKeys.NEWEST_EPISODE; -import static com.miz.functions.SortingKeys.RATING; -import static com.miz.functions.SortingKeys.RELEASE; -import static com.miz.functions.SortingKeys.RELEASE_YEAR; -import static com.miz.functions.SortingKeys.TITLE; -import static com.miz.functions.SortingKeys.UNWATCHED_SHOWS; -import static com.miz.functions.SortingKeys.WEIGHTED_RATING; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.Random; -import java.util.TreeMap; -import java.util.regex.Pattern; - import android.annotation.SuppressLint; -import android.app.ActionBar; -import android.app.ActionBar.OnNavigationListener; import android.app.AlertDialog; import android.app.SearchManager; import android.content.BroadcastReceiver; @@ -59,12 +32,17 @@ import android.graphics.Bitmap.Config; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.v4.app.ActivityCompat; +import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.app.Fragment; import android.support.v4.app.LoaderManager.LoaderCallbacks; import android.support.v4.content.Loader; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat.OnActionExpandListener; +import android.support.v7.app.ActionBar; +import android.support.v7.app.ActionBarActivity; +import android.support.v7.widget.SearchView; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.Menu; @@ -80,8 +58,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; -import android.widget.SearchView; -import android.widget.SearchView.OnQueryTextListener; import android.widget.TextView; import com.miz.db.DatabaseHelper; @@ -96,7 +72,6 @@ import com.miz.functions.SQLiteCursorLoader; import com.miz.functions.SpinnerItem; import com.miz.functions.TvShowSortHelper; -import com.miz.mizuu.Main; import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; import com.miz.mizuu.TvShow; @@ -105,9 +80,35 @@ import com.miz.mizuu.UnidentifiedTvShows; import com.miz.mizuu.Update; import com.miz.utils.LocalBroadcastUtils; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; -public class TvShowLibraryFragment extends Fragment implements OnNavigationListener, OnSharedPreferenceChangeListener { +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Random; +import java.util.TreeMap; +import java.util.regex.Pattern; + +import static com.miz.functions.PreferenceKeys.GRID_ITEM_SIZE; +import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; +import static com.miz.functions.PreferenceKeys.SHOW_TITLES_IN_GRID; +import static com.miz.functions.PreferenceKeys.SORTING_TVSHOWS; +import static com.miz.functions.SortingKeys.ALL_SHOWS; +import static com.miz.functions.SortingKeys.CERTIFICATION; +import static com.miz.functions.SortingKeys.DURATION; +import static com.miz.functions.SortingKeys.FAVORITES; +import static com.miz.functions.SortingKeys.GENRES; +import static com.miz.functions.SortingKeys.NEWEST_EPISODE; +import static com.miz.functions.SortingKeys.RATING; +import static com.miz.functions.SortingKeys.RELEASE; +import static com.miz.functions.SortingKeys.RELEASE_YEAR; +import static com.miz.functions.SortingKeys.TITLE; +import static com.miz.functions.SortingKeys.UNWATCHED_SHOWS; +import static com.miz.functions.SortingKeys.WEIGHTED_RATING; + +public class TvShowLibraryFragment extends Fragment implements ActionBar.OnNavigationListener, OnSharedPreferenceChangeListener { private SharedPreferences mSharedPreferences; private int mImageThumbSize, mImageThumbSpacing, mResizedWidth, mResizedHeight, mCurrentSort; @@ -173,18 +174,17 @@ else if (thumbnailSize.equals(getString(R.string.normal))) public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); + getActivity().setTitle(R.string.chooserTVShows); + // Setup ActionBar with the action list setupActionBar(); - if (mActionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST) - mActionBar.setListNavigationCallbacks(mSpinnerAdapter, this); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.UPDATE_TV_SHOW_LIBRARY)); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver, new IntentFilter("mizuu-shows-actor-search")); } private void setupActionBar() { - mActionBar = getActivity().getActionBar(); - mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); + mActionBar = ((ActionBarActivity) getActivity()).getSupportActionBar(); if (mSpinnerAdapter == null) mSpinnerAdapter = new ActionBarSpinner(); } @@ -261,7 +261,7 @@ protected Void doInBackground(Void... params) { @Override protected void onPostExecute(Void result) { - showTvShowSection(mActionBar.getSelectedNavigationIndex()); + showTvShowSection(0); getActivity().invalidateOptionsMenu(); @@ -293,9 +293,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa mEmptyLibraryLayout = v.findViewById(R.id.empty_library_layout); mEmptyLibraryTitle = (TextView) v.findViewById(R.id.empty_library_title); - mEmptyLibraryTitle.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "RobotoCondensed-Regular.ttf")); + mEmptyLibraryTitle.setTypeface(TypefaceUtils.getRobotoCondensedRegular(getActivity())); mEmptyLibraryDescription = (TextView) v.findViewById(R.id.empty_library_description); - mEmptyLibraryDescription.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-Light.ttf")); + mEmptyLibraryDescription.setTypeface(TypefaceUtils.getRobotoLight(getActivity())); mAdapter = new LoaderAdapter(getActivity()); @@ -329,7 +329,9 @@ public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { Intent intent = new Intent(); intent.putExtra("showId", mTvShows.get(mTvShowKeys.get(arg2)).getId()); intent.setClass(getActivity(), TvShowDetails.class); - startActivityForResult(intent, 0); + + ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), arg1.findViewById(R.id.cover), "cover"); + ActivityCompat.startActivityForResult(getActivity(), intent, 0, options.toBundle()); } }); @@ -419,7 +421,7 @@ public View getView(int position, View convertView, ViewGroup container) { holder.subtext = (TextView) convertView.findViewById(R.id.gridCoverSubtitle); holder.subtext.setSingleLine(true); - holder.text.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf")); + holder.text.setTypeface(TypefaceUtils.getRobotoMedium(mContext)); convertView.setTag(holder); } else { @@ -529,7 +531,7 @@ protected Boolean doInBackground(Void... params) { protected void onPostExecute(Boolean success) { // Make sure that the loading was successful, that the Fragment is still added and // that the currently selected navigation index is the same as when we started loading - if (success && isAdded() && mActionBar.getSelectedNavigationIndex() == mPosition) { + if (success && isAdded()) { mTvShowKeys.addAll(mTempKeys); sortTvShows(); @@ -541,60 +543,51 @@ protected void onPostExecute(Boolean success) { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - if (((Main) getActivity()).isDrawerOpen()) { - if (mActionBar == null && getActivity() != null) - mActionBar = getActivity().getActionBar(); - mActionBar.setNavigationMode(ActionBar.DISPLAY_SHOW_TITLE); - ((Main) getActivity()).showDrawerOptionsMenu(menu, inflater); - } else { - setupActionBar(); - inflater.inflate(R.menu.menutv, menu); - - if (mTvShows.size() == 0) - menu.findItem(R.id.random).setVisible(false); - else - menu.findItem(R.id.random).setVisible(true); - - MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.search_textbox), new OnActionExpandListener() { - @Override - public boolean onMenuItemActionExpand(MenuItem item) { - return true; - } + setupActionBar(); + inflater.inflate(R.menu.menutv, menu); + + if (mTvShows.size() == 0) + menu.findItem(R.id.random).setVisible(false); + else + menu.findItem(R.id.random).setVisible(true); + + MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.search_textbox), new OnActionExpandListener() { + @Override + public boolean onMenuItemActionExpand(MenuItem item) { + return true; + } + + @Override + public boolean onMenuItemActionCollapse(MenuItem item) { + onSearchViewCollapsed(); + return true; + } + }); + + SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); + SearchView searchView = (SearchView) menu.findItem(R.id.search_textbox).getActionView(); + ComponentName cn = new ComponentName(getActivity(), TvShowActorSearchActivity.class); + searchView.setSearchableInfo(searchManager.getSearchableInfo(cn)); + searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { + @Override + public boolean onQueryTextChange(String newText) { + if (newText.length() > 0) { + search(newText); + } else { + onSearchViewCollapsed(); + } + return true; + } + @Override + public boolean onQueryTextSubmit(String query) { return false; } + }); - @Override - public boolean onMenuItemActionCollapse(MenuItem item) { - onSearchViewCollapsed(); - return true; - } - }); - - SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); - SearchView searchView = (SearchView) menu.findItem(R.id.search_textbox).getActionView(); - ComponentName cn = new ComponentName(getActivity(), TvShowActorSearchActivity.class); - searchView.setSearchableInfo(searchManager.getSearchableInfo(cn)); - searchView.setOnQueryTextListener(new OnQueryTextListener() { - @Override - public boolean onQueryTextChange(String newText) { - if (newText.length() > 0) { - search(newText); - } else { - onSearchViewCollapsed(); - } - return true; - } - @Override - public boolean onQueryTextSubmit(String query) { return false; } - }); - } super.onCreateOptionsMenu(menu, inflater); } private void onSearchViewCollapsed() { if (isAdded() && mActionBar != null) { - if (mActionBar.getSelectedNavigationIndex() == ALL_SHOWS) - showTvShowSection(ALL_SHOWS); - else - mActionBar.setSelectedNavigationItem(ALL_SHOWS); + showTvShowSection(ALL_SHOWS); } } @@ -637,7 +630,7 @@ public boolean onOptionsItemSelected(MenuItem item) { startActivity(new Intent(getActivity(), UnidentifiedTvShows.class)); break; case R.id.clear_filters: - showTvShowSection(mActionBar.getSelectedNavigationIndex()); + showTvShowSection(0); break; case R.id.random: if (mTvShowKeys.size() > 0) { diff --git a/src/com/miz/mizuu/fragments/TvShowSeasonsEpisodesFragment.java b/app/src/main/java/com/miz/mizuu/fragments/TvShowSeasonsEpisodesFragment.java similarity index 99% rename from src/com/miz/mizuu/fragments/TvShowSeasonsEpisodesFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/TvShowSeasonsEpisodesFragment.java index 7020b03d..11cc89e4 100644 --- a/src/com/miz/mizuu/fragments/TvShowSeasonsEpisodesFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/TvShowSeasonsEpisodesFragment.java @@ -89,7 +89,7 @@ public void onViewCreated(View v, Bundle savedInstanceState) { MizLib.addActionBarPadding(getActivity(), v.findViewById(R.id.container)); FragmentTransaction ft = mFragmentManager.beginTransaction(); - ft.replace(R.id.seasons, TvShowSeasonsFragment.newInstance(mShowId, mDualPane)); + ft.replace(R.id.seasons, TvShowSeasonsFragment.newInstance(mShowId, mDualPane, 0)); ft.commit(); } diff --git a/src/com/miz/mizuu/fragments/TvShowSeasonsFragment.java b/app/src/main/java/com/miz/mizuu/fragments/TvShowSeasonsFragment.java similarity index 93% rename from src/com/miz/mizuu/fragments/TvShowSeasonsFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/TvShowSeasonsFragment.java index 09edfbcb..0fe53f9a 100644 --- a/src/com/miz/mizuu/fragments/TvShowSeasonsFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/TvShowSeasonsFragment.java @@ -16,18 +16,9 @@ package com.miz.mizuu.fragments; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; -import android.content.Intent; import android.graphics.Bitmap.Config; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -57,19 +48,29 @@ import com.miz.functions.EpisodeCounter; import com.miz.functions.GridEpisode; import com.miz.functions.GridSeason; +import com.miz.functions.IntentKeys; import com.miz.functions.LibrarySectionAsyncTask; import com.miz.functions.MizLib; import com.miz.functions.TvShowEpisode; import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; -import com.miz.mizuu.TvShowEpisodes; import com.miz.utils.FileUtils; +import com.miz.utils.IntentUtils; import com.miz.utils.LocalBroadcastUtils; import com.miz.utils.TvShowDatabaseUtils; +import com.miz.utils.TypefaceUtils; import com.squareup.otto.Bus; import com.squareup.otto.Subscribe; import com.squareup.picasso.Picasso; +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + public class TvShowSeasonsFragment extends Fragment { private static final String SHOW_ID = "showId"; @@ -89,12 +90,14 @@ public class TvShowSeasonsFragment extends Fragment { private boolean mDualPane, mContextualActionBarEnabled; private Bus mBus; private Context mContext; + private int mToolbarColor; - public static TvShowSeasonsFragment newInstance(String showId, boolean dualPane) { + public static TvShowSeasonsFragment newInstance(String showId, boolean dualPane, int color) { TvShowSeasonsFragment frag = new TvShowSeasonsFragment(); Bundle b = new Bundle(); b.putString(SHOW_ID, showId); b.putBoolean(DUAL_PANE, dualPane); + b.putInt(IntentKeys.TOOLBAR_COLOR, color); frag.setArguments(b); return frag; } @@ -113,14 +116,12 @@ public void onCreate(Bundle savedInstanceState) { mPicasso = MizuuApplication.getPicasso(mContext); mConfig = MizuuApplication.getBitmapConfig(); - if (!MizLib.isTablet(mContext)) - mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 1.5); - else - mImageThumbSize = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size); + mImageThumbSize = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size); mImageThumbSpacing = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); mShowId = getArguments().getString(SHOW_ID); mDualPane = getArguments().getBoolean(DUAL_PANE); + mToolbarColor = getArguments().getInt(IntentKeys.TOOLBAR_COLOR); } @Override @@ -174,13 +175,8 @@ public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { if (!mDualPane) { // Show the episode browser Activity for the given season - - Intent i = new Intent(getActivity(), TvShowEpisodes.class); - i.putExtra(SHOW_ID, mShowId); - i.putExtra(SEASON, mItems.get(arg2).getSeason()); - i.putExtra(EPISODE_COUNT, mItems.get(arg2).getEpisodeCount()); - getActivity().startActivityForResult(i, 0); - } else { + getActivity().startActivityForResult(IntentUtils.getTvShowSeasonIntent(getActivity(), mShowId, mItems.get(arg2).getSeason(), mItems.get(arg2).getEpisodeCount(), mToolbarColor), 0); + } else { // Notify the parent fragment that the right-hand fragment should be swapped mBus.post(mItems.get(arg2)); @@ -368,7 +364,7 @@ public View getView(final int position, View convertView, ViewGroup container) { holder.subtext = (TextView) convertView.findViewById(R.id.gridCoverSubtitle); holder.subtext.setSingleLine(true); - holder.text.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf")); + holder.text.setTypeface(TypefaceUtils.getRobotoMedium(mContext)); convertView.setTag(holder); } else { @@ -393,11 +389,7 @@ public View getView(final int position, View convertView, ViewGroup container) { } } - if (mSeason.getSeason() == 0) - holder.text.setText(R.string.stringSpecials); - else - holder.text.setText(getString(R.string.showSeason) + " " + mSeason.getSeasonZeroIndex()); - + holder.text.setText(mSeason.getHeaderText()); holder.subtext.setText(mSeason.getSubtitleText()); mPicasso.load(mSeason.getCover()).error(R.drawable.loading_image).fit().config(mConfig).into(holder.cover); @@ -434,7 +426,7 @@ protected Void doInBackground(Void... params) { File temp = null; for (String key : seasons.keySet()) { temp = FileUtils.getTvShowSeason(mContext, mShowId, key); - mItems.add(new GridSeason(mContext, Integer.valueOf(key), seasons.get(key).getEpisodeCount(), seasons.get(key).getWatchedCount(), + mItems.add(new GridSeason(mContext, mShowId, Integer.valueOf(key), seasons.get(key).getEpisodeCount(), seasons.get(key).getWatchedCount(), temp.exists() ? temp : FileUtils.getTvShowThumb(mContext, mShowId))); } diff --git a/src/com/miz/mizuu/fragments/WebVideoFragment.java b/app/src/main/java/com/miz/mizuu/fragments/WebVideoFragment.java similarity index 97% rename from src/com/miz/mizuu/fragments/WebVideoFragment.java rename to app/src/main/java/com/miz/mizuu/fragments/WebVideoFragment.java index 0c24add4..0633556b 100644 --- a/src/com/miz/mizuu/fragments/WebVideoFragment.java +++ b/app/src/main/java/com/miz/mizuu/fragments/WebVideoFragment.java @@ -16,17 +16,13 @@ package com.miz.mizuu.fragments; -import java.util.ArrayList; - -import org.json.JSONArray; -import org.json.JSONObject; - import android.content.Context; import android.content.Intent; import android.graphics.Bitmap.Config; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -48,8 +44,14 @@ import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; +import com.miz.utils.TypefaceUtils; import com.squareup.picasso.Picasso; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.util.ArrayList; + public class WebVideoFragment extends Fragment { private int mImageThumbSize, mImageThumbSpacing; @@ -153,7 +155,7 @@ public void onResume() { @Override public void onStart() { super.onStart(); - getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); + ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } private class ImageAdapter extends BaseAdapter { @@ -196,7 +198,7 @@ public View getView(int position, View convertView, ViewGroup container) { holder.cover = (ImageView) convertView.findViewById(R.id.cover); holder.text = (TextView) convertView.findViewById(R.id.text); - holder.text.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf")); + holder.text.setTypeface(TypefaceUtils.getRobotoMedium(mContext)); convertView.setTag(holder); } else { diff --git a/app/src/main/java/com/miz/mizuu/fragments/WebVideosViewPagerFragment.java b/app/src/main/java/com/miz/mizuu/fragments/WebVideosViewPagerFragment.java new file mode 100644 index 00000000..670b000e --- /dev/null +++ b/app/src/main/java/com/miz/mizuu/fragments/WebVideosViewPagerFragment.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.mizuu.fragments; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; +import android.support.v4.view.ViewPager.OnPageChangeListener; +import android.support.v7.app.ActionBar; +import android.support.v7.app.ActionBarActivity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.astuetz.PagerSlidingTabStrip; +import com.miz.functions.ActionBarSpinner; +import com.miz.functions.MizLib; +import com.miz.functions.SpinnerItem; +import com.miz.mizuu.R; + +import java.util.ArrayList; + +public class WebVideosViewPagerFragment extends Fragment { + + private ViewPager mViewPager; + private PagerSlidingTabStrip mTabs; + + public WebVideosViewPagerFragment() {} + + public static WebVideosViewPagerFragment newInstance() { + return new WebVideosViewPagerFragment(); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setHasOptionsMenu(true); + setRetainInstance(true); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return inflater.inflate(R.layout.viewpager_with_tabs, container, false); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + getActivity().setTitle(R.string.drawerWebVideos); + } + + @Override + public void onViewCreated(View v, Bundle savedInstanceState) { + super.onViewCreated(v, savedInstanceState); + + mViewPager = (ViewPager) v.findViewById(R.id.awesomepager); + mViewPager.setOffscreenPageLimit(3); + mViewPager.setAdapter(new WebVideosAdapter(getChildFragmentManager())); + + mTabs = (PagerSlidingTabStrip) v.findViewById(R.id.tabs); + mTabs.setShouldExpand(true); + mTabs.setViewPager(mViewPager); + + if (MizLib.hasLollipop()) + ((ActionBarActivity) getActivity()).getSupportActionBar().setElevation(0); + + if (savedInstanceState != null) { + mViewPager.setCurrentItem(savedInstanceState.getInt("selectedIndex", 0)); + } + } + + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putInt("selectedIndex", mViewPager.getCurrentItem()); + } + + private class WebVideosAdapter extends FragmentPagerAdapter { + + private final String[] TITLES = {getString(R.string.choiceYouTube), getString(R.string.choiceReddit), getString(R.string.choiceTedTalks)}; + + public WebVideosAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public CharSequence getPageTitle(int position) { + return TITLES[position]; + } + + @Override + public Fragment getItem(int index) { + return WebVideoFragment.newInstance(getPageTitle(index).toString()); + } + + @Override + public int getCount() { + return 3; + } + } +} \ No newline at end of file diff --git a/src/com/miz/remoteplayback/RemotePlayback.java b/app/src/main/java/com/miz/remoteplayback/RemotePlayback.java similarity index 75% rename from src/com/miz/remoteplayback/RemotePlayback.java rename to app/src/main/java/com/miz/remoteplayback/RemotePlayback.java index 7fa1c7d6..aa91a353 100644 --- a/src/com/miz/remoteplayback/RemotePlayback.java +++ b/app/src/main/java/com/miz/remoteplayback/RemotePlayback.java @@ -18,11 +18,13 @@ import android.os.Bundle; import android.support.v4.app.FragmentManager; -import android.support.v7.app.ActionBarActivity; -public class RemotePlayback extends ActionBarActivity { +import com.miz.base.MizActivity; +import com.miz.mizuu.R; - protected void onCreate(Bundle savedInstanceState) { +public class RemotePlayback extends MizActivity { + + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get Intent extras @@ -30,12 +32,18 @@ protected void onCreate(Bundle savedInstanceState) { final String videoUrl = extras.getString("videoUrl"); final String coverUrl = extras.getString("coverUrl"); final String title = extras.getString("title"); + final String id = extras.getString("id"); final FragmentManager fm = getSupportFragmentManager(); if (fm.findFragmentById(android.R.id.content) == null) { - fm.beginTransaction().add(android.R.id.content, RemotePlaybackFragment.newInstance(videoUrl, coverUrl, title)).commit(); + fm.beginTransaction().add(android.R.id.content, RemotePlaybackFragment.newInstance(videoUrl, coverUrl, title, id)).commit(); } } -} + @Override + protected int getLayoutResource() { + return R.layout.empty_layout_with_toolbar; + } + +} \ No newline at end of file diff --git a/src/com/miz/remoteplayback/RemotePlaybackFragment.java b/app/src/main/java/com/miz/remoteplayback/RemotePlaybackFragment.java similarity index 90% rename from src/com/miz/remoteplayback/RemotePlaybackFragment.java rename to app/src/main/java/com/miz/remoteplayback/RemotePlaybackFragment.java index cd556118..6d4197e0 100644 --- a/src/com/miz/remoteplayback/RemotePlaybackFragment.java +++ b/app/src/main/java/com/miz/remoteplayback/RemotePlaybackFragment.java @@ -18,6 +18,7 @@ import android.app.Activity; import android.net.Uri; +import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.view.MenuItemCompat; @@ -31,6 +32,7 @@ import android.support.v7.media.RemotePlaybackClient; import android.support.v7.media.RemotePlaybackClient.ItemActionCallback; import android.support.v7.media.RemotePlaybackClient.SessionActionCallback; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -39,8 +41,11 @@ import android.view.ViewGroup; import android.widget.ImageView; +import com.miz.apis.tmdb.TMDbMovieService; import com.miz.mizuu.R; +import java.util.List; + /** * Work in progress...... * @author Michell @@ -55,16 +60,17 @@ public class RemotePlaybackFragment extends Fragment { private Menu mMenu; private ImageView mBackgroundImage; - private String mVideoUrl, mTitle, mCoverUrl; + private String mVideoUrl, mTitle, mCoverUrl, mId; public RemotePlaybackFragment() {} // Empty constructor - public static RemotePlaybackFragment newInstance(String videoUrl, String coverUrl, String title) { + public static RemotePlaybackFragment newInstance(String videoUrl, String coverUrl, String title, String id) { RemotePlaybackFragment fragment = new RemotePlaybackFragment(); Bundle args = new Bundle(); args.putString("videoUrl", videoUrl); args.putString("coverUrl", coverUrl); args.putString("title", title); + args.putString("id", id); fragment.setArguments(args); return fragment; } @@ -80,8 +86,11 @@ public void onCreate(Bundle savedInstanceState) { mVideoUrl = arguments.getString("videoUrl"); mCoverUrl = arguments.getString("coverUrl"); mTitle = arguments.getString("title"); + mId = arguments.getString("id"); mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK).build(); + + new CoverLoader().execute(); } @Override @@ -327,4 +336,24 @@ private void postCallback(RunnableSessionActionCallback callback) { private void removeCallbacks(RunnableSessionActionCallback callback) { mBackgroundImage.removeCallbacks(callback); } + + private class CoverLoader extends AsyncTask { + @Override + protected String doInBackground(Void... params) { + + TMDbMovieService service = TMDbMovieService.getInstance(getActivity()); + List covers = service.getCovers(mId); + + if (covers.size() > 0) { + return covers.get(0); + } + + return null; + } + + protected void onPostExecute(String result) { + if (!TextUtils.isEmpty(result)) + mCoverUrl = result; + } + } } \ No newline at end of file diff --git a/src/com/miz/service/DeleteFile.java b/app/src/main/java/com/miz/service/DeleteFile.java similarity index 100% rename from src/com/miz/service/DeleteFile.java rename to app/src/main/java/com/miz/service/DeleteFile.java index 9ff08a88..fba052cd 100644 --- a/src/com/miz/service/DeleteFile.java +++ b/app/src/main/java/com/miz/service/DeleteFile.java @@ -16,20 +16,20 @@ package com.miz.service; -import java.io.File; -import java.util.ArrayList; +import android.app.IntentService; +import android.content.Intent; +import android.os.Handler; +import android.os.Looper; +import android.widget.Toast; import com.miz.functions.FileSource; import com.miz.functions.MizLib; import com.miz.mizuu.R; -import jcifs.smb.SmbFile; +import java.io.File; +import java.util.ArrayList; -import android.app.IntentService; -import android.content.Intent; -import android.os.Handler; -import android.os.Looper; -import android.widget.Toast; +import jcifs.smb.SmbFile; public class DeleteFile extends IntentService { diff --git a/src/com/miz/service/DownloadImageService.java b/app/src/main/java/com/miz/service/DownloadImageService.java similarity index 100% rename from src/com/miz/service/DownloadImageService.java rename to app/src/main/java/com/miz/service/DownloadImageService.java index 7b52d65b..bb143e74 100644 --- a/src/com/miz/service/DownloadImageService.java +++ b/app/src/main/java/com/miz/service/DownloadImageService.java @@ -16,15 +16,6 @@ package com.miz.service; -import java.io.File; - -import com.miz.functions.MizLib; -import com.miz.mizuu.MizuuApplication; -import com.miz.mizuu.R; -import com.miz.utils.FileUtils; -import com.miz.utils.LocalBroadcastUtils; -import com.miz.utils.WidgetUtils; - import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; @@ -37,6 +28,15 @@ import android.support.v4.app.NotificationCompat; import android.widget.Toast; +import com.miz.functions.MizLib; +import com.miz.mizuu.MizuuApplication; +import com.miz.mizuu.R; +import com.miz.utils.FileUtils; +import com.miz.utils.LocalBroadcastUtils; +import com.miz.utils.WidgetUtils; + +import java.io.File; + public class DownloadImageService extends IntentService { public static final String IMAGE_URL = "imageUrl"; diff --git a/src/com/miz/service/IdentifyMovieService.java b/app/src/main/java/com/miz/service/IdentifyMovieService.java similarity index 84% rename from src/com/miz/service/IdentifyMovieService.java rename to app/src/main/java/com/miz/service/IdentifyMovieService.java index 798f5007..be31bd05 100644 --- a/src/com/miz/service/IdentifyMovieService.java +++ b/app/src/main/java/com/miz/service/IdentifyMovieService.java @@ -16,8 +16,6 @@ package com.miz.service; -import java.util.ArrayList; - import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; @@ -36,12 +34,12 @@ import com.miz.functions.MovieLibraryUpdateCallback; import com.miz.identification.MovieIdentification; import com.miz.identification.MovieStructure; -import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; -import com.miz.utils.FileUtils; import com.miz.utils.LocalBroadcastUtils; import com.miz.utils.WidgetUtils; +import java.util.ArrayList; + public class IdentifyMovieService extends IntentService implements MovieLibraryUpdateCallback { private boolean mDebugging = true; @@ -97,13 +95,11 @@ public void run() { mMovieId = b.getString("movieId"); mLanguage = b.getString("language", "en"); mFilepath = b.getString("filepath"); + mOldMovieId = b.getString("currentMovieId"); log("setupList()"); setupList(); - log("removeOldData()"); - removeOldData(); - log("start()"); start(); } @@ -112,26 +108,10 @@ private void setupList() { mFiles.add(new MovieStructure(mFilepath)); } - private void removeOldData() { - // Get the movie ID of the old mapping - mOldMovieId = MizuuApplication.getMovieMappingAdapter().getIdForFilepath(mFilepath); - - // Check if there's just one filepath mapping for this particular movie - if (MizuuApplication.getMovieMappingAdapter().getMovieFilepaths(mOldMovieId).size() == 1) { - // Delete database entries - MizuuApplication.getMovieAdapter().deleteMovie(mOldMovieId); - - // Delete the old movie cover art and backdrop images - FileUtils.getMovieThumb(this, mOldMovieId).delete(); - FileUtils.getMovieBackdrop(this, mOldMovieId).delete(); - - LocalBroadcastUtils.updateMovieLibrary(this); - } - } - private void start() { MovieIdentification identification = new MovieIdentification(this, this, mFiles, null); identification.setMovieId(mMovieId); + identification.setCurrentMovieId(mOldMovieId); identification.setLanguage(mLanguage); identification.start(); } @@ -149,13 +129,13 @@ private void clear() { private void setup() { // Setup up notification mBuilder = new NotificationCompat.Builder(getApplicationContext()); - mBuilder.setSmallIcon(R.drawable.refresh); + mBuilder.setSmallIcon(R.drawable.ic_sync_white_24dp); mBuilder.setTicker(getString(R.string.identifying_movie)); mBuilder.setContentTitle(getString(R.string.identifying_movie)); mBuilder.setContentText(getString(R.string.gettingReady)); mBuilder.setOngoing(true); mBuilder.setOnlyAlertOnce(true); - mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.refresh)); + mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_sync_white_24dp)); // Build notification Notification updateNotification = mBuilder.build(); diff --git a/src/com/miz/service/IdentifyTvShowEpisodeService.java b/app/src/main/java/com/miz/service/IdentifyTvShowEpisodeService.java similarity index 98% rename from src/com/miz/service/IdentifyTvShowEpisodeService.java rename to app/src/main/java/com/miz/service/IdentifyTvShowEpisodeService.java index 5723bc55..a8889b75 100644 --- a/src/com/miz/service/IdentifyTvShowEpisodeService.java +++ b/app/src/main/java/com/miz/service/IdentifyTvShowEpisodeService.java @@ -16,8 +16,6 @@ package com.miz.service; -import java.util.ArrayList; - import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; @@ -41,6 +39,8 @@ import com.miz.utils.TvShowDatabaseUtils; import com.miz.utils.WidgetUtils; +import java.util.ArrayList; + public class IdentifyTvShowEpisodeService extends IntentService implements TvShowLibraryUpdateCallback { private boolean mDebugging = true; @@ -153,13 +153,13 @@ private void clear() { private void setup() { // Setup up notification mBuilder = new NotificationCompat.Builder(getApplicationContext()); - mBuilder.setSmallIcon(R.drawable.refresh); + mBuilder.setSmallIcon(R.drawable.ic_sync_white_24dp); mBuilder.setTicker(getString(R.string.identifying_episodes)); mBuilder.setContentTitle(getString(R.string.identifying_episodes)); mBuilder.setContentText(getString(R.string.gettingReady)); mBuilder.setOngoing(true); mBuilder.setOnlyAlertOnce(true); - mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.refresh)); + mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_sync_white_24dp)); // Build notification Notification updateNotification = mBuilder.build(); diff --git a/src/com/miz/service/IdentifyTvShowService.java b/app/src/main/java/com/miz/service/IdentifyTvShowService.java similarity index 98% rename from src/com/miz/service/IdentifyTvShowService.java rename to app/src/main/java/com/miz/service/IdentifyTvShowService.java index c5aa1bc7..98e70ef0 100644 --- a/src/com/miz/service/IdentifyTvShowService.java +++ b/app/src/main/java/com/miz/service/IdentifyTvShowService.java @@ -16,9 +16,6 @@ package com.miz.service; -import java.io.File; -import java.util.ArrayList; - import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; @@ -46,6 +43,9 @@ import com.miz.utils.LocalBroadcastUtils; import com.miz.utils.WidgetUtils; +import java.io.File; +import java.util.ArrayList; + public class IdentifyTvShowService extends IntentService implements TvShowLibraryUpdateCallback { private boolean mDebugging = true; @@ -180,13 +180,13 @@ private void clear() { private void setup() { // Setup up notification mBuilder = new NotificationCompat.Builder(getApplicationContext()); - mBuilder.setSmallIcon(R.drawable.refresh); + mBuilder.setSmallIcon(R.drawable.ic_sync_white_24dp); mBuilder.setTicker(getString(R.string.identifying_show)); mBuilder.setContentTitle(getString(R.string.identifying_show)); mBuilder.setContentText(getString(R.string.gettingReady)); mBuilder.setOngoing(true); mBuilder.setOnlyAlertOnce(true); - mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.refresh)); + mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_sync_white_24dp)); // Build notification Notification updateNotification = mBuilder.build(); diff --git a/src/com/miz/service/MakeAvailableOffline.java b/app/src/main/java/com/miz/service/MakeAvailableOffline.java similarity index 99% rename from src/com/miz/service/MakeAvailableOffline.java rename to app/src/main/java/com/miz/service/MakeAvailableOffline.java index c2d84c65..0c0a0c93 100644 --- a/src/com/miz/service/MakeAvailableOffline.java +++ b/app/src/main/java/com/miz/service/MakeAvailableOffline.java @@ -16,24 +16,6 @@ package com.miz.service; -import static com.miz.functions.PreferenceKeys.BUFFER_SIZE; -import static com.miz.functions.PreferenceKeys.IGNORE_FILESIZE_CHECK; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.DecimalFormat; - -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.smb.SmbException; -import jcifs.smb.SmbFile; -import jcifs.smb.SmbFileInputStream; import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; @@ -57,6 +39,25 @@ import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.text.DecimalFormat; + +import jcifs.smb.NtlmPasswordAuthentication; +import jcifs.smb.SmbException; +import jcifs.smb.SmbFile; +import jcifs.smb.SmbFileInputStream; + +import static com.miz.functions.PreferenceKeys.BUFFER_SIZE; +import static com.miz.functions.PreferenceKeys.IGNORE_FILESIZE_CHECK; + public class MakeAvailableOffline extends IntentService { private static final int NOTIFICATION_ID = 20; diff --git a/src/com/miz/service/MoveFilesService.java b/app/src/main/java/com/miz/service/MoveFilesService.java similarity index 98% rename from src/com/miz/service/MoveFilesService.java rename to app/src/main/java/com/miz/service/MoveFilesService.java index b72230cc..e4a976c8 100644 --- a/src/com/miz/service/MoveFilesService.java +++ b/app/src/main/java/com/miz/service/MoveFilesService.java @@ -16,15 +16,6 @@ package com.miz.service; -import java.io.File; -import java.io.IOException; - -import com.miz.mizuu.MizuuApplication; -import com.miz.mizuu.R; -import com.miz.mizuu.SplashScreen; -import com.miz.utils.FileUtils; - - import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; @@ -33,6 +24,14 @@ import android.graphics.BitmapFactory; import android.support.v4.app.NotificationCompat; +import com.miz.mizuu.MizuuApplication; +import com.miz.mizuu.R; +import com.miz.mizuu.SplashScreen; +import com.miz.utils.FileUtils; + +import java.io.File; +import java.io.IOException; + public class MoveFilesService extends IntentService { public MoveFilesService() { @@ -44,13 +43,13 @@ protected void onHandleIntent(Intent intent) { // Setup up notification NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext()); - builder.setSmallIcon(R.drawable.refresh); + builder.setSmallIcon(R.drawable.ic_sync_white_24dp); builder.setTicker(getString(R.string.movingDataFiles)); builder.setContentTitle(getString(R.string.movingDataFiles)); builder.setContentText(getString(R.string.movingDataFilesDescription)); builder.setOngoing(true); builder.setOnlyAlertOnce(true); - builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.refresh)); + builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_sync_white_24dp)); // Build notification Notification updateNotification = builder.build(); diff --git a/src/com/miz/service/MovieLibraryUpdate.java b/app/src/main/java/com/miz/service/MovieLibraryUpdate.java similarity index 96% rename from src/com/miz/service/MovieLibraryUpdate.java rename to app/src/main/java/com/miz/service/MovieLibraryUpdate.java index b4fb6435..8e278fb7 100644 --- a/src/com/miz/service/MovieLibraryUpdate.java +++ b/app/src/main/java/com/miz/service/MovieLibraryUpdate.java @@ -16,19 +16,6 @@ package com.miz.service; -import static com.miz.functions.PreferenceKeys.CLEAR_LIBRARY_MOVIES; -import static com.miz.functions.PreferenceKeys.DISABLE_ETHERNET_WIFI_CHECK; -import static com.miz.functions.PreferenceKeys.ENABLE_SUBFOLDER_SEARCH; -import static com.miz.functions.PreferenceKeys.IGNORED_FILES_ENABLED; -import static com.miz.functions.PreferenceKeys.IGNORED_NFO_FILES; -import static com.miz.functions.PreferenceKeys.REMOVE_UNAVAILABLE_FILES_MOVIES; -import static com.miz.functions.PreferenceKeys.SYNC_WITH_TRAKT; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; @@ -66,6 +53,19 @@ import com.miz.utils.MovieDatabaseUtils; import com.miz.utils.WidgetUtils; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import static com.miz.functions.PreferenceKeys.CLEAR_LIBRARY_MOVIES; +import static com.miz.functions.PreferenceKeys.DISABLE_ETHERNET_WIFI_CHECK; +import static com.miz.functions.PreferenceKeys.ENABLE_SUBFOLDER_SEARCH; +import static com.miz.functions.PreferenceKeys.IGNORED_FILES_ENABLED; +import static com.miz.functions.PreferenceKeys.IGNORED_NFO_FILES; +import static com.miz.functions.PreferenceKeys.REMOVE_UNAVAILABLE_FILES_MOVIES; +import static com.miz.functions.PreferenceKeys.SYNC_WITH_TRAKT; + public class MovieLibraryUpdate extends IntentService implements MovieLibraryUpdateCallback { public static final String STOP_MOVIE_LIBRARY_UPDATE = "mizuu-stop-movie-library-update"; @@ -237,13 +237,13 @@ private void setupMovieFileSources(boolean mIgnoreRemovedFiles, boolean mSearchS return; switch (fileSource.getFileSourceType()) { case FileSource.FILE: - mMovieFileSources.add(new FileMovie(getApplicationContext(), fileSource, mIgnoreRemovedFiles, mSearchSubfolders, mClearLibrary, mDisableEthernetWiFiCheck)); + mMovieFileSources.add(new FileMovie(getApplicationContext(), fileSource, mSearchSubfolders, mClearLibrary, mDisableEthernetWiFiCheck)); break; case FileSource.SMB: - mMovieFileSources.add(new SmbMovie(getApplicationContext(), fileSource, mIgnoreRemovedFiles, mSearchSubfolders, mClearLibrary, mDisableEthernetWiFiCheck)); + mMovieFileSources.add(new SmbMovie(getApplicationContext(), fileSource, mSearchSubfolders, mClearLibrary, mDisableEthernetWiFiCheck)); break; case FileSource.UPNP: - mMovieFileSources.add(new UpnpMovie(getApplicationContext(), fileSource, mIgnoreRemovedFiles, mSearchSubfolders, mClearLibrary, mDisableEthernetWiFiCheck)); + mMovieFileSources.add(new UpnpMovie(getApplicationContext(), fileSource, mSearchSubfolders, mClearLibrary, mDisableEthernetWiFiCheck)); break; } } @@ -306,14 +306,14 @@ private void setup() { // Setup up notification mBuilder = new NotificationCompat.Builder(getApplicationContext()); mBuilder.setPriority(NotificationCompat.PRIORITY_MAX); - mBuilder.setSmallIcon(R.drawable.refresh); + mBuilder.setSmallIcon(R.drawable.ic_sync_white_24dp); mBuilder.setTicker(getString(R.string.updatingMovies)); mBuilder.setContentTitle(getString(R.string.updatingMovies)); mBuilder.setContentText(getString(R.string.gettingReady)); mBuilder.setContentIntent(contentIntent); mBuilder.setOngoing(true); mBuilder.setOnlyAlertOnce(true); - mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.refresh)); + mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_sync_white_24dp)); mBuilder.addAction(R.drawable.ic_action_discard, getString(android.R.string.cancel), contentIntent); // Build notification @@ -404,8 +404,8 @@ private void updateMovieAddedNotification(String title, Bitmap cover, Bitmap bac } private void updateMovieScaningNotification(String filesource) { - mBuilder.setSmallIcon(R.drawable.refresh); - mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.refresh)); + mBuilder.setSmallIcon(R.drawable.ic_sync_white_24dp); + mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_sync_white_24dp)); mBuilder.setContentTitle(getString(R.string.updatingMovies)); mBuilder.setContentText(getString(R.string.scanning) + ": " + filesource); @@ -424,11 +424,11 @@ private void showPostUpdateNotification() { // Setup up notification mBuilder = new NotificationCompat.Builder(getApplicationContext()); if (!mStopUpdate) { - mBuilder.setSmallIcon(R.drawable.done); + mBuilder.setSmallIcon(R.drawable.ic_done_white_24dp); mBuilder.setTicker(getString(R.string.finishedMovieLibraryUpdate)); mBuilder.setContentTitle(getString(R.string.finishedMovieLibraryUpdate)); mBuilder.setContentText(getString(R.string.stringJustAdded) + " " + mCount + " " + getResources().getQuantityString(R.plurals.moviesInLibrary, mCount, mCount)); - mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.done)); + mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_done_white_24dp)); } else { mBuilder.setSmallIcon(R.drawable.ignoresmallfiles); mBuilder.setTicker(getString(R.string.stringUpdateCancelled)); diff --git a/src/com/miz/service/TraktMoviesSyncService.java b/app/src/main/java/com/miz/service/TraktMoviesSyncService.java similarity index 99% rename from src/com/miz/service/TraktMoviesSyncService.java rename to app/src/main/java/com/miz/service/TraktMoviesSyncService.java index 97f0a096..07994db8 100644 --- a/src/com/miz/service/TraktMoviesSyncService.java +++ b/app/src/main/java/com/miz/service/TraktMoviesSyncService.java @@ -16,11 +16,6 @@ package com.miz.service; -import java.util.ArrayList; -import java.util.HashSet; - -import org.json.JSONArray; - import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; @@ -39,6 +34,11 @@ import com.miz.mizuu.R; import com.miz.utils.LocalBroadcastUtils; +import org.json.JSONArray; + +import java.util.ArrayList; +import java.util.HashSet; + public class TraktMoviesSyncService extends IntentService { private ArrayList mMovies; @@ -158,7 +158,7 @@ private void setupNotification() { private void loadMovieLibrary() { // Get movies mMovieDatabase = MizuuApplication.getMovieAdapter(); - Cursor cursor = mMovieDatabase.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC", false); + Cursor cursor = mMovieDatabase.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC"); ColumnIndexCache cache = new ColumnIndexCache(); try { @@ -340,8 +340,8 @@ private void showPostUpdateNotification() { mBuilder = new NotificationCompat.Builder(getApplicationContext()); mBuilder.setTicker(getString(R.string.finishedTraktMovieSync)); mBuilder.setContentTitle(getString(R.string.finishedTraktMovieSync)); - mBuilder.setSmallIcon(R.drawable.done); - mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.done)); + mBuilder.setSmallIcon(R.drawable.ic_done_white_24dp); + mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_done_white_24dp)); mBuilder.setOngoing(false); mBuilder.setAutoCancel(true); mBuilder.setOnlyAlertOnce(true); diff --git a/src/com/miz/service/TraktTvShowsSyncService.java b/app/src/main/java/com/miz/service/TraktTvShowsSyncService.java similarity index 99% rename from src/com/miz/service/TraktTvShowsSyncService.java rename to app/src/main/java/com/miz/service/TraktTvShowsSyncService.java index 1f01cd3f..524aa512 100644 --- a/src/com/miz/service/TraktTvShowsSyncService.java +++ b/app/src/main/java/com/miz/service/TraktTvShowsSyncService.java @@ -16,15 +16,6 @@ package com.miz.service; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.Set; - -import org.json.JSONArray; -import org.json.JSONObject; - import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; @@ -37,8 +28,8 @@ import com.google.common.collect.Multimap; import com.miz.apis.trakt.Trakt; import com.miz.apis.trakt.TraktTvShow; -import com.miz.db.DbAdapterTvShows; import com.miz.db.DbAdapterTvShowEpisodes; +import com.miz.db.DbAdapterTvShows; import com.miz.functions.ColumnIndexCache; import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; @@ -46,6 +37,15 @@ import com.miz.mizuu.TvShow; import com.miz.utils.LocalBroadcastUtils; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Set; + public class TraktTvShowsSyncService extends IntentService { private NotificationCompat.Builder mBuilder; @@ -407,8 +407,8 @@ private void showPostUpdateNotification() { mBuilder = new NotificationCompat.Builder(getApplicationContext()); mBuilder.setTicker(getString(R.string.finishedTraktTvShowSync)); mBuilder.setContentTitle(getString(R.string.finishedTraktTvShowSync)); - mBuilder.setSmallIcon(R.drawable.done); - mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.done)); + mBuilder.setSmallIcon(R.drawable.ic_done_white_24dp); + mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_done_white_24dp)); mBuilder.setOngoing(false); mBuilder.setAutoCancel(true); mBuilder.setOnlyAlertOnce(true); diff --git a/src/com/miz/service/TvShowsLibraryUpdate.java b/app/src/main/java/com/miz/service/TvShowsLibraryUpdate.java similarity index 96% rename from src/com/miz/service/TvShowsLibraryUpdate.java rename to app/src/main/java/com/miz/service/TvShowsLibraryUpdate.java index fe373b34..d8842f16 100644 --- a/src/com/miz/service/TvShowsLibraryUpdate.java +++ b/app/src/main/java/com/miz/service/TvShowsLibraryUpdate.java @@ -16,10 +16,6 @@ package com.miz.service; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; @@ -41,8 +37,8 @@ import com.miz.abstractclasses.TvShowFileSource; import com.miz.apis.trakt.Trakt; import com.miz.db.DbAdapterSources; -import com.miz.db.DbAdapterTvShows; import com.miz.db.DbAdapterTvShowEpisodes; +import com.miz.db.DbAdapterTvShows; import com.miz.filesources.FileTvShow; import com.miz.filesources.SmbTvShow; import com.miz.filesources.UpnpTvShow; @@ -59,12 +55,16 @@ import com.miz.utils.LocalBroadcastUtils; import com.miz.utils.WidgetUtils; -import static com.miz.functions.PreferenceKeys.SYNC_WITH_TRAKT; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + import static com.miz.functions.PreferenceKeys.CLEAR_LIBRARY_TVSHOWS; -import static com.miz.functions.PreferenceKeys.ENABLE_SUBFOLDER_SEARCH; -import static com.miz.functions.PreferenceKeys.REMOVE_UNAVAILABLE_FILES_TVSHOWS; import static com.miz.functions.PreferenceKeys.DISABLE_ETHERNET_WIFI_CHECK; +import static com.miz.functions.PreferenceKeys.ENABLE_SUBFOLDER_SEARCH; import static com.miz.functions.PreferenceKeys.IGNORED_FILES_ENABLED; +import static com.miz.functions.PreferenceKeys.REMOVE_UNAVAILABLE_FILES_TVSHOWS; +import static com.miz.functions.PreferenceKeys.SYNC_WITH_TRAKT; public class TvShowsLibraryUpdate extends IntentService implements TvShowLibraryUpdateCallback { @@ -229,13 +229,13 @@ private void setupTvShowsFileSources(boolean mIgnoreRemovedFiles, boolean mSearc return; switch (fileSource.getFileSourceType()) { case FileSource.FILE: - mTvShowFileSources.add(new FileTvShow(getApplicationContext(), fileSource, mIgnoreRemovedFiles, mSearchSubfolders, mClearLibrary, mDisableEthernetWiFiCheck)); + mTvShowFileSources.add(new FileTvShow(getApplicationContext(), fileSource, mSearchSubfolders, mClearLibrary, mDisableEthernetWiFiCheck)); break; case FileSource.SMB: - mTvShowFileSources.add(new SmbTvShow(getApplicationContext(), fileSource, mIgnoreRemovedFiles, mSearchSubfolders, mClearLibrary, mDisableEthernetWiFiCheck)); + mTvShowFileSources.add(new SmbTvShow(getApplicationContext(), fileSource, mSearchSubfolders, mClearLibrary, mDisableEthernetWiFiCheck)); break; case FileSource.UPNP: - mTvShowFileSources.add(new UpnpTvShow(getApplicationContext(), fileSource, mIgnoreRemovedFiles, mSearchSubfolders, mClearLibrary, mDisableEthernetWiFiCheck)); + mTvShowFileSources.add(new UpnpTvShow(getApplicationContext(), fileSource, mSearchSubfolders, mClearLibrary, mDisableEthernetWiFiCheck)); break; } } @@ -310,14 +310,14 @@ private void setup() { // Setup up notification mBuilder = new NotificationCompat.Builder(getApplicationContext()); - mBuilder.setSmallIcon(R.drawable.refresh); + mBuilder.setSmallIcon(R.drawable.ic_sync_white_24dp); mBuilder.setTicker(getString(R.string.updatingTvShows)); mBuilder.setContentTitle(getString(R.string.updatingTvShows)); mBuilder.setContentText(getString(R.string.gettingReady)); mBuilder.setContentIntent(contentIntent); mBuilder.setOngoing(true); mBuilder.setOnlyAlertOnce(true); - mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.refresh)); + mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_sync_white_24dp)); mBuilder.addAction(R.drawable.ic_action_discard, getString(android.R.string.cancel), contentIntent); // Build notification @@ -446,8 +446,8 @@ private void updateTvShowAddedNotification(String showId, String title, Bitmap c } private void updateTvShowScanningNotification(String filesource) { - mBuilder.setSmallIcon(R.drawable.refresh); - mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.refresh)); + mBuilder.setSmallIcon(R.drawable.ic_sync_white_24dp); + mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_sync_white_24dp)); mBuilder.setContentTitle(getString(R.string.updatingTvShows)); mBuilder.setContentText(getString(R.string.scanning) + ": " + filesource); @@ -456,8 +456,8 @@ private void updateTvShowScanningNotification(String filesource) { } private void showTvShowAnalyzingNotification() { - mBuilder.setSmallIcon(R.drawable.refresh); - mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.refresh)); + mBuilder.setSmallIcon(R.drawable.ic_sync_white_24dp); + mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_sync_white_24dp)); mBuilder.setContentTitle(getString(R.string.updatingTvShows)); mBuilder.setContentText(getString(R.string.analyzing_files)); @@ -478,11 +478,11 @@ private void showPostUpdateNotification() { // Setup up notification mBuilder = new NotificationCompat.Builder(getApplicationContext()); if (!mStopUpdate) { - mBuilder.setSmallIcon(R.drawable.done); + mBuilder.setSmallIcon(R.drawable.ic_done_white_24dp); mBuilder.setTicker(getString(R.string.finishedTvShowsLibraryUpdate)); mBuilder.setContentTitle(getString(R.string.finishedTvShowsLibraryUpdate)); mBuilder.setContentText(getString(R.string.stringJustAdded) + " " + mShowCount + " " + getResources().getQuantityString(R.plurals.showsInLibrary, mShowCount, mShowCount) + " (" + mEpisodeCount + " " + getResources().getQuantityString(R.plurals.episodes, mEpisodeCount, mEpisodeCount) + ")"); - mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.done)); + mBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_done_white_24dp)); } else { mBuilder.setSmallIcon(R.drawable.ignoresmallfiles); mBuilder.setTicker(getString(R.string.stringUpdateCancelled)); diff --git a/src/com/miz/service/WireUpnpService.java b/app/src/main/java/com/miz/service/WireUpnpService.java similarity index 99% rename from src/com/miz/service/WireUpnpService.java rename to app/src/main/java/com/miz/service/WireUpnpService.java index a43d312d..64c29c42 100644 --- a/src/com/miz/service/WireUpnpService.java +++ b/app/src/main/java/com/miz/service/WireUpnpService.java @@ -17,6 +17,7 @@ package com.miz.service; import android.net.wifi.WifiManager; + import org.teleal.cling.android.AndroidUpnpServiceConfiguration; import org.teleal.cling.android.AndroidUpnpServiceImpl; diff --git a/src/com/miz/smbstreamer/Response.java b/app/src/main/java/com/miz/smbstreamer/Response.java similarity index 100% rename from src/com/miz/smbstreamer/Response.java rename to app/src/main/java/com/miz/smbstreamer/Response.java diff --git a/src/com/miz/smbstreamer/StreamServer.java b/app/src/main/java/com/miz/smbstreamer/StreamServer.java similarity index 100% rename from src/com/miz/smbstreamer/StreamServer.java rename to app/src/main/java/com/miz/smbstreamer/StreamServer.java index 0d405f01..8014e105 100644 --- a/src/com/miz/smbstreamer/StreamServer.java +++ b/app/src/main/java/com/miz/smbstreamer/StreamServer.java @@ -16,6 +16,9 @@ package com.miz.smbstreamer; +import android.net.Uri; +import android.util.Log; + import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; @@ -33,9 +36,6 @@ import java.util.StringTokenizer; import java.util.TimeZone; -import android.net.Uri; -import android.util.Log; - import static com.miz.smbstreamer.Response.HTTP_BADREQUEST; import static com.miz.smbstreamer.Response.HTTP_INTERNALERROR; diff --git a/src/com/miz/smbstreamer/StreamSource.java b/app/src/main/java/com/miz/smbstreamer/StreamSource.java similarity index 100% rename from src/com/miz/smbstreamer/StreamSource.java rename to app/src/main/java/com/miz/smbstreamer/StreamSource.java index aeaddfe3..18ceeb17 100644 --- a/src/com/miz/smbstreamer/StreamSource.java +++ b/app/src/main/java/com/miz/smbstreamer/StreamSource.java @@ -16,11 +16,11 @@ package com.miz.smbstreamer; +import com.miz.utils.VideoUtils; + import java.io.IOException; import java.io.InputStream; -import com.miz.utils.VideoUtils; - import jcifs.smb.SmbException; import jcifs.smb.SmbFile; import jcifs.smb.SmbFileInputStreamOld; diff --git a/src/com/miz/smbstreamer/Streamer.java b/app/src/main/java/com/miz/smbstreamer/Streamer.java similarity index 94% rename from src/com/miz/smbstreamer/Streamer.java rename to app/src/main/java/com/miz/smbstreamer/Streamer.java index 566a79ea..6515eb73 100644 --- a/src/com/miz/smbstreamer/Streamer.java +++ b/app/src/main/java/com/miz/smbstreamer/Streamer.java @@ -16,13 +16,16 @@ package com.miz.smbstreamer; +import android.util.Log; + +import com.miz.utils.NetworkUtils; + import java.io.File; import java.io.IOException; import java.util.List; import java.util.Properties; import jcifs.smb.SmbFile; -import android.util.Log; import static com.miz.smbstreamer.Response.HTTP_FORBIDDEN; import static com.miz.smbstreamer.Response.HTTP_NOTFOUND; @@ -32,8 +35,8 @@ public class Streamer extends StreamServer { - public static final int PORT = 7871; - public static final String URL = "http://127.0.0.1:" + PORT; + public static final int PORT = 50002; + private String mUrl = "http://127.0.0.1:" + PORT; private SmbFile mFile; private List mExtras; // subtitles, etc. @@ -41,8 +44,14 @@ public class Streamer extends StreamServer { protected Streamer(int port) throws IOException { super(port, new File(".")); + + mUrl = "http://" + NetworkUtils.getIPAddress(true) + ":" + PORT; } + public String getUrl() { + return mUrl; + } + public static Streamer getInstance() { if (sInstance == null) try { @@ -56,7 +65,7 @@ public static Streamer getInstance() { public void setStreamSrc(SmbFile file,List extraFiles) { mFile = file; mExtras = extraFiles; - } + } @Override public Response serve(String uri, String method, Properties header, Properties parms, Properties files) { diff --git a/src/com/miz/utils/FileUtils.java b/app/src/main/java/com/miz/utils/FileUtils.java similarity index 100% rename from src/com/miz/utils/FileUtils.java rename to app/src/main/java/com/miz/utils/FileUtils.java index f1ff2624..e5623d37 100644 --- a/src/com/miz/utils/FileUtils.java +++ b/app/src/main/java/com/miz/utils/FileUtils.java @@ -16,6 +16,13 @@ package com.miz.utils; +import android.content.Context; +import android.os.Environment; + +import com.miz.db.DatabaseHelper; +import com.miz.functions.MizLib; +import com.miz.mizuu.MizuuApplication; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -23,13 +30,6 @@ import java.io.InputStream; import java.io.OutputStream; -import com.miz.db.DatabaseHelper; -import com.miz.functions.MizLib; -import com.miz.mizuu.MizuuApplication; - -import android.content.Context; -import android.os.Environment; - public class FileUtils { private FileUtils() {} // No instantiation! diff --git a/src/com/miz/utils/IntentUtils.java b/app/src/main/java/com/miz/utils/IntentUtils.java similarity index 74% rename from src/com/miz/utils/IntentUtils.java rename to app/src/main/java/com/miz/utils/IntentUtils.java index bb5253a6..1489d521 100644 --- a/src/com/miz/utils/IntentUtils.java +++ b/app/src/main/java/com/miz/utils/IntentUtils.java @@ -16,9 +16,12 @@ package com.miz.utils; -import java.util.List; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; import com.miz.functions.Actor; +import com.miz.functions.IntentKeys; import com.miz.functions.MizLib; import com.miz.functions.WebMovie; import com.miz.mizuu.ActorBrowser; @@ -32,10 +35,10 @@ import com.miz.mizuu.MovieDetails; import com.miz.mizuu.SimilarMovies; import com.miz.mizuu.TMDbMovieDetails; +import com.miz.mizuu.TvShowEpisodes; +import com.miz.mizuu.TvShowSeasons; -import android.content.Context; -import android.content.Intent; -import android.net.Uri; +import java.util.List; public class IntentUtils { @@ -74,24 +77,26 @@ public static Intent getActorIntent(Context context, Actor actor) { * @param movieId * @return */ - public static Intent getActorBrowserMovies(Context context, String title, String movieId) { + public static Intent getActorBrowserMovies(Context context, String title, String movieId, int toolbarColor) { Intent actorIntent = new Intent(context, ActorBrowser.class); actorIntent.putExtra("title", title); actorIntent.putExtra("movieId", movieId); + actorIntent.putExtra(IntentKeys.TOOLBAR_COLOR, toolbarColor); return actorIntent; } /** - * Intent for the movie actor browser. + * Intent for the TV show actor browser. * @param context * @param title - * @param movieId + * @param showId * @return */ - public static Intent getActorBrowserTvShows(Context context, String title, String showId) { + public static Intent getActorBrowserTvShows(Context context, String title, String showId, int toolbarColor) { Intent actorIntent = new Intent(context, ActorBrowserTv.class); actorIntent.putExtra("title", title); actorIntent.putExtra("showId", showId); + actorIntent.putExtra(IntentKeys.TOOLBAR_COLOR, toolbarColor); return actorIntent; } @@ -102,10 +107,11 @@ public static Intent getActorBrowserTvShows(Context context, String title, Strin * @param movieId * @return */ - public static Intent getSimilarMovies(Context context, String title, String movieId) { + public static Intent getSimilarMovies(Context context, String title, String movieId, int toolbarColor) { Intent similarMoviesIntent = new Intent(context, SimilarMovies.class); similarMoviesIntent.putExtra("title", title); similarMoviesIntent.putExtra("movieId", movieId); + similarMoviesIntent.putExtra(IntentKeys.TOOLBAR_COLOR, toolbarColor); return similarMoviesIntent; } @@ -147,31 +153,52 @@ public static Intent getActorTaggedPhotoIntent(Context context, List pho return intent; } - public static Intent getActorMoviesIntent(Context context, String actorName, String actorId) { + public static Intent getActorMoviesIntent(Context context, String actorName, String actorId, int toolbarColor) { Intent actorMoviesIntent = new Intent(context, ActorMovies.class); actorMoviesIntent.putExtra("actorName", actorName); actorMoviesIntent.putExtra("actorId", actorId); + actorMoviesIntent.putExtra(IntentKeys.TOOLBAR_COLOR, toolbarColor); return actorMoviesIntent; } - public static Intent getActorTvShowsIntent(Context context, String actorName, String actorId) { + public static Intent getActorTvShowsIntent(Context context, String actorName, String actorId, int toolbarColor) { Intent actorTvShowIntent = new Intent(context, ActorTvShows.class); actorTvShowIntent.putExtra("actorName", actorName); actorTvShowIntent.putExtra("actorId", actorId); + actorTvShowIntent.putExtra(IntentKeys.TOOLBAR_COLOR, toolbarColor); return actorTvShowIntent; } - public static Intent getActorPhotosIntent(Context context, String actorName, String actorId) { + public static Intent getActorPhotosIntent(Context context, String actorName, String actorId, int toolbarColor) { Intent actorPhotosIntent = new Intent(context, ActorPhotos.class); actorPhotosIntent.putExtra("actorName", actorName); actorPhotosIntent.putExtra("actorId", actorId); + actorPhotosIntent.putExtra(IntentKeys.TOOLBAR_COLOR, toolbarColor); return actorPhotosIntent; } - public static Intent getActorTaggedPhotosIntent(Context context, String actorName, String actorId) { + public static Intent getActorTaggedPhotosIntent(Context context, String actorName, String actorId, int toolbarColor) { Intent actorTaggedPhotosIntent = new Intent(context, ActorTaggedPhotos.class); actorTaggedPhotosIntent.putExtra("actorName", actorName); actorTaggedPhotosIntent.putExtra("actorId", actorId); + actorTaggedPhotosIntent.putExtra(IntentKeys.TOOLBAR_COLOR, toolbarColor); return actorTaggedPhotosIntent; } + + public static Intent getTvShowSeasonsIntent(Context context, String title, String showId, int toolbarColor) { + Intent seasonsIntent = new Intent(context, TvShowSeasons.class); + seasonsIntent.putExtra("showTitle", title); + seasonsIntent.putExtra("showId", showId); + seasonsIntent.putExtra(IntentKeys.TOOLBAR_COLOR, toolbarColor); + return seasonsIntent; + } + + public static Intent getTvShowSeasonIntent(Context context, String showId, int season, int episodeCount, int toolbarColor) { + Intent seasonIntent = new Intent(context, TvShowEpisodes.class); + seasonIntent.putExtra("showId", showId); + seasonIntent.putExtra("season", season); + seasonIntent.putExtra("episodeCount", episodeCount); + seasonIntent.putExtra(IntentKeys.TOOLBAR_COLOR, toolbarColor); + return seasonIntent; + } } \ No newline at end of file diff --git a/src/com/miz/utils/LocalBroadcastUtils.java b/app/src/main/java/com/miz/utils/LocalBroadcastUtils.java similarity index 100% rename from src/com/miz/utils/LocalBroadcastUtils.java rename to app/src/main/java/com/miz/utils/LocalBroadcastUtils.java index ba7195d6..1b1ac2b9 100644 --- a/src/com/miz/utils/LocalBroadcastUtils.java +++ b/app/src/main/java/com/miz/utils/LocalBroadcastUtils.java @@ -16,12 +16,12 @@ package com.miz.utils; -import com.miz.mizuu.MizuuApplication; - import android.content.Context; import android.content.Intent; import android.support.v4.content.LocalBroadcastManager; +import com.miz.mizuu.MizuuApplication; + public class LocalBroadcastUtils { public static final String UPDATE_MOVIE_LIBRARY = "mizuu-movies-update"; diff --git a/src/com/miz/utils/MovieDatabaseUtils.java b/app/src/main/java/com/miz/utils/MovieDatabaseUtils.java similarity index 52% rename from src/com/miz/utils/MovieDatabaseUtils.java rename to app/src/main/java/com/miz/utils/MovieDatabaseUtils.java index 0e1515ac..28cedc7f 100644 --- a/src/com/miz/utils/MovieDatabaseUtils.java +++ b/app/src/main/java/com/miz/utils/MovieDatabaseUtils.java @@ -16,10 +16,11 @@ package com.miz.utils; -import com.miz.mizuu.MizuuApplication; - import android.content.Context; +import com.miz.db.DbAdapterMovies; +import com.miz.mizuu.MizuuApplication; + public class MovieDatabaseUtils { private MovieDatabaseUtils() {} // No instantiation @@ -46,4 +47,36 @@ public static void deleteAllMovies(Context context) { public static void removeAllUnidentifiedFiles() { MizuuApplication.getMovieMappingAdapter().deleteAllUnidentifiedFilepaths(); } + + public static void deleteMovie(Context context, String tmdbId) { + DbAdapterMovies db = MizuuApplication.getMovieAdapter(); + + // Delete the movie details + db.deleteMovie(tmdbId); + + // When deleting a movie, check if there's other movies + // linked to the collection - if not, delete the collection entry + String collectionId = db.getCollectionId(tmdbId); + if (MizuuApplication.getCollectionsAdapter().getMovieCount(collectionId) == 1) + MizuuApplication.getCollectionsAdapter().deleteCollection(collectionId); + + // Finally, delete all filepath mappings to this movie ID + MizuuApplication.getMovieMappingAdapter().deleteMovie(tmdbId); + } + + public static void ignoreMovie(String tmdbId) { + DbAdapterMovies db = MizuuApplication.getMovieAdapter(); + + // We delete the movie... + db.deleteMovie(tmdbId); + + // ... check if there's other movies linked to the collection + // - if not, we delete the collection entry as well + String collectionId = db.getCollectionId(tmdbId); + if (MizuuApplication.getCollectionsAdapter().getMovieCount(collectionId) == 1) + MizuuApplication.getCollectionsAdapter().deleteCollection(collectionId); + + // And finally we make sure that Mizuu ignores the filepath in the future + MizuuApplication.getMovieMappingAdapter().ignoreMovie(tmdbId); + } } \ No newline at end of file diff --git a/app/src/main/java/com/miz/utils/NetworkUtils.java b/app/src/main/java/com/miz/utils/NetworkUtils.java new file mode 100644 index 00000000..d967741d --- /dev/null +++ b/app/src/main/java/com/miz/utils/NetworkUtils.java @@ -0,0 +1,57 @@ +package com.miz.utils;/* + * Copyright (C) 2014 Michell Bak + * + * 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. + */ + +import org.apache.http.conn.util.InetAddressUtils; + +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.util.Collections; +import java.util.List; + +public class NetworkUtils { + + /** + * Get IP address from first non-localhost interface. + * Taken from http://stackoverflow.com/a/13007325/762442. + * @param useIPv4 true=return ipv4, false=return ipv6 + * @return address or empty string + */ + public static String getIPAddress(boolean useIPv4) { + try { + List interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); + for (NetworkInterface intf : interfaces) { + List addrs = Collections.list(intf.getInetAddresses()); + for (InetAddress addr : addrs) { + if (!addr.isLoopbackAddress()) { + String sAddr = addr.getHostAddress().toUpperCase(); + boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr); + if (useIPv4) { + if (isIPv4) + return sAddr; + } else { + if (!isIPv4) { + int delim = sAddr.indexOf('%'); // drop ip6 port suffix + return delim<0 ? sAddr : sAddr.substring(0, delim); + } + } + } + } + } + } catch (Exception ex) { } // for now eat exceptions + return ""; + } + +} diff --git a/src/com/miz/utils/StringUtils.java b/app/src/main/java/com/miz/utils/StringUtils.java similarity index 100% rename from src/com/miz/utils/StringUtils.java rename to app/src/main/java/com/miz/utils/StringUtils.java diff --git a/src/com/miz/utils/TvShowDatabaseUtils.java b/app/src/main/java/com/miz/utils/TvShowDatabaseUtils.java similarity index 100% rename from src/com/miz/utils/TvShowDatabaseUtils.java rename to app/src/main/java/com/miz/utils/TvShowDatabaseUtils.java index 8c1d6ecd..0039b0e4 100644 --- a/src/com/miz/utils/TvShowDatabaseUtils.java +++ b/app/src/main/java/com/miz/utils/TvShowDatabaseUtils.java @@ -16,9 +16,6 @@ package com.miz.utils; -import java.util.ArrayList; -import java.util.List; - import android.content.Context; import android.database.Cursor; import android.preference.PreferenceManager; @@ -31,6 +28,9 @@ import com.miz.functions.PreferenceKeys; import com.miz.mizuu.MizuuApplication; +import java.util.ArrayList; +import java.util.List; + public class TvShowDatabaseUtils { private TvShowDatabaseUtils() {} // No instantiation diff --git a/app/src/main/java/com/miz/utils/TypefaceUtils.java b/app/src/main/java/com/miz/utils/TypefaceUtils.java new file mode 100644 index 00000000..c779fa06 --- /dev/null +++ b/app/src/main/java/com/miz/utils/TypefaceUtils.java @@ -0,0 +1,86 @@ +package com.miz.utils; + +/* + * Copyright (C) 2014 Michell Bak + * + * 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. + */ +/* + * Copyright (C) 2014 Michell Bak + * + * 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. + */ + +import android.content.Context; +import android.graphics.Typeface; + +import com.miz.mizuu.MizuuApplication; + +public class TypefaceUtils { + + private TypefaceUtils() {} // No instantiation + + public static Typeface getRoboto(Context context) { + return MizuuApplication.getOrCreateTypeface(context, "Roboto-Regular.ttf"); + } + + public static Typeface getRobotoLight(Context context) { + return MizuuApplication.getOrCreateTypeface(context, "Roboto-Light.ttf"); + } + + public static Typeface getRobotoLightItalic(Context context) { + return MizuuApplication.getOrCreateTypeface(context, "Roboto-LightItalic.ttf"); + } + + public static Typeface getRobotoThin(Context context) { + return MizuuApplication.getOrCreateTypeface(context, "Roboto-Thin.ttf"); + } + + public static Typeface getRobotoMedium(Context context) { + return MizuuApplication.getOrCreateTypeface(context, "Roboto-Medium.ttf"); + } + + public static Typeface getRobotoMediumItalic(Context context) { + return MizuuApplication.getOrCreateTypeface(context, "Roboto-MediumItalic.ttf"); + } + + public static Typeface getRobotoBold(Context context) { + return MizuuApplication.getOrCreateTypeface(context, "Roboto-Bold.ttf"); + } + + public static Typeface getRobotoBoldItalic(Context context) { + return MizuuApplication.getOrCreateTypeface(context, "Roboto-BoldItalic.ttf"); + } + + public static Typeface getRobotoCondensedRegular(Context context) { + return MizuuApplication.getOrCreateTypeface(context, "RobotoCondensed-Regular.ttf"); + } + + public static Typeface getRobotoCondensedLight(Context context) { + return MizuuApplication.getOrCreateTypeface(context, "RobotoCondensed-Light.ttf"); + } + + public static Typeface getRobotoCondensedLightItalic(Context context) { + return MizuuApplication.getOrCreateTypeface(context, "RobotoCondensed-LightItalic.ttf"); + } +} diff --git a/src/com/miz/utils/VideoUtils.java b/app/src/main/java/com/miz/utils/VideoUtils.java similarity index 82% rename from src/com/miz/utils/VideoUtils.java rename to app/src/main/java/com/miz/utils/VideoUtils.java index 2840e718..f3be0b16 100644 --- a/src/com/miz/utils/VideoUtils.java +++ b/app/src/main/java/com/miz/utils/VideoUtils.java @@ -16,16 +16,13 @@ package com.miz.utils; -import static com.miz.functions.PreferenceKeys.BUFFER_SIZE; -import static com.miz.functions.PreferenceKeys.IGNORE_VIDEO_FILE_TYPE; - -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.util.HashMap; - -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.smb.SmbFile; +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.text.TextUtils; +import android.widget.Toast; import com.google.android.youtube.player.YouTubeApiServiceUtil; import com.google.android.youtube.player.YouTubeInitializationResult; @@ -39,13 +36,16 @@ import com.miz.mizuu.TvShowEpisode; import com.miz.smbstreamer.Streamer; -import android.app.Activity; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.text.TextUtils; -import android.widget.Toast; +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.util.HashMap; + +import jcifs.smb.NtlmPasswordAuthentication; +import jcifs.smb.SmbFile; + +import static com.miz.functions.PreferenceKeys.BUFFER_SIZE; +import static com.miz.functions.PreferenceKeys.IGNORE_VIDEO_FILE_TYPE; public class VideoUtils { @@ -116,11 +116,11 @@ public void run(){ activity.runOnUiThread(new Runnable(){ public void run(){ try{ - Uri uri = Uri.parse(Streamer.URL + Uri.fromFile(new File(Uri.parse(filepath).getPath())).getEncodedPath()); + Uri uri = Uri.parse(s.getUrl() + Uri.fromFile(new File(Uri.parse(filepath).getPath())).getEncodedPath()); activity.startActivity(getVideoIntent(uri, videoWildcard, videoObject)); } catch (Exception e) { try { // Attempt to launch intent based on wildcard MIME type - Uri uri = Uri.parse(Streamer.URL + Uri.fromFile(new File(Uri.parse(filepath).getPath())).getEncodedPath()); + Uri uri = Uri.parse(s.getUrl() + Uri.fromFile(new File(Uri.parse(filepath).getPath())).getEncodedPath()); activity.startActivity(getVideoIntent(uri, "video/*", videoObject)); } catch (Exception e2) { Toast.makeText(activity, activity.getString(R.string.noVideoPlayerFound), Toast.LENGTH_LONG).show(); @@ -136,6 +136,51 @@ public void run(){ return true; } + + public static String startSmbServer(final Activity activity, final String filepath, final Object videoObject) { + if (!MizLib.isWifiConnected(activity)) { + Toast.makeText(activity, activity.getString(R.string.noConnection), Toast.LENGTH_LONG).show(); + return ""; + } + + int bufferSize; + String buff = PreferenceManager.getDefaultSharedPreferences(activity).getString(BUFFER_SIZE, activity.getString(R.string._16kb)); + if (buff.equals(activity.getString(R.string._16kb))) + bufferSize = 8192 * 2; // This appears to be the limit for most video players + else bufferSize = 8192; + + final Streamer s = Streamer.getInstance(); + if (s != null) + s.setBufferSize(bufferSize); + else { + Toast.makeText(activity, activity.getString(R.string.errorOccured), Toast.LENGTH_SHORT).show(); + return ""; + } + + int contentType = (videoObject instanceof Movie) ? MizLib.TYPE_MOVIE : MizLib.TYPE_SHOWS; + final NtlmPasswordAuthentication auth = MizLib.getAuthFromFilepath(contentType, filepath); + + new Thread(){ + public void run(){ + try{ + final SmbFile file = new SmbFile( + MizLib.createSmbLoginString( + auth.getDomain(), + auth.getUsername(), + auth.getPassword(), + filepath, + false + )); + + s.setStreamSrc(file, MizLib.getSubtitleFiles(filepath, auth)); //the second argument can be a list of subtitle files + } + catch (MalformedURLException e) {} + catch (UnsupportedEncodingException e1) {} + } + }.start(); + + return Uri.parse(s.getUrl() + Uri.fromFile(new File(Uri.parse(filepath).getPath())).getEncodedPath()).toString(); + } public static void playTrailer(final Activity activity, final Movie movie) { String localTrailer = ""; diff --git a/app/src/main/java/com/miz/utils/ViewUtils.java b/app/src/main/java/com/miz/utils/ViewUtils.java new file mode 100644 index 00000000..1cbc0a7c --- /dev/null +++ b/app/src/main/java/com/miz/utils/ViewUtils.java @@ -0,0 +1,509 @@ +/* + * Copyright (C) 2014 Michell Bak + * + * 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.miz.utils; + +import android.animation.Animator; +import android.animation.ObjectAnimator; +import android.annotation.SuppressLint; +import android.app.ActionBar; +import android.app.Activity; +import android.content.Context; +import android.graphics.Color; +import android.graphics.Point; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; +import android.support.v4.app.ActivityCompat; +import android.support.v4.app.ActivityOptionsCompat; +import android.support.v7.widget.Toolbar; +import android.view.Display; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.view.Window; +import android.view.WindowManager; +import android.view.animation.AccelerateInterpolator; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ScrollView; +import android.widget.TextView; + +import com.miz.functions.Actor; +import com.miz.functions.GridSeason; +import com.miz.functions.MizLib; +import com.miz.functions.WebMovie; +import com.miz.mizuu.MizuuApplication; +import com.miz.mizuu.R; +import com.miz.views.ObservableScrollView; +import com.squareup.picasso.Picasso; + +import java.util.List; + +public class ViewUtils { + + private ViewUtils() {} // No instantiation + + /** + * Returns a actor card with name, character, image and click listener. + * @param context + * @param picasso + * @param actor + * @return + */ + @SuppressLint("InflateParams") + public static View setupActorCard(final Activity context, Picasso picasso, final Actor actor) { + View v = LayoutInflater.from(context).inflate(R.layout.horizontal_grid_item_small, null); + + // Load image + picasso.load(actor.getUrl()).placeholder(R.color.card_background_dark).error(R.drawable.noactor).config(MizuuApplication.getBitmapConfig()).into(((ImageView) v.findViewById(R.id.cover))); + + // Set title + ((TextView) v.findViewById(R.id.text)).setText(actor.getName()); + ((TextView) v.findViewById(R.id.text)).setTypeface(TypefaceUtils.getRobotoMedium(context)); + + // Set subtitle + ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setText(actor.getCharacter()); + ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setSingleLine(true); + + // Set click listener + v.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + context.startActivity(IntentUtils.getActorIntent(context, actor)); + } + }); + + return v; + } + + /** + * Returns a movie card with title, release date, image and click listener. + * @param context + * @param picasso + * @param movie + * @return + */ + @SuppressLint("InflateParams") + public static View setupMovieCard(final Activity context, Picasso picasso, final WebMovie movie) { + final View v = LayoutInflater.from(context).inflate(R.layout.horizontal_grid_item_small, null); + + // Load image + picasso.load(movie.getUrl()).placeholder(R.color.card_background_dark).error(R.drawable.loading_image).config(MizuuApplication.getBitmapConfig()).into(((ImageView) v.findViewById(R.id.cover))); + + // Set title + ((TextView) v.findViewById(R.id.text)).setText(movie.getTitle()); + ((TextView) v.findViewById(R.id.text)).setTypeface(TypefaceUtils.getRobotoMedium(context)); + + // Set subtitle + ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setText(movie.getSubtitle()); + ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setSingleLine(true); + + // Set click listener + v.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(context, v.findViewById(R.id.cover), "cover"); + ActivityCompat.startActivity(context, IntentUtils.getTmdbMovieDetails(context, movie), options.toBundle()); + } + }); + + return v; + } + + /** + * Returns a TV show card with title, release date, image and click listener. + * @param context + * @param picasso + * @param show + * @return + */ + @SuppressLint("InflateParams") + public static View setupTvShowCard(final Context context, Picasso picasso, final WebMovie show) { + View v = LayoutInflater.from(context).inflate(R.layout.horizontal_grid_item_small, null); + + // Load image + picasso.load(show.getUrl()).placeholder(R.color.card_background_dark).error(R.drawable.loading_image).config(MizuuApplication.getBitmapConfig()).into(((ImageView) v.findViewById(R.id.cover))); + + // Set title + ((TextView) v.findViewById(R.id.text)).setText(show.getTitle()); + ((TextView) v.findViewById(R.id.text)).setTypeface(TypefaceUtils.getRobotoMedium(context)); + + // Set subtitle + ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setText(show.getSubtitle()); + ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setSingleLine(true); + + // Set click listener + v.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + context.startActivity(IntentUtils.getTmdbTvShowLink(show)); + } + }); + + return v; + } + + /** + * Returns a TV show season card with title, release date, image and click listener. + * @param context + * @param picasso + * @param season + * @return + */ + @SuppressLint("InflateParams") + public static View setupTvShowSeasonCard(final Activity context, Picasso picasso, final GridSeason season, final int toolbarColor) { + final View v = LayoutInflater.from(context).inflate(R.layout.horizontal_grid_item_small, null); + + // Load image + picasso.load(season.getCover()).placeholder(R.color.card_background_dark).error(R.drawable.loading_image).config(MizuuApplication.getBitmapConfig()).into(((ImageView) v.findViewById(R.id.cover))); + + // Set title + ((TextView) v.findViewById(R.id.text)).setText(season.getHeaderText()); + ((TextView) v.findViewById(R.id.text)).setTypeface(TypefaceUtils.getRobotoMedium(context)); + + // Set subtitle + ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setText(season.getSimpleSubtitleText()); + ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setSingleLine(true); + + // Set click listener + v.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + context.startActivityForResult(IntentUtils.getTvShowSeasonIntent(context, season.getShowId(), season.getSeason(), season.getEpisodeCount(), toolbarColor), 0); + } + }); + + return v; + } + + /** + * Returns a photo card with image and click listener. + * @param context + * @param picasso + * @param url + * @param items + * @param index + * @return + */ + @SuppressLint("InflateParams") + public static View setupPhotoCard(final Context context, Picasso picasso, final String url, final List items, final int index) { + final View v = LayoutInflater.from(context).inflate(R.layout.horizontal_grid_item_small_no_text, null); + + // Load image + picasso.load(url).placeholder(R.color.card_background_dark).error(R.drawable.noactor).config(MizuuApplication.getBitmapConfig()).into(((ImageView) v.findViewById(R.id.cover))); + + // Set click listener + v.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + context.startActivity(IntentUtils.getActorPhotoIntent(context, items, index)); + } + }); + + return v; + } + + /** + * Returns a photo card with image and click listener. + * @param context + * @param picasso + * @param url + * @param items + * @param index + * @return + */ + @SuppressLint("InflateParams") + public static View setupTaggedPhotoCard(final Context context, Picasso picasso, final String url, final List items, final int index) { + View v = LayoutInflater.from(context).inflate(R.layout.horizontal_grid_item_small_landscape_no_text, null); + + // Load image + picasso.load(url).placeholder(R.color.card_background_dark).error(R.drawable.noactor).config(MizuuApplication.getBitmapConfig()).into(((ImageView) v.findViewById(R.id.cover))); + + // Set click listener + v.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + context.startActivity(IntentUtils.getActorTaggedPhotoIntent(context, items, index)); + } + }); + + return v; + } + + /** + * Used to update the ActionBar for movie details view as the user scrolls. + * @param context + * @param actionBarBackgroundDrawable + * @param actionBar + * @param title + * @param newAlpha + * @param setBackground + * @param showActionBar + */ + public static void updateActionBarDrawable(Context context, Drawable actionBarBackgroundDrawable, + ActionBar actionBar, String title, int newAlpha, boolean setBackground, boolean showActionBar) { + + if (!MizLib.isPortrait(context)) { + newAlpha = 0; + setBackground = true; + showActionBar = true; + } else { + if (!MizLib.isTablet(context) && !MizLib.usesNavigationControl(context)) { + if (newAlpha == 0) { + actionBar.hide(); + } else + actionBar.show(); + } + } + + actionBar.setTitle(newAlpha > 127 ? title : null); + + if (setBackground) { + actionBarBackgroundDrawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[]{Color.parseColor("#" + ((Integer.toHexString(newAlpha).length() == 1) ? ("0" + Integer.toHexString(newAlpha)) : Integer.toHexString(newAlpha)) + "000000"), (newAlpha >= 170) ? Color.parseColor("#" + Integer.toHexString(newAlpha) + "000000") : 0xaa000000}); + actionBar.setBackgroundDrawable(actionBarBackgroundDrawable); + } + + if (showActionBar) { + actionBar.show(); + } + } + + /** + * Used to update the ActionBar for movie details view as the user scrolls. + * @param context + * @param actionBarBackgroundDrawable + * @param actionBar + * @param title + * @param newAlpha + * @param setBackground + * @param showActionBar + */ + public static void updateActionBarDrawable(Context context, Drawable actionBarBackgroundDrawable, + android.support.v7.app.ActionBar actionBar, String title, int newAlpha, boolean setBackground, boolean showActionBar) { + + if (!MizLib.isPortrait(context)) { + newAlpha = 0; + setBackground = true; + showActionBar = true; + } else { + if (!MizLib.isTablet(context) && !MizLib.usesNavigationControl(context)) { + if (newAlpha == 0) { + actionBar.hide(); + } else + actionBar.show(); + } + } + + actionBar.setTitle(newAlpha > 127 ? title : null); + + if (showActionBar) { + actionBar.show(); + } + } + + /** + * Animates the transition when changing the maxLines + * attribute of a TextView. + * @param text + * @param maxLines + */ + public static void animateTextViewMaxLines(TextView text, int maxLines) { + ObjectAnimator animation = ObjectAnimator.ofInt(text, "maxLines", maxLines); + animation.setInterpolator(new AccelerateInterpolator()); + animation.setDuration(200); + animation.start(); + } + + public static void animateFabJump(View fab, Animator.AnimatorListener listener) { + ObjectAnimator animation = ObjectAnimator.ofFloat(fab, "translationY", -10f, -5f, 0f, 5f, 10f, 5f, 0f, -5f, -10f, -5f, 0f); + animation.setDuration(350); + animation.addListener(listener); + animation.start(); + } + + /** + * Update the Toolbar background color and title. + * @param activity + * @param toolbar + * @param alpha + * @param title + * @param color + */ + public static void updateToolbarBackground(Activity activity, Toolbar toolbar, int alpha, String title, int color) { + if (alpha < 127) { + toolbar.setTitle(null); + toolbar.setBackgroundResource(R.drawable.transparent_actionbar); + + if (MizLib.hasLollipop()) + activity.getWindow().setStatusBarColor(Color.TRANSPARENT); + } else { + toolbar.setTitle(title); + toolbar.setBackgroundColor(adjustAlpha(color, alpha)); + } + } + + public static int adjustAlpha(int color, int alpha) { + int red = Color.red(color); + int green = Color.green(color); + int blue = Color.blue(color); + return Color.argb(alpha, red, green, blue); + } + + public static boolean isTranslucentDecorAvailable(Context context) { + int id = context.getResources().getIdentifier("config_enableTranslucentDecor", "bool", "android"); + return (id == 0) ? false : context.getResources().getBoolean(id); + } + + public static int getStatusBarHeight(Context context) { + int result = 0; + int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); + if (resourceId > 0) { + result = context.getResources().getDimensionPixelSize(resourceId); + } + return result; + } + + public static int getNavigationDrawerWidth(Context context) { + int drawerWidth = 0; + + // The navigation drawer should have a width equal to + // the screen width minus the Toolbar height - at least + // on mobile devices. Tablets are accounted for below. + int toolbarHeight = MizLib.getActionBarHeight(context); + + // Get the display size + Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)) + .getDefaultDisplay(); + + Point size = new Point(); + display.getSize(size); + + // Get the smallest number + int smallestDisplayWidth = Math.min(size.x, size.y); + + // Calculate the drawer width + drawerWidth = smallestDisplayWidth - toolbarHeight; + + // Make sure that the calculated drawer width + // isn't greater than the max width, i.e. + // 5 times the standard increment (56dp for + // mobile or 64dp for tablets). + int maxWidth = MizLib.convertDpToPixels(context, 5 * (MizLib.isTablet(context) ? 64 : 56)); + + if (drawerWidth > maxWidth) + drawerWidth = maxWidth; + + return drawerWidth; + } + + /** + * Since Toolbar needs to be bigger than the default height in some cases, + * this method will change the height to include the status bar on Kitkat and newer. + * @param context + * @param toolbar + */ + public static void setProperToolbarSize(Context context, Toolbar toolbar) { + toolbar.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + MizLib.hasKitKat() ? MizLib.getActionBarAndStatusBarHeight(context) : MizLib.getActionBarHeight(context))); + } + + public static void setupWindowFlagsForStatusbarOverlay(Window window, boolean fullscreen, boolean setBackgroundResource) { + // If requested, make it fullscreen + if (fullscreen) + window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); + + if (MizLib.isKitKat()) { + // If we're running on KitKat, we want to enable + // the translucent status bar + window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, + WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + } + + if (MizLib.hasKitKat()) { + // If we're running on KitKat or above, we want to show + // the background image beneath the status bar as well. + window.getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + } + + // Make the status bar color transparent to begin with + if (MizLib.hasLollipop()) + window.setStatusBarColor(Color.TRANSPARENT); + + // If requested, set a background resource on the Window object + if (setBackgroundResource) + window.setBackgroundDrawableResource(R.drawable.bg); + } + + public static void setLayoutParamsForDetailsEmptyView(Context context, View layout, ImageView background, ObservableScrollView scrollView, ViewTreeObserver.OnGlobalLayoutListener listener) { + if (!MizLib.isPortrait(context)) { + // Let's set the size of the empty view on the scroll container + View empty = layout.findViewById(R.id.empty_view); + + // First, we get the height of the background image, since that + // fills the available screen estate in its entirety + int fullHeight = background.getHeight(); + + // Then we get the content height - this is how much of the content + // will be shown on the screen at a minimum + int contentHeight = context.getResources().getDimensionPixelSize(R.dimen.content_details_main_height); + + // Finally we set the empty view to fill the width and have a height + // that fills the gap between the full height and content height + empty.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, fullHeight - contentHeight)); + } + + // Remove the ViewTreeObserver when we're done :-) + MizLib.removeViewTreeObserver(scrollView.getViewTreeObserver(), listener); + } + + public static void handleOnScrollChangedEvent(Activity activity, View layout, View background, String title, int height, int t, Toolbar toolbar, int toolbarColor) { + final int headerHeight = (MizLib.isPortrait(activity) ? background.getHeight() : layout.findViewById(R.id.empty_view).getHeight()) - height; + final float ratio = (float) Math.min(Math.max(t, 0), headerHeight) / headerHeight; + final int newAlpha = (int) (ratio * 255); + + // Update the Toolbar + ViewUtils.updateToolbarBackground(activity, toolbar, newAlpha, title, toolbarColor); + + if (MizLib.isPortrait(activity)) { + // Such parallax, much wow + background.setPadding(0, (int) (t / 1.5), 0, 0); + } + + // Update scroll background in landscape mode + if (!MizLib.isPortrait(activity)) { + View v = layout.findViewById(R.id.background_view); + View v2 = layout.findViewById(R.id.background_view_more); + final int backgroundAlpha = (int) (ratio * 15) + 240; + + v.setBackgroundColor(ViewUtils.adjustAlpha(Color.parseColor("#303030"), backgroundAlpha)); + v2.setBackgroundColor(ViewUtils.adjustAlpha(Color.parseColor("#303030"), backgroundAlpha)); + } + } + + public static void setToolbarAndStatusBarColor(android.support.v7.app.ActionBar actionBar, Window window, int color) { + if (color != 0) { + actionBar.setBackgroundDrawable(new ColorDrawable(color)); + if (MizLib.hasLollipop()) + window.setStatusBarColor(color); + } + } +} diff --git a/src/com/miz/utils/WidgetUtils.java b/app/src/main/java/com/miz/utils/WidgetUtils.java similarity index 100% rename from src/com/miz/utils/WidgetUtils.java rename to app/src/main/java/com/miz/utils/WidgetUtils.java index c2c1d6ff..c4050391 100644 --- a/src/com/miz/utils/WidgetUtils.java +++ b/app/src/main/java/com/miz/utils/WidgetUtils.java @@ -16,6 +16,10 @@ package com.miz.utils; +import android.appwidget.AppWidgetManager; +import android.content.ComponentName; +import android.content.Context; + import com.miz.mizuu.R; import com.miz.widgets.MovieBackdropWidgetProvider; import com.miz.widgets.MovieCoverWidgetProvider; @@ -24,10 +28,6 @@ import com.miz.widgets.ShowCoverWidgetProvider; import com.miz.widgets.ShowStackWidgetProvider; -import android.appwidget.AppWidgetManager; -import android.content.ComponentName; -import android.content.Context; - public class WidgetUtils { private WidgetUtils() {} // No instantiation diff --git a/src/com/miz/views/AspectRatioImageViewBackdrop.java b/app/src/main/java/com/miz/views/AspectRatioImageViewBackdrop.java similarity index 100% rename from src/com/miz/views/AspectRatioImageViewBackdrop.java rename to app/src/main/java/com/miz/views/AspectRatioImageViewBackdrop.java diff --git a/src/com/miz/views/AspectRatioImageViewBackdropLarge.java b/app/src/main/java/com/miz/views/AspectRatioImageViewBackdropLarge.java similarity index 100% rename from src/com/miz/views/AspectRatioImageViewBackdropLarge.java rename to app/src/main/java/com/miz/views/AspectRatioImageViewBackdropLarge.java diff --git a/src/com/miz/views/AspectRatioImageViewCover.java b/app/src/main/java/com/miz/views/AspectRatioImageViewCover.java similarity index 100% rename from src/com/miz/views/AspectRatioImageViewCover.java rename to app/src/main/java/com/miz/views/AspectRatioImageViewCover.java diff --git a/src/com/miz/views/CircularImageView.java b/app/src/main/java/com/miz/views/CircularImageView.java similarity index 99% rename from src/com/miz/views/CircularImageView.java rename to app/src/main/java/com/miz/views/CircularImageView.java index 8f269771..2d6b7585 100644 --- a/src/com/miz/views/CircularImageView.java +++ b/app/src/main/java/com/miz/views/CircularImageView.java @@ -35,7 +35,7 @@ */ public class CircularImageView extends ImageView { - private int borderWidth = 2; + private int borderWidth = 0; private int viewWidth, viewHeight; private Bitmap image; private Paint paint, paintBorder; diff --git a/src/com/miz/views/EpisodePhotoImageView.java b/app/src/main/java/com/miz/views/EpisodePhotoImageView.java similarity index 100% rename from src/com/miz/views/EpisodePhotoImageView.java rename to app/src/main/java/com/miz/views/EpisodePhotoImageView.java diff --git a/src/com/miz/views/ForegroundLinearLayout.java b/app/src/main/java/com/miz/views/ForegroundLinearLayout.java similarity index 100% rename from src/com/miz/views/ForegroundLinearLayout.java rename to app/src/main/java/com/miz/views/ForegroundLinearLayout.java diff --git a/src/com/miz/views/GridItemImageView.java b/app/src/main/java/com/miz/views/GridItemImageView.java similarity index 100% rename from src/com/miz/views/GridItemImageView.java rename to app/src/main/java/com/miz/views/GridItemImageView.java diff --git a/src/com/miz/views/HorizontalCardLayout.java b/app/src/main/java/com/miz/views/HorizontalCardLayout.java similarity index 87% rename from src/com/miz/views/HorizontalCardLayout.java rename to app/src/main/java/com/miz/views/HorizontalCardLayout.java index 4d7e7ba5..187d9cdd 100644 --- a/src/com/miz/views/HorizontalCardLayout.java +++ b/app/src/main/java/com/miz/views/HorizontalCardLayout.java @@ -16,8 +16,7 @@ package com.miz.views; -import java.util.List; - +import android.app.Activity; import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; @@ -28,16 +27,19 @@ import android.widget.TextView; import com.miz.functions.Actor; +import com.miz.functions.GridSeason; import com.miz.functions.WebMovie; -import com.miz.mizuu.MizuuApplication; import com.miz.mizuu.R; +import com.miz.utils.TypefaceUtils; import com.miz.utils.ViewUtils; import com.squareup.picasso.Picasso; +import java.util.List; + public class HorizontalCardLayout extends LinearLayout { public static final int MOVIES = 1000, TV_SHOWS = 1100, PHOTOS = 1200, - TAGGED_PHOTOS = 1300, RELATED_MOVIES = 1400, ACTORS = 1500; + TAGGED_PHOTOS = 1300, RELATED_MOVIES = 1400, ACTORS = 1500, SEASONS = 1600; private final View mTitleLayout; private final TextView mTitleTextView, mSeeMoreTextView; @@ -65,11 +67,11 @@ public HorizontalCardLayout(Context context, AttributeSet attrs, int defStyle) { mTitleTextView = (TextView) mTitleLayout.findViewById(R.id.title); if (!isInEditMode()) - mTitleTextView.setTypeface(MizuuApplication.getOrCreateTypeface(context, "RobotoCondensed-LightItalic.ttf")); + mTitleTextView.setTypeface(TypefaceUtils.getRobotoMedium(context)); mSeeMoreTextView = (TextView) mTitleLayout.findViewById(R.id.see_more); if (!isInEditMode()) - mSeeMoreTextView.setTypeface(MizuuApplication.getOrCreateTypeface(context, "RobotoCondensed-Regular.ttf")); + mSeeMoreTextView.setTypeface(TypefaceUtils.getRobotoCondensedRegular(context)); if (!isInEditMode()) { mCardContent = (LinearLayout) getChildAt(1).findViewById(R.id.linear_layout); @@ -124,7 +126,7 @@ public void addView(View child, int index, ViewGroup.LayoutParams params) { } @SuppressWarnings("unchecked") - public void loadItems(Context context, Picasso picasso, int capacity, int width, List items, int type) { + public void loadItems(Activity context, Picasso picasso, int capacity, int width, List items, int type, int toolbarColor) { if (items.size() > 0) { LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, LayoutParams.WRAP_CONTENT); lp.setMargins(0, 0, getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing), 0); @@ -140,7 +142,9 @@ public void loadItems(Context context, Picasso picasso, int capacity, int width, addView(ViewUtils.setupTaggedPhotoCard(context, picasso, (String) items.get(i), (List) items, i), i, lp); } else if (type == ACTORS) { addView(ViewUtils.setupActorCard(context, picasso, (Actor) items.get(i)), i, lp); - } + } else if (type == SEASONS) { + addView(ViewUtils.setupTvShowSeasonCard(context, picasso, (GridSeason) items.get(i), toolbarColor), i, lp); + } } setSeeMoreVisibility(items.size() > capacity); diff --git a/src/com/miz/views/LargeGridItemImageView.java b/app/src/main/java/com/miz/views/LargeGridItemImageView.java similarity index 100% rename from src/com/miz/views/LargeGridItemImageView.java rename to app/src/main/java/com/miz/views/LargeGridItemImageView.java diff --git a/src/com/miz/views/ObservableScrollView.java b/app/src/main/java/com/miz/views/ObservableScrollView.java similarity index 100% rename from src/com/miz/views/ObservableScrollView.java rename to app/src/main/java/com/miz/views/ObservableScrollView.java diff --git a/src/com/miz/views/SeasonCoverImageView.java b/app/src/main/java/com/miz/views/SeasonCoverImageView.java similarity index 100% rename from src/com/miz/views/SeasonCoverImageView.java rename to app/src/main/java/com/miz/views/SeasonCoverImageView.java diff --git a/src/com/miz/widgets/MovieBackdropWidgetProvider.java b/app/src/main/java/com/miz/widgets/MovieBackdropWidgetProvider.java similarity index 100% rename from src/com/miz/widgets/MovieBackdropWidgetProvider.java rename to app/src/main/java/com/miz/widgets/MovieBackdropWidgetProvider.java index 83ea6bda..fd3aba8f 100644 --- a/src/com/miz/widgets/MovieBackdropWidgetProvider.java +++ b/app/src/main/java/com/miz/widgets/MovieBackdropWidgetProvider.java @@ -16,9 +16,6 @@ package com.miz.widgets; -import com.miz.mizuu.MovieDetails; -import com.miz.mizuu.R; - import android.app.PendingIntent; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; @@ -27,6 +24,9 @@ import android.net.Uri; import android.widget.RemoteViews; +import com.miz.mizuu.MovieDetails; +import com.miz.mizuu.R; + public class MovieBackdropWidgetProvider extends AppWidgetProvider { public static final String MOVIE_BACKDROP_WIDGET = "movieBackdropWidget"; diff --git a/src/com/miz/widgets/MovieBackdropWidgetService.java b/app/src/main/java/com/miz/widgets/MovieBackdropWidgetService.java similarity index 99% rename from src/com/miz/widgets/MovieBackdropWidgetService.java rename to app/src/main/java/com/miz/widgets/MovieBackdropWidgetService.java index 019ba0d4..43042323 100644 --- a/src/com/miz/widgets/MovieBackdropWidgetService.java +++ b/app/src/main/java/com/miz/widgets/MovieBackdropWidgetService.java @@ -16,10 +16,6 @@ package com.miz.widgets; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; - import android.appwidget.AppWidgetManager; import android.content.Context; import android.content.Intent; @@ -37,6 +33,10 @@ import com.miz.mizuu.R; import com.squareup.picasso.Picasso; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; + import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; public class MovieBackdropWidgetService extends RemoteViewsService { @@ -120,7 +120,7 @@ private void update() { // Create and open database DbAdapterMovies dbHelper = MizuuApplication.getMovieAdapter(); - Cursor cursor = dbHelper.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC", false); + Cursor cursor = dbHelper.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC"); ColumnIndexCache cache = new ColumnIndexCache(); try { diff --git a/src/com/miz/widgets/MovieCoverWidgetProvider.java b/app/src/main/java/com/miz/widgets/MovieCoverWidgetProvider.java similarity index 100% rename from src/com/miz/widgets/MovieCoverWidgetProvider.java rename to app/src/main/java/com/miz/widgets/MovieCoverWidgetProvider.java index 18b2eb35..de84ea45 100644 --- a/src/com/miz/widgets/MovieCoverWidgetProvider.java +++ b/app/src/main/java/com/miz/widgets/MovieCoverWidgetProvider.java @@ -16,9 +16,6 @@ package com.miz.widgets; -import com.miz.mizuu.MovieDetails; -import com.miz.mizuu.R; - import android.app.PendingIntent; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; @@ -27,6 +24,9 @@ import android.net.Uri; import android.widget.RemoteViews; +import com.miz.mizuu.MovieDetails; +import com.miz.mizuu.R; + public class MovieCoverWidgetProvider extends AppWidgetProvider { public static final String MOVIE_COVER_WIDGET = "movieCoverWidget"; diff --git a/src/com/miz/widgets/MovieCoverWidgetService.java b/app/src/main/java/com/miz/widgets/MovieCoverWidgetService.java similarity index 99% rename from src/com/miz/widgets/MovieCoverWidgetService.java rename to app/src/main/java/com/miz/widgets/MovieCoverWidgetService.java index abe834e2..f1a1de1a 100644 --- a/src/com/miz/widgets/MovieCoverWidgetService.java +++ b/app/src/main/java/com/miz/widgets/MovieCoverWidgetService.java @@ -16,12 +16,6 @@ package com.miz.widgets; -import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; - import android.appwidget.AppWidgetManager; import android.content.Context; import android.content.Intent; @@ -39,6 +33,12 @@ import com.miz.mizuu.R; import com.squareup.picasso.Picasso; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; + +import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; + public class MovieCoverWidgetService extends RemoteViewsService { @Override @@ -120,7 +120,7 @@ private void update() { // Create and open database DbAdapterMovies dbHelper = MizuuApplication.getMovieAdapter(); - Cursor cursor = dbHelper.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC", false); + Cursor cursor = dbHelper.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC"); ColumnIndexCache cache = new ColumnIndexCache(); try { diff --git a/src/com/miz/widgets/MovieStackWidgetProvider.java b/app/src/main/java/com/miz/widgets/MovieStackWidgetProvider.java similarity index 100% rename from src/com/miz/widgets/MovieStackWidgetProvider.java rename to app/src/main/java/com/miz/widgets/MovieStackWidgetProvider.java index 3c67a4aa..fec35252 100644 --- a/src/com/miz/widgets/MovieStackWidgetProvider.java +++ b/app/src/main/java/com/miz/widgets/MovieStackWidgetProvider.java @@ -16,9 +16,6 @@ package com.miz.widgets; -import com.miz.mizuu.MovieDetails; -import com.miz.mizuu.R; - import android.app.PendingIntent; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; @@ -27,6 +24,9 @@ import android.net.Uri; import android.widget.RemoteViews; +import com.miz.mizuu.MovieDetails; +import com.miz.mizuu.R; + public class MovieStackWidgetProvider extends AppWidgetProvider { public final static String MOVIE_STACK_WIDGET = "movieStackWidget"; diff --git a/src/com/miz/widgets/MovieStackWidgetService.java b/app/src/main/java/com/miz/widgets/MovieStackWidgetService.java similarity index 99% rename from src/com/miz/widgets/MovieStackWidgetService.java rename to app/src/main/java/com/miz/widgets/MovieStackWidgetService.java index 0c93b24f..16db5bd3 100644 --- a/src/com/miz/widgets/MovieStackWidgetService.java +++ b/app/src/main/java/com/miz/widgets/MovieStackWidgetService.java @@ -16,10 +16,6 @@ package com.miz.widgets; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; - import android.content.Context; import android.content.Intent; import android.database.Cursor; @@ -36,6 +32,10 @@ import com.miz.mizuu.R; import com.squareup.picasso.Picasso; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; + import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; public class MovieStackWidgetService extends RemoteViewsService { @@ -104,7 +104,7 @@ private void update() { // Create and open database dbHelper = MizuuApplication.getMovieAdapter(); - Cursor cursor = dbHelper.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC", false); + Cursor cursor = dbHelper.fetchAllMovies(DbAdapterMovies.KEY_TITLE + " ASC"); ColumnIndexCache cache = new ColumnIndexCache(); try { diff --git a/src/com/miz/widgets/ShowBackdropWidgetProvider.java b/app/src/main/java/com/miz/widgets/ShowBackdropWidgetProvider.java similarity index 100% rename from src/com/miz/widgets/ShowBackdropWidgetProvider.java rename to app/src/main/java/com/miz/widgets/ShowBackdropWidgetProvider.java diff --git a/src/com/miz/widgets/ShowBackdropWidgetService.java b/app/src/main/java/com/miz/widgets/ShowBackdropWidgetService.java similarity index 100% rename from src/com/miz/widgets/ShowBackdropWidgetService.java rename to app/src/main/java/com/miz/widgets/ShowBackdropWidgetService.java index 94761b87..a98a23c5 100644 --- a/src/com/miz/widgets/ShowBackdropWidgetService.java +++ b/app/src/main/java/com/miz/widgets/ShowBackdropWidgetService.java @@ -16,9 +16,6 @@ package com.miz.widgets; -import java.util.ArrayList; -import java.util.Collections; - import android.appwidget.AppWidgetManager; import android.content.Context; import android.content.Intent; @@ -35,8 +32,11 @@ import com.miz.functions.ColumnIndexCache; import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; -import com.miz.mizuu.TvShow; import com.miz.mizuu.R; +import com.miz.mizuu.TvShow; + +import java.util.ArrayList; +import java.util.Collections; import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; diff --git a/src/com/miz/widgets/ShowCoverWidgetProvider.java b/app/src/main/java/com/miz/widgets/ShowCoverWidgetProvider.java similarity index 100% rename from src/com/miz/widgets/ShowCoverWidgetProvider.java rename to app/src/main/java/com/miz/widgets/ShowCoverWidgetProvider.java diff --git a/src/com/miz/widgets/ShowCoverWidgetService.java b/app/src/main/java/com/miz/widgets/ShowCoverWidgetService.java similarity index 100% rename from src/com/miz/widgets/ShowCoverWidgetService.java rename to app/src/main/java/com/miz/widgets/ShowCoverWidgetService.java index b0b16dd5..cd3916be 100644 --- a/src/com/miz/widgets/ShowCoverWidgetService.java +++ b/app/src/main/java/com/miz/widgets/ShowCoverWidgetService.java @@ -16,9 +16,6 @@ package com.miz.widgets; -import java.util.ArrayList; -import java.util.Collections; - import android.appwidget.AppWidgetManager; import android.content.Context; import android.content.Intent; @@ -35,8 +32,11 @@ import com.miz.functions.ColumnIndexCache; import com.miz.functions.MizLib; import com.miz.mizuu.MizuuApplication; -import com.miz.mizuu.TvShow; import com.miz.mizuu.R; +import com.miz.mizuu.TvShow; + +import java.util.ArrayList; +import java.util.Collections; import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; diff --git a/src/com/miz/widgets/ShowStackWidgetProvider.java b/app/src/main/java/com/miz/widgets/ShowStackWidgetProvider.java similarity index 100% rename from src/com/miz/widgets/ShowStackWidgetProvider.java rename to app/src/main/java/com/miz/widgets/ShowStackWidgetProvider.java diff --git a/src/com/miz/widgets/ShowStackWidgetService.java b/app/src/main/java/com/miz/widgets/ShowStackWidgetService.java similarity index 100% rename from src/com/miz/widgets/ShowStackWidgetService.java rename to app/src/main/java/com/miz/widgets/ShowStackWidgetService.java index a1998ca0..29b21654 100644 --- a/src/com/miz/widgets/ShowStackWidgetService.java +++ b/app/src/main/java/com/miz/widgets/ShowStackWidgetService.java @@ -20,21 +20,21 @@ import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Bitmap.Config; +import android.graphics.BitmapFactory; import android.preference.PreferenceManager; import android.view.View; import android.widget.RemoteViews; import android.widget.RemoteViewsService; -import java.util.ArrayList; -import java.util.Collections; - import com.miz.db.DbAdapterTvShows; import com.miz.functions.ColumnIndexCache; import com.miz.mizuu.MizuuApplication; -import com.miz.mizuu.TvShow; import com.miz.mizuu.R; +import com.miz.mizuu.TvShow; + +import java.util.ArrayList; +import java.util.Collections; import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; diff --git a/res/anim/fade_in.xml b/app/src/main/res/anim/fade_in.xml similarity index 100% rename from res/anim/fade_in.xml rename to app/src/main/res/anim/fade_in.xml diff --git a/res/anim/fade_out.xml b/app/src/main/res/anim/fade_out.xml similarity index 100% rename from res/anim/fade_out.xml rename to app/src/main/res/anim/fade_out.xml diff --git a/res/anim/mainfadein.xml b/app/src/main/res/anim/mainfadein.xml similarity index 100% rename from res/anim/mainfadein.xml rename to app/src/main/res/anim/mainfadein.xml diff --git a/res/anim/splashfadeout.xml b/app/src/main/res/anim/splashfadeout.xml similarity index 100% rename from res/anim/splashfadeout.xml rename to app/src/main/res/anim/splashfadeout.xml diff --git a/app/src/main/res/drawable-hdpi/menuicon.png b/app/src/main/res/drawable-hdpi/menuicon.png new file mode 100644 index 00000000..a3228240 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/menuicon.png differ diff --git a/app/src/main/res/drawable-hdpi/shadow.png b/app/src/main/res/drawable-hdpi/shadow.png new file mode 100644 index 00000000..51a1d54c Binary files /dev/null and b/app/src/main/res/drawable-hdpi/shadow.png differ diff --git a/app/src/main/res/drawable-mdpi/menuicon.png b/app/src/main/res/drawable-mdpi/menuicon.png new file mode 100644 index 00000000..c26cdd42 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/menuicon.png differ diff --git a/app/src/main/res/drawable-mdpi/shadow.png b/app/src/main/res/drawable-mdpi/shadow.png new file mode 100644 index 00000000..91582e52 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/shadow.png differ diff --git a/res/drawable-nodpi/bg_with_border.9.png b/app/src/main/res/drawable-nodpi/bg_with_border.9.png similarity index 100% rename from res/drawable-nodpi/bg_with_border.9.png rename to app/src/main/res/drawable-nodpi/bg_with_border.9.png diff --git a/res/drawable-nodpi/border.9.png b/app/src/main/res/drawable-nodpi/border.9.png similarity index 100% rename from res/drawable-nodpi/border.9.png rename to app/src/main/res/drawable-nodpi/border.9.png diff --git a/app/src/main/res/drawable-nodpi/default_menu_backdrop.jpg b/app/src/main/res/drawable-nodpi/default_menu_backdrop.jpg new file mode 100644 index 00000000..e5ca7e27 Binary files /dev/null and b/app/src/main/res/drawable-nodpi/default_menu_backdrop.jpg differ diff --git a/res/drawable-nodpi/menu_bg.png b/app/src/main/res/drawable-nodpi/menu_bg.png similarity index 100% rename from res/drawable-nodpi/menu_bg.png rename to app/src/main/res/drawable-nodpi/menu_bg.png diff --git a/res/drawable-nodpi/widget_movie_backdrop.png b/app/src/main/res/drawable-nodpi/widget_movie_backdrop.png similarity index 100% rename from res/drawable-nodpi/widget_movie_backdrop.png rename to app/src/main/res/drawable-nodpi/widget_movie_backdrop.png diff --git a/res/drawable-nodpi/widget_movie_cover.png b/app/src/main/res/drawable-nodpi/widget_movie_cover.png similarity index 100% rename from res/drawable-nodpi/widget_movie_cover.png rename to app/src/main/res/drawable-nodpi/widget_movie_cover.png diff --git a/res/drawable-nodpi/widget_movie_stack.png b/app/src/main/res/drawable-nodpi/widget_movie_stack.png similarity index 100% rename from res/drawable-nodpi/widget_movie_stack.png rename to app/src/main/res/drawable-nodpi/widget_movie_stack.png diff --git a/res/drawable-nodpi/widget_show_backdrop.png b/app/src/main/res/drawable-nodpi/widget_show_backdrop.png similarity index 100% rename from res/drawable-nodpi/widget_show_backdrop.png rename to app/src/main/res/drawable-nodpi/widget_show_backdrop.png diff --git a/res/drawable-nodpi/widget_show_cover.png b/app/src/main/res/drawable-nodpi/widget_show_cover.png similarity index 100% rename from res/drawable-nodpi/widget_show_cover.png rename to app/src/main/res/drawable-nodpi/widget_show_cover.png diff --git a/res/drawable-nodpi/widget_show_stack.png b/app/src/main/res/drawable-nodpi/widget_show_stack.png similarity index 100% rename from res/drawable-nodpi/widget_show_stack.png rename to app/src/main/res/drawable-nodpi/widget_show_stack.png diff --git a/app/src/main/res/drawable-v21/selectable_background.xml b/app/src/main/res/drawable-v21/selectable_background.xml new file mode 100644 index 00000000..93668a93 --- /dev/null +++ b/app/src/main/res/drawable-v21/selectable_background.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/res/drawable-xhdpi/accent_bottom_border.9.png b/app/src/main/res/drawable-xhdpi/accent_bottom_border.9.png similarity index 100% rename from res/drawable-xhdpi/accent_bottom_border.9.png rename to app/src/main/res/drawable-xhdpi/accent_bottom_border.9.png diff --git a/res/drawable-xhdpi/accent_bottom_border_grey.9.png b/app/src/main/res/drawable-xhdpi/accent_bottom_border_grey.9.png similarity index 100% rename from res/drawable-xhdpi/accent_bottom_border_grey.9.png rename to app/src/main/res/drawable-xhdpi/accent_bottom_border_grey.9.png diff --git a/res/drawable-xhdpi/backdrops.png b/app/src/main/res/drawable-xhdpi/backdrops.png similarity index 100% rename from res/drawable-xhdpi/backdrops.png rename to app/src/main/res/drawable-xhdpi/backdrops.png diff --git a/res/drawable-xhdpi/buffer_size.png b/app/src/main/res/drawable-xhdpi/buffer_size.png similarity index 100% rename from res/drawable-xhdpi/buffer_size.png rename to app/src/main/res/drawable-xhdpi/buffer_size.png diff --git a/res/drawable-xhdpi/director.png b/app/src/main/res/drawable-xhdpi/director.png similarity index 100% rename from res/drawable-xhdpi/director.png rename to app/src/main/res/drawable-xhdpi/director.png diff --git a/res/drawable-xhdpi/drawer_list_shadow.9.png b/app/src/main/res/drawable-xhdpi/drawer_list_shadow.9.png similarity index 100% rename from res/drawable-xhdpi/drawer_list_shadow.9.png rename to app/src/main/res/drawable-xhdpi/drawer_list_shadow.9.png diff --git a/res/drawable-xhdpi/file.png b/app/src/main/res/drawable-xhdpi/file.png similarity index 100% rename from res/drawable-xhdpi/file.png rename to app/src/main/res/drawable-xhdpi/file.png diff --git a/res/drawable-xhdpi/folder.png b/app/src/main/res/drawable-xhdpi/folder.png similarity index 100% rename from res/drawable-xhdpi/folder.png rename to app/src/main/res/drawable-xhdpi/folder.png diff --git a/res/drawable-xhdpi/ic_action_calendar_day.png b/app/src/main/res/drawable-xhdpi/ic_action_calendar_day.png similarity index 100% rename from res/drawable-xhdpi/ic_action_calendar_day.png rename to app/src/main/res/drawable-xhdpi/ic_action_calendar_day.png diff --git a/res/drawable-xhdpi/ic_action_calendar_month.png b/app/src/main/res/drawable-xhdpi/ic_action_calendar_month.png similarity index 100% rename from res/drawable-xhdpi/ic_action_calendar_month.png rename to app/src/main/res/drawable-xhdpi/ic_action_calendar_month.png diff --git a/res/drawable-xhdpi/ic_action_clock.png b/app/src/main/res/drawable-xhdpi/ic_action_clock.png similarity index 100% rename from res/drawable-xhdpi/ic_action_clock.png rename to app/src/main/res/drawable-xhdpi/ic_action_clock.png diff --git a/res/drawable-xhdpi/ic_action_discard.png b/app/src/main/res/drawable-xhdpi/ic_action_discard.png similarity index 100% rename from res/drawable-xhdpi/ic_action_discard.png rename to app/src/main/res/drawable-xhdpi/ic_action_discard.png diff --git a/res/drawable-xhdpi/ic_action_download.png b/app/src/main/res/drawable-xhdpi/ic_action_download.png similarity index 100% rename from res/drawable-xhdpi/ic_action_download.png rename to app/src/main/res/drawable-xhdpi/ic_action_download.png diff --git a/res/drawable-xhdpi/ic_action_edit.png b/app/src/main/res/drawable-xhdpi/ic_action_edit.png similarity index 100% rename from res/drawable-xhdpi/ic_action_edit.png rename to app/src/main/res/drawable-xhdpi/ic_action_edit.png diff --git a/res/drawable-xhdpi/ic_action_expand.png b/app/src/main/res/drawable-xhdpi/ic_action_expand.png similarity index 100% rename from res/drawable-xhdpi/ic_action_expand.png rename to app/src/main/res/drawable-xhdpi/ic_action_expand.png diff --git a/res/drawable-xhdpi/ic_action_flag.png b/app/src/main/res/drawable-xhdpi/ic_action_flag.png similarity index 100% rename from res/drawable-xhdpi/ic_action_flag.png rename to app/src/main/res/drawable-xhdpi/ic_action_flag.png diff --git a/res/drawable-xhdpi/ic_action_globe.png b/app/src/main/res/drawable-xhdpi/ic_action_globe.png similarity index 100% rename from res/drawable-xhdpi/ic_action_globe.png rename to app/src/main/res/drawable-xhdpi/ic_action_globe.png diff --git a/res/drawable-xhdpi/ic_action_google_play.png b/app/src/main/res/drawable-xhdpi/ic_action_google_play.png similarity index 100% rename from res/drawable-xhdpi/ic_action_google_play.png rename to app/src/main/res/drawable-xhdpi/ic_action_google_play.png diff --git a/res/drawable-xhdpi/ic_action_key.png b/app/src/main/res/drawable-xhdpi/ic_action_key.png similarity index 100% rename from res/drawable-xhdpi/ic_action_key.png rename to app/src/main/res/drawable-xhdpi/ic_action_key.png diff --git a/res/drawable-xhdpi/ic_action_list_2.png b/app/src/main/res/drawable-xhdpi/ic_action_list_2.png similarity index 100% rename from res/drawable-xhdpi/ic_action_list_2.png rename to app/src/main/res/drawable-xhdpi/ic_action_list_2.png diff --git a/res/drawable-xhdpi/ic_action_list_grid.png b/app/src/main/res/drawable-xhdpi/ic_action_list_grid.png similarity index 100% rename from res/drawable-xhdpi/ic_action_list_grid.png rename to app/src/main/res/drawable-xhdpi/ic_action_list_grid.png diff --git a/res/drawable-xhdpi/ic_action_lock_closed.png b/app/src/main/res/drawable-xhdpi/ic_action_lock_closed.png similarity index 100% rename from res/drawable-xhdpi/ic_action_lock_closed.png rename to app/src/main/res/drawable-xhdpi/ic_action_lock_closed.png diff --git a/res/drawable-xhdpi/ic_action_mail.png b/app/src/main/res/drawable-xhdpi/ic_action_mail.png similarity index 100% rename from res/drawable-xhdpi/ic_action_mail.png rename to app/src/main/res/drawable-xhdpi/ic_action_mail.png diff --git a/res/drawable-xhdpi/ic_action_movie.png b/app/src/main/res/drawable-xhdpi/ic_action_movie.png similarity index 100% rename from res/drawable-xhdpi/ic_action_movie.png rename to app/src/main/res/drawable-xhdpi/ic_action_movie.png diff --git a/res/drawable-xhdpi/ic_action_playback_play.png b/app/src/main/res/drawable-xhdpi/ic_action_playback_play.png similarity index 100% rename from res/drawable-xhdpi/ic_action_playback_play.png rename to app/src/main/res/drawable-xhdpi/ic_action_playback_play.png diff --git a/res/drawable-xhdpi/ic_action_puzzle.png b/app/src/main/res/drawable-xhdpi/ic_action_puzzle.png similarity index 100% rename from res/drawable-xhdpi/ic_action_puzzle.png rename to app/src/main/res/drawable-xhdpi/ic_action_puzzle.png diff --git a/res/drawable-xhdpi/ic_action_ratings.png b/app/src/main/res/drawable-xhdpi/ic_action_ratings.png similarity index 100% rename from res/drawable-xhdpi/ic_action_ratings.png rename to app/src/main/res/drawable-xhdpi/ic_action_ratings.png diff --git a/res/drawable-xhdpi/ic_action_send.png b/app/src/main/res/drawable-xhdpi/ic_action_send.png similarity index 100% rename from res/drawable-xhdpi/ic_action_send.png rename to app/src/main/res/drawable-xhdpi/ic_action_send.png diff --git a/res/drawable-xhdpi/ic_action_settings.png b/app/src/main/res/drawable-xhdpi/ic_action_settings.png similarity index 100% rename from res/drawable-xhdpi/ic_action_settings.png rename to app/src/main/res/drawable-xhdpi/ic_action_settings.png diff --git a/res/drawable-xhdpi/ic_action_show.png b/app/src/main/res/drawable-xhdpi/ic_action_show.png similarity index 100% rename from res/drawable-xhdpi/ic_action_show.png rename to app/src/main/res/drawable-xhdpi/ic_action_show.png diff --git a/res/drawable-xhdpi/ic_action_star_0.png b/app/src/main/res/drawable-xhdpi/ic_action_star_0.png similarity index 100% rename from res/drawable-xhdpi/ic_action_star_0.png rename to app/src/main/res/drawable-xhdpi/ic_action_star_0.png diff --git a/res/drawable-xhdpi/ic_action_subtitles.png b/app/src/main/res/drawable-xhdpi/ic_action_subtitles.png similarity index 100% rename from res/drawable-xhdpi/ic_action_subtitles.png rename to app/src/main/res/drawable-xhdpi/ic_action_subtitles.png diff --git a/res/drawable-xhdpi/ic_action_tags.png b/app/src/main/res/drawable-xhdpi/ic_action_tags.png similarity index 100% rename from res/drawable-xhdpi/ic_action_tags.png rename to app/src/main/res/drawable-xhdpi/ic_action_tags.png diff --git a/res/drawable-xhdpi/ic_action_tiles_large.png b/app/src/main/res/drawable-xhdpi/ic_action_tiles_large.png similarity index 100% rename from res/drawable-xhdpi/ic_action_tiles_large.png rename to app/src/main/res/drawable-xhdpi/ic_action_tiles_large.png diff --git a/res/drawable-xhdpi/ic_action_tv.png b/app/src/main/res/drawable-xhdpi/ic_action_tv.png similarity index 100% rename from res/drawable-xhdpi/ic_action_tv.png rename to app/src/main/res/drawable-xhdpi/ic_action_tv.png diff --git a/res/drawable-xhdpi/ic_action_users.png b/app/src/main/res/drawable-xhdpi/ic_action_users.png similarity index 100% rename from res/drawable-xhdpi/ic_action_users.png rename to app/src/main/res/drawable-xhdpi/ic_action_users.png diff --git a/res/drawable-xhdpi/ic_action_wifi.png b/app/src/main/res/drawable-xhdpi/ic_action_wifi.png similarity index 100% rename from res/drawable-xhdpi/ic_action_wifi.png rename to app/src/main/res/drawable-xhdpi/ic_action_wifi.png diff --git a/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png new file mode 100644 index 00000000..67042105 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png new file mode 100644 index 00000000..addbfc88 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_cast_connected_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_cast_connected_white_24dp.png new file mode 100644 index 00000000..6ddef782 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_cast_connected_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_cloud_grey600_24dp.png b/app/src/main/res/drawable-xhdpi/ic_cloud_grey600_24dp.png new file mode 100644 index 00000000..efcffe3f Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_cloud_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png new file mode 100644 index 00000000..cdb230c2 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_done_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_done_white_24dp.png new file mode 100644 index 00000000..e5024472 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_done_white_24dp.png differ diff --git a/res/drawable-xhdpi/ic_drawer.png b/app/src/main/res/drawable-xhdpi/ic_drawer.png similarity index 100% rename from res/drawable-xhdpi/ic_drawer.png rename to app/src/main/res/drawable-xhdpi/ic_drawer.png diff --git a/app/src/main/res/drawable-xhdpi/ic_exit_to_app_grey600_24dp.png b/app/src/main/res/drawable-xhdpi/ic_exit_to_app_grey600_24dp.png new file mode 100644 index 00000000..ff25b950 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_exit_to_app_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_favorite_outline_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_favorite_outline_white_24dp.png new file mode 100644 index 00000000..9b817780 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_favorite_outline_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_favorite_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_favorite_white_24dp.png new file mode 100644 index 00000000..7f9a2078 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_favorite_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_filter_list_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_filter_list_white_24dp.png new file mode 100644 index 00000000..d4ca77bf Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_filter_list_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_folder_open_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_folder_open_white_24dp.png new file mode 100644 index 00000000..1b86e82b Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_folder_open_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_grade_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_grade_white_24dp.png new file mode 100644 index 00000000..33cc8ed4 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_grade_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_help_grey600_24dp.png b/app/src/main/res/drawable-xhdpi/ic_help_grey600_24dp.png new file mode 100644 index 00000000..5f01b936 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_help_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_insert_drive_file_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_insert_drive_file_white_24dp.png new file mode 100644 index 00000000..dbf80e33 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_insert_drive_file_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_language_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_language_white_24dp.png new file mode 100644 index 00000000..b6957490 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_language_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_local_movies_grey600_24dp.png b/app/src/main/res/drawable-xhdpi/ic_local_movies_grey600_24dp.png new file mode 100644 index 00000000..8002dfb6 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_local_movies_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_more_vert_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_more_vert_white_24dp.png new file mode 100644 index 00000000..1b04eda0 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_more_vert_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_movie_grey600_24dp.png b/app/src/main/res/drawable-xhdpi/ic_movie_grey600_24dp.png new file mode 100644 index 00000000..6bbb98a6 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_movie_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_queue_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_queue_white_24dp.png new file mode 100644 index 00000000..0475fa38 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_queue_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_search_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_search_white_24dp.png new file mode 100644 index 00000000..043759ac Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_search_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_settings_grey600_24dp.png b/app/src/main/res/drawable-xhdpi/ic_settings_grey600_24dp.png new file mode 100644 index 00000000..2251d2bb Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_settings_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png new file mode 100644 index 00000000..dd536bca Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_share_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_sort_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_sort_white_24dp.png new file mode 100644 index 00000000..89008555 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_sort_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_sync_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_sync_white_24dp.png new file mode 100644 index 00000000..93c3e0b1 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_sync_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_tv_grey600_24dp.png b/app/src/main/res/drawable-xhdpi/ic_tv_grey600_24dp.png new file mode 100644 index 00000000..5a4f0dcf Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_tv_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_video_collection_grey600_24dp.png b/app/src/main/res/drawable-xhdpi/ic_video_collection_grey600_24dp.png new file mode 100644 index 00000000..b8783091 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_video_collection_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_video_collection_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_video_collection_white_24dp.png new file mode 100644 index 00000000..312b0330 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_video_collection_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_visibility_off_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_visibility_off_white_24dp.png new file mode 100644 index 00000000..1e1d7e62 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_visibility_off_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_visibility_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_visibility_white_24dp.png new file mode 100644 index 00000000..d3cd8a7c Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_visibility_white_24dp.png differ diff --git a/res/drawable-xhdpi/ignoresmallfiles.png b/app/src/main/res/drawable-xhdpi/ignoresmallfiles.png similarity index 100% rename from res/drawable-xhdpi/ignoresmallfiles.png rename to app/src/main/res/drawable-xhdpi/ignoresmallfiles.png diff --git a/res/drawable-xhdpi/loading_image.png b/app/src/main/res/drawable-xhdpi/loading_image.png similarity index 100% rename from res/drawable-xhdpi/loading_image.png rename to app/src/main/res/drawable-xhdpi/loading_image.png diff --git a/app/src/main/res/drawable-xhdpi/menuicon.png b/app/src/main/res/drawable-xhdpi/menuicon.png new file mode 100644 index 00000000..e3d94b7a Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/menuicon.png differ diff --git a/res/drawable-xhdpi/no_content_face.png b/app/src/main/res/drawable-xhdpi/no_content_face.png similarity index 100% rename from res/drawable-xhdpi/no_content_face.png rename to app/src/main/res/drawable-xhdpi/no_content_face.png diff --git a/res/drawable-xhdpi/noactor.png b/app/src/main/res/drawable-xhdpi/noactor.png similarity index 100% rename from res/drawable-xhdpi/noactor.png rename to app/src/main/res/drawable-xhdpi/noactor.png diff --git a/res/drawable-xhdpi/nobackdrop.png b/app/src/main/res/drawable-xhdpi/nobackdrop.png similarity index 100% rename from res/drawable-xhdpi/nobackdrop.png rename to app/src/main/res/drawable-xhdpi/nobackdrop.png diff --git a/res/drawable-xhdpi/other.png b/app/src/main/res/drawable-xhdpi/other.png similarity index 100% rename from res/drawable-xhdpi/other.png rename to app/src/main/res/drawable-xhdpi/other.png diff --git a/res/drawable-xhdpi/photo.png b/app/src/main/res/drawable-xhdpi/photo.png similarity index 100% rename from res/drawable-xhdpi/photo.png rename to app/src/main/res/drawable-xhdpi/photo.png diff --git a/res/drawable-xhdpi/reddit.png b/app/src/main/res/drawable-xhdpi/reddit.png similarity index 100% rename from res/drawable-xhdpi/reddit.png rename to app/src/main/res/drawable-xhdpi/reddit.png diff --git a/app/src/main/res/drawable-xhdpi/shadow.png b/app/src/main/res/drawable-xhdpi/shadow.png new file mode 100644 index 00000000..1d513670 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/shadow.png differ diff --git a/res/drawable-xhdpi/startup.png b/app/src/main/res/drawable-xhdpi/startup.png similarity index 100% rename from res/drawable-xhdpi/startup.png rename to app/src/main/res/drawable-xhdpi/startup.png diff --git a/res/drawable-xhdpi/tedtalks.png b/app/src/main/res/drawable-xhdpi/tedtalks.png similarity index 100% rename from res/drawable-xhdpi/tedtalks.png rename to app/src/main/res/drawable-xhdpi/tedtalks.png diff --git a/res/drawable-xhdpi/titles.png b/app/src/main/res/drawable-xhdpi/titles.png similarity index 100% rename from res/drawable-xhdpi/titles.png rename to app/src/main/res/drawable-xhdpi/titles.png diff --git a/res/drawable-xhdpi/unknown_user.png b/app/src/main/res/drawable-xhdpi/unknown_user.png similarity index 100% rename from res/drawable-xhdpi/unknown_user.png rename to app/src/main/res/drawable-xhdpi/unknown_user.png diff --git a/res/drawable-xhdpi/user_interface.png b/app/src/main/res/drawable-xhdpi/user_interface.png similarity index 100% rename from res/drawable-xhdpi/user_interface.png rename to app/src/main/res/drawable-xhdpi/user_interface.png diff --git a/res/drawable-xhdpi/white_app_icon.png b/app/src/main/res/drawable-xhdpi/white_app_icon.png similarity index 100% rename from res/drawable-xhdpi/white_app_icon.png rename to app/src/main/res/drawable-xhdpi/white_app_icon.png diff --git a/res/drawable-xhdpi/youtube.png b/app/src/main/res/drawable-xhdpi/youtube.png similarity index 100% rename from res/drawable-xhdpi/youtube.png rename to app/src/main/res/drawable-xhdpi/youtube.png diff --git a/res/drawable-xxhdpi/backdrops.png b/app/src/main/res/drawable-xxhdpi/backdrops.png similarity index 100% rename from res/drawable-xxhdpi/backdrops.png rename to app/src/main/res/drawable-xxhdpi/backdrops.png diff --git a/res/drawable-xxhdpi/buffer_size.png b/app/src/main/res/drawable-xxhdpi/buffer_size.png similarity index 100% rename from res/drawable-xxhdpi/buffer_size.png rename to app/src/main/res/drawable-xxhdpi/buffer_size.png diff --git a/res/drawable-xxhdpi/file.png b/app/src/main/res/drawable-xxhdpi/file.png similarity index 100% rename from res/drawable-xxhdpi/file.png rename to app/src/main/res/drawable-xxhdpi/file.png diff --git a/res/drawable-xxhdpi/folder.png b/app/src/main/res/drawable-xxhdpi/folder.png similarity index 100% rename from res/drawable-xxhdpi/folder.png rename to app/src/main/res/drawable-xxhdpi/folder.png diff --git a/res/drawable-xxhdpi/ic_action_bargraph.png b/app/src/main/res/drawable-xxhdpi/ic_action_bargraph.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_bargraph.png rename to app/src/main/res/drawable-xxhdpi/ic_action_bargraph.png diff --git a/res/drawable-xxhdpi/ic_action_calendar_day.png b/app/src/main/res/drawable-xxhdpi/ic_action_calendar_day.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_calendar_day.png rename to app/src/main/res/drawable-xxhdpi/ic_action_calendar_day.png diff --git a/res/drawable-xxhdpi/ic_action_calendar_month.png b/app/src/main/res/drawable-xxhdpi/ic_action_calendar_month.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_calendar_month.png rename to app/src/main/res/drawable-xxhdpi/ic_action_calendar_month.png diff --git a/res/drawable-xxhdpi/ic_action_clock.png b/app/src/main/res/drawable-xxhdpi/ic_action_clock.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_clock.png rename to app/src/main/res/drawable-xxhdpi/ic_action_clock.png diff --git a/res/drawable-xxhdpi/ic_action_discard.png b/app/src/main/res/drawable-xxhdpi/ic_action_discard.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_discard.png rename to app/src/main/res/drawable-xxhdpi/ic_action_discard.png diff --git a/res/drawable-xxhdpi/ic_action_download.png b/app/src/main/res/drawable-xxhdpi/ic_action_download.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_download.png rename to app/src/main/res/drawable-xxhdpi/ic_action_download.png diff --git a/res/drawable-xxhdpi/ic_action_edit.png b/app/src/main/res/drawable-xxhdpi/ic_action_edit.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_edit.png rename to app/src/main/res/drawable-xxhdpi/ic_action_edit.png diff --git a/res/drawable-xxhdpi/ic_action_expand.png b/app/src/main/res/drawable-xxhdpi/ic_action_expand.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_expand.png rename to app/src/main/res/drawable-xxhdpi/ic_action_expand.png diff --git a/res/drawable-xxhdpi/ic_action_flag.png b/app/src/main/res/drawable-xxhdpi/ic_action_flag.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_flag.png rename to app/src/main/res/drawable-xxhdpi/ic_action_flag.png diff --git a/res/drawable-xxhdpi/ic_action_globe.png b/app/src/main/res/drawable-xxhdpi/ic_action_globe.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_globe.png rename to app/src/main/res/drawable-xxhdpi/ic_action_globe.png diff --git a/res/drawable-xxhdpi/ic_action_google_play.png b/app/src/main/res/drawable-xxhdpi/ic_action_google_play.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_google_play.png rename to app/src/main/res/drawable-xxhdpi/ic_action_google_play.png diff --git a/res/drawable-xxhdpi/ic_action_key.png b/app/src/main/res/drawable-xxhdpi/ic_action_key.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_key.png rename to app/src/main/res/drawable-xxhdpi/ic_action_key.png diff --git a/res/drawable-xxhdpi/ic_action_list_2.png b/app/src/main/res/drawable-xxhdpi/ic_action_list_2.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_list_2.png rename to app/src/main/res/drawable-xxhdpi/ic_action_list_2.png diff --git a/res/drawable-xxhdpi/ic_action_list_grid.png b/app/src/main/res/drawable-xxhdpi/ic_action_list_grid.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_list_grid.png rename to app/src/main/res/drawable-xxhdpi/ic_action_list_grid.png diff --git a/res/drawable-xxhdpi/ic_action_lock_closed.png b/app/src/main/res/drawable-xxhdpi/ic_action_lock_closed.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_lock_closed.png rename to app/src/main/res/drawable-xxhdpi/ic_action_lock_closed.png diff --git a/res/drawable-xxhdpi/ic_action_mail.png b/app/src/main/res/drawable-xxhdpi/ic_action_mail.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_mail.png rename to app/src/main/res/drawable-xxhdpi/ic_action_mail.png diff --git a/res/drawable-xxhdpi/ic_action_movie.png b/app/src/main/res/drawable-xxhdpi/ic_action_movie.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_movie.png rename to app/src/main/res/drawable-xxhdpi/ic_action_movie.png diff --git a/res/drawable-xxhdpi/ic_action_playback_play.png b/app/src/main/res/drawable-xxhdpi/ic_action_playback_play.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_playback_play.png rename to app/src/main/res/drawable-xxhdpi/ic_action_playback_play.png diff --git a/res/drawable-xxhdpi/ic_action_puzzle.png b/app/src/main/res/drawable-xxhdpi/ic_action_puzzle.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_puzzle.png rename to app/src/main/res/drawable-xxhdpi/ic_action_puzzle.png diff --git a/res/drawable-xxhdpi/ic_action_ratings.png b/app/src/main/res/drawable-xxhdpi/ic_action_ratings.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_ratings.png rename to app/src/main/res/drawable-xxhdpi/ic_action_ratings.png diff --git a/res/drawable-xxhdpi/ic_action_send.png b/app/src/main/res/drawable-xxhdpi/ic_action_send.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_send.png rename to app/src/main/res/drawable-xxhdpi/ic_action_send.png diff --git a/res/drawable-xxhdpi/ic_action_settings.png b/app/src/main/res/drawable-xxhdpi/ic_action_settings.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_settings.png rename to app/src/main/res/drawable-xxhdpi/ic_action_settings.png diff --git a/res/drawable-xxhdpi/ic_action_show.png b/app/src/main/res/drawable-xxhdpi/ic_action_show.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_show.png rename to app/src/main/res/drawable-xxhdpi/ic_action_show.png diff --git a/res/drawable-xxhdpi/ic_action_star_0.png b/app/src/main/res/drawable-xxhdpi/ic_action_star_0.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_star_0.png rename to app/src/main/res/drawable-xxhdpi/ic_action_star_0.png diff --git a/res/drawable-xxhdpi/ic_action_subtitles.png b/app/src/main/res/drawable-xxhdpi/ic_action_subtitles.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_subtitles.png rename to app/src/main/res/drawable-xxhdpi/ic_action_subtitles.png diff --git a/res/drawable-xxhdpi/ic_action_tags.png b/app/src/main/res/drawable-xxhdpi/ic_action_tags.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_tags.png rename to app/src/main/res/drawable-xxhdpi/ic_action_tags.png diff --git a/res/drawable-xxhdpi/ic_action_tiles_large.png b/app/src/main/res/drawable-xxhdpi/ic_action_tiles_large.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_tiles_large.png rename to app/src/main/res/drawable-xxhdpi/ic_action_tiles_large.png diff --git a/res/drawable-xxhdpi/ic_action_tv.png b/app/src/main/res/drawable-xxhdpi/ic_action_tv.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_tv.png rename to app/src/main/res/drawable-xxhdpi/ic_action_tv.png diff --git a/res/drawable-xxhdpi/ic_action_users.png b/app/src/main/res/drawable-xxhdpi/ic_action_users.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_users.png rename to app/src/main/res/drawable-xxhdpi/ic_action_users.png diff --git a/res/drawable-xxhdpi/ic_action_wifi.png b/app/src/main/res/drawable-xxhdpi/ic_action_wifi.png similarity index 100% rename from res/drawable-xxhdpi/ic_action_wifi.png rename to app/src/main/res/drawable-xxhdpi/ic_action_wifi.png diff --git a/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png new file mode 100644 index 00000000..72cedcad Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_back_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_back_white_24dp.png new file mode 100644 index 00000000..4057cc54 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_arrow_back_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_cast_connected_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_cast_connected_white_24dp.png new file mode 100644 index 00000000..78615ccd Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_cast_connected_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_cloud_grey600_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_cloud_grey600_24dp.png new file mode 100644 index 00000000..0bcacc54 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_cloud_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png new file mode 100644 index 00000000..0e95e9b1 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_done_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_done_white_24dp.png new file mode 100644 index 00000000..f801e7ab Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_done_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_exit_to_app_grey600_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_exit_to_app_grey600_24dp.png new file mode 100644 index 00000000..a88bf1ed Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_exit_to_app_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_favorite_outline_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_favorite_outline_white_24dp.png new file mode 100644 index 00000000..9e0133ac Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_favorite_outline_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_favorite_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_favorite_white_24dp.png new file mode 100644 index 00000000..b3dd9ad4 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_favorite_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_filter_list_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_filter_list_white_24dp.png new file mode 100644 index 00000000..802b3cd5 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_filter_list_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_folder_open_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_folder_open_white_24dp.png new file mode 100644 index 00000000..0cc53b5e Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_folder_open_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_grade_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_grade_white_24dp.png new file mode 100644 index 00000000..33a28c00 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_grade_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_help_grey600_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_help_grey600_24dp.png new file mode 100644 index 00000000..d64fa516 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_help_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_insert_drive_file_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_insert_drive_file_white_24dp.png new file mode 100644 index 00000000..58b208df Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_insert_drive_file_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_language_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_language_white_24dp.png new file mode 100644 index 00000000..fd0acd20 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_language_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_local_movies_grey600_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_local_movies_grey600_24dp.png new file mode 100644 index 00000000..d368c956 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_local_movies_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_24dp.png new file mode 100644 index 00000000..2955c02e Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_movie_grey600_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_movie_grey600_24dp.png new file mode 100644 index 00000000..4bf55ec3 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_movie_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_queue_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_queue_white_24dp.png new file mode 100644 index 00000000..efdcf086 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_queue_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_search_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_search_white_24dp.png new file mode 100644 index 00000000..0bbeab15 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_search_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_settings_grey600_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_settings_grey600_24dp.png new file mode 100644 index 00000000..6a70402b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_settings_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png new file mode 100644 index 00000000..9963c6a0 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_share_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_sort_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_sort_white_24dp.png new file mode 100644 index 00000000..d1127ebc Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_sort_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_sync_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_sync_white_24dp.png new file mode 100644 index 00000000..f667f36d Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_sync_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_tv_grey600_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_tv_grey600_24dp.png new file mode 100644 index 00000000..ce3b9bbe Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_tv_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_video_collection_grey600_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_video_collection_grey600_24dp.png new file mode 100644 index 00000000..e63c8089 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_video_collection_grey600_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_video_collection_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_video_collection_white_24dp.png new file mode 100644 index 00000000..9c13aeef Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_video_collection_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_visibility_off_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_visibility_off_white_24dp.png new file mode 100644 index 00000000..7992e5e5 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_visibility_off_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_visibility_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_visibility_white_24dp.png new file mode 100644 index 00000000..6da14d6e Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_visibility_white_24dp.png differ diff --git a/res/drawable-xxhdpi/ignoresmallfiles.png b/app/src/main/res/drawable-xxhdpi/ignoresmallfiles.png similarity index 100% rename from res/drawable-xxhdpi/ignoresmallfiles.png rename to app/src/main/res/drawable-xxhdpi/ignoresmallfiles.png diff --git a/app/src/main/res/drawable-xxhdpi/menuicon.png b/app/src/main/res/drawable-xxhdpi/menuicon.png new file mode 100644 index 00000000..d2db40ff Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/menuicon.png differ diff --git a/res/drawable-xxhdpi/other.png b/app/src/main/res/drawable-xxhdpi/other.png similarity index 100% rename from res/drawable-xxhdpi/other.png rename to app/src/main/res/drawable-xxhdpi/other.png diff --git a/res/drawable-xxhdpi/photo.png b/app/src/main/res/drawable-xxhdpi/photo.png similarity index 100% rename from res/drawable-xxhdpi/photo.png rename to app/src/main/res/drawable-xxhdpi/photo.png diff --git a/res/drawable-xxhdpi/reddit.png b/app/src/main/res/drawable-xxhdpi/reddit.png similarity index 100% rename from res/drawable-xxhdpi/reddit.png rename to app/src/main/res/drawable-xxhdpi/reddit.png diff --git a/app/src/main/res/drawable-xxhdpi/shadow.png b/app/src/main/res/drawable-xxhdpi/shadow.png new file mode 100644 index 00000000..1df1c16a Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/shadow.png differ diff --git a/res/drawable-xxhdpi/startup.png b/app/src/main/res/drawable-xxhdpi/startup.png similarity index 100% rename from res/drawable-xxhdpi/startup.png rename to app/src/main/res/drawable-xxhdpi/startup.png diff --git a/res/drawable-xxhdpi/tedtalks.png b/app/src/main/res/drawable-xxhdpi/tedtalks.png similarity index 100% rename from res/drawable-xxhdpi/tedtalks.png rename to app/src/main/res/drawable-xxhdpi/tedtalks.png diff --git a/res/drawable-xxhdpi/titles.png b/app/src/main/res/drawable-xxhdpi/titles.png similarity index 100% rename from res/drawable-xxhdpi/titles.png rename to app/src/main/res/drawable-xxhdpi/titles.png diff --git a/res/drawable-xxhdpi/unknown_user.png b/app/src/main/res/drawable-xxhdpi/unknown_user.png similarity index 100% rename from res/drawable-xxhdpi/unknown_user.png rename to app/src/main/res/drawable-xxhdpi/unknown_user.png diff --git a/res/drawable-xxhdpi/user_interface.png b/app/src/main/res/drawable-xxhdpi/user_interface.png similarity index 100% rename from res/drawable-xxhdpi/user_interface.png rename to app/src/main/res/drawable-xxhdpi/user_interface.png diff --git a/res/drawable-xxhdpi/youtube.png b/app/src/main/res/drawable-xxhdpi/youtube.png similarity index 100% rename from res/drawable-xxhdpi/youtube.png rename to app/src/main/res/drawable-xxhdpi/youtube.png diff --git a/app/src/main/res/drawable-xxxhdpi/menuicon.png b/app/src/main/res/drawable-xxxhdpi/menuicon.png new file mode 100644 index 00000000..9e455ad3 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/menuicon.png differ diff --git a/app/src/main/res/drawable/background_tab.xml b/app/src/main/res/drawable/background_tab.xml new file mode 100644 index 00000000..885cf036 --- /dev/null +++ b/app/src/main/res/drawable/background_tab.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/res/drawable/bg.xml b/app/src/main/res/drawable/bg.xml similarity index 81% rename from res/drawable/bg.xml rename to app/src/main/res/drawable/bg.xml index ce37e418..cd374798 100644 --- a/res/drawable/bg.xml +++ b/app/src/main/res/drawable/bg.xml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/res/drawable/bottom_shadow.xml b/app/src/main/res/drawable/bottom_shadow.xml similarity index 100% rename from res/drawable/bottom_shadow.xml rename to app/src/main/res/drawable/bottom_shadow.xml diff --git a/res/drawable/buttonstyle.xml b/app/src/main/res/drawable/buttonstyle.xml similarity index 100% rename from res/drawable/buttonstyle.xml rename to app/src/main/res/drawable/buttonstyle.xml diff --git a/res/drawable/drawer_shadow.xml b/app/src/main/res/drawable/drawer_shadow.xml similarity index 100% rename from res/drawable/drawer_shadow.xml rename to app/src/main/res/drawable/drawer_shadow.xml diff --git a/res/drawable/gradient_black_to_transparent.xml b/app/src/main/res/drawable/gradient_black_to_transparent.xml similarity index 82% rename from res/drawable/gradient_black_to_transparent.xml rename to app/src/main/res/drawable/gradient_black_to_transparent.xml index 64c431a5..ccbef1bc 100644 --- a/res/drawable/gradient_black_to_transparent.xml +++ b/app/src/main/res/drawable/gradient_black_to_transparent.xml @@ -4,6 +4,6 @@ + android:startColor="#AA000000" /> \ No newline at end of file diff --git a/res/drawable/gray.xml b/app/src/main/res/drawable/gray.xml similarity index 100% rename from res/drawable/gray.xml rename to app/src/main/res/drawable/gray.xml diff --git a/res/drawable/highlighted_bg.xml b/app/src/main/res/drawable/highlighted_bg.xml similarity index 100% rename from res/drawable/highlighted_bg.xml rename to app/src/main/res/drawable/highlighted_bg.xml diff --git a/res/drawable/list_selector.xml b/app/src/main/res/drawable/list_selector.xml similarity index 100% rename from res/drawable/list_selector.xml rename to app/src/main/res/drawable/list_selector.xml diff --git a/res/drawable/menu_bg_drawable.xml b/app/src/main/res/drawable/menu_bg_drawable.xml similarity index 100% rename from res/drawable/menu_bg_drawable.xml rename to app/src/main/res/drawable/menu_bg_drawable.xml diff --git a/res/drawable/menu_selector.xml b/app/src/main/res/drawable/menu_selector.xml similarity index 100% rename from res/drawable/menu_selector.xml rename to app/src/main/res/drawable/menu_selector.xml diff --git a/res/drawable/overlay_bg.xml b/app/src/main/res/drawable/overlay_bg.xml similarity index 100% rename from res/drawable/overlay_bg.xml rename to app/src/main/res/drawable/overlay_bg.xml diff --git a/res/drawable/pressed_background.xml b/app/src/main/res/drawable/pressed_background.xml similarity index 100% rename from res/drawable/pressed_background.xml rename to app/src/main/res/drawable/pressed_background.xml diff --git a/res/drawable/reverse_overlay_bg.xml b/app/src/main/res/drawable/reverse_overlay_bg.xml similarity index 100% rename from res/drawable/reverse_overlay_bg.xml rename to app/src/main/res/drawable/reverse_overlay_bg.xml diff --git a/res/drawable/seasons_episodes_shadow.xml b/app/src/main/res/drawable/seasons_episodes_shadow.xml similarity index 100% rename from res/drawable/seasons_episodes_shadow.xml rename to app/src/main/res/drawable/seasons_episodes_shadow.xml diff --git a/res/drawable/selectable_background.xml b/app/src/main/res/drawable/selectable_background.xml similarity index 73% rename from res/drawable/selectable_background.xml rename to app/src/main/res/drawable/selectable_background.xml index c3c8e996..f4c18b19 100644 --- a/res/drawable/selectable_background.xml +++ b/app/src/main/res/drawable/selectable_background.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/res/drawable/selected_bg.xml b/app/src/main/res/drawable/selected_bg.xml similarity index 100% rename from res/drawable/selected_bg.xml rename to app/src/main/res/drawable/selected_bg.xml diff --git a/res/drawable/selected_menu_bg.xml b/app/src/main/res/drawable/selected_menu_bg.xml similarity index 100% rename from res/drawable/selected_menu_bg.xml rename to app/src/main/res/drawable/selected_menu_bg.xml diff --git a/res/drawable/top_rounded_corner.xml b/app/src/main/res/drawable/top_rounded_corner.xml similarity index 100% rename from res/drawable/top_rounded_corner.xml rename to app/src/main/res/drawable/top_rounded_corner.xml diff --git a/res/drawable/transparent_actionbar.xml b/app/src/main/res/drawable/transparent_actionbar.xml similarity index 100% rename from res/drawable/transparent_actionbar.xml rename to app/src/main/res/drawable/transparent_actionbar.xml diff --git a/res/drawable/transparent_bg.xml b/app/src/main/res/drawable/transparent_bg.xml similarity index 100% rename from res/drawable/transparent_bg.xml rename to app/src/main/res/drawable/transparent_bg.xml diff --git a/app/src/main/res/layout-land/actor_details.xml b/app/src/main/res/layout-land/actor_details.xml new file mode 100644 index 00000000..0268d0de --- /dev/null +++ b/app/src/main/res/layout-land/actor_details.xml @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-land/filebrowser.xml b/app/src/main/res/layout-land/filebrowser.xml similarity index 100% rename from res/layout-land/filebrowser.xml rename to app/src/main/res/layout-land/filebrowser.xml diff --git a/res/layout-land/filesource_browser.xml b/app/src/main/res/layout-land/filesource_browser.xml similarity index 100% rename from res/layout-land/filesource_browser.xml rename to app/src/main/res/layout-land/filesource_browser.xml diff --git a/app/src/main/res/layout-land/movie_and_tv_show_details.xml b/app/src/main/res/layout-land/movie_and_tv_show_details.xml new file mode 100644 index 00000000..faf6631f --- /dev/null +++ b/app/src/main/res/layout-land/movie_and_tv_show_details.xml @@ -0,0 +1,319 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-land/new_episode_details.xml b/app/src/main/res/layout-land/new_episode_details.xml similarity index 98% rename from res/layout-land/new_episode_details.xml rename to app/src/main/res/layout-land/new_episode_details.xml index 9a8dcfad..131180fc 100644 --- a/res/layout-land/new_episode_details.xml +++ b/app/src/main/res/layout-land/new_episode_details.xml @@ -103,7 +103,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="@dimen/movie_details_padding" - android:drawableLeft="@drawable/fav" + android:drawableLeft="@drawable/ic_grade_white_24dp" android:drawablePadding="@dimen/movie_details_padding" android:focusable="false" android:gravity="center_vertical" @@ -160,7 +160,7 @@ android:layout_marginBottom="@dimen/details_medium_padding" android:layout_marginRight="@dimen/movie_details_padding" android:layout_marginTop="@dimen/movie_details_padding" - android:drawableLeft="@drawable/file" + android:drawableLeft="@drawable/ic_folder_open_white_24dp" android:drawablePadding="@dimen/movie_details_padding" android:focusable="false" android:gravity="center_vertical" diff --git a/res/layout-sw600dp-land/show_episodes_layout.xml b/app/src/main/res/layout-sw600dp-land/show_episodes_layout.xml similarity index 100% rename from res/layout-sw600dp-land/show_episodes_layout.xml rename to app/src/main/res/layout-sw600dp-land/show_episodes_layout.xml diff --git a/app/src/main/res/layout-sw600dp/add_file_source.xml b/app/src/main/res/layout-sw600dp/add_file_source.xml new file mode 100644 index 00000000..c3ed03ae --- /dev/null +++ b/app/src/main/res/layout-sw600dp/add_file_source.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-sw600dp/edit_episode.xml b/app/src/main/res/layout-sw600dp/edit_episode.xml similarity index 100% rename from res/layout-sw600dp/edit_episode.xml rename to app/src/main/res/layout-sw600dp/edit_episode.xml diff --git a/app/src/main/res/layout-sw600dp/edit_movie.xml b/app/src/main/res/layout-sw600dp/edit_movie.xml new file mode 100644 index 00000000..6b5fd1e0 --- /dev/null +++ b/app/src/main/res/layout-sw600dp/edit_movie.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-sw600dp/edit_movie_layout_buttons.xml b/app/src/main/res/layout-sw600dp/edit_movie_layout_buttons.xml similarity index 100% rename from res/layout-sw600dp/edit_movie_layout_buttons.xml rename to app/src/main/res/layout-sw600dp/edit_movie_layout_buttons.xml diff --git a/res/layout-sw600dp/filebrowser.xml b/app/src/main/res/layout-sw600dp/filebrowser.xml similarity index 100% rename from res/layout-sw600dp/filebrowser.xml rename to app/src/main/res/layout-sw600dp/filebrowser.xml diff --git a/res/layout-sw600dp/filesource_browser.xml b/app/src/main/res/layout-sw600dp/filesource_browser.xml similarity index 100% rename from res/layout-sw600dp/filesource_browser.xml rename to app/src/main/res/layout-sw600dp/filesource_browser.xml diff --git a/app/src/main/res/layout-sw600dp/filesources_layout.xml b/app/src/main/res/layout-sw600dp/filesources_layout.xml new file mode 100644 index 00000000..5f998a59 --- /dev/null +++ b/app/src/main/res/layout-sw600dp/filesources_layout.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw600dp/identify_movie_and_tv_show.xml b/app/src/main/res/layout-sw600dp/identify_movie_and_tv_show.xml new file mode 100644 index 00000000..f436d917 --- /dev/null +++ b/app/src/main/res/layout-sw600dp/identify_movie_and_tv_show.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-sw600dp/show_episodes_layout.xml b/app/src/main/res/layout-sw600dp/show_episodes_layout.xml similarity index 100% rename from res/layout-sw600dp/show_episodes_layout.xml rename to app/src/main/res/layout-sw600dp/show_episodes_layout.xml diff --git a/app/src/main/res/layout-sw600dp/unidentified_files_layout.xml b/app/src/main/res/layout-sw600dp/unidentified_files_layout.xml new file mode 100644 index 00000000..775973c1 --- /dev/null +++ b/app/src/main/res/layout-sw600dp/unidentified_files_layout.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw600dp/update_layout.xml b/app/src/main/res/layout-sw600dp/update_layout.xml new file mode 100644 index 00000000..c65ff68e --- /dev/null +++ b/app/src/main/res/layout-sw600dp/update_layout.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/account_layout.xml b/app/src/main/res/layout/account_layout.xml similarity index 100% rename from res/layout/account_layout.xml rename to app/src/main/res/layout/account_layout.xml diff --git a/app/src/main/res/layout/actor_details.xml b/app/src/main/res/layout/actor_details.xml new file mode 100644 index 00000000..5a5e3dac --- /dev/null +++ b/app/src/main/res/layout/actor_details.xml @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/add_file_source.xml b/app/src/main/res/layout/add_file_source.xml new file mode 100644 index 00000000..ecb7d80e --- /dev/null +++ b/app/src/main/res/layout/add_file_source.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/res/layout/add_file_source_inner.xml b/app/src/main/res/layout/add_file_source_inner.xml similarity index 99% rename from res/layout/add_file_source_inner.xml rename to app/src/main/res/layout/add_file_source_inner.xml index 06954241..781ab4c4 100644 --- a/res/layout/add_file_source_inner.xml +++ b/app/src/main/res/layout/add_file_source_inner.xml @@ -98,6 +98,7 @@ android:layout_marginTop="16dp" android:paddingLeft="16dp" android:paddingRight="16dp" + android:textColor="#fff" android:text="@string/continueString" /> diff --git a/res/layout/addnetwork.xml b/app/src/main/res/layout/addnetwork.xml similarity index 97% rename from res/layout/addnetwork.xml rename to app/src/main/res/layout/addnetwork.xml index 73ba6dab..24128292 100644 --- a/res/layout/addnetwork.xml +++ b/app/src/main/res/layout/addnetwork.xml @@ -18,7 +18,7 @@ android:layout_gravity="bottom" android:layout_marginRight="8dp" android:layout_weight="1" - android:drawableLeft="@drawable/localizedinfo" + android:drawableLeft="@drawable/ic_language_white_24dp" android:drawablePadding="8dp" android:ems="10" android:hint="@string/networkIpAddress" @@ -33,7 +33,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="search" - android:src="@drawable/search" /> + android:src="@drawable/ic_search_white_24dp" /> + + \ No newline at end of file diff --git a/res/layout/edit_movie_layout.xml b/app/src/main/res/layout/edit_movie_layout.xml similarity index 100% rename from res/layout/edit_movie_layout.xml rename to app/src/main/res/layout/edit_movie_layout.xml diff --git a/res/layout/edit_movie_layout_buttons.xml b/app/src/main/res/layout/edit_movie_layout_buttons.xml similarity index 100% rename from res/layout/edit_movie_layout_buttons.xml rename to app/src/main/res/layout/edit_movie_layout_buttons.xml diff --git a/res/layout/empty_layout.xml b/app/src/main/res/layout/empty_layout.xml similarity index 81% rename from res/layout/empty_layout.xml rename to app/src/main/res/layout/empty_layout.xml index 0e2cbbdb..4d36b196 100644 --- a/res/layout/empty_layout.xml +++ b/app/src/main/res/layout/empty_layout.xml @@ -3,5 +3,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg" > + + \ No newline at end of file diff --git a/app/src/main/res/layout/empty_layout_with_toolbar.xml b/app/src/main/res/layout/empty_layout_with_toolbar.xml new file mode 100644 index 00000000..4600553f --- /dev/null +++ b/app/src/main/res/layout/empty_layout_with_toolbar.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/res/layout/episode_grid_item.xml b/app/src/main/res/layout/episode_grid_item.xml similarity index 97% rename from res/layout/episode_grid_item.xml rename to app/src/main/res/layout/episode_grid_item.xml index a926c7a3..d9a6d277 100644 --- a/res/layout/episode_grid_item.xml +++ b/app/src/main/res/layout/episode_grid_item.xml @@ -56,7 +56,7 @@ android:background="#80000000" android:paddingLeft="@dimen/episode_grid_padding" android:paddingRight="@dimen/episode_grid_padding" - android:src="@drawable/done" /> + android:src="@drawable/ic_done_white_24dp" /> + android:src="@drawable/ic_done_white_24dp" /> \ No newline at end of file diff --git a/res/layout/file_list_item.xml b/app/src/main/res/layout/file_list_item.xml similarity index 95% rename from res/layout/file_list_item.xml rename to app/src/main/res/layout/file_list_item.xml index c73cba19..04b34bed 100644 --- a/res/layout/file_list_item.xml +++ b/app/src/main/res/layout/file_list_item.xml @@ -11,7 +11,7 @@ android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/file" /> + android:src="@drawable/ic_insert_drive_file_white_24dp" /> + + \ No newline at end of file diff --git a/res/layout/frame.xml b/app/src/main/res/layout/frame.xml similarity index 100% rename from res/layout/frame.xml rename to app/src/main/res/layout/frame.xml diff --git a/res/layout/grid_episode.xml b/app/src/main/res/layout/grid_episode.xml similarity index 100% rename from res/layout/grid_episode.xml rename to app/src/main/res/layout/grid_episode.xml diff --git a/res/layout/grid_item.xml b/app/src/main/res/layout/grid_item.xml similarity index 95% rename from res/layout/grid_item.xml rename to app/src/main/res/layout/grid_item.xml index 4dea6322..afcd141d 100644 --- a/res/layout/grid_item.xml +++ b/app/src/main/res/layout/grid_item.xml @@ -11,7 +11,8 @@ android:layout_height="match_parent" android:adjustViewBounds="true" android:cropToPadding="true" - android:scaleType="centerCrop" /> + android:scaleType="centerCrop" + android:transitionName="cover" /> + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/horizontal_grid_item_small_landscape_no_text.xml b/app/src/main/res/layout/horizontal_grid_item_small_landscape_no_text.xml similarity index 100% rename from res/layout/horizontal_grid_item_small_landscape_no_text.xml rename to app/src/main/res/layout/horizontal_grid_item_small_landscape_no_text.xml diff --git a/res/layout/horizontal_grid_item_small_no_text.xml b/app/src/main/res/layout/horizontal_grid_item_small_no_text.xml similarity index 100% rename from res/layout/horizontal_grid_item_small_no_text.xml rename to app/src/main/res/layout/horizontal_grid_item_small_no_text.xml diff --git a/res/layout/horizontal_grid_items.xml b/app/src/main/res/layout/horizontal_grid_items.xml similarity index 91% rename from res/layout/horizontal_grid_items.xml rename to app/src/main/res/layout/horizontal_grid_items.xml index dabb319e..574adff6 100644 --- a/res/layout/horizontal_grid_items.xml +++ b/app/src/main/res/layout/horizontal_grid_items.xml @@ -1,6 +1,5 @@ - + + android:textSize="@dimen/content_details_subheader" /> + android:orientation="vertical"> + + diff --git a/res/layout/image_grid_fragment.xml b/app/src/main/res/layout/image_grid_fragment.xml similarity index 98% rename from res/layout/image_grid_fragment.xml rename to app/src/main/res/layout/image_grid_fragment.xml index f7e9427c..05858be8 100644 --- a/res/layout/image_grid_fragment.xml +++ b/app/src/main/res/layout/image_grid_fragment.xml @@ -1,6 +1,7 @@ diff --git a/res/layout/list.xml b/app/src/main/res/layout/list.xml similarity index 100% rename from res/layout/list.xml rename to app/src/main/res/layout/list.xml diff --git a/res/layout/list_episode.xml b/app/src/main/res/layout/list_episode.xml similarity index 89% rename from res/layout/list_episode.xml rename to app/src/main/res/layout/list_episode.xml index 46c4e0c3..a8eb4a4d 100644 --- a/res/layout/list_episode.xml +++ b/app/src/main/res/layout/list_episode.xml @@ -22,7 +22,10 @@ android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical" - android:padding="@dimen/movie_details_padding" > + android:paddingLeft="@dimen/movie_details_padding" + android:paddingRight="@dimen/movie_details_padding" + android:paddingBottom="@dimen/details_very_small_padding" + android:paddingTop="@dimen/details_very_small_padding"> + android:layout_height="match_parent" + android:fitsSystemWindows="true" > - + + + android:orientation="vertical" + android:fitsSystemWindows="false"> + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/menu_drawer_header_item.xml b/app/src/main/res/layout/menu_drawer_header_item.xml new file mode 100644 index 00000000..ceec9436 --- /dev/null +++ b/app/src/main/res/layout/menu_drawer_header_item.xml @@ -0,0 +1,12 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/menu_drawer_item.xml b/app/src/main/res/layout/menu_drawer_item.xml new file mode 100644 index 00000000..a234b161 --- /dev/null +++ b/app/src/main/res/layout/menu_drawer_item.xml @@ -0,0 +1,38 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/menu_drawer_separator.xml b/app/src/main/res/layout/menu_drawer_separator.xml new file mode 100644 index 00000000..6182603f --- /dev/null +++ b/app/src/main/res/layout/menu_drawer_separator.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/menu_drawer_separator_extra_padding.xml b/app/src/main/res/layout/menu_drawer_separator_extra_padding.xml new file mode 100644 index 00000000..f4fc4fbf --- /dev/null +++ b/app/src/main/res/layout/menu_drawer_separator_extra_padding.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/menu_drawer_small_item.xml b/app/src/main/res/layout/menu_drawer_small_item.xml new file mode 100644 index 00000000..749b1a22 --- /dev/null +++ b/app/src/main/res/layout/menu_drawer_small_item.xml @@ -0,0 +1,29 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/movie_and_tv_show_details.xml b/app/src/main/res/layout/movie_and_tv_show_details.xml new file mode 100644 index 00000000..8f31a786 --- /dev/null +++ b/app/src/main/res/layout/movie_and_tv_show_details.xml @@ -0,0 +1,286 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/movie_backdrop_widget.xml b/app/src/main/res/layout/movie_backdrop_widget.xml similarity index 100% rename from res/layout/movie_backdrop_widget.xml rename to app/src/main/res/layout/movie_backdrop_widget.xml diff --git a/res/layout/movie_backdrop_widget_item.xml b/app/src/main/res/layout/movie_backdrop_widget_item.xml similarity index 100% rename from res/layout/movie_backdrop_widget_item.xml rename to app/src/main/res/layout/movie_backdrop_widget_item.xml diff --git a/res/layout/movie_cover_widget.xml b/app/src/main/res/layout/movie_cover_widget.xml similarity index 100% rename from res/layout/movie_cover_widget.xml rename to app/src/main/res/layout/movie_cover_widget.xml diff --git a/res/layout/movie_cover_widget_item.xml b/app/src/main/res/layout/movie_cover_widget_item.xml similarity index 100% rename from res/layout/movie_cover_widget_item.xml rename to app/src/main/res/layout/movie_cover_widget_item.xml diff --git a/res/layout/new_episode_details.xml b/app/src/main/res/layout/new_episode_details.xml similarity index 98% rename from res/layout/new_episode_details.xml rename to app/src/main/res/layout/new_episode_details.xml index cddb38dc..74050919 100644 --- a/res/layout/new_episode_details.xml +++ b/app/src/main/res/layout/new_episode_details.xml @@ -19,7 +19,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" > - + android:layout_height="match_parent" + android:transitionName="cover"/> \ No newline at end of file diff --git a/res/layout/remote_playback.xml b/app/src/main/res/layout/remote_playback.xml similarity index 100% rename from res/layout/remote_playback.xml rename to app/src/main/res/layout/remote_playback.xml diff --git a/res/layout/row.xml b/app/src/main/res/layout/row.xml similarity index 100% rename from res/layout/row.xml rename to app/src/main/res/layout/row.xml diff --git a/res/layout/row_header.xml b/app/src/main/res/layout/row_header.xml similarity index 100% rename from res/layout/row_header.xml rename to app/src/main/res/layout/row_header.xml diff --git a/res/layout/scheduled_updates.xml b/app/src/main/res/layout/scheduled_updates.xml similarity index 100% rename from res/layout/scheduled_updates.xml rename to app/src/main/res/layout/scheduled_updates.xml diff --git a/res/layout/seasons_grid.xml b/app/src/main/res/layout/seasons_grid.xml similarity index 82% rename from res/layout/seasons_grid.xml rename to app/src/main/res/layout/seasons_grid.xml index c0ec8833..a12d43c9 100644 --- a/res/layout/seasons_grid.xml +++ b/app/src/main/res/layout/seasons_grid.xml @@ -1,14 +1,10 @@ - + android:layout_height="match_parent"> + android:src="@drawable/ic_done_white_24dp" /> \ No newline at end of file diff --git a/res/layout/show_episodes_layout.xml b/app/src/main/res/layout/show_episodes_layout.xml similarity index 100% rename from res/layout/show_episodes_layout.xml rename to app/src/main/res/layout/show_episodes_layout.xml diff --git a/res/layout/simple_list.xml b/app/src/main/res/layout/simple_list.xml similarity index 100% rename from res/layout/simple_list.xml rename to app/src/main/res/layout/simple_list.xml diff --git a/res/layout/spinner_header.xml b/app/src/main/res/layout/spinner_header.xml similarity index 100% rename from res/layout/spinner_header.xml rename to app/src/main/res/layout/spinner_header.xml diff --git a/res/layout/split_file_item.xml b/app/src/main/res/layout/split_file_item.xml similarity index 100% rename from res/layout/split_file_item.xml rename to app/src/main/res/layout/split_file_item.xml diff --git a/res/layout/support.xml b/app/src/main/res/layout/support.xml similarity index 100% rename from res/layout/support.xml rename to app/src/main/res/layout/support.xml diff --git a/app/src/main/res/layout/tab.xml b/app/src/main/res/layout/tab.xml new file mode 100644 index 00000000..80b104b5 --- /dev/null +++ b/app/src/main/res/layout/tab.xml @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/layout/toolbar_layout.xml b/app/src/main/res/layout/toolbar_layout.xml new file mode 100644 index 00000000..077c1ab8 --- /dev/null +++ b/app/src/main/res/layout/toolbar_layout.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/res/layout/unidentified_files.xml b/app/src/main/res/layout/unidentified_files.xml similarity index 100% rename from res/layout/unidentified_files.xml rename to app/src/main/res/layout/unidentified_files.xml diff --git a/res/layout/unidentified_files_layout.xml b/app/src/main/res/layout/unidentified_files_layout.xml similarity index 62% rename from res/layout/unidentified_files_layout.xml rename to app/src/main/res/layout/unidentified_files_layout.xml index 4d905059..54bf43e1 100644 --- a/res/layout/unidentified_files_layout.xml +++ b/app/src/main/res/layout/unidentified_files_layout.xml @@ -1,7 +1,10 @@ + android:layout_gravity="center_horizontal" + android:orientation="vertical" > + + diff --git a/res/layout/update.xml b/app/src/main/res/layout/update.xml similarity index 98% rename from res/layout/update.xml rename to app/src/main/res/layout/update.xml index d8d1e1b2..1bd9eded 100644 --- a/res/layout/update.xml +++ b/app/src/main/res/layout/update.xml @@ -76,7 +76,7 @@ android:layout_width="match_parent" android:layout_height="60dp" android:layout_marginTop="8dp" - android:drawableLeft="@drawable/refresh" + android:drawableLeft="@drawable/ic_sync_white_24dp" android:onClick="startUpdate" android:text="@string/newuser_btStartSearch" > diff --git a/res/layout/update_layout.xml b/app/src/main/res/layout/update_layout.xml similarity index 60% rename from res/layout/update_layout.xml rename to app/src/main/res/layout/update_layout.xml index 7de9e029..294781d9 100644 --- a/res/layout/update_layout.xml +++ b/app/src/main/res/layout/update_layout.xml @@ -1,7 +1,10 @@ + android:layout_gravity="center_horizontal" + android:orientation="vertical" > + + diff --git a/res/layout/upnp_list.xml b/app/src/main/res/layout/upnp_list.xml similarity index 88% rename from res/layout/upnp_list.xml rename to app/src/main/res/layout/upnp_list.xml index 916da502..3284b3d8 100644 --- a/res/layout/upnp_list.xml +++ b/app/src/main/res/layout/upnp_list.xml @@ -1,8 +1,7 @@ + android:layout_height="match_parent"> - - + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/viewpager_with_toolbar.xml b/app/src/main/res/layout/viewpager_with_toolbar.xml new file mode 100644 index 00000000..e6acf3f9 --- /dev/null +++ b/app/src/main/res/layout/viewpager_with_toolbar.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/viewpager_with_toolbar_and_tabs.xml b/app/src/main/res/layout/viewpager_with_toolbar_and_tabs.xml new file mode 100644 index 00000000..862794d4 --- /dev/null +++ b/app/src/main/res/layout/viewpager_with_toolbar_and_tabs.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/viewpager_with_toolbar_overlay.xml b/app/src/main/res/layout/viewpager_with_toolbar_overlay.xml new file mode 100644 index 00000000..6f6451ae --- /dev/null +++ b/app/src/main/res/layout/viewpager_with_toolbar_overlay.xml @@ -0,0 +1,22 @@ + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/webvideo_item.xml b/app/src/main/res/layout/webvideo_item.xml similarity index 100% rename from res/layout/webvideo_item.xml rename to app/src/main/res/layout/webvideo_item.xml diff --git a/res/layout/welcome.xml b/app/src/main/res/layout/welcome.xml similarity index 100% rename from res/layout/welcome.xml rename to app/src/main/res/layout/welcome.xml diff --git a/res/layout/widget_item.xml b/app/src/main/res/layout/widget_item.xml similarity index 100% rename from res/layout/widget_item.xml rename to app/src/main/res/layout/widget_item.xml diff --git a/res/layout/widget_layout.xml b/app/src/main/res/layout/widget_layout.xml similarity index 100% rename from res/layout/widget_layout.xml rename to app/src/main/res/layout/widget_layout.xml diff --git a/res/menu/add_file_source.xml b/app/src/main/res/menu/add_file_source.xml similarity index 65% rename from res/menu/add_file_source.xml rename to app/src/main/res/menu/add_file_source.xml index b1ad5d2c..c143b2f9 100644 --- a/res/menu/add_file_source.xml +++ b/app/src/main/res/menu/add_file_source.xml @@ -1,8 +1,9 @@ - + diff --git a/res/menu/edit_movie_and_tv_show.xml b/app/src/main/res/menu/edit_movie_and_tv_show.xml similarity index 60% rename from res/menu/edit_movie_and_tv_show.xml rename to app/src/main/res/menu/edit_movie_and_tv_show.xml index ae775314..054691cf 100644 --- a/res/menu/edit_movie_and_tv_show.xml +++ b/app/src/main/res/menu/edit_movie_and_tv_show.xml @@ -1,16 +1,15 @@ + xmlns:app="http://schemas.android.com/apk/res-auto"> \ No newline at end of file diff --git a/res/menu/episode_details.xml b/app/src/main/res/menu/episode_details.xml similarity index 72% rename from res/menu/episode_details.xml rename to app/src/main/res/menu/episode_details.xml index 5e649ad4..baaa41f0 100644 --- a/res/menu/episode_details.xml +++ b/app/src/main/res/menu/episode_details.xml @@ -1,24 +1,25 @@ - + \ No newline at end of file diff --git a/res/menu/episodes_contextual.xml b/app/src/main/res/menu/episodes_contextual.xml similarity index 53% rename from res/menu/episodes_contextual.xml rename to app/src/main/res/menu/episodes_contextual.xml index ea2fa266..a0d1aef7 100644 --- a/res/menu/episodes_contextual.xml +++ b/app/src/main/res/menu/episodes_contextual.xml @@ -1,24 +1,28 @@ - + - diff --git a/app/src/main/res/menu/filebrowser.xml b/app/src/main/res/menu/filebrowser.xml new file mode 100644 index 00000000..68ccbd93 --- /dev/null +++ b/app/src/main/res/menu/filebrowser.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/res/menu/menu.xml b/app/src/main/res/menu/menu.xml similarity index 83% rename from res/menu/menu.xml rename to app/src/main/res/menu/menu.xml index 4084b4f1..2c090605 100644 --- a/res/menu/menu.xml +++ b/app/src/main/res/menu/menu.xml @@ -1,15 +1,15 @@ - + diff --git a/res/menu/menu_web_movies.xml b/app/src/main/res/menu/menu_web_movies.xml similarity index 55% rename from res/menu/menu_web_movies.xml rename to app/src/main/res/menu/menu_web_movies.xml index 50cb9d42..65b8c27f 100644 --- a/res/menu/menu_web_movies.xml +++ b/app/src/main/res/menu/menu_web_movies.xml @@ -1,9 +1,10 @@ - + diff --git a/res/menu/menutv.xml b/app/src/main/res/menu/menutv.xml similarity index 82% rename from res/menu/menutv.xml rename to app/src/main/res/menu/menutv.xml index acc6932d..fbd06ad0 100644 --- a/res/menu/menutv.xml +++ b/app/src/main/res/menu/menutv.xml @@ -1,15 +1,16 @@ - + diff --git a/res/menu/movie_details.xml b/app/src/main/res/menu/movie_details.xml similarity index 81% rename from res/menu/movie_details.xml rename to app/src/main/res/menu/movie_details.xml index 0725ea43..fa19217c 100644 --- a/res/menu/movie_details.xml +++ b/app/src/main/res/menu/movie_details.xml @@ -1,23 +1,19 @@ - + - - diff --git a/res/menu/open_in_browser.xml b/app/src/main/res/menu/open_in_browser.xml similarity index 100% rename from res/menu/open_in_browser.xml rename to app/src/main/res/menu/open_in_browser.xml diff --git a/app/src/main/res/menu/remote_playback.xml b/app/src/main/res/menu/remote_playback.xml new file mode 100644 index 00000000..feb7fe8f --- /dev/null +++ b/app/src/main/res/menu/remote_playback.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/res/menu/seasons_contextual.xml b/app/src/main/res/menu/seasons_contextual.xml similarity index 54% rename from res/menu/seasons_contextual.xml rename to app/src/main/res/menu/seasons_contextual.xml index 20801753..2e99dc7c 100644 --- a/res/menu/seasons_contextual.xml +++ b/app/src/main/res/menu/seasons_contextual.xml @@ -1,19 +1,22 @@ - + diff --git a/res/menu/seasons_tab.xml b/app/src/main/res/menu/seasons_tab.xml similarity index 52% rename from res/menu/seasons_tab.xml rename to app/src/main/res/menu/seasons_tab.xml index 358fc1cf..9ad085e7 100644 --- a/res/menu/seasons_tab.xml +++ b/app/src/main/res/menu/seasons_tab.xml @@ -1,9 +1,10 @@ - + diff --git a/app/src/main/res/menu/switch_button.xml b/app/src/main/res/menu/switch_button.xml new file mode 100644 index 00000000..167189bd --- /dev/null +++ b/app/src/main/res/menu/switch_button.xml @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file diff --git a/res/menu/tmdb_details.xml b/app/src/main/res/menu/tmdb_details.xml similarity index 61% rename from res/menu/tmdb_details.xml rename to app/src/main/res/menu/tmdb_details.xml index a4940ab3..b968bd6e 100644 --- a/res/menu/tmdb_details.xml +++ b/app/src/main/res/menu/tmdb_details.xml @@ -1,18 +1,12 @@ - + - - + diff --git a/res/menu/unidentified.xml b/app/src/main/res/menu/unidentified.xml similarity index 100% rename from res/menu/unidentified.xml rename to app/src/main/res/menu/unidentified.xml diff --git a/res/menu/unidentified_files.xml b/app/src/main/res/menu/unidentified_files.xml similarity index 85% rename from res/menu/unidentified_files.xml rename to app/src/main/res/menu/unidentified_files.xml index 3cc1622c..1aee0e90 100644 --- a/res/menu/unidentified_files.xml +++ b/app/src/main/res/menu/unidentified_files.xml @@ -7,7 +7,7 @@ diff --git a/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml similarity index 99% rename from res/values-ar/strings.xml rename to app/src/main/res/values-ar/strings.xml index ed7daf03..012a35e6 100644 --- a/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -249,8 +249,6 @@ استخدام اللغة الإنجليزية بدلًا من لغة النظام، يتطلب هذا إعادة تشغيل التطبيق. عرض شبكة عرض قائمة - تخطيط مواسم برامج التلفاز - استخدام تخطيط الشبكة أو القائمة لعرض مواسم برامج التلفاز. حذف الملف تصفية كل التصنيفات العمرية diff --git a/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml similarity index 99% rename from res/values-cs/strings.xml rename to app/src/main/res/values-cs/strings.xml index 0be4fee2..9510f39f 100644 --- a/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -249,8 +249,6 @@ Místo jazyka systému se použije angličtina. Vyžaduje restartování aplikace. Zobrazení mřížky Zobrazení seznamu - Rozložení epizod TV seriálů - Zobrazit epizody TV seriálů v mřížce nebo v seznamu? Odstranit soubor Filtry Všechny certifikace diff --git a/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml similarity index 99% rename from res/values-da/strings.xml rename to app/src/main/res/values-da/strings.xml index 942ca229..72e4278c 100644 --- a/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -251,8 +251,6 @@ Brug engelsk i stedet for systemsproget. Kræver genstart af programmet. Gittervisning Listevisning - Vælg layout for TV-serie sæsoner - Vis TV-serie sæsoner som gitter eller liste. Slet fil Filtre Alle certificeringer diff --git a/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml similarity index 99% rename from res/values-de/strings.xml rename to app/src/main/res/values-de/strings.xml index 29942151..7f47d7e4 100644 --- a/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -251,8 +251,6 @@ Verwenden englischer Sprache statt der Systemsprache. Anwendung muss neu gestartet werden. Rasteransicht Listenansicht - Aussehen der Serien festlegen - Raster oder Listenansicht für die Serien auswählen. Datei löschen Filter Alle Altersfreigaben diff --git a/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml similarity index 99% rename from res/values-es/strings.xml rename to app/src/main/res/values-es/strings.xml index 948df8b8..32eb427a 100644 --- a/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -249,8 +249,6 @@ Utilizar el idioma Inglés en lugar del idioma del sistema. Requiere reiniciar la aplicación. Ver como cuadrícula Ver como lista - Establecer Diseño para las series de TV por temporada - Usar una vista de cuadrícula o de lista para desplegar las temporadas de la serie de TV. Borrar archivo Filtros Todas las certificaciones diff --git a/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml similarity index 99% rename from res/values-fi/strings.xml rename to app/src/main/res/values-fi/strings.xml index 7f70c794..fe7d12ea 100644 --- a/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -249,8 +249,6 @@ Ohita järjestelmän kieli ja käytä englanniksi. Vaatii sovelluksen uudelleenkäynnistyksen. Ruudukkonäkymä Luettelonäkymä - Kausien asettelu - Käytä ruudukko- tai luettelonäkymää TV-ohjelmien kausien näyttämiseen. Poista tiedosto Suodattimet Kaikki sertifioinnit diff --git a/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml similarity index 99% rename from res/values-fr/strings.xml rename to app/src/main/res/values-fr/strings.xml index f6942131..c9df8232 100644 --- a/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -251,8 +251,6 @@ Forcer l\'application à utiliser l\'Anglais comme langue, à la place de la langue du système. Nécessite le redémarrage de l\'application. Vue mosaïque Vue en liste - Configurer le mode d\'affichage des séries TV - Utiliser la vue mosaïque ou liste pour afficher les saisons des séries TV. Supprimer le fichier Filtres Toutes les classifications diff --git a/res/values-he/strings.xml b/app/src/main/res/values-he/strings.xml similarity index 98% rename from res/values-he/strings.xml rename to app/src/main/res/values-he/strings.xml index 158a5264..557b06e1 100644 --- a/res/values-he/strings.xml +++ b/app/src/main/res/values-he/strings.xml @@ -246,8 +246,6 @@ השתמש בשפה האנגלית במקום בשפת המערכת. דורש אתחול מחדש של היישום. תצוגת רשת תצוגת רשימה - הגדר פריסת עונות של תוכנית טלוויזיה - השתמש בתצוגת רשת או רשימה כדי להציג עונות של תוכנית טלוויזיה. מחק קובץ מסננים כל האישורים diff --git a/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml similarity index 99% rename from res/values-hr/strings.xml rename to app/src/main/res/values-hr/strings.xml index 9bfcb382..7e66074c 100644 --- a/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -249,8 +249,6 @@ Koristi engleski jezik umjesto jezik sustava. Zahtijeva ponovno pokretanje aplikacije. Mrežni prikaz Spisak - Naćin prikaza sezone serijala - Koristi mrežni prikaz ili oblik spiska za prkazivanje sezone serijala. Izbriši datoteku Filteri Sve klasifikacije diff --git a/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml similarity index 99% rename from res/values-hu/strings.xml rename to app/src/main/res/values-hu/strings.xml index 9f9ded1b..66a6cf9c 100644 --- a/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -246,8 +246,6 @@ Az angol nyelv használata a rendszer nyelve helyett. Az alkalmazás újraindítása szükséges. Rács nézet Lista nézet - TV sorozatok évad nézete - Rács vagy lista nézet használata a TV sorozatok évadjainak megtekintéséhez. Fájl törlése Szűrők Minden minősítés diff --git a/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml similarity index 99% rename from res/values-it/strings.xml rename to app/src/main/res/values-it/strings.xml index 380c6234..ba8d5173 100644 --- a/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -251,8 +251,6 @@ Usa la lingua inglese invece della lingua di sistema. Richiede un riavvio dell\'applicazione. Vista griglia Vista lista - Imposta layout vista per le stagioni delle serie TV - Usa una vista griglia o lista per le stagioni delle serie TV. Elimina file Filtri Tutti le certificazioni diff --git a/res/values-land/dimens.xml b/app/src/main/res/values-land/dimens.xml similarity index 100% rename from res/values-land/dimens.xml rename to app/src/main/res/values-land/dimens.xml diff --git a/res/values-large/dimens.xml b/app/src/main/res/values-large/dimens.xml similarity index 93% rename from res/values-large/dimens.xml rename to app/src/main/res/values-large/dimens.xml index 9bc03860..a1b3b2d8 100644 --- a/res/values-large/dimens.xml +++ b/app/src/main/res/values-large/dimens.xml @@ -4,7 +4,6 @@ 135dp 291dp 260dp - 1dp 340dp 500dp 22sp diff --git a/res/values-nl-rNL/strings.xml b/app/src/main/res/values-nl-rNL/strings.xml similarity index 99% rename from res/values-nl-rNL/strings.xml rename to app/src/main/res/values-nl-rNL/strings.xml index b5788b38..90a54a65 100644 --- a/res/values-nl-rNL/strings.xml +++ b/app/src/main/res/values-nl-rNL/strings.xml @@ -251,8 +251,6 @@ Gebruik Engels in plaats van de ingestelde systeemtaal. Hier is een herstart van de app voor nodig. Raster Lijst - Weergave seizoenen TV-series instellen - Gebruik raster- of lijstweergave om seizoenen van TV-series te tonen. Bestand verwijderen Filters Alle kijkwijzeraanduidingen diff --git a/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml similarity index 99% rename from res/values-pl/strings.xml rename to app/src/main/res/values-pl/strings.xml index 5e02371d..1c443b8b 100644 --- a/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -249,8 +249,6 @@ Ustaw język angielski zamiast języka systemowego urządzenia. Wymaga restartu urządzenia. Widok siatki Widok listy - Układ sezonów seriali - Użyj widoku siatki lub listy, aby wyświetlić sezony serialu. Usuń plik Filtry Dla wszystkich diff --git a/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml similarity index 98% rename from res/values-pt/strings.xml rename to app/src/main/res/values-pt/strings.xml index f966d7f6..ac56bfc4 100644 --- a/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -242,8 +242,6 @@ Usar a língua inglesa em vez da língua de sistema. É necessário reiniciar a aplicação. Vista em grelha Vista em lista - Definir opções de exibição das temporadas de séries - Usar uma vista de grelha ou lista para exibir as temporadas de séries. Apagar ficheiro Filtros Todas as classificações diff --git a/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml similarity index 99% rename from res/values-ro/strings.xml rename to app/src/main/res/values-ro/strings.xml index c2de1445..c3384f4e 100644 --- a/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -249,8 +249,6 @@ Utilizaţi limba engleză în loc de limba sistemului. Impune repornirea aplicaţiei. Afișare tip grilă Afișare tip listă - Aspectul pentru sezoanele serialelor - Utilizează o vizualizare grilă sau listă pentru a afişa sezoanele serialelor. Şterge fişier Filtre Toate certificările diff --git a/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml similarity index 99% rename from res/values-sv/strings.xml rename to app/src/main/res/values-sv/strings.xml index d611c481..ffca695d 100644 --- a/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -246,8 +246,6 @@ Använd engelska istället för systemspråket. Kräver omstart. Visa som rutnät Visa som lista - Utseende för säsonger - Visa säsonger som rutnät eller lista. Ta bort fil Filter Alla certifieringar diff --git a/res/values-sw540dp-land/dimens.xml b/app/src/main/res/values-sw540dp-land/dimens.xml similarity index 100% rename from res/values-sw540dp-land/dimens.xml rename to app/src/main/res/values-sw540dp-land/dimens.xml diff --git a/res/values-sw540dp/dimens.xml b/app/src/main/res/values-sw540dp/dimens.xml similarity index 100% rename from res/values-sw540dp/dimens.xml rename to app/src/main/res/values-sw540dp/dimens.xml diff --git a/res/values-sw600dp-land/integers.xml b/app/src/main/res/values-sw600dp-land/integers.xml similarity index 100% rename from res/values-sw600dp-land/integers.xml rename to app/src/main/res/values-sw600dp-land/integers.xml diff --git a/res/values-sw600dp/dimens.xml b/app/src/main/res/values-sw600dp/dimens.xml similarity index 67% rename from res/values-sw600dp/dimens.xml rename to app/src/main/res/values-sw600dp/dimens.xml index d13f6a46..e6487a95 100644 --- a/res/values-sw600dp/dimens.xml +++ b/app/src/main/res/values-sw600dp/dimens.xml @@ -56,5 +56,28 @@ 120dp 180dp + 64dp + 32dp + 424dp + 392dp + 261dp + 40sp + 8dp + 2dp + 22sp + 0dp + 24dp + 40dp + 136dp + 16sp + 20sp + 20sp + 14sp + 200dp + 300dp + -96dp + -32dp + 32dp + 16dp \ No newline at end of file diff --git a/res/values-sw720dp/dimens.xml b/app/src/main/res/values-sw720dp/dimens.xml similarity index 100% rename from res/values-sw720dp/dimens.xml rename to app/src/main/res/values-sw720dp/dimens.xml diff --git a/res/values-sw720dp/integers.xml b/app/src/main/res/values-sw720dp/integers.xml similarity index 100% rename from res/values-sw720dp/integers.xml rename to app/src/main/res/values-sw720dp/integers.xml diff --git a/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml similarity index 100% rename from res/values-tr/strings.xml rename to app/src/main/res/values-tr/strings.xml diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml new file mode 100644 index 00000000..94b2abbd --- /dev/null +++ b/app/src/main/res/values-v21/styles.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/api_keys.xml b/app/src/main/res/values/api_keys.xml new file mode 100644 index 00000000..afdabbc5 --- /dev/null +++ b/app/src/main/res/values/api_keys.xml @@ -0,0 +1,7 @@ + + + 8f5f9f44983b8af692aae5f9974500f8 + 1CB9725D261FAF38 + AIzaSyACKcfmngguy_PhREycetiispyMZ4fLPDY + b85f6110fd2522022bc53614965415bf + \ No newline at end of file diff --git a/res/values/arrays.xml b/app/src/main/res/values/arrays.xml similarity index 100% rename from res/values/arrays.xml rename to app/src/main/res/values/arrays.xml diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml new file mode 100644 index 00000000..5366ed82 --- /dev/null +++ b/app/src/main/res/values/attrs.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values/colors.xml b/app/src/main/res/values/colors.xml similarity index 71% rename from res/values/colors.xml rename to app/src/main/res/values/colors.xml index 4452dba1..051cb848 100644 --- a/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,11 +1,13 @@ - #CC336699 + #CC3f51b5 #d0d0d0 #181818 #292929 #88336699 #ffffff + #666 + #777 \ No newline at end of file diff --git a/res/values/dimens.xml b/app/src/main/res/values/dimens.xml similarity index 63% rename from res/values/dimens.xml rename to app/src/main/res/values/dimens.xml index 746d9f91..51748d2f 100644 --- a/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -59,7 +59,40 @@ 16dp 162dp - 80dp + 96dp 120dp + + 64dp + 56dp + 8dp + 6dp + + 4dp + 8dp + 48dp + + 48dp + 16dp + 240dp + 226dp + 151dp + 28sp + 4dp + 0dp + 18sp + -12dp + 12dp + 16dp + 92dp + 12sp + 16sp + 16sp + 10sp + 100dp + 150dp + -32dp + -28dp + 20dp + 8dp \ No newline at end of file diff --git a/res/values/integers.xml b/app/src/main/res/values/integers.xml similarity index 100% rename from res/values/integers.xml rename to app/src/main/res/values/integers.xml diff --git a/res/values/strings.xml b/app/src/main/res/values/strings.xml similarity index 97% rename from res/values/strings.xml rename to app/src/main/res/values/strings.xml index 1d9a1582..b7ef40a9 100644 --- a/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -17,6 +17,10 @@ episode episodes + + season + seasons + day days @@ -225,7 +229,7 @@ Upcoming In theaters Popular - Folder content + Add file source Local folder Network folder Done @@ -538,5 +542,14 @@ Known credits Background images for movies and TV shows will be blurry in landscape mode. Blur background images + Enable panning background image + Animates the background image in portrait mode. + Sign in with Trakt.tv + Logged in as %s + Use DVD ordering + Identify seasons and episodes using DVD ordering, if available. + Early access testing + Chromecast support (preview) + Enable support for casting of SMB and UPnP files. \ No newline at end of file diff --git a/res/values/styles.xml b/app/src/main/res/values/styles.xml similarity index 55% rename from res/values/styles.xml rename to app/src/main/res/values/styles.xml index d7fad23e..7f623282 100644 --- a/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,40 +1,57 @@ - - - - - - - + + - + @@ -53,40 +70,6 @@ sans-serif-light - - - - - - - - - - - + + + + \ No newline at end of file diff --git a/res/xml-sw600dp/movie_backdrop_widget_info.xml b/app/src/main/res/xml-sw600dp/movie_backdrop_widget_info.xml similarity index 100% rename from res/xml-sw600dp/movie_backdrop_widget_info.xml rename to app/src/main/res/xml-sw600dp/movie_backdrop_widget_info.xml diff --git a/res/xml-sw600dp/movie_cover_widget_info.xml b/app/src/main/res/xml-sw600dp/movie_cover_widget_info.xml similarity index 100% rename from res/xml-sw600dp/movie_cover_widget_info.xml rename to app/src/main/res/xml-sw600dp/movie_cover_widget_info.xml diff --git a/res/xml-sw600dp/movie_stack_widget_info.xml b/app/src/main/res/xml-sw600dp/movie_stack_widget_info.xml similarity index 100% rename from res/xml-sw600dp/movie_stack_widget_info.xml rename to app/src/main/res/xml-sw600dp/movie_stack_widget_info.xml diff --git a/res/xml-sw600dp/show_backdrop_widget_info.xml b/app/src/main/res/xml-sw600dp/show_backdrop_widget_info.xml similarity index 100% rename from res/xml-sw600dp/show_backdrop_widget_info.xml rename to app/src/main/res/xml-sw600dp/show_backdrop_widget_info.xml diff --git a/res/xml-sw600dp/show_cover_widget_info.xml b/app/src/main/res/xml-sw600dp/show_cover_widget_info.xml similarity index 100% rename from res/xml-sw600dp/show_cover_widget_info.xml rename to app/src/main/res/xml-sw600dp/show_cover_widget_info.xml diff --git a/res/xml-sw600dp/show_stack_widget_info.xml b/app/src/main/res/xml-sw600dp/show_stack_widget_info.xml similarity index 100% rename from res/xml-sw600dp/show_stack_widget_info.xml rename to app/src/main/res/xml-sw600dp/show_stack_widget_info.xml diff --git a/res/xml/advanced_prefs.xml b/app/src/main/res/xml/advanced_prefs.xml similarity index 84% rename from res/xml/advanced_prefs.xml rename to app/src/main/res/xml/advanced_prefs.xml index 63500e61..6206ab85 100644 --- a/res/xml/advanced_prefs.xml +++ b/app/src/main/res/xml/advanced_prefs.xml @@ -14,7 +14,7 @@ android:title="@string/confirmBackPressTitle" /> @@ -50,5 +50,13 @@ android:summary="@string/ignoreFileTypeDescription" android:title="@string/ignoreFileType" /> + + + \ No newline at end of file diff --git a/res/xml/general_prefs.xml b/app/src/main/res/xml/general_prefs.xml similarity index 95% rename from res/xml/general_prefs.xml rename to app/src/main/res/xml/general_prefs.xml index 02a8f6de..add69664 100644 --- a/res/xml/general_prefs.xml +++ b/app/src/main/res/xml/general_prefs.xml @@ -20,7 +20,7 @@ diff --git a/res/xml/identification_search_prefs.xml b/app/src/main/res/xml/identification_search_prefs.xml similarity index 90% rename from res/xml/identification_search_prefs.xml rename to app/src/main/res/xml/identification_search_prefs.xml index 5ca01d4f..bebe2015 100644 --- a/res/xml/identification_search_prefs.xml +++ b/app/src/main/res/xml/identification_search_prefs.xml @@ -2,7 +2,7 @@ @@ -32,14 +32,14 @@ @@ -88,6 +88,12 @@ android:key="prefsShowsRatingsSource" android:summary="@string/dataSourceOfShowRatings" android:title="@string/sourceForShowRatings" /> + \ No newline at end of file diff --git a/res/xml/movie_backdrop_widget_info.xml b/app/src/main/res/xml/movie_backdrop_widget_info.xml similarity index 100% rename from res/xml/movie_backdrop_widget_info.xml rename to app/src/main/res/xml/movie_backdrop_widget_info.xml diff --git a/res/xml/movie_cover_widget_info.xml b/app/src/main/res/xml/movie_cover_widget_info.xml similarity index 100% rename from res/xml/movie_cover_widget_info.xml rename to app/src/main/res/xml/movie_cover_widget_info.xml diff --git a/res/xml/movie_stack_widget_info.xml b/app/src/main/res/xml/movie_stack_widget_info.xml similarity index 100% rename from res/xml/movie_stack_widget_info.xml rename to app/src/main/res/xml/movie_stack_widget_info.xml diff --git a/res/xml/other_prefs.xml b/app/src/main/res/xml/other_prefs.xml similarity index 94% rename from res/xml/other_prefs.xml rename to app/src/main/res/xml/other_prefs.xml index a3acb022..23a20039 100644 --- a/res/xml/other_prefs.xml +++ b/app/src/main/res/xml/other_prefs.xml @@ -102,13 +102,6 @@ android:action="android.intent.action.VIEW" android:data="http://4thline.org/projects/cling/" /> - - - + android:title="PagerSlidingTabStrip by Andreas Stuetz and Javier Pardo" + android:summary="Apache License, Version 2.0"> + android:data="https://github.com/jpardogo/PagerSlidingTabStrip" /> + android:summary="Apache License, Version 2.0" + android:title="Picasso by Square, Inc." > + android:data="http://square.github.io/picasso/" />
- - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..6ace99f5 --- /dev/null +++ b/build.gradle @@ -0,0 +1,16 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + jcenter() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:0.14.2' + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/compiled versions/Mizuu v2.3.apk b/compiled versions/Mizuu v2.3.apk deleted file mode 100644 index 7802bec7..00000000 Binary files a/compiled versions/Mizuu v2.3.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.4.2.apk b/compiled versions/Mizuu_2.4.2.apk deleted file mode 100644 index 0699af81..00000000 Binary files a/compiled versions/Mizuu_2.4.2.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.4.3.apk b/compiled versions/Mizuu_2.4.3.apk deleted file mode 100644 index 3e7dd072..00000000 Binary files a/compiled versions/Mizuu_2.4.3.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.4.apk b/compiled versions/Mizuu_2.4.apk deleted file mode 100644 index 5b148a92..00000000 Binary files a/compiled versions/Mizuu_2.4.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.4_1.apk b/compiled versions/Mizuu_2.4_1.apk deleted file mode 100644 index bd84fb3d..00000000 Binary files a/compiled versions/Mizuu_2.4_1.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.5-beta1.apk b/compiled versions/Mizuu_2.5-beta1.apk deleted file mode 100644 index 7c4d788f..00000000 Binary files a/compiled versions/Mizuu_2.5-beta1.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.5-beta2.apk b/compiled versions/Mizuu_2.5-beta2.apk deleted file mode 100644 index afde5998..00000000 Binary files a/compiled versions/Mizuu_2.5-beta2.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.5-beta3.apk b/compiled versions/Mizuu_2.5-beta3.apk deleted file mode 100644 index 7b126ac5..00000000 Binary files a/compiled versions/Mizuu_2.5-beta3.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.5.1.apk b/compiled versions/Mizuu_2.5.1.apk deleted file mode 100644 index 759225d1..00000000 Binary files a/compiled versions/Mizuu_2.5.1.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.5.apk b/compiled versions/Mizuu_2.5.apk deleted file mode 100644 index 33bf145a..00000000 Binary files a/compiled versions/Mizuu_2.5.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.6-beta1.apk b/compiled versions/Mizuu_2.6-beta1.apk deleted file mode 100644 index 264e1019..00000000 Binary files a/compiled versions/Mizuu_2.6-beta1.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.6-beta2.apk b/compiled versions/Mizuu_2.6-beta2.apk deleted file mode 100644 index 86069927..00000000 Binary files a/compiled versions/Mizuu_2.6-beta2.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.6.0.1.apk b/compiled versions/Mizuu_2.6.0.1.apk deleted file mode 100644 index 5609d58b..00000000 Binary files a/compiled versions/Mizuu_2.6.0.1.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.6.0.2.apk b/compiled versions/Mizuu_2.6.0.2.apk deleted file mode 100644 index bbac45d8..00000000 Binary files a/compiled versions/Mizuu_2.6.0.2.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.6.0.3.apk b/compiled versions/Mizuu_2.6.0.3.apk deleted file mode 100644 index 8d3412f4..00000000 Binary files a/compiled versions/Mizuu_2.6.0.3.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.6.0.4.apk b/compiled versions/Mizuu_2.6.0.4.apk deleted file mode 100644 index ead7079d..00000000 Binary files a/compiled versions/Mizuu_2.6.0.4.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.6.1.apk b/compiled versions/Mizuu_2.6.1.apk deleted file mode 100644 index 4e0d2aa5..00000000 Binary files a/compiled versions/Mizuu_2.6.1.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.6.apk b/compiled versions/Mizuu_2.6.apk deleted file mode 100644 index 3222f327..00000000 Binary files a/compiled versions/Mizuu_2.6.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.7-beta1.apk b/compiled versions/Mizuu_2.7-beta1.apk deleted file mode 100644 index e0b73223..00000000 Binary files a/compiled versions/Mizuu_2.7-beta1.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.7-beta2.apk b/compiled versions/Mizuu_2.7-beta2.apk deleted file mode 100644 index 80c31cf0..00000000 Binary files a/compiled versions/Mizuu_2.7-beta2.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.7-beta3.apk b/compiled versions/Mizuu_2.7-beta3.apk deleted file mode 100644 index 561a1cc7..00000000 Binary files a/compiled versions/Mizuu_2.7-beta3.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.7-beta4.apk b/compiled versions/Mizuu_2.7-beta4.apk deleted file mode 100644 index 87b1022f..00000000 Binary files a/compiled versions/Mizuu_2.7-beta4.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.7.1.1.apk b/compiled versions/Mizuu_2.7.1.1.apk deleted file mode 100644 index df140525..00000000 Binary files a/compiled versions/Mizuu_2.7.1.1.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.7.1.2.apk b/compiled versions/Mizuu_2.7.1.2.apk deleted file mode 100644 index 2de0a9a5..00000000 Binary files a/compiled versions/Mizuu_2.7.1.2.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.7.1.3.apk b/compiled versions/Mizuu_2.7.1.3.apk deleted file mode 100644 index 7dcff2ef..00000000 Binary files a/compiled versions/Mizuu_2.7.1.3.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.7.1.apk b/compiled versions/Mizuu_2.7.1.apk deleted file mode 100644 index 9f7c7a99..00000000 Binary files a/compiled versions/Mizuu_2.7.1.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.7.apk b/compiled versions/Mizuu_2.7.apk deleted file mode 100644 index 5cc28175..00000000 Binary files a/compiled versions/Mizuu_2.7.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.8-beta.apk b/compiled versions/Mizuu_2.8-beta.apk deleted file mode 100644 index 4b40b746..00000000 Binary files a/compiled versions/Mizuu_2.8-beta.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.8.0.1.apk b/compiled versions/Mizuu_2.8.0.1.apk deleted file mode 100644 index 836799a2..00000000 Binary files a/compiled versions/Mizuu_2.8.0.1.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.8.0.2.apk b/compiled versions/Mizuu_2.8.0.2.apk deleted file mode 100644 index 6da10d71..00000000 Binary files a/compiled versions/Mizuu_2.8.0.2.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.8.0.3.apk b/compiled versions/Mizuu_2.8.0.3.apk deleted file mode 100644 index 1ee612c0..00000000 Binary files a/compiled versions/Mizuu_2.8.0.3.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.8.9.1.apk b/compiled versions/Mizuu_2.8.9.1.apk deleted file mode 100644 index 742a6092..00000000 Binary files a/compiled versions/Mizuu_2.8.9.1.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.8.9.2.apk b/compiled versions/Mizuu_2.8.9.2.apk deleted file mode 100644 index a8ab523f..00000000 Binary files a/compiled versions/Mizuu_2.8.9.2.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.8.9.apk b/compiled versions/Mizuu_2.8.9.apk deleted file mode 100644 index 291d1e10..00000000 Binary files a/compiled versions/Mizuu_2.8.9.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.8.apk b/compiled versions/Mizuu_2.8.apk deleted file mode 100644 index 5d71e3cd..00000000 Binary files a/compiled versions/Mizuu_2.8.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.9-beta1.apk b/compiled versions/Mizuu_2.9-beta1.apk deleted file mode 100644 index 9eaee70f..00000000 Binary files a/compiled versions/Mizuu_2.9-beta1.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.9-beta2.apk b/compiled versions/Mizuu_2.9-beta2.apk deleted file mode 100644 index ced4cb94..00000000 Binary files a/compiled versions/Mizuu_2.9-beta2.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.9-beta3.apk b/compiled versions/Mizuu_2.9-beta3.apk deleted file mode 100644 index c609f316..00000000 Binary files a/compiled versions/Mizuu_2.9-beta3.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.9-beta4.apk b/compiled versions/Mizuu_2.9-beta4.apk deleted file mode 100644 index 612ebc63..00000000 Binary files a/compiled versions/Mizuu_2.9-beta4.apk and /dev/null differ diff --git a/compiled versions/Mizuu_2.9-beta4_patched.apk b/compiled versions/Mizuu_2.9-beta4_patched.apk deleted file mode 100644 index e11f749a..00000000 Binary files a/compiled versions/Mizuu_2.9-beta4_patched.apk and /dev/null differ diff --git a/compiled versions/Mizuu_AppGratis.apk b/compiled versions/Mizuu_AppGratis.apk deleted file mode 100644 index b7b6a471..00000000 Binary files a/compiled versions/Mizuu_AppGratis.apk and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..8c0fb64a Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..ffaa281a --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Apr 10 15:27:10 PDT 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip diff --git a/gradlew b/gradlew new file mode 100644 index 00000000..91a7e269 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..8a0b282a --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/import-summary.txt b/import-summary.txt new file mode 100644 index 00000000..f28fdeed --- /dev/null +++ b/import-summary.txt @@ -0,0 +1,122 @@ +ECLIPSE ANDROID PROJECT IMPORT SUMMARY +====================================== + +Ignored Files: +-------------- +The following files were *not* copied into the new Gradle project; you +should evaluate whether these are still needed in your project and if +so manually move them: + +* .gitignore +* CONTRIBUTING.md +* LICENSE.txt +* README.md +* TRANSLATING.md +* compiled versions\ +* compiled versions\Mizuu v2.3.apk +* compiled versions\Mizuu_2.4.2.apk +* compiled versions\Mizuu_2.4.3.apk +* compiled versions\Mizuu_2.4.apk +* compiled versions\Mizuu_2.4_1.apk +* compiled versions\Mizuu_2.5-beta1.apk +* compiled versions\Mizuu_2.5-beta2.apk +* compiled versions\Mizuu_2.5-beta3.apk +* compiled versions\Mizuu_2.5.1.apk +* compiled versions\Mizuu_2.5.apk +* compiled versions\Mizuu_2.6-beta1.apk +* compiled versions\Mizuu_2.6-beta2.apk +* compiled versions\Mizuu_2.6.0.1.apk +* compiled versions\Mizuu_2.6.0.2.apk +* compiled versions\Mizuu_2.6.0.3.apk +* compiled versions\Mizuu_2.6.0.4.apk +* compiled versions\Mizuu_2.6.1.apk +* compiled versions\Mizuu_2.6.apk +* compiled versions\Mizuu_2.7-beta1.apk +* compiled versions\Mizuu_2.7-beta2.apk +* compiled versions\Mizuu_2.7-beta3.apk +* compiled versions\Mizuu_2.7-beta4.apk +* compiled versions\Mizuu_2.7.1.1.apk +* compiled versions\Mizuu_2.7.1.2.apk +* compiled versions\Mizuu_2.7.1.3.apk +* compiled versions\Mizuu_2.7.1.apk +* compiled versions\Mizuu_2.7.apk +* compiled versions\Mizuu_2.8-beta.apk +* compiled versions\Mizuu_2.8.0.1.apk +* compiled versions\Mizuu_2.8.0.2.apk +* compiled versions\Mizuu_2.8.0.3.apk +* compiled versions\Mizuu_2.8.9.1.apk +* compiled versions\Mizuu_2.8.9.2.apk +* compiled versions\Mizuu_2.8.9.apk +* compiled versions\Mizuu_2.8.apk +* compiled versions\Mizuu_2.9-beta1.apk +* compiled versions\Mizuu_2.9-beta2.apk +* compiled versions\Mizuu_2.9-beta3.apk +* compiled versions\Mizuu_2.9-beta4.apk +* compiled versions\Mizuu_2.9-beta4_patched.apk +* compiled versions\Mizuu_AppGratis.apk +* mizuu_logo.psd +* mizuu_logo_large.png +* new_mizuu_icon.psd +* proguard.cfg + +Replaced Jars with Dependencies: +-------------------------------- +The importer recognized the following .jar files as third party +libraries and replaced them with Gradle dependencies instead. This has +the advantage that more explicit version information is known, and the +libraries can be updated automatically. However, it is possible that +the .jar file in your project was of an older version than the +dependency we picked, which could render the project not compileable. +You can disable the jar replacement in the import wizard and try again: + +android-support-v4.jar => com.android.support:support-v4:21.0.0 +guava-16.0.1.jar => com.google.guava:guava:16.0.1 + +Potentially Missing Dependency: +------------------------------- +When we replaced the following .jar files with a Gradle dependency, we +inferred the dependency version number from the filename. This +specific version may not actually be available from the repository. +If you get a build error stating that the dependency is missing, edit +the version number to for example "+" to pick up the latest version +instead. (This may require you to update your code if the library APIs +have changed.) + +guava-16.0.1.jar => version 16.0.1 in com.google.guava:guava:16.0.1 + +Moved Files: +------------ +Android Gradle projects use a different directory structure than ADT +Eclipse projects. Here's how the projects were restructured: + +* AndroidManifest.xml => app\src\main\AndroidManifest.xml +* assets\ => app\src\main\assets\ +* bin\res\ => app\src\androidTest\res\ +* libs\cling-core-1.0.5.jar => app\libs\cling-core-1.0.5.jar +* libs\cling-support-1.0.5.jar => app\libs\cling-support-1.0.5.jar +* libs\jcifs.jar => app\libs\jcifs.jar +* libs\okhttp-2.0.0.jar => app\libs\okhttp-2.0.0.jar +* libs\okhttp-urlconnection-2.0.0.jar => app\libs\okhttp-urlconnection-2.0.0.jar +* libs\okio-1.0.1.jar => app\libs\okio-1.0.1.jar +* libs\otto-1.3.4.jar => app\libs\otto-1.3.4.jar +* libs\picasso-2.3.4.jar => app\libs\picasso-2.3.4.jar +* libs\teleal-common-1.0.13.jar => app\libs\teleal-common-1.0.13.jar +* libs\YouTubeAndroidPlayerApi.jar => app\libs\YouTubeAndroidPlayerApi.jar +* lint.xml => app\lint.xml +* res\ => app\src\main\res\ +* src\ => app\src\main\java\ + +Next Steps: +----------- +You can now build the project. The Gradle project needs network +connectivity to download dependencies. + +Bugs: +----- +If for some reason your project does not build, and you determine that +it is due to a bug or limitation of the Eclipse to Gradle importer, +please file a bug at http://b.android.com with category +Component-Tools. + +(This import summary is for your information only, and can be deleted +after import once you are satisfied with the results.) diff --git a/libs/Palette.jar b/libs/Palette.jar deleted file mode 100644 index 0dba4029..00000000 Binary files a/libs/Palette.jar and /dev/null differ diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar deleted file mode 100644 index c31cede4..00000000 Binary files a/libs/android-support-v4.jar and /dev/null differ diff --git a/libs/guava-16.0.1.jar b/libs/guava-16.0.1.jar deleted file mode 100644 index 2c8127d1..00000000 Binary files a/libs/guava-16.0.1.jar and /dev/null differ diff --git a/libs/repackaged-okhttp-2.0.0.jar b/libs/repackaged-okhttp-2.0.0.jar deleted file mode 100644 index 282d54e1..00000000 Binary files a/libs/repackaged-okhttp-2.0.0.jar and /dev/null differ diff --git a/libs/repackaged-okhttp-urlconnection-2.0.0.jar b/libs/repackaged-okhttp-urlconnection-2.0.0.jar deleted file mode 100644 index ed29110a..00000000 Binary files a/libs/repackaged-okhttp-urlconnection-2.0.0.jar and /dev/null differ diff --git a/libs/repackaged-okio-1.0.0.jar b/libs/repackaged-okio-1.0.0.jar deleted file mode 100644 index fb8567bb..00000000 Binary files a/libs/repackaged-okio-1.0.0.jar and /dev/null differ diff --git a/mizuu_logo.psd b/mizuu_logo.psd deleted file mode 100644 index 0859aef9..00000000 Binary files a/mizuu_logo.psd and /dev/null differ diff --git a/mizuu_logo_large.png b/mizuu_logo_large.png deleted file mode 100644 index 1cfb894c..00000000 Binary files a/mizuu_logo_large.png and /dev/null differ diff --git a/new_mizuu_icon.psd b/new_mizuu_icon.psd deleted file mode 100644 index 9facc73a..00000000 Binary files a/new_mizuu_icon.psd and /dev/null differ diff --git a/proguard.cfg b/proguard.cfg deleted file mode 100644 index 4dc32b10..00000000 --- a/proguard.cfg +++ /dev/null @@ -1,36 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembers class * { - native ; -} - --keepclasseswithmembers class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembers class * { - public (android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/project.properties b/project.properties deleted file mode 100644 index 7916d633..00000000 --- a/project.properties +++ /dev/null @@ -1,16 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-19 -android.library=false - -renderscript.target=19 -renderscript.support.mode=true -sdk.buildtools=20 \ No newline at end of file diff --git a/res/drawable-hdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png b/res/drawable-hdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png deleted file mode 100644 index 9871ea88..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_check_off_disabled_holo_dark.png b/res/drawable-hdpi/apptheme_btn_check_off_disabled_holo_dark.png deleted file mode 100644 index 4bcc51d5..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_check_off_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_check_off_focused_holo_dark.png b/res/drawable-hdpi/apptheme_btn_check_off_focused_holo_dark.png deleted file mode 100644 index 8e0c8ffe..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_check_off_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_check_off_holo_dark.png b/res/drawable-hdpi/apptheme_btn_check_off_holo_dark.png deleted file mode 100644 index 8a463164..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_check_off_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_check_off_pressed_holo_dark.png b/res/drawable-hdpi/apptheme_btn_check_off_pressed_holo_dark.png deleted file mode 100644 index ba389cca..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_check_off_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png b/res/drawable-hdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png deleted file mode 100644 index 55b49700..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_check_on_disabled_holo_dark.png b/res/drawable-hdpi/apptheme_btn_check_on_disabled_holo_dark.png deleted file mode 100644 index cccd61ef..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_check_on_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_check_on_focused_holo_dark.png b/res/drawable-hdpi/apptheme_btn_check_on_focused_holo_dark.png deleted file mode 100644 index 3bed8822..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_check_on_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_check_on_holo_dark.png b/res/drawable-hdpi/apptheme_btn_check_on_holo_dark.png deleted file mode 100644 index a166dc19..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_check_on_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_check_on_pressed_holo_dark.png b/res/drawable-hdpi/apptheme_btn_check_on_pressed_holo_dark.png deleted file mode 100644 index e7230558..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_check_on_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png b/res/drawable-hdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png deleted file mode 100644 index 7feb4d0b..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_radio_off_disabled_holo_dark.png b/res/drawable-hdpi/apptheme_btn_radio_off_disabled_holo_dark.png deleted file mode 100644 index eb586483..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_radio_off_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_radio_off_focused_holo_dark.png b/res/drawable-hdpi/apptheme_btn_radio_off_focused_holo_dark.png deleted file mode 100644 index 5381005a..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_radio_off_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_radio_off_holo_dark.png b/res/drawable-hdpi/apptheme_btn_radio_off_holo_dark.png deleted file mode 100644 index a4a2fc2a..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_radio_off_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_radio_off_pressed_holo_dark.png b/res/drawable-hdpi/apptheme_btn_radio_off_pressed_holo_dark.png deleted file mode 100644 index 05b150fe..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_radio_off_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png b/res/drawable-hdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png deleted file mode 100644 index dd4cb5cf..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_radio_on_disabled_holo_dark.png b/res/drawable-hdpi/apptheme_btn_radio_on_disabled_holo_dark.png deleted file mode 100644 index 6ebb1845..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_radio_on_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_radio_on_focused_holo_dark.png b/res/drawable-hdpi/apptheme_btn_radio_on_focused_holo_dark.png deleted file mode 100644 index 475bd03f..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_radio_on_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_radio_on_holo_dark.png b/res/drawable-hdpi/apptheme_btn_radio_on_holo_dark.png deleted file mode 100644 index 35ba1dda..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_radio_on_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/apptheme_btn_radio_on_pressed_holo_dark.png b/res/drawable-hdpi/apptheme_btn_radio_on_pressed_holo_dark.png deleted file mode 100644 index 196fb3b3..00000000 Binary files a/res/drawable-hdpi/apptheme_btn_radio_on_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-hdpi/menuicon.png b/res/drawable-hdpi/menuicon.png deleted file mode 100644 index 0855e4e2..00000000 Binary files a/res/drawable-hdpi/menuicon.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png b/res/drawable-mdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png deleted file mode 100644 index cc032b82..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_check_off_disabled_holo_dark.png b/res/drawable-mdpi/apptheme_btn_check_off_disabled_holo_dark.png deleted file mode 100644 index 654d449b..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_check_off_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_check_off_focused_holo_dark.png b/res/drawable-mdpi/apptheme_btn_check_off_focused_holo_dark.png deleted file mode 100644 index 4aff7364..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_check_off_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_check_off_holo_dark.png b/res/drawable-mdpi/apptheme_btn_check_off_holo_dark.png deleted file mode 100644 index 2b6c1313..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_check_off_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_check_off_pressed_holo_dark.png b/res/drawable-mdpi/apptheme_btn_check_off_pressed_holo_dark.png deleted file mode 100644 index 9a91dedf..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_check_off_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png b/res/drawable-mdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png deleted file mode 100644 index 2b0ab111..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_check_on_disabled_holo_dark.png b/res/drawable-mdpi/apptheme_btn_check_on_disabled_holo_dark.png deleted file mode 100644 index e180ea76..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_check_on_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_check_on_focused_holo_dark.png b/res/drawable-mdpi/apptheme_btn_check_on_focused_holo_dark.png deleted file mode 100644 index 8621b33c..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_check_on_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_check_on_holo_dark.png b/res/drawable-mdpi/apptheme_btn_check_on_holo_dark.png deleted file mode 100644 index 27a0ebb9..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_check_on_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_check_on_pressed_holo_dark.png b/res/drawable-mdpi/apptheme_btn_check_on_pressed_holo_dark.png deleted file mode 100644 index ebc64cb6..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_check_on_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png b/res/drawable-mdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png deleted file mode 100644 index 2ccac340..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_radio_off_disabled_holo_dark.png b/res/drawable-mdpi/apptheme_btn_radio_off_disabled_holo_dark.png deleted file mode 100644 index 20d3d772..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_radio_off_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_radio_off_focused_holo_dark.png b/res/drawable-mdpi/apptheme_btn_radio_off_focused_holo_dark.png deleted file mode 100644 index e37b5da0..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_radio_off_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_radio_off_holo_dark.png b/res/drawable-mdpi/apptheme_btn_radio_off_holo_dark.png deleted file mode 100644 index c7970a66..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_radio_off_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_radio_off_pressed_holo_dark.png b/res/drawable-mdpi/apptheme_btn_radio_off_pressed_holo_dark.png deleted file mode 100644 index 1f488863..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_radio_off_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png b/res/drawable-mdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png deleted file mode 100644 index 6646af46..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_radio_on_disabled_holo_dark.png b/res/drawable-mdpi/apptheme_btn_radio_on_disabled_holo_dark.png deleted file mode 100644 index 605af763..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_radio_on_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_radio_on_focused_holo_dark.png b/res/drawable-mdpi/apptheme_btn_radio_on_focused_holo_dark.png deleted file mode 100644 index c012dfbc..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_radio_on_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_radio_on_holo_dark.png b/res/drawable-mdpi/apptheme_btn_radio_on_holo_dark.png deleted file mode 100644 index 4206aa6f..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_radio_on_holo_dark.png and /dev/null differ diff --git a/res/drawable-mdpi/apptheme_btn_radio_on_pressed_holo_dark.png b/res/drawable-mdpi/apptheme_btn_radio_on_pressed_holo_dark.png deleted file mode 100644 index 5f367904..00000000 Binary files a/res/drawable-mdpi/apptheme_btn_radio_on_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-nodpi/Thumbs.db b/res/drawable-nodpi/Thumbs.db deleted file mode 100644 index bcf5a46f..00000000 Binary files a/res/drawable-nodpi/Thumbs.db and /dev/null differ diff --git a/res/drawable-v21/top_rounded_corner.xml b/res/drawable-v21/top_rounded_corner.xml deleted file mode 100644 index 55036a12..00000000 --- a/res/drawable-v21/top_rounded_corner.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/res/drawable-xhdpi/Thumbs.db b/res/drawable-xhdpi/Thumbs.db deleted file mode 100644 index d39fc015..00000000 Binary files a/res/drawable-xhdpi/Thumbs.db and /dev/null differ diff --git a/res/drawable-xhdpi/add.png b/res/drawable-xhdpi/add.png deleted file mode 100644 index 9daba2ed..00000000 Binary files a/res/drawable-xhdpi/add.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png deleted file mode 100644 index 0e4fe00c..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_check_off_disabled_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_check_off_disabled_holo_dark.png deleted file mode 100644 index 85ab4785..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_check_off_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_check_off_focused_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_check_off_focused_holo_dark.png deleted file mode 100644 index eb6afb08..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_check_off_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_check_off_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_check_off_holo_dark.png deleted file mode 100644 index e06ab5d8..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_check_off_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_check_off_pressed_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_check_off_pressed_holo_dark.png deleted file mode 100644 index c9584bf7..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_check_off_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png deleted file mode 100644 index dcbfe33e..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_check_on_disabled_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_check_on_disabled_holo_dark.png deleted file mode 100644 index 499147ea..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_check_on_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_check_on_focused_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_check_on_focused_holo_dark.png deleted file mode 100644 index a550e271..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_check_on_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_check_on_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_check_on_holo_dark.png deleted file mode 100644 index 9ba68209..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_check_on_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_check_on_pressed_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_check_on_pressed_holo_dark.png deleted file mode 100644 index a8741280..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_check_on_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png deleted file mode 100644 index a5c818aa..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_radio_off_disabled_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_radio_off_disabled_holo_dark.png deleted file mode 100644 index aa5f830b..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_radio_off_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_radio_off_focused_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_radio_off_focused_holo_dark.png deleted file mode 100644 index 93c010d4..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_radio_off_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_radio_off_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_radio_off_holo_dark.png deleted file mode 100644 index f02cf03a..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_radio_off_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_radio_off_pressed_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_radio_off_pressed_holo_dark.png deleted file mode 100644 index f37b9e8d..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_radio_off_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png deleted file mode 100644 index 953c0917..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_radio_on_disabled_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_radio_on_disabled_holo_dark.png deleted file mode 100644 index 346909d3..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_radio_on_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_radio_on_focused_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_radio_on_focused_holo_dark.png deleted file mode 100644 index 980bdad2..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_radio_on_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_radio_on_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_radio_on_holo_dark.png deleted file mode 100644 index 4fcae0fe..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_radio_on_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/apptheme_btn_radio_on_pressed_holo_dark.png b/res/drawable-xhdpi/apptheme_btn_radio_on_pressed_holo_dark.png deleted file mode 100644 index 4d85a316..00000000 Binary files a/res/drawable-xhdpi/apptheme_btn_radio_on_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-xhdpi/delete.png b/res/drawable-xhdpi/delete.png deleted file mode 100644 index 4a9ae826..00000000 Binary files a/res/drawable-xhdpi/delete.png and /dev/null differ diff --git a/res/drawable-xhdpi/done.png b/res/drawable-xhdpi/done.png deleted file mode 100644 index 7b73d54d..00000000 Binary files a/res/drawable-xhdpi/done.png and /dev/null differ diff --git a/res/drawable-xhdpi/fav.png b/res/drawable-xhdpi/fav.png deleted file mode 100644 index b66231ec..00000000 Binary files a/res/drawable-xhdpi/fav.png and /dev/null differ diff --git a/res/drawable-xhdpi/ic_action_filter.png b/res/drawable-xhdpi/ic_action_filter.png deleted file mode 100644 index 4c57dc57..00000000 Binary files a/res/drawable-xhdpi/ic_action_filter.png and /dev/null differ diff --git a/res/drawable-xhdpi/ic_action_overflow_round.png b/res/drawable-xhdpi/ic_action_overflow_round.png deleted file mode 100644 index 12832c89..00000000 Binary files a/res/drawable-xhdpi/ic_action_overflow_round.png and /dev/null differ diff --git a/res/drawable-xhdpi/ic_arrow_back.png b/res/drawable-xhdpi/ic_arrow_back.png deleted file mode 100644 index 46e9362d..00000000 Binary files a/res/drawable-xhdpi/ic_arrow_back.png and /dev/null differ diff --git a/res/drawable-xhdpi/localizedinfo.png b/res/drawable-xhdpi/localizedinfo.png deleted file mode 100644 index 4893a052..00000000 Binary files a/res/drawable-xhdpi/localizedinfo.png and /dev/null differ diff --git a/res/drawable-xhdpi/menuicon.png b/res/drawable-xhdpi/menuicon.png deleted file mode 100644 index 7fd0c6f7..00000000 Binary files a/res/drawable-xhdpi/menuicon.png and /dev/null differ diff --git a/res/drawable-xhdpi/refresh.png b/res/drawable-xhdpi/refresh.png deleted file mode 100644 index 83b9df21..00000000 Binary files a/res/drawable-xhdpi/refresh.png and /dev/null differ diff --git a/res/drawable-xhdpi/search.png b/res/drawable-xhdpi/search.png deleted file mode 100644 index 97dc17c8..00000000 Binary files a/res/drawable-xhdpi/search.png and /dev/null differ diff --git a/res/drawable-xhdpi/settings_small.png b/res/drawable-xhdpi/settings_small.png deleted file mode 100644 index d532dd3e..00000000 Binary files a/res/drawable-xhdpi/settings_small.png and /dev/null differ diff --git a/res/drawable-xhdpi/share.png b/res/drawable-xhdpi/share.png deleted file mode 100644 index 168481f0..00000000 Binary files a/res/drawable-xhdpi/share.png and /dev/null differ diff --git a/res/drawable-xhdpi/sort.png b/res/drawable-xhdpi/sort.png deleted file mode 100644 index 4efc20bb..00000000 Binary files a/res/drawable-xhdpi/sort.png and /dev/null differ diff --git a/res/drawable-xhdpi/support_small.png b/res/drawable-xhdpi/support_small.png deleted file mode 100644 index 9ede9476..00000000 Binary files a/res/drawable-xhdpi/support_small.png and /dev/null differ diff --git a/res/drawable-xhdpi/watchlist_add.png b/res/drawable-xhdpi/watchlist_add.png deleted file mode 100644 index 4830aaa6..00000000 Binary files a/res/drawable-xhdpi/watchlist_add.png and /dev/null differ diff --git a/res/drawable-xhdpi/watchlist_remove.png b/res/drawable-xhdpi/watchlist_remove.png deleted file mode 100644 index cf81b55e..00000000 Binary files a/res/drawable-xhdpi/watchlist_remove.png and /dev/null differ diff --git a/res/drawable-xxhdpi/add.png b/res/drawable-xxhdpi/add.png deleted file mode 100644 index 2fc67807..00000000 Binary files a/res/drawable-xxhdpi/add.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png deleted file mode 100644 index f555ca71..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_check_off_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_check_off_disabled_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_check_off_disabled_holo_dark.png deleted file mode 100644 index e74b8b70..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_check_off_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_check_off_focused_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_check_off_focused_holo_dark.png deleted file mode 100644 index 7329ae78..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_check_off_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_check_off_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_check_off_holo_dark.png deleted file mode 100644 index 28c341ca..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_check_off_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_check_off_pressed_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_check_off_pressed_holo_dark.png deleted file mode 100644 index 62558bb5..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_check_off_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png deleted file mode 100644 index dd123124..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_check_on_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_check_on_disabled_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_check_on_disabled_holo_dark.png deleted file mode 100644 index eff125b5..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_check_on_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_check_on_focused_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_check_on_focused_holo_dark.png deleted file mode 100644 index 6a1933d1..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_check_on_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_check_on_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_check_on_holo_dark.png deleted file mode 100644 index 1212b602..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_check_on_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_check_on_pressed_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_check_on_pressed_holo_dark.png deleted file mode 100644 index e9aa870d..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_check_on_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png deleted file mode 100644 index b6f5ee09..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_radio_off_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_radio_off_disabled_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_radio_off_disabled_holo_dark.png deleted file mode 100644 index 946936e5..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_radio_off_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_radio_off_focused_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_radio_off_focused_holo_dark.png deleted file mode 100644 index 0aa72e9e..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_radio_off_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_radio_off_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_radio_off_holo_dark.png deleted file mode 100644 index a6e87004..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_radio_off_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_radio_off_pressed_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_radio_off_pressed_holo_dark.png deleted file mode 100644 index 37b50b0b..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_radio_off_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png deleted file mode 100644 index 6e92a04b..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_radio_on_disabled_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_radio_on_disabled_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_radio_on_disabled_holo_dark.png deleted file mode 100644 index 66b833d6..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_radio_on_disabled_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_radio_on_focused_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_radio_on_focused_holo_dark.png deleted file mode 100644 index 77e49a47..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_radio_on_focused_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_radio_on_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_radio_on_holo_dark.png deleted file mode 100644 index ccde05b8..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_radio_on_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/apptheme_btn_radio_on_pressed_holo_dark.png b/res/drawable-xxhdpi/apptheme_btn_radio_on_pressed_holo_dark.png deleted file mode 100644 index 7a8fbd53..00000000 Binary files a/res/drawable-xxhdpi/apptheme_btn_radio_on_pressed_holo_dark.png and /dev/null differ diff --git a/res/drawable-xxhdpi/delete.png b/res/drawable-xxhdpi/delete.png deleted file mode 100644 index 727775c0..00000000 Binary files a/res/drawable-xxhdpi/delete.png and /dev/null differ diff --git a/res/drawable-xxhdpi/done.png b/res/drawable-xxhdpi/done.png deleted file mode 100644 index 32b3d365..00000000 Binary files a/res/drawable-xxhdpi/done.png and /dev/null differ diff --git a/res/drawable-xxhdpi/fav.png b/res/drawable-xxhdpi/fav.png deleted file mode 100644 index e71b5250..00000000 Binary files a/res/drawable-xxhdpi/fav.png and /dev/null differ diff --git a/res/drawable-xxhdpi/ic_action_filter.png b/res/drawable-xxhdpi/ic_action_filter.png deleted file mode 100644 index 4ccad6be..00000000 Binary files a/res/drawable-xxhdpi/ic_action_filter.png and /dev/null differ diff --git a/res/drawable-xxhdpi/ic_action_overflow_round.png b/res/drawable-xxhdpi/ic_action_overflow_round.png deleted file mode 100644 index bd7c8bdc..00000000 Binary files a/res/drawable-xxhdpi/ic_action_overflow_round.png and /dev/null differ diff --git a/res/drawable-xxhdpi/ic_arrow_back.png b/res/drawable-xxhdpi/ic_arrow_back.png deleted file mode 100644 index 50b15bf9..00000000 Binary files a/res/drawable-xxhdpi/ic_arrow_back.png and /dev/null differ diff --git a/res/drawable-xxhdpi/localizedinfo.png b/res/drawable-xxhdpi/localizedinfo.png deleted file mode 100644 index e045a962..00000000 Binary files a/res/drawable-xxhdpi/localizedinfo.png and /dev/null differ diff --git a/res/drawable-xxhdpi/menuicon.png b/res/drawable-xxhdpi/menuicon.png deleted file mode 100644 index c9a2837f..00000000 Binary files a/res/drawable-xxhdpi/menuicon.png and /dev/null differ diff --git a/res/drawable-xxhdpi/refresh.png b/res/drawable-xxhdpi/refresh.png deleted file mode 100644 index 522517fe..00000000 Binary files a/res/drawable-xxhdpi/refresh.png and /dev/null differ diff --git a/res/drawable-xxhdpi/search.png b/res/drawable-xxhdpi/search.png deleted file mode 100644 index 5505a05c..00000000 Binary files a/res/drawable-xxhdpi/search.png and /dev/null differ diff --git a/res/drawable-xxhdpi/settings_small.png b/res/drawable-xxhdpi/settings_small.png deleted file mode 100644 index 810095e5..00000000 Binary files a/res/drawable-xxhdpi/settings_small.png and /dev/null differ diff --git a/res/drawable-xxhdpi/share.png b/res/drawable-xxhdpi/share.png deleted file mode 100644 index 60320a73..00000000 Binary files a/res/drawable-xxhdpi/share.png and /dev/null differ diff --git a/res/drawable-xxhdpi/sort.png b/res/drawable-xxhdpi/sort.png deleted file mode 100644 index 801bf9b2..00000000 Binary files a/res/drawable-xxhdpi/sort.png and /dev/null differ diff --git a/res/drawable-xxhdpi/support_small.png b/res/drawable-xxhdpi/support_small.png deleted file mode 100644 index 4cc2480f..00000000 Binary files a/res/drawable-xxhdpi/support_small.png and /dev/null differ diff --git a/res/drawable-xxhdpi/watchlist_add.png b/res/drawable-xxhdpi/watchlist_add.png deleted file mode 100644 index 1500518a..00000000 Binary files a/res/drawable-xxhdpi/watchlist_add.png and /dev/null differ diff --git a/res/drawable-xxhdpi/watchlist_remove.png b/res/drawable-xxhdpi/watchlist_remove.png deleted file mode 100644 index 7c08782c..00000000 Binary files a/res/drawable-xxhdpi/watchlist_remove.png and /dev/null differ diff --git a/res/drawable/btn_check_holo_dark.xml b/res/drawable/btn_check_holo_dark.xml deleted file mode 100644 index 5f6593eb..00000000 --- a/res/drawable/btn_check_holo_dark.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/drawable/btn_radio_holo_dark.xml b/res/drawable/btn_radio_holo_dark.xml deleted file mode 100644 index f06d56ee..00000000 --- a/res/drawable/btn_radio_holo_dark.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/layout-land/actor_bio.xml b/res/layout-land/actor_bio.xml deleted file mode 100644 index dc9b0b3d..00000000 --- a/res/layout-land/actor_bio.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout-land/actor_details.xml b/res/layout-land/actor_details.xml deleted file mode 100644 index 48bcc8c4..00000000 --- a/res/layout-land/actor_details.xml +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout-land/movie_and_tv_show_details.xml b/res/layout-land/movie_and_tv_show_details.xml deleted file mode 100644 index 6c53e43f..00000000 --- a/res/layout-land/movie_and_tv_show_details.xml +++ /dev/null @@ -1,265 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout-land/show_details.xml b/res/layout-land/show_details.xml deleted file mode 100644 index 4d623daf..00000000 --- a/res/layout-land/show_details.xml +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout-sw600dp-land/actor_bio.xml b/res/layout-sw600dp-land/actor_bio.xml deleted file mode 100644 index 5fc8f1fa..00000000 --- a/res/layout-sw600dp-land/actor_bio.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout-sw600dp/add_file_source.xml b/res/layout-sw600dp/add_file_source.xml deleted file mode 100644 index 55b04df0..00000000 --- a/res/layout-sw600dp/add_file_source.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/res/layout-sw600dp/edit_movie.xml b/res/layout-sw600dp/edit_movie.xml deleted file mode 100644 index 57e79ab1..00000000 --- a/res/layout-sw600dp/edit_movie.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/res/layout-sw600dp/filesources_layout.xml b/res/layout-sw600dp/filesources_layout.xml deleted file mode 100644 index f39a88fc..00000000 --- a/res/layout-sw600dp/filesources_layout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/res/layout-sw600dp/unidentified_files_layout.xml b/res/layout-sw600dp/unidentified_files_layout.xml deleted file mode 100644 index b9bdfd33..00000000 --- a/res/layout-sw600dp/unidentified_files_layout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/res/layout-sw600dp/update_layout.xml b/res/layout-sw600dp/update_layout.xml deleted file mode 100644 index 4fccd768..00000000 --- a/res/layout-sw600dp/update_layout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/res/layout-sw720dp-land/show_details.xml b/res/layout-sw720dp-land/show_details.xml deleted file mode 100644 index 51e69e87..00000000 --- a/res/layout-sw720dp-land/show_details.xml +++ /dev/null @@ -1,225 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout/actor_bio.xml b/res/layout/actor_bio.xml deleted file mode 100644 index 2cc0a746..00000000 --- a/res/layout/actor_bio.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout/actor_details.xml b/res/layout/actor_details.xml deleted file mode 100644 index be3cc8c9..00000000 --- a/res/layout/actor_details.xml +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout/add_file_source.xml b/res/layout/add_file_source.xml deleted file mode 100644 index f01572c8..00000000 --- a/res/layout/add_file_source.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/res/layout/horizontal_grid_item_small.xml b/res/layout/horizontal_grid_item_small.xml deleted file mode 100644 index 6a6af80c..00000000 --- a/res/layout/horizontal_grid_item_small.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/res/layout/identify_movie_and_tv_show.xml b/res/layout/identify_movie_and_tv_show.xml deleted file mode 100644 index a5df4fad..00000000 --- a/res/layout/identify_movie_and_tv_show.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/res/layout/menu_drawer_header.xml b/res/layout/menu_drawer_header.xml deleted file mode 100644 index 99fbe1d8..00000000 --- a/res/layout/menu_drawer_header.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout/menu_drawer_header_item.xml b/res/layout/menu_drawer_header_item.xml deleted file mode 100644 index e544ac70..00000000 --- a/res/layout/menu_drawer_header_item.xml +++ /dev/null @@ -1,8 +0,0 @@ - - \ No newline at end of file diff --git a/res/layout/menu_drawer_item.xml b/res/layout/menu_drawer_item.xml deleted file mode 100644 index 20b13db2..00000000 --- a/res/layout/menu_drawer_item.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/res/layout/menu_drawer_small_item.xml b/res/layout/menu_drawer_small_item.xml deleted file mode 100644 index ce3b26fd..00000000 --- a/res/layout/menu_drawer_small_item.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout/movie_and_tv_show_details.xml b/res/layout/movie_and_tv_show_details.xml deleted file mode 100644 index 6a2ca339..00000000 --- a/res/layout/movie_and_tv_show_details.xml +++ /dev/null @@ -1,274 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout/show_details.xml b/res/layout/show_details.xml deleted file mode 100644 index 77b75de1..00000000 --- a/res/layout/show_details.xml +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout/viewpager_with_tabs.xml b/res/layout/viewpager_with_tabs.xml deleted file mode 100644 index 9c43f1af..00000000 --- a/res/layout/viewpager_with_tabs.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/res/menu/filebrowser.xml b/res/menu/filebrowser.xml deleted file mode 100644 index 105e983d..00000000 --- a/res/menu/filebrowser.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/res/menu/remote_playback.xml b/res/menu/remote_playback.xml deleted file mode 100644 index bf810183..00000000 --- a/res/menu/remote_playback.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - diff --git a/res/values-v19/styles.xml b/res/values-v19/styles.xml deleted file mode 100644 index d0ae382b..00000000 --- a/res/values-v19/styles.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/res/values/attrs.xml b/res/values/attrs.xml deleted file mode 100644 index 51cb6a45..00000000 --- a/res/values/attrs.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..e7b4def4 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/src/com/miz/db/DbAdapterMovies.java b/src/com/miz/db/DbAdapterMovies.java deleted file mode 100644 index 1e90ca03..00000000 --- a/src/com/miz/db/DbAdapterMovies.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.db; - -import java.util.ArrayList; - -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.database.SQLException; -import android.text.TextUtils; - -import com.miz.mizuu.MizuuApplication; - -public class DbAdapterMovies extends AbstractDbAdapter { - - // Database fields - public static final String KEY_TMDB_ID = "tmdbid"; // Unidentified movies and .nfo files without TMDb ID use the filepath - public static final String KEY_TITLE = "title"; - public static final String KEY_PLOT = "plot"; - public static final String KEY_IMDB_ID = "imdbid"; - public static final String KEY_RATING = "rating"; - public static final String KEY_TAGLINE = "tagline"; - public static final String KEY_RELEASEDATE = "release"; - public static final String KEY_CERTIFICATION = "certification"; - public static final String KEY_RUNTIME = "runtime"; - public static final String KEY_TRAILER = "trailer"; - public static final String KEY_GENRES = "genres"; - public static final String KEY_FAVOURITE = "favourite"; - public static final String KEY_ACTORS = "actors"; - public static final String KEY_COLLECTION_ID = "collection_id"; - public static final String KEY_TO_WATCH = "to_watch"; - public static final String KEY_HAS_WATCHED = "has_watched"; - public static final String KEY_DATE_ADDED = "date_added"; - - public static final String DATABASE_TABLE = "movie"; - - public static final String UNIDENTIFIED_ID = "invalid"; - public static final String REMOVED_MOVIE_TITLE = "MIZ_REMOVED_MOVIE"; - - public static final String[] SELECT_ALL = new String[] {KEY_TMDB_ID, KEY_TITLE, KEY_PLOT, KEY_IMDB_ID, KEY_RATING, KEY_TAGLINE, KEY_RELEASEDATE, KEY_CERTIFICATION, - KEY_RUNTIME, KEY_TRAILER, KEY_GENRES, KEY_FAVOURITE, KEY_ACTORS, KEY_COLLECTION_ID, KEY_TO_WATCH, KEY_HAS_WATCHED, KEY_DATE_ADDED}; - - public DbAdapterMovies(Context context) { - super(context); - } - - /** - * Create a new movie - */ - public void createMovie(String tmdbid, String title, String plot, String imdbid, String rating, String tagline, String release, - String certification, String runtime, String trailer, String genres, String favourite, String actors, String collection, - String collectionId, String toWatch, String hasWatched, String date) { - - if (tmdbid.equals(UNIDENTIFIED_ID)) - return; // We're not interesting in adding this to the movie database - - if (movieExists(tmdbid)) - return; // It already exists, let's not create it again - - ContentValues initialValues = createContentValues(tmdbid, title, plot, imdbid, rating, tagline, release, certification, runtime, trailer, genres, favourite, actors, collectionId, toWatch, hasWatched, date, true); - mDatabase.insert(DATABASE_TABLE, null, initialValues); - - MizuuApplication.getCollectionsAdapter().createCollection(collectionId, collection); - } - - public void createOrUpdateMovie(String tmdbid, String title, String plot, String imdbid, String rating, String tagline, String release, - String certification, String runtime, String trailer, String genres, String favourite, String actors, String collection, - String collectionId, String toWatch, String hasWatched, String date) { - if (movieExists(tmdbid)) { - // It already exists - let's update it while keeping - // favourite, watchlist and watched status data intact - updateMovie(tmdbid, title, plot, imdbid, rating, tagline, release, certification, runtime, trailer, genres, - actors, collection, collectionId, date); - } else { - // It doesn't exist! Let's create it - createMovie(tmdbid, title, plot, imdbid, rating, tagline, release, certification, runtime, trailer, genres, - favourite, actors, collection, collectionId, toWatch, hasWatched, date); - } - } - - /** - * Update the movie - */ - public boolean updateMovie(String tmdbid, String title, String plot, String imdbid, String rating, String tagline, String release, - String certification, String runtime, String trailer, String genres, String actors, String collection, String collectionId, String date) { - - ContentValues updateValues = createUpdateContentValues(title, plot, imdbid, rating, tagline, release, certification, - runtime, trailer, genres, actors, collectionId, date); - - return mDatabase.update(DATABASE_TABLE, updateValues, KEY_TMDB_ID + " = ?", new String[]{tmdbid}) > 0 && - MizuuApplication.getCollectionsAdapter().createCollection(collectionId, collectionId) > 0; - } - - public boolean updateMovieSingleItem(String tmdbId, String column, String value) { - ContentValues values = new ContentValues(); - values.put(column, value); - - return mDatabase.update(DATABASE_TABLE, values, KEY_TMDB_ID + " = ?", new String[]{tmdbId}) > 0; - } - - /** - * Update the movie - */ - public boolean editUpdateMovie(String tmdbId, String title, String plot, String rating, String tagline, String release, - String certification, String runtime, String genres, String toWatch, String hasWatched, String date) { - ContentValues updateValues = createEditContentValues(title, plot, rating, tagline, release, certification, runtime, genres, toWatch, hasWatched, date); - return mDatabase.update(DATABASE_TABLE, updateValues, KEY_TMDB_ID + " = ?", new String[]{tmdbId}) > 0; - } - - public boolean editMovie(String movieId, String title, String tagline, String description, - String genres, String runtime, String rating, String releaseDate, String certification) { - ContentValues cv = new ContentValues(); - cv.put(KEY_TITLE, title); - cv.put(KEY_PLOT, description); - cv.put(KEY_RATING, rating); - cv.put(KEY_TAGLINE, tagline); - cv.put(KEY_RELEASEDATE, releaseDate); - cv.put(KEY_CERTIFICATION, certification); - cv.put(KEY_RUNTIME, runtime); - cv.put(KEY_GENRES, genres); - return mDatabase.update(DATABASE_TABLE, cv, KEY_TMDB_ID + " = ?", new String[]{movieId}) > 0; - } - - /** - * Marks movie as ignored - */ - public boolean ignoreMovie(String tmdbId) { - boolean result = updateMovieSingleItem(tmdbId, KEY_TITLE, REMOVED_MOVIE_TITLE); - return result && MizuuApplication.getMovieMappingAdapter().ignoreMovie(tmdbId); - } - - /** - * Deletes movie - */ - public boolean deleteMovie(String tmdbId) { - boolean result = mDatabase.delete(DATABASE_TABLE, KEY_TMDB_ID + " = ?", new String[]{tmdbId}) > 0; - - // When deleting a movie, check if there's other movies - // linked to the collection - if not, delete the collection entry - String collectionId = getCollectionId(tmdbId); - if (!hasMultipleCollectionMappings(collectionId)) - result = result && MizuuApplication.getCollectionsAdapter().deleteCollection(collectionId); - - return result && MizuuApplication.getMovieMappingAdapter().deleteMovie(tmdbId); - } - - public boolean deleteAllMovies() { - return mDatabase.delete(DATABASE_TABLE, null, null) > 0; - } - - public String getCollectionId(String tmdbId) { - Cursor cursor = mDatabase.query(DATABASE_TABLE, SELECT_ALL, KEY_TMDB_ID + " = ?", new String[]{tmdbId}, null, null, null); - String collectionId = ""; - - if (cursor != null) { - try { - if (cursor.moveToFirst()) { - collectionId = cursor.getString(cursor.getColumnIndex(KEY_COLLECTION_ID)); - } - } catch (Exception e) { - } finally { - cursor.close(); - } - } - - return collectionId; - } - - public boolean hasMultipleCollectionMappings(String collectionId) { - Cursor cursor = mDatabase.query(DATABASE_TABLE, SELECT_ALL, KEY_COLLECTION_ID + " = ?", new String[]{collectionId}, null, null, null); - boolean result = false; - - if (cursor != null) { - try { - if (cursor.getCount() > 1) - result = true; - } catch (Exception e) { - } finally { - cursor.close(); - } - } - - return result; - } - - /** - * Return a Cursor over the list of all movies in the database - */ - public Cursor fetchAllMovies(String sort, boolean includeRemoved) { - return mDatabase.query(DATABASE_TABLE, SELECT_ALL, includeRemoved ? null : "NOT(" + KEY_TITLE + " = '" + REMOVED_MOVIE_TITLE + "')", null, null, null, sort); - } - - public Cursor getAllIgnoredMovies() { - return mDatabase.query(DATABASE_TABLE, SELECT_ALL, KEY_TITLE + " = '" + REMOVED_MOVIE_TITLE + "'", null, null, null, null); - } - - /** - * Return a Cursor over the list of all genres in the database - */ - public Cursor fetchAllGenres() { - return mDatabase.query(DATABASE_TABLE, SELECT_ALL, null, null, KEY_GENRES, null, KEY_GENRES + " ASC"); - } - - public Cursor fetchMovie(String movieId) throws SQLException { - Cursor cursor = mDatabase.query(DATABASE_TABLE, SELECT_ALL, KEY_TMDB_ID + " = ?", new String[]{movieId}, null, null, null, null); - if (cursor != null) { - cursor.moveToFirst(); - } - return cursor; - } - - public boolean movieExists(String movieId) { - Cursor mCursor = mDatabase.query(DATABASE_TABLE, SELECT_ALL, KEY_TMDB_ID + " = ?", new String[]{movieId}, null, null, null, null); - if (mCursor == null) - return false; - try { - if (mCursor.getCount() == 0) { - mCursor.close(); - return false; - } - } catch (Exception e) { - mCursor.close(); - return false; - } - - mCursor.close(); - return true; - } - - private ContentValues createContentValues(String tmdbid, String title, - String plot, String imdbid, String rating, String tagline, String release, - String certification, String runtime, String trailer, String genres, String favourite, String actors, - String collectionId, String toWatch, String hasWatched, String date, boolean includeTmdbId) { - ContentValues values = new ContentValues(); - values.put(KEY_TITLE, title); - values.put(KEY_PLOT, plot); - if (includeTmdbId) - values.put(KEY_TMDB_ID, tmdbid); - values.put(KEY_IMDB_ID, imdbid); - values.put(KEY_RATING, rating); - values.put(KEY_TAGLINE, tagline); - values.put(KEY_RELEASEDATE, release); - values.put(KEY_CERTIFICATION, certification); - values.put(KEY_RUNTIME, runtime); - values.put(KEY_TRAILER, trailer); - values.put(KEY_GENRES, genres); - values.put(KEY_FAVOURITE, favourite); - values.put(KEY_ACTORS, actors); - values.put(KEY_COLLECTION_ID, collectionId); - values.put(KEY_TO_WATCH, toWatch); - values.put(KEY_HAS_WATCHED, hasWatched); - values.put(KEY_DATE_ADDED, date); - return values; - } - - private ContentValues createUpdateContentValues(String title, String plot, String imdbid, - String rating, String tagline, String release, String certification, String runtime, - String trailer, String genres, String actors, String collectionId, String date) { - ContentValues values = new ContentValues(); - values.put(KEY_TITLE, title); - values.put(KEY_PLOT, plot); - values.put(KEY_IMDB_ID, imdbid); - values.put(KEY_RATING, rating); - values.put(KEY_TAGLINE, tagline); - values.put(KEY_RELEASEDATE, release); - values.put(KEY_CERTIFICATION, certification); - values.put(KEY_RUNTIME, runtime); - values.put(KEY_TRAILER, trailer); - values.put(KEY_GENRES, genres); - values.put(KEY_ACTORS, actors); - values.put(KEY_COLLECTION_ID, collectionId); - values.put(KEY_DATE_ADDED, date); - return values; - } - - private ContentValues createEditContentValues(String title, String plot, String rating, String tagline, - String release, String certification, String runtime, String genres, String toWatch, String hasWatched, String date) { - ContentValues values = new ContentValues(); - values.put(KEY_TITLE, title); - values.put(KEY_PLOT, plot); - values.put(KEY_RATING, rating); - values.put(KEY_TAGLINE, tagline); - values.put(KEY_RELEASEDATE, release); - values.put(KEY_CERTIFICATION, certification); - values.put(KEY_RUNTIME, runtime); - values.put(KEY_GENRES, genres); - values.put(KEY_TO_WATCH, toWatch); - values.put(KEY_HAS_WATCHED, hasWatched); - values.put(KEY_DATE_ADDED, date); - return values; - } - - public int count() { - Cursor c = mDatabase.query(DATABASE_TABLE, new String[]{KEY_TITLE, KEY_TMDB_ID}, "NOT(" + KEY_TITLE + " = '" + REMOVED_MOVIE_TITLE + "') AND NOT(" + KEY_TMDB_ID + " = '" + UNIDENTIFIED_ID + "')", null, null, null, null); - int count = c.getCount(); - c.close(); - return count; - } - - public int countWatchlist() { - Cursor c = mDatabase.query(DATABASE_TABLE, new String[] {KEY_TO_WATCH}, KEY_TO_WATCH + " = '1' AND NOT(" + KEY_TITLE + " = '" + REMOVED_MOVIE_TITLE + "')", null, null, null, null); - int count = c.getCount(); - c.close(); - return count; - } - - public ArrayList getCertifications() { - ArrayList certifications = new ArrayList(); - Cursor cursor = mDatabase.query(DATABASE_TABLE, new String[]{KEY_CERTIFICATION}, null, null, KEY_CERTIFICATION, null, null); - - if (cursor != null) { - try { - while (cursor.moveToNext()) { - String certification = cursor.getString(cursor.getColumnIndex(KEY_CERTIFICATION)); - if (!TextUtils.isEmpty(certification)) - certifications.add(certification); - } - } catch (Exception e) { - } finally { - cursor.close(); - } - } - - return certifications; - } -} \ No newline at end of file diff --git a/src/com/miz/mizuu/Main.java b/src/com/miz/mizuu/Main.java deleted file mode 100644 index dc5b93ce..00000000 --- a/src/com/miz/mizuu/Main.java +++ /dev/null @@ -1,540 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.mizuu; - -import static com.miz.functions.PreferenceKeys.CONFIRM_BACK_PRESS; -import static com.miz.functions.PreferenceKeys.STARTUP_SELECTION; -import static com.miz.functions.PreferenceKeys.TRAKT_FULL_NAME; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import android.annotation.SuppressLint; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.SharedPreferences; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.res.Configuration; -import android.graphics.Typeface; -import android.os.Bundle; -import android.preference.PreferenceActivity; -import android.preference.PreferenceManager; -import android.support.v4.app.ActionBarDrawerToggle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentTransaction; -import android.support.v4.content.LocalBroadcastManager; -import android.support.v4.view.GravityCompat; -import android.support.v4.widget.DrawerLayout; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.BaseAdapter; -import android.widget.ImageView; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; - -import com.miz.base.MizActivity; -import com.miz.db.DbAdapterMovies; -import com.miz.db.DbAdapterTvShows; -import com.miz.functions.MenuItem; -import com.miz.functions.MizLib; -import com.miz.mizuu.fragments.ContactDeveloperFragment; -import com.miz.mizuu.fragments.MovieDiscoveryViewPagerFragment; -import com.miz.mizuu.fragments.MovieLibraryFragment; -import com.miz.mizuu.fragments.TvShowLibraryFragment; -import com.miz.mizuu.fragments.WebVideosViewPagerFragment; -import com.miz.utils.LocalBroadcastUtils; -import com.squareup.picasso.Picasso; - -@SuppressLint("NewApi") -public class Main extends MizActivity { - - public static final int MOVIES = 1, SHOWS = 2, WATCHLIST = 3, WEB_MOVIES = 4, WEB_VIDEOS = 5; - private int mNumMovies, mNumShows, mNumWatchlist, selectedIndex, mStartup; - private Typeface mTfMedium, mTfCondensed, mTfLight; - private DrawerLayout mDrawerLayout; - protected ListView mDrawerList; - private ActionBarDrawerToggle mDrawerToggle; - private DbAdapterMovies mDbHelper; - private DbAdapterTvShows mDbHelperTv; - private boolean mConfirmExit, mTriedOnce = false; - private ArrayList mMenuItems = new ArrayList(); - private List mApplicationList; - private Picasso mPicasso; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - MizuuApplication.setupTheme(this); - - setContentView(R.layout.menu_drawer); - - mPicasso = MizuuApplication.getPicasso(getApplicationContext()); - - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); - mConfirmExit = settings.getBoolean(CONFIRM_BACK_PRESS, false); - mStartup = Integer.valueOf(settings.getString(STARTUP_SELECTION, "1")); - - mDbHelper = MizuuApplication.getMovieAdapter(); - mDbHelperTv = MizuuApplication.getTvDbAdapter(); - - mTfCondensed = MizuuApplication.getOrCreateTypeface(getApplicationContext(), "RobotoCondensed-Regular.ttf"); - mTfMedium = MizuuApplication.getOrCreateTypeface(getApplicationContext(), "Roboto-Medium.ttf"); - mTfLight = MizuuApplication.getOrCreateTypeface(getApplicationContext(), "Roboto-Light.ttf"); - - setupMenuItems(true); - - mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); - mDrawerLayout.setDrawerShadow(R.drawable.drawer_list_shadow, GravityCompat.START); - - mDrawerList = (ListView) findViewById(R.id.listView1); - mDrawerList.setAdapter(new MenuAdapter()); - mDrawerList.setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { - switch (mMenuItems.get(arg2).getType()) { - case MenuItem.SECTION: - loadFragment(mMenuItems.get(arg2).getFragment()); - break; - case MenuItem.THIRD_PARTY_APP: - final PackageManager pm = getPackageManager(); - Intent i = pm.getLaunchIntentForPackage(mMenuItems.get(arg2).getPackageName()); - if (i != null) { - i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(i); - } - break; - case MenuItem.SMALL_SECTION: - - Intent smallIntent = new Intent(getApplicationContext(), Preferences.class); - if (mMenuItems.get(arg2).getIcon() == R.drawable.support_small) { - smallIntent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, ContactDeveloperFragment.class.getName()); - smallIntent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true); - smallIntent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE, getString(R.string.menuAboutContact)); - smallIntent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_SHORT_TITLE, getString(R.string.menuAboutContact)); - } - - startActivity(smallIntent); - - mDrawerLayout.closeDrawers(); - - break; - } - } - }); - - getActionBar().setDisplayHomeAsUpEnabled(true); - getActionBar().setHomeButtonEnabled(true); - - mDrawerToggle = new ActionBarDrawerToggle( - this, /* host Activity */ - mDrawerLayout, /* DrawerLayout object */ - R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ - R.string.drawer_open, /* "open drawer" description for accessibility */ - R.string.drawer_close /* "close drawer" description for accessibility */ - ) { - public void onDrawerClosed(View view) { - getActionBar().setTitle(null); - invalidateOptionsMenu(); - } - - public void onDrawerOpened(View drawerView) { - invalidateOptionsMenu(); - if (MizLib.usesNavigationControl(getApplicationContext())) - mDrawerList.requestFocus(); - } - }; - mDrawerLayout.setDrawerListener(mDrawerToggle); - if (savedInstanceState != null && savedInstanceState.containsKey("selectedIndex")) { - selectedIndex = savedInstanceState.getInt("selectedIndex"); - loadFragment(selectedIndex); - } else if (getIntent().getExtras() != null && getIntent().getExtras().containsKey("startup")) { - loadFragment(Integer.parseInt(getIntent().getExtras().getString("startup"))); - } else { - loadFragment(mStartup); - } - - LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.UPDATE_MOVIE_LIBRARY)); - LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.UPDATE_TV_SHOW_LIBRARY)); - } - - private void loadFragment(int type) { - if (type == 0) - type = 1; - - setTitle(null); - - Fragment frag = getSupportFragmentManager().findFragmentByTag("frag" + type); - if (frag == null) { - final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.setCustomAnimations(R.anim.fade_in, R.anim.fade_out); - switch (type) { - case MOVIES: - ft.replace(R.id.content_frame, MovieLibraryFragment.newInstance(MovieLibraryFragment.MAIN), "frag" + type); - break; - case SHOWS: - ft.replace(R.id.content_frame, TvShowLibraryFragment.newInstance(), "frag" + type); - break; - case WATCHLIST: - ft.replace(R.id.content_frame, MovieLibraryFragment.newInstance(MovieLibraryFragment.OTHER), "frag" + type); - break; - case WEB_MOVIES: - ft.replace(R.id.content_frame, MovieDiscoveryViewPagerFragment.newInstance(), "frag" + type); - break; - case WEB_VIDEOS: - ft.replace(R.id.content_frame, WebVideosViewPagerFragment.newInstance(), "frag" + type); - break; - } - ft.commit(); - } - - selectListIndex(type); - - if (mDrawerLayout != null) - mDrawerLayout.closeDrawers(); - } - - @Override - public void onNewIntent(Intent newIntent) { - super.onNewIntent(newIntent); - - if (!newIntent.hasExtra("fromUpdate")) { - Intent i = null; - if (selectedIndex == MOVIES) - i = new Intent("mizuu-movie-actor-search"); - else // TV shows - i = new Intent("mizuu-shows-actor-search"); - i.putExtras(newIntent.getExtras()); - LocalBroadcastManager.getInstance(this).sendBroadcast(i); - } - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - - outState.putInt("selectedIndex", selectedIndex); - } - - private void setupMenuItems(boolean refreshThirdPartyApps) { - mMenuItems.clear(); - - // Menu header - // We only want to add a header if there's a backdrop image and we're not running on Google TV or a non-tablet in landscape mode - if (!MizLib.getRandomBackdropPath(getApplicationContext()).isEmpty() && !((!MizLib.isTablet(this) && !MizLib.isPortrait(this)) || MizLib.usesNavigationControl(getApplicationContext()))) - mMenuItems.add(new MenuItem(null, -1, MenuItem.HEADER, null)); - - // Regular menu items - mMenuItems.add(new MenuItem(getString(R.string.drawerMyMovies), mNumMovies, MenuItem.SECTION, null, MOVIES)); - mMenuItems.add(new MenuItem(getString(R.string.drawerMyTvShows), mNumShows, MenuItem.SECTION, null, SHOWS)); - mMenuItems.add(new MenuItem(getString(R.string.chooserWatchList), mNumWatchlist, MenuItem.SECTION, null, WATCHLIST)); - mMenuItems.add(new MenuItem(getString(R.string.drawerOnlineMovies), -1, MenuItem.SECTION, null, WEB_MOVIES)); - mMenuItems.add(new MenuItem(getString(R.string.drawerWebVideos), -1, MenuItem.SECTION, null, WEB_VIDEOS)); - - // Third party applications - final PackageManager pm = getPackageManager(); - - if (refreshThirdPartyApps) { - mApplicationList = pm.getInstalledApplications(PackageManager.GET_META_DATA); - } - - List temp = new ArrayList(); - for (int i = 0; i < mApplicationList.size(); i++) { - if (MizLib.isMediaApp(mApplicationList.get(i))) { - temp.add(new MenuItem(pm.getApplicationLabel(mApplicationList.get(i)).toString(), -1, MenuItem.THIRD_PARTY_APP, mApplicationList.get(i).packageName)); - } - } - - if (temp.size() > 0) - // Menu section header - mMenuItems.add(new MenuItem(getString(R.string.installed_media_apps), -1, MenuItem.SEPARATOR, null)); - - Collections.sort(temp, new Comparator() { - @Override - public int compare(MenuItem lhs, MenuItem rhs) { - return lhs.getTitle().compareToIgnoreCase(rhs.getTitle()); - } - }); - - for (int i = 0; i < temp.size(); i++) { - mMenuItems.add(temp.get(i)); - } - - temp.clear(); - temp = null; - - mMenuItems.add(new MenuItem(getString(R.string.settings_name), MenuItem.SMALL_SECTION, R.drawable.settings_small)); - mMenuItems.add(new MenuItem(getString(R.string.menuAboutContact), MenuItem.SMALL_SECTION, R.drawable.support_small)); - } - - private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - updateLibraryCounts(); - } - }; - - protected void selectListIndex(int index) { - if (!(!MizLib.getRandomBackdropPath(getApplicationContext()).isEmpty() && !((!MizLib.isTablet(this) && !MizLib.isPortrait(this)) || MizLib.usesNavigationControl(getApplicationContext())))) - index--; - - if (mMenuItems.get(index).getType() == MenuItem.SECTION) { - selectedIndex = mMenuItems.get(index).getFragment(); - mDrawerList.setItemChecked(index, true); - } - } - - @Override - public void onResume() { - super.onResume(); - - updateLibraryCounts(); - } - - private void updateLibraryCounts() { - new Thread() { - @Override - public void run() { - try { - mNumMovies = mDbHelper.count(); - mNumWatchlist = mDbHelper.countWatchlist(); - mNumShows = mDbHelperTv.count(); - - runOnUiThread(new Runnable() { - @Override - public void run() { - setupMenuItems(false); - ((BaseAdapter) mDrawerList.getAdapter()).notifyDataSetChanged(); - } - }); - } catch (Exception e) {} // Problemer med at kontakte databasen - } - }.start(); - } - - @Override - public void onDestroy() { - // Unregister since the activity is about to be closed. - LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver); - - super.onDestroy(); - } - - @Override - public boolean onOptionsItemSelected(android.view.MenuItem item) { - if (mDrawerToggle.onOptionsItemSelected(item)) { - return true; - } - - switch(item.getItemId()) { - case android.R.id.home: - if (!mDrawerLayout.isDrawerOpen(mDrawerList)) { - mDrawerLayout.openDrawer(mDrawerList); - } else { - mDrawerLayout.closeDrawer(mDrawerList); - } - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - super.onPostCreate(savedInstanceState); - mDrawerToggle.syncState(); - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - mDrawerToggle.onConfigurationChanged(newConfig); - } - - public class MenuAdapter extends BaseAdapter { - - private String mBackdropPath; - private boolean mTablet; - private LayoutInflater mInflater; - - public MenuAdapter() { - mInflater = LayoutInflater.from(getApplicationContext()); - mTablet = MizLib.isTablet(getApplicationContext()); - mBackdropPath = MizLib.getRandomBackdropPath(getApplicationContext()); - } - - @Override - public int getCount() { - return mMenuItems.size(); - } - - @Override - public Object getItem(int position) { - return null; - } - - @Override - public long getItemId(int position) { - return 0; - } - - @Override - public int getViewTypeCount() { - return 4; - } - - @Override - public int getItemViewType(int position) { - switch (mMenuItems.get(position).getType()) { - case MenuItem.HEADER: - return 0; - case MenuItem.SEPARATOR: - return 1; - case MenuItem.THIRD_PARTY_APP: - case MenuItem.SECTION: - return 2; - default: - return 3; - } - } - - @Override - public boolean isEnabled(int position) { - if (mMenuItems.get(position).getType() == MenuItem.SEPARATOR || mMenuItems.get(position).getType() == MenuItem.HEADER) - return false; - return true; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - if (mMenuItems.get(position).getType() == MenuItem.HEADER) { - convertView = mInflater.inflate(R.layout.menu_drawer_header, parent, false); - - final String fullName = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString(TRAKT_FULL_NAME, ""); - final ImageView backgroundImage = ((ImageView) convertView.findViewById(R.id.userCover)); - final ImageView userImage = ((ImageView) convertView.findViewById(R.id.userPhoto)); - final TextView userName = ((TextView) convertView.findViewById(R.id.username)); - - userName.setTextSize(26f); - userName.setTypeface(mTfCondensed); - - if (!TextUtils.isEmpty(fullName)) { - userName.setText(fullName); - mPicasso.load(new File(MizuuApplication.getCacheFolder(getApplicationContext()), "avatar.jpg")).resize(MizLib.convertDpToPixels(getApplicationContext(), 72), MizLib.convertDpToPixels(getApplicationContext(), 72)).error(R.drawable.unknown_user).into(userImage); - } else - convertView.findViewById(R.id.drawer_user_info).setVisibility(View.GONE); - - if (!mBackdropPath.isEmpty()) - mPicasso.load(mBackdropPath).resize(MizLib.convertDpToPixels(getApplicationContext(), 320), MizLib.convertDpToPixels(getApplicationContext(), 180)).into(backgroundImage); - - } else if (mMenuItems.get(position).getType() == MenuItem.SEPARATOR) { - convertView = mInflater.inflate(R.layout.menu_drawer_header_item, parent, false); - TextView title = (TextView) convertView.findViewById(R.id.title); - title.setText(mMenuItems.get(position).getTitle()); - } else if (mMenuItems.get(position).getType() == MenuItem.THIRD_PARTY_APP || mMenuItems.get(position).getType() == MenuItem.SECTION) { - convertView = mInflater.inflate(R.layout.menu_drawer_item, parent, false); - - // Title - TextView title = (TextView) convertView.findViewById(R.id.title); - title.setText(mMenuItems.get(position).getTitle()); - if (mMenuItems.get(position).getFragment() == selectedIndex) - title.setTypeface(mTfMedium, Typeface.BOLD); - else - title.setTypeface(mTfLight); - title.setLayerType(View.LAYER_TYPE_SOFTWARE, null); - - // Tablets need slightly larger text size :-) - if (mTablet) - title.setTextSize(22f); - - // Description - TextView description = (TextView) convertView.findViewById(R.id.count); - description.setTypeface(mTfLight); - description.setLayerType(View.LAYER_TYPE_SOFTWARE, null); - - if (mMenuItems.get(position).getCount() >= 0) - description.setText(String.valueOf(mMenuItems.get(position).getCount())); - else - description.setVisibility(View.GONE); - } else { - convertView = mInflater.inflate(R.layout.menu_drawer_small_item, parent, false); - - // Title - TextView title = (TextView) convertView.findViewById(R.id.title); - title.setText(mMenuItems.get(position).getTitle()); - - ImageView image = (ImageView) convertView.findViewById(R.id.icon); - image.setImageResource(mMenuItems.get(position).getIcon()); - - } - - return convertView; - } - } - - @Override - public void onBackPressed() { - if (mStartup == 0 && !mDrawerLayout.isDrawerOpen(findViewById(R.id.left_drawer)) && MizLib.isTablet(this)) { // Welcome screen - Intent i = new Intent(Intent.ACTION_VIEW); - i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK); - i.setClass(getApplicationContext(), Welcome.class); - startActivity(i); - finish(); - return; - } - - if (!mDrawerLayout.isDrawerOpen(findViewById(R.id.left_drawer))) { - if (mConfirmExit) { - if (mTriedOnce) { - finish(); - } else { - Toast.makeText(this, getString(R.string.pressBackToExit), Toast.LENGTH_SHORT).show(); - mTriedOnce = true; - } - } else { - finish(); - } - } else { - mDrawerLayout.closeDrawers(); - } - } - - public void showDrawerOptionsMenu(Menu menu, MenuInflater inflater) { - getActionBar().setTitle(R.string.app_name); - menu.clear(); - } - - public boolean isDrawerOpen() { - View v = findViewById(R.id.left_drawer); - if (v == null) - return false; - return mDrawerLayout.isDrawerOpen(v); - } -} \ No newline at end of file diff --git a/src/com/miz/mizuu/MovieCoverFanartBrowser.java b/src/com/miz/mizuu/MovieCoverFanartBrowser.java deleted file mode 100644 index 83ee901b..00000000 --- a/src/com/miz/mizuu/MovieCoverFanartBrowser.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.mizuu; - -import java.util.ArrayList; - -import android.app.ActionBar; -import android.app.ActionBar.OnNavigationListener; -import android.content.Context; -import android.os.AsyncTask; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import com.miz.base.MizActivity; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.view.View; -import android.widget.ProgressBar; -import android.widget.Toast; - -import com.miz.functions.ActionBarSpinner; -import com.miz.functions.MizLib; -import com.miz.functions.SpinnerItem; -import com.miz.mizuu.fragments.CollectionCoverSearchFragment; -import com.miz.mizuu.fragments.CoverSearchFragment; -import com.miz.mizuu.fragments.FanartSearchFragment; - -public class MovieCoverFanartBrowser extends MizActivity implements OnNavigationListener { - - private String tmdbId, collectionId, baseUrl = "", json = "", collection = "", mTmdbApiKey; - private ViewPager awesomePager; - private ArrayList spinnerItems = new ArrayList(); - private ActionBarSpinner spinnerAdapter; - private ActionBar actionBar; - private ProgressBar pbar; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - MizuuApplication.setupTheme(this); - - setContentView(R.layout.viewpager); - - tmdbId = getIntent().getExtras().getString("tmdbId"); - collectionId = getIntent().getExtras().getString("collectionId"); - mTmdbApiKey = MizLib.getTmdbApiKey(this); - - pbar = (ProgressBar) findViewById(R.id.progressbar); - pbar.setVisibility(View.VISIBLE); - - awesomePager = (ViewPager) findViewById(R.id.awesomepager); - awesomePager.setOffscreenPageLimit(2); - awesomePager.setPageMargin(MizLib.convertDpToPixels(this, 16)); - awesomePager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { - @Override - public void onPageSelected(int position) { - actionBar.setSelectedNavigationItem(position); - } - }); - - if (savedInstanceState != null) { - json = savedInstanceState.getString("json", ""); - baseUrl = savedInstanceState.getString("baseUrl"); - collection = savedInstanceState.getString("collection"); - setupActionBarStuff(); - - awesomePager.setCurrentItem(savedInstanceState.getInt("tab", 0)); - } else { - new MovieLoader(getApplicationContext()).execute(tmdbId, collectionId); - } - } - - private void setupSpinnerItems() { - spinnerItems.clear(); - spinnerItems.add(new SpinnerItem(getString(R.string.browseMedia), getString(R.string.coverart))); - spinnerItems.add(new SpinnerItem(getString(R.string.browseMedia), getString(R.string.backdrop))); - spinnerItems.add(new SpinnerItem(getString(R.string.browseMedia), getString(R.string.collectionart))); - - actionBar.setListNavigationCallbacks(spinnerAdapter, this); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putInt("tab", awesomePager.getCurrentItem()); - outState.putString("json", json); - outState.putString("baseUrl", baseUrl); - outState.putString("collection", collection); - } - - private class PagerAdapter extends FragmentPagerAdapter { - - public PagerAdapter(FragmentManager fm) { - super(fm); - } - - @Override - public Fragment getItem(int index) { - switch (index) { - case 0: - return CoverSearchFragment.newInstance(tmdbId, json, baseUrl); - case 1: - return FanartSearchFragment.newInstance(tmdbId, json, baseUrl); - default: - return CollectionCoverSearchFragment.newInstance(collectionId, collection, baseUrl); - } - } - - @Override - public int getCount() { - if (!MizLib.isValidTmdbId(collectionId)) - return 2; - return 3; - } - } - - private class MovieLoader extends AsyncTask { - - private Context mContext; - - public MovieLoader(Context context) { - mContext = context; - } - - @Override - protected String doInBackground(Object... params) { - try { - baseUrl = MizLib.getTmdbImageBaseUrl(mContext); - - json = MizLib.getJSONObject(mContext, "https://api.themoviedb.org/3/movie/" + params[0] + "/images?api_key=" + mTmdbApiKey).toString(); - - if (MizLib.isValidTmdbId(collectionId)) { - collection = MizLib.getJSONObject(mContext, "https://api.themoviedb.org/3/collection/" + params[1] + "/images?api_key=" + mTmdbApiKey).toString(); - } - - return json; - } catch (Exception e) {} // If the fragment is no longer attached to the Activity - - return null; - } - - @Override - protected void onPostExecute(String result) { - if (result != null) { - setupActionBarStuff(); - } else { - Toast.makeText(getApplicationContext(), R.string.errorSomethingWentWrong, Toast.LENGTH_SHORT).show(); - } - } - } - - @Override - public boolean onNavigationItemSelected(int itemPosition, long itemId) { - awesomePager.setCurrentItem(itemPosition); - return true; - } - - private void setupActionBarStuff() { - actionBar = getActionBar(); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - if (spinnerAdapter == null) - spinnerAdapter = new ActionBarSpinner(getApplicationContext(), spinnerItems); - - setTitle(null); - - if (!MizLib.isPortrait(getApplicationContext())) - findViewById(R.id.layout).setBackgroundResource(0); - pbar.setVisibility(View.GONE); - - awesomePager.setAdapter(new PagerAdapter(getSupportFragmentManager())); - setupSpinnerItems(); - } -} \ No newline at end of file diff --git a/src/com/miz/mizuu/ShowCoverFanartBrowser.java b/src/com/miz/mizuu/ShowCoverFanartBrowser.java deleted file mode 100644 index 4008d2ac..00000000 --- a/src/com/miz/mizuu/ShowCoverFanartBrowser.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.mizuu; - -import java.util.ArrayList; - -import android.app.ActionBar; -import android.app.ActionBar.OnNavigationListener; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import com.miz.base.MizActivity; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; - -import com.miz.functions.ActionBarSpinner; -import com.miz.functions.MizLib; -import com.miz.functions.SpinnerItem; -import com.miz.mizuu.fragments.CoverSearchFragmentTv; -import com.miz.mizuu.fragments.FanartSearchFragmentTv; - -public class ShowCoverFanartBrowser extends MizActivity implements OnNavigationListener { - - private String tvdbId; - private ViewPager awesomePager; - private ActionBar actionBar; - private ArrayList spinnerItems = new ArrayList(); - private ActionBarSpinner spinnerAdapter; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - MizuuApplication.setupTheme(this); - - setContentView(R.layout.viewpager); - - tvdbId = getIntent().getExtras().getString("id"); - - actionBar = getActionBar(); - - setupSpinnerItems(); - - awesomePager = (ViewPager) findViewById(R.id.awesomepager); - awesomePager.setOffscreenPageLimit(2); - awesomePager.setPageMargin(MizLib.convertDpToPixels(this, 16)); - awesomePager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { - @Override - public void onPageSelected(int position) { - actionBar.setSelectedNavigationItem(position); - } - }); - awesomePager.setAdapter(new PagerAdapter(getSupportFragmentManager())); - - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - if (spinnerAdapter == null) - spinnerAdapter = new ActionBarSpinner(getApplicationContext(), spinnerItems); - - setTitle(null); - - setupSpinnerItems(); - - if (savedInstanceState != null) { - getActionBar().setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); - } - } - - private void setupSpinnerItems() { - spinnerItems.clear(); - spinnerItems.add(new SpinnerItem(getString(R.string.browseMedia), getString(R.string.coverart))); - spinnerItems.add(new SpinnerItem(getString(R.string.browseMedia), getString(R.string.backdrop))); - - actionBar.setListNavigationCallbacks(spinnerAdapter, this); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putInt("tab", getActionBar().getSelectedNavigationIndex()); - } - - private class PagerAdapter extends FragmentPagerAdapter { - - public PagerAdapter(FragmentManager fm) { - super(fm); - } - - @Override - public Fragment getItem(int index) { - switch (index) { - case 0: - return CoverSearchFragmentTv.newInstance(tvdbId); - default: - return FanartSearchFragmentTv.newInstance(tvdbId); - } - } - - @Override - public int getCount() { - return 2; - } - } - - @Override - public boolean onNavigationItemSelected(int itemPosition, long itemId) { - awesomePager.setCurrentItem(itemPosition); - return true; - } -} \ No newline at end of file diff --git a/src/com/miz/mizuu/TMDbMovieDetails.java b/src/com/miz/mizuu/TMDbMovieDetails.java deleted file mode 100644 index 1a197d8f..00000000 --- a/src/com/miz/mizuu/TMDbMovieDetails.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.mizuu; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentTransaction; -import android.view.MenuItem; -import android.view.Window; - -import com.miz.base.MizActivity; -import com.miz.functions.MizLib; -import com.miz.mizuu.fragments.TmdbMovieDetailsFragment; - -public class TMDbMovieDetails extends MizActivity { - - private static String TAG = "TmdbMovieDetailsFragment"; - private String mMovieId; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - if (isFullscreen()) - setTheme(R.style.Mizuu_Theme_Transparent_NoBackGround_FullScreen); - else - setTheme(R.style.Mizuu_Theme_NoBackGround_Transparent); - - if (MizLib.isPortrait(this)) { - getWindow().setBackgroundDrawableResource(R.drawable.bg); - } - - getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); - - setTitle(null); - - mMovieId = getIntent().getExtras().getString("tmdbId"); - - Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG); - if (frag == null) { - final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.add(android.R.id.content, TmdbMovieDetailsFragment.newInstance(mMovieId), TAG); - ft.commit(); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - @Override - public void onStart() { - super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); - } -} \ No newline at end of file diff --git a/src/com/miz/mizuu/TvShowDetails.java b/src/com/miz/mizuu/TvShowDetails.java deleted file mode 100644 index 6d2e0d17..00000000 --- a/src/com/miz/mizuu/TvShowDetails.java +++ /dev/null @@ -1,452 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.mizuu; - -import java.util.ArrayList; - -import android.app.ActionBar; -import android.app.ActionBar.OnNavigationListener; -import android.app.Activity; -import android.app.AlertDialog; -import android.app.SearchManager; -import android.content.DialogInterface; -import android.content.Intent; -import android.database.Cursor; -import android.graphics.Color; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.GradientDrawable; -import android.net.Uri; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.support.v4.app.Fragment; - -import com.miz.apis.trakt.Trakt; -import com.miz.base.MizActivity; -import com.miz.db.DbAdapterTvShowEpisodeMappings; -import com.miz.db.DbAdapterTvShows; - -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.Window; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.Toast; -import android.widget.FrameLayout.LayoutParams; - -import com.miz.functions.ActionBarSpinner; -import com.miz.functions.MizLib; -import com.miz.functions.SpinnerItem; -import com.miz.mizuu.fragments.TvShowDetailsFragment; -import com.miz.mizuu.fragments.TvShowSeasonsEpisodesFragment; -import com.miz.utils.LocalBroadcastUtils; -import com.squareup.otto.Bus; -import com.squareup.otto.Subscribe; - -import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; -import static com.miz.functions.PreferenceKeys.TVSHOWS_START_PAGE; - -public class TvShowDetails extends MizActivity implements OnNavigationListener { - - private ViewPager mViewPager; - private TvShow thisShow; - private DbAdapterTvShows dbHelper; - private boolean ignorePrefixes; - private ArrayList spinnerItems = new ArrayList(); - private ActionBarSpinner spinnerAdapter; - private ActionBar mActionBar; - private Bus mBus; - private Drawable mActionBarBackgroundDrawable; - private ImageView mActionBarOverlay; - - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - mBus = MizuuApplication.getBus(); - - if (isFullscreen()) - setTheme(R.style.Mizuu_Theme_Transparent_NoBackGround_FullScreen); - else - setTheme(R.style.Mizuu_Theme_NoBackGround_Transparent); - - if (MizLib.isPortrait(this)) { - getWindow().setBackgroundDrawableResource(R.drawable.bg); - } - - getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); - - setContentView(R.layout.viewpager); - - mActionBarOverlay = (ImageView) findViewById(R.id.actionbar_overlay); - mActionBarOverlay.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, isFullscreen() ? MizLib.getActionBarHeight(this) : MizLib.getActionBarAndStatusBarHeight(this))); - - mActionBar = getActionBar(); - mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - if (spinnerAdapter == null) - spinnerAdapter = new ActionBarSpinner(this, spinnerItems); - - setTitle(null); - - mViewPager = (ViewPager) findViewById(R.id.awesomepager); - mViewPager.setOffscreenPageLimit(3); // Required in order to retain all fragments when swiping between them - mViewPager.setAdapter(new ShowDetailsAdapter(getSupportFragmentManager())); - mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { - @Override - public void onPageSelected(int position) { - mActionBar.setSelectedNavigationItem(position); - invalidateOptionsMenu(); - - updateActionBarDrawable(1, true, false); - } - }); - - ignorePrefixes = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(IGNORED_TITLE_PREFIXES, false); - - // Create and open database - dbHelper = MizuuApplication.getTvDbAdapter(); - - String showId = ""; - // Fetch the database ID of the TV show to view - if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) { - showId = getIntent().getStringExtra(SearchManager.EXTRA_DATA_KEY); - } else { - showId = getIntent().getStringExtra("showId"); - } - - Cursor cursor = dbHelper.getShow(showId); - try { - while (cursor.moveToNext()) { - thisShow = new TvShow(this, - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_ID)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_TITLE)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_PLOT)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_RATING)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_GENRES)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_ACTORS)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_CERTIFICATION)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_FIRST_AIRDATE)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_RUNTIME)), - ignorePrefixes, - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_FAVOURITE)), - MizuuApplication.getTvEpisodeDbAdapter().getLatestEpisodeAirdate(cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_ID))) - ); - } - } catch (Exception e) { - finish(); - return; - } finally { - cursor.close(); - } - - if (thisShow == null) { - finish(); // Finish the activity if the movie doesn't load - return; - } - - setupSpinnerItems(); - - if (savedInstanceState != null) { - mViewPager.setCurrentItem(savedInstanceState.getInt("tab", 0)); - } - - // Set the current page item to 1 (episode page) if the TV show start page setting has been changed from TV show details - if (!PreferenceManager.getDefaultSharedPreferences(this).getString(TVSHOWS_START_PAGE, getString(R.string.showDetails)).equals(getString(R.string.showDetails))) - mViewPager.setCurrentItem(1); - } - - @Subscribe - public void onScrollChanged(Integer newAlpha) { - updateActionBarDrawable(newAlpha, true, false); - } - - private void updateActionBarDrawable(int newAlpha, boolean setBackground, boolean showActionBar) { - if (mViewPager.getCurrentItem() == 0) { // Details page - mActionBarOverlay.setVisibility(View.VISIBLE); - - if (MizLib.isPortrait(this) && !MizLib.isTablet(this) && !MizLib.usesNavigationControl(this)) - if (newAlpha == 0) { - mActionBar.hide(); - mActionBarOverlay.setVisibility(View.GONE); - } else - mActionBar.show(); - - if (setBackground) { - mActionBarBackgroundDrawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[]{Color.parseColor("#" + ((Integer.toHexString(newAlpha).length() == 1) ? ("0" + Integer.toHexString(newAlpha)) : Integer.toHexString(newAlpha)) + "000000"), (newAlpha >= 170) ? Color.parseColor("#" + Integer.toHexString(newAlpha) + "000000") : 0xaa000000}); - mActionBarOverlay.setImageDrawable(mActionBarBackgroundDrawable); - } - } else { - mActionBarBackgroundDrawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[]{Color.parseColor("#FF000000"), Color.parseColor("#FF000000")}); - mActionBarOverlay.setImageDrawable(mActionBarBackgroundDrawable); - - mActionBarOverlay.setVisibility(View.VISIBLE); - - if (MizLib.isPortrait(this) && !MizLib.isTablet(this) && !MizLib.usesNavigationControl(this)) - mActionBar.show(); - } - - if (showActionBar) { - mActionBar.show(); - } - } - - public void onResume() { - super.onResume(); - - mBus.register(this); - updateActionBarDrawable(1, true, true); - } - - @Override - public void onPause() { - super.onPause(); - - mBus.unregister(this); - } - - private void setupSpinnerItems() { - spinnerItems.clear(); - spinnerItems.add(new SpinnerItem(thisShow.getTitle(), getString(R.string.overview))); - spinnerItems.add(new SpinnerItem(thisShow.getTitle(), getString(R.string.seasons))); - - mActionBar.setListNavigationCallbacks(spinnerAdapter, this); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putInt("tab", mViewPager.getCurrentItem()); - } - - @Override - public void onStart() { - super.onStart(); - getActionBar().setDisplayHomeAsUpEnabled(true); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - - switch (mViewPager.getCurrentItem()) { - case 0: - getMenuInflater().inflate(R.menu.tv_show_details, menu); - - // If this is a tablet, we have more room to display icons - if (MizLib.isTablet(this)) - menu.findItem(R.id.share).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - - boolean favorite = false; - if (thisShow != null) - favorite = thisShow.isFavorite(); - - menu.findItem(R.id.show_fav).setIcon(favorite ? R.drawable.fav : R.drawable.ic_action_star_0); - menu.findItem(R.id.show_fav).setTitle(favorite ? R.string.menuFavouriteTitleRemove : R.string.menuFavouriteTitle); - - break; - - case 1: - getMenuInflater().inflate(R.menu.seasons_tab, menu); - - break; - } - - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - if (getIntent().getExtras().getBoolean("isFromWidget")) { - Intent i = new Intent(Intent.ACTION_VIEW); - i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK); - i.putExtra("startup", String.valueOf(Main.SHOWS)); - i.setClass(getApplicationContext(), Main.class); - startActivity(i); - } - finish(); - - return true; - case R.id.show_fav: - favAction(); - break; - case R.id.menuDeleteShow: - deleteShow(); - break; - case R.id.change_cover: - searchCover(); - break; - case R.id.identify_show: - identifyShow(); - break; - case R.id.editTvShow: - editTvShow(); - break; - case R.id.openInBrowser: - Intent browserIntent = new Intent(Intent.ACTION_VIEW); - if (thisShow.getIdType() == TvShow.TMDB) { - browserIntent.setData(Uri.parse("https://www.themoviedb.org/tv/" + thisShow.getIdWithoutHack())); - } else { - browserIntent.setData(Uri.parse("http://thetvdb.com/?tab=series&id=" + thisShow.getId())); - } - startActivity(browserIntent); - break; - case R.id.share: - Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType("text/plain"); - intent.putExtra(Intent.EXTRA_TEXT, ((thisShow.getIdType() == TvShow.THETVDB) ? "http://thetvdb.com/?tab=series&id=" : "http://www.themoviedb.org/tv/") + thisShow.getIdWithoutHack()); - startActivity(intent); - return true; - } - return false; - } - - private void identifyShow() { - ArrayList files = new ArrayList(); - - Cursor cursor = MizuuApplication.getTvShowEpisodeMappingsDbAdapter().getAllFilepaths(thisShow.getId()); - while (cursor.moveToNext()) - files.add(cursor.getString(cursor.getColumnIndex(DbAdapterTvShowEpisodeMappings.KEY_FILEPATH))); - - cursor.close(); - - Intent i = new Intent(); - i.setClass(this, IdentifyTvShow.class); - i.putExtra("showTitle", thisShow.getTitle()); - i.putExtra("showId", thisShow.getId()); - startActivityForResult(i, 0); - } - - private void editTvShow() { - Intent intent = new Intent(this, EditTvShow.class); - intent.putExtra("showId", thisShow.getId()); - startActivityForResult(intent, 1); - } - - public void favAction() { - // Create and open database - thisShow.setFavorite(!thisShow.isFavorite()); // Reverse the favourite boolean - - if (dbHelper.updateShowSingleItem(thisShow.getId(), DbAdapterTvShows.KEY_SHOW_FAVOURITE, thisShow.getFavorite())) { - invalidateOptionsMenu(); - - Toast.makeText(this, getString(thisShow.isFavorite() ? R.string.addedToFavs : R.string.removedFromFavs), Toast.LENGTH_SHORT).show(); - - LocalBroadcastUtils.updateTvShowLibrary(this); - - } else Toast.makeText(this, getString(R.string.errorOccured), Toast.LENGTH_SHORT).show(); - - new Thread() { - @Override - public void run() { - ArrayList show = new ArrayList(); - show.add(thisShow); - Trakt.tvShowFavorite(show, getApplicationContext()); - } - }.start(); - } - - private void searchCover() { - Intent i = new Intent(); - i.putExtra("id", thisShow.getId()); - i.setClass(this, ShowCoverFanartBrowser.class); - startActivity(i); - } - - private void deleteShow() { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage(getString(R.string.areYouSure)) - .setTitle(getString(R.string.removeShow)) - .setCancelable(false) - .setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - MizLib.deleteShow(getApplicationContext(), thisShow, true); - LocalBroadcastUtils.updateTvShowLibrary(getApplicationContext()); - finish(); - return; - } - }) - .setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.cancel(); - } - }) - .create().show(); - } - - private class ShowDetailsAdapter extends FragmentPagerAdapter { - - public ShowDetailsAdapter(FragmentManager fm) { - super(fm); - } - - @Override - public Fragment getItem(int index) { - switch (index) { - case 0: - return TvShowDetailsFragment.newInstance(thisShow.getId()); - default: - return TvShowSeasonsEpisodesFragment.newInstance(thisShow.getId()); - } - } - - @Override - public int getCount() { - return 2; - } - - @Override - public CharSequence getPageTitle(int position) { - switch (position) { - case 0: return getString(R.string.overview); - default: return getString(R.string.episodes); - } - } - } - - @Override - public boolean onNavigationItemSelected(int itemPosition, long itemId) { - mViewPager.setCurrentItem(itemPosition); - - return true; - } - - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == 0) { - if (resultCode == Activity.RESULT_OK) { - finish(); - } - } else if (requestCode == 1) { - if (resultCode == Activity.RESULT_OK) { - Toast.makeText(this, getString(R.string.updatedTvShow), Toast.LENGTH_SHORT).show(); - - // Create a new Intent with the Bundle - Intent intent = new Intent(); - intent.setClass(getApplicationContext(), TvShowDetails.class); - intent.putExtra("showId", thisShow.getId()); - - // Start the Intent for result - startActivity(intent); - - finish(); - return; - } - } - } -} \ No newline at end of file diff --git a/src/com/miz/mizuu/fragments/MovieDetailsFragment.java b/src/com/miz/mizuu/fragments/MovieDetailsFragment.java deleted file mode 100644 index 8adaf8df..00000000 --- a/src/com/miz/mizuu/fragments/MovieDetailsFragment.java +++ /dev/null @@ -1,1081 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use mContext 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.miz.mizuu.fragments; - -import static com.miz.functions.PreferenceKeys.ALWAYS_DELETE_FILE; -import static com.miz.functions.PreferenceKeys.IGNORED_FILES_ENABLED; -import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; -import static com.miz.functions.PreferenceKeys.REMOVE_MOVIES_FROM_WATCHLIST; -import static com.miz.functions.PreferenceKeys.SHOW_FILE_LOCATION; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import android.annotation.SuppressLint; -import android.app.ActionBar; -import android.app.AlertDialog; -import android.app.Dialog; -import android.app.ProgressDialog; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentFilter; -import android.database.Cursor; -import android.database.DataSetObserver; -import android.graphics.Typeface; -import android.graphics.drawable.Drawable; -import android.net.Uri; -import android.os.AsyncTask; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.support.v4.app.Fragment; -import android.support.v4.content.LocalBroadcastManager; -import android.text.Html; -import android.text.TextUtils; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.view.ViewGroup.LayoutParams; -import android.view.ViewTreeObserver; -import android.widget.CheckBox; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.ImageView.ScaleType; -import android.widget.ScrollView; -import android.widget.TextView; -import android.widget.Toast; - -import com.miz.abstractclasses.MovieApiService; -import com.miz.apis.trakt.Trakt; -import com.miz.db.DbAdapterMovies; -import com.miz.functions.Actor; -import com.miz.functions.BlurTransformation; -import com.miz.functions.FileSource; -import com.miz.functions.Filepath; -import com.miz.functions.MizLib; -import com.miz.functions.Movie; -import com.miz.functions.PaletteTransformation; -import com.miz.functions.PreferenceKeys; -import com.miz.mizuu.EditMovie; -import com.miz.mizuu.IdentifyMovie; -import com.miz.mizuu.Main; -import com.miz.mizuu.MizuuApplication; -import com.miz.mizuu.MovieCoverFanartBrowser; -import com.miz.mizuu.R; -import com.miz.service.DeleteFile; -import com.miz.service.MakeAvailableOffline; -import com.miz.utils.IntentUtils; -import com.miz.utils.LocalBroadcastUtils; -import com.miz.utils.VideoUtils; -import com.miz.utils.ViewUtils; -import com.miz.views.HorizontalCardLayout; -import com.miz.views.ObservableScrollView; -import com.miz.views.ObservableScrollView.OnScrollChangedListener; -import com.miz.views.PanningView; -import com.squareup.picasso.Callback; -import com.squareup.picasso.Picasso; - -public class MovieDetailsFragment extends Fragment { - - private Context mContext; - private Movie mMovie; - private DbAdapterMovies mDatabase; - private TextView mTitle, mPlot, mSrc, mGenre, mRuntime, mReleaseDate, mRating, mTagline, mCertification; - private View mDetailsArea; - private HorizontalCardLayout mActorsLayout; - private boolean mIgnorePrefixes, mShowFileLocation, mIgnoreDeletedFiles, mRemoveMoviesFromWatchlist; - private ImageView mBackground, mCover; - private Picasso mPicasso; - private Typeface mLight, mLightItalic, mMedium, mBoldItalic; - private int mImageThumbSize, mImageThumbSpacing; - private long mVideoPlaybackStarted, mVideoPlaybackEnded; - private Drawable mActionBarBackgroundDrawable; - private ImageView mActionBarOverlay; - private ActionBar mActionBar; - - /** - * Empty constructor as per the Fragment documentation - */ - public MovieDetailsFragment() {} - - public static MovieDetailsFragment newInstance(String tmdbId) { - MovieDetailsFragment pageFragment = new MovieDetailsFragment(); - Bundle bundle = new Bundle(); - bundle.putString("tmdbId", tmdbId); - pageFragment.setArguments(bundle); - return pageFragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setHasOptionsMenu(true); - setRetainInstance(true); - - mContext = getActivity(); - - mActionBar = getActivity().getActionBar(); - - mIgnorePrefixes = PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(IGNORED_TITLE_PREFIXES, false); - mShowFileLocation = PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(SHOW_FILE_LOCATION, true); - mIgnoreDeletedFiles = PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(IGNORED_FILES_ENABLED, false); - mRemoveMoviesFromWatchlist = PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(REMOVE_MOVIES_FROM_WATCHLIST, true); - - mLight = MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Light.ttf"); - mLightItalic = MizuuApplication.getOrCreateTypeface(mContext, "Roboto-LightItalic.ttf"); - mMedium = MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf"); - mBoldItalic = MizuuApplication.getOrCreateTypeface(mContext, "Roboto-BoldItalic.ttf"); - - mPicasso = MizuuApplication.getPicassoDetailsView(mContext); - - mDatabase = MizuuApplication.getMovieAdapter(); - - Cursor cursor = mDatabase.fetchMovie(getArguments().getString("tmdbId")); - try { - mMovie = new Movie(mContext, - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_TITLE)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_PLOT)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_TAGLINE)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_TMDB_ID)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_IMDB_ID)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_RATING)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_RELEASEDATE)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_CERTIFICATION)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_RUNTIME)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_TRAILER)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_GENRES)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_FAVOURITE)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_ACTORS)), - MizuuApplication.getCollectionsAdapter().getCollection(cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_COLLECTION_ID))), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_COLLECTION_ID)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_TO_WATCH)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_HAS_WATCHED)), - cursor.getString(cursor.getColumnIndex(DbAdapterMovies.KEY_DATE_ADDED)), - mIgnorePrefixes - ); - } catch (Exception e) {} finally { - if (cursor != null) { - cursor.close(); - } else { // Cursor is null, yikes! - getActivity().finish(); - return; - } - } - - LocalBroadcastManager.getInstance(mContext).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.CLEAR_IMAGE_CACHE)); - } - - @Override - public void onResume() { - super.onResume(); - - mVideoPlaybackEnded = System.currentTimeMillis(); - - if (mVideoPlaybackStarted > 0 && mVideoPlaybackEnded - mVideoPlaybackStarted > (1000 * 60 * 5)) { - if (!mMovie.hasWatched()) - watched(false); // Mark it as watched - } - } - - private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - loadImages(); - } - }; - - @Override - public void onDestroy() { - super.onDestroy(); - - // Unregister since the activity is about to be closed. - LocalBroadcastManager.getInstance(mContext).unregisterReceiver(mMessageReceiver); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.movie_and_tv_show_details, container, false); - } - - @Override - public void onViewCreated(final View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - // This needs to be re-initialized here and not in onCreate() - mImageThumbSize = getResources().getDimensionPixelSize(R.dimen.horizontal_grid_item_width); - mImageThumbSpacing = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); - - mDetailsArea = view.findViewById(R.id.details_area); - mBackground = (ImageView) view.findViewById(R.id.imageBackground); - mTitle = (TextView) view.findViewById(R.id.movieTitle); - mPlot = (TextView) view.findViewById(R.id.textView2); - mSrc = (TextView) view.findViewById(R.id.textView3); - mGenre = (TextView) view.findViewById(R.id.textView7); - mRuntime = (TextView) view.findViewById(R.id.textView9); - mReleaseDate = (TextView) view.findViewById(R.id.textReleaseDate); - mRating = (TextView) view.findViewById(R.id.textView12); - mTagline = (TextView) view.findViewById(R.id.textView6); - mCertification = (TextView) view.findViewById(R.id.textView11); - mCover = (ImageView) view.findViewById(R.id.traktIcon); - mActorsLayout = (HorizontalCardLayout) view.findViewById(R.id.horizontal_card_layout); - - mActionBarOverlay = (ImageView) view.findViewById(R.id.actionbar_overlay); - mActionBarOverlay.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, - MizuuApplication.isFullscreen(mContext) ? MizLib.getActionBarHeight(mContext) : MizLib.getActionBarAndStatusBarHeight(mContext))); - - if (MizLib.isPortrait(mContext)) { - final boolean fullscreen = MizuuApplication.isFullscreen(mContext); - final int height = fullscreen ? MizLib.getActionBarHeight(mContext) : MizLib.getActionBarAndStatusBarHeight(mContext); - - ObservableScrollView sv = (ObservableScrollView) view.findViewById(R.id.scrollView1); - sv.setOnScrollChangedListener(new OnScrollChangedListener() { - @Override - public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { - final int headerHeight = mBackground.getHeight() - height; - final float ratio = (float) Math.min(Math.max(t, 0), headerHeight) / headerHeight; - final int newAlpha = (int) (ratio * 255); - - // We only want to update the ActionBar if it would actually make a change (times 1.2 to handle fast flings) - if (t <= headerHeight * 1.2) { - ViewUtils.updateActionBarDrawable(mContext, mActionBarOverlay, mActionBarBackgroundDrawable, mActionBar, mMovie.getTitle(), newAlpha, true, false); - - // Such parallax, much wow - mBackground.setPadding(0, (int) (t / 1.5), 0, 0); - } - } - }); - } - - // Set the movie title - mTitle.setVisibility(View.VISIBLE); - mTitle.setText(mMovie.getTitle()); - mTitle.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "RobotoCondensed-Regular.ttf")); - - mPlot.setTypeface(mLight); - mSrc.setTypeface(mLight); - - mRuntime.setTypeface(mMedium); - mCertification.setTypeface(mMedium); - mRating.setTypeface(mMedium); - - // Set the movie plot - if (!MizLib.isPortrait(mContext)) { - mPlot.setBackgroundResource(R.drawable.selectable_background); - if (!mMovie.getTagline().isEmpty()) - mPlot.setMaxLines(mContext.getResources().getInteger(R.integer.movie_details_max_lines)); - else - mPlot.setMaxLines(mContext.getResources().getInteger(R.integer.show_details_max_lines)); - mPlot.setTag(true); // true = collapsed - mPlot.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (((Boolean) mPlot.getTag())) { - mPlot.setMaxLines(1000); - mPlot.setTag(false); - } else { - if (!mMovie.getTagline().isEmpty()) - mPlot.setMaxLines(mContext.getResources().getInteger(R.integer.movie_details_max_lines)); - else - mPlot.setMaxLines(mContext.getResources().getInteger(R.integer.show_details_max_lines)); - mPlot.setTag(true); - } - } - }); - mPlot.setEllipsize(TextUtils.TruncateAt.END); - mPlot.setFocusable(true); - } else { - if (MizLib.isTablet(mContext)) - mPlot.setLineSpacing(0, 1.15f); - } - mPlot.setText(mMovie.getPlot()); - - // Set the movie file source - if (mShowFileLocation) { - mSrc.setText(mMovie.getAllFilepaths()); - } else { - mSrc.setVisibility(View.GONE); - } - - // Set movie tag line - mTagline.setTypeface(mBoldItalic); - if (mMovie.getTagline().isEmpty()) - mTagline.setVisibility(TextView.GONE); - else - mTagline.setText(mMovie.getTagline()); - - // Set the movie genre - mGenre.setTypeface(mLightItalic); - if (!TextUtils.isEmpty(mMovie.getGenres())) { - mGenre.setText(mMovie.getGenres()); - } else { - mGenre.setVisibility(View.GONE); - } - - // Set the movie runtime - mRuntime.setText(MizLib.getPrettyRuntime(mContext, Integer.parseInt(mMovie.getRuntime()))); - - // Set the movie release date - mReleaseDate.setTypeface(mMedium); - mReleaseDate.setText(MizLib.getPrettyDate(mContext, mMovie.getReleasedate())); - - // Set the movie rating - if (!mMovie.getRating().equals("0.0")) { - try { - int rating = (int) (Double.parseDouble(mMovie.getRating()) * 10); - mRating.setText(Html.fromHtml(+ rating + " %")); - } catch (NumberFormatException e) { - mRating.setText(mMovie.getRating()); - } - } else { - mRating.setText(R.string.stringNA); - } - - // Set the movie certification - if (!TextUtils.isEmpty(mMovie.getCertification())) { - mCertification.setText(mMovie.getCertification()); - } else { - mCertification.setText(R.string.stringNA); - } - - mActorsLayout.setTitle(R.string.detailsActors); - mActorsLayout.setSeeMoreVisibility(true); - mActorsLayout.getViewTreeObserver().addOnGlobalLayoutListener( - new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - if (mActorsLayout.getWidth() > 0) { - final int numColumns = (int) Math.floor(mActorsLayout.getWidth() / (mImageThumbSize + mImageThumbSpacing)); - mImageThumbSize = (mActorsLayout.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; - - loadActors(numColumns); - MizLib.removeViewTreeObserver(mActorsLayout.getViewTreeObserver(), this); - } - } - }); - mActorsLayout.setSeeMoreOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - startActivity(IntentUtils.getActorBrowserMovies(mContext, mMovie.getTitle(), mMovie.getTmdbId())); - } - }); - - ViewUtils.updateActionBarDrawable(mContext, mActionBarOverlay, mActionBarBackgroundDrawable, mActionBar, mMovie.getTitle(), 1, true, true); - - loadImages(); - } - - private void loadActors(final int capacity) { - // Show ProgressBar - new AsyncTask() { - private List mActors; - - @Override - protected Void doInBackground(Void... params) { - MovieApiService service = MizuuApplication.getMovieService(mContext); - mActors = service.getActors(mMovie.getTmdbId()); - - return null; - } - - @Override - protected void onPostExecute(Void result) { - mActorsLayout.loadItems(mContext, mPicasso, capacity, mImageThumbSize, mActors, HorizontalCardLayout.ACTORS); - } - }.execute(); - } - - private void loadImages() { - mPicasso.load(mMovie.getThumbnail()).error(R.drawable.loading_image).placeholder(R.drawable.loading_image).transform(new PaletteTransformation(mMovie.getThumbnail().getAbsolutePath(), mDetailsArea, mActorsLayout.getSeeMoreView())).into(mCover); - - if (!MizLib.isPortrait(mContext)) { - if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(PreferenceKeys.BLUR_BACKDROPS, false)) { - mPicasso.load(mMovie.getBackdrop()).skipMemoryCache().error(R.drawable.bg).placeholder(R.drawable.bg).transform(new BlurTransformation(mContext, mMovie.getBackdrop().getAbsolutePath(), 8)).into(mBackground); - } else { - mPicasso.load(mMovie.getBackdrop()).skipMemoryCache().error(R.drawable.bg).placeholder(R.drawable.bg).into(mBackground); - } - } else { - mPicasso.load(mMovie.getBackdrop()).skipMemoryCache().placeholder(R.drawable.bg).into(mBackground, new Callback() { - @Override - public void onError() { - if (!isAdded()) - return; - ((PanningView) mBackground).setScaleType(ScaleType.CENTER_CROP); - mPicasso.load(mMovie.getThumbnail()).skipMemoryCache().placeholder(R.drawable.bg).error(R.drawable.bg).into(mBackground); - } - - @Override - public void onSuccess() { - if (!isAdded()) - return; - ((PanningView) mBackground).startPanning(); - } - }); - } - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - inflater.inflate(R.menu.movie_details, menu); - - // If this is a tablet, we have more room to display icons - if (MizLib.isTablet(mContext)) { - menu.findItem(R.id.movie_fav).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - menu.findItem(R.id.share).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - menu.findItem(R.id.watch_list).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - } - - // Favourite - menu.findItem(R.id.movie_fav).setIcon(mMovie.isFavourite() ? - R.drawable.fav : R.drawable.ic_action_star_0) - .setTitle(mMovie.isFavourite() ? - R.string.menuFavouriteTitleRemove : R.string.menuFavouriteTitle); - - // Watchlist - menu.findItem(R.id.watch_list).setIcon(mMovie.toWatch() ? - R.drawable.watchlist_remove : R.drawable.watchlist_add) - .setTitle(mMovie.toWatch() ? - R.string.removeFromWatchlist : R.string.watchLater); - - // Watched / unwatched - menu.findItem(R.id.watched).setTitle(mMovie.hasWatched() ? - R.string.stringMarkAsUnwatched : R.string.stringMarkAsWatched); - - // Only allow the user to browse artwork if it's a valid TMDb movie - menu.findItem(R.id.change_cover).setVisible(MizLib.isValidTmdbId(mMovie.getTmdbId())); - - // Go through filepaths and find a network file for offline watching - for (Filepath path : mMovie.getFilepaths()) { - if (path.isNetworkFile()) { - menu.findItem(R.id.watchOffline) - .setVisible(true) - .setTitle(mMovie.hasOfflineCopy(path) ? - R.string.removeOfflineCopy : R.string.watchOffline); - - break; - } - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - if (getActivity().getIntent().getExtras().getBoolean("isFromWidget")) { - Intent i = new Intent(Intent.ACTION_VIEW); - i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK); - i.putExtra("startup", String.valueOf(Main.MOVIES)); - i.setClass(mContext, Main.class); - startActivity(i); - } - - getActivity().finish(); - return true; - case R.id.share: - Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType("text/plain"); - intent.putExtra(Intent.EXTRA_TEXT, "http://www.imdb.com/title/" + mMovie.getImdbId()); - startActivity(intent); - return true; - case R.id.imdb: - Intent imdbIntent = new Intent(Intent.ACTION_VIEW); - imdbIntent.setData(Uri.parse("http://www.imdb.com/title/" + mMovie.getImdbId())); - startActivity(imdbIntent); - return true; - case R.id.tmdb: - Intent tmdbIntent = new Intent(Intent.ACTION_VIEW); - tmdbIntent.setData(Uri.parse("http://www.themoviedb.org/movie/" + mMovie.getTmdbId())); - startActivity(tmdbIntent); - return true; - case R.id.play_video: - playMovie(); - return true; - case R.id.watchOffline: - watchOffline(); - return true; - case R.id.change_cover: - searchCover(); - return true; - case R.id.editMovie: - editMovie(); - return true; - case R.id.identify: - identifyMovie(); - return true; - case R.id.watched: - watched(true); - return true; - case R.id.trailer: - VideoUtils.playTrailer(getActivity(), mMovie); - return true; - case R.id.watch_list: - watchList(); - return true; - case R.id.movie_fav: - favAction(); - return true; - case R.id.delete_movie: - deleteMovie(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - @SuppressLint("InflateParams") - public void deleteMovie() { - AlertDialog.Builder builder = new AlertDialog.Builder(mContext); - - View dialogLayout = LayoutInflater.from(mContext).inflate(R.layout.delete_file_dialog_layout, null); - final CheckBox cb = (CheckBox) dialogLayout.findViewById(R.id.deleteFile); - - - if (mMovie.getFilepaths().size() == 1 && mMovie.getFilepaths().get(0).getType() == FileSource.UPNP) - cb.setEnabled(false); - else - cb.setChecked(PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(ALWAYS_DELETE_FILE, false)); - - builder.setTitle(getString(R.string.removeMovie)) - .setView(dialogLayout) - .setCancelable(false) - .setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - - boolean deleted = true; - if (mIgnoreDeletedFiles) { - deleted = mDatabase.ignoreMovie(mMovie.getTmdbId()); - } else { - deleted = mDatabase.deleteMovie(mMovie.getTmdbId()); - } - - if (deleted) { - if (cb.isChecked()) { - for (Filepath path : mMovie.getFilepaths()) { - Intent deleteIntent = new Intent(mContext, DeleteFile.class); - deleteIntent.putExtra("filepath", path.getFilepath()); - mContext.startService(deleteIntent); - } - } - - boolean movieExists = mDatabase.movieExists(mMovie.getTmdbId()); - - // We only want to delete movie images, if there are no other versions of the same movie - if (!movieExists) { - try { // Delete cover art image - File coverArt = mMovie.getPoster(); - if (coverArt.exists() && coverArt.getAbsolutePath().contains("com.miz.mizuu")) { - MizLib.deleteFile(coverArt); - } - } catch (NullPointerException e) {} // No file to delete - - try { // Delete thumbnail image - File thumbnail = mMovie.getThumbnail(); - if (thumbnail.exists() && thumbnail.getAbsolutePath().contains("com.miz.mizuu")) { - MizLib.deleteFile(thumbnail); - } - } catch (NullPointerException e) {} // No file to delete - - try { // Delete backdrop image - File backdrop = mMovie.getBackdrop(); - if (backdrop.exists() && backdrop.getAbsolutePath().contains("com.miz.mizuu")) { - MizLib.deleteFile(backdrop); - } - } catch (NullPointerException e) {} // No file to delete - } - - notifyDatasetChanges(); - getActivity().finish(); - return; - } else { - Toast.makeText(mContext, getString(R.string.failedToRemoveMovie), Toast.LENGTH_SHORT).show(); - } - } - }) - .setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.cancel(); - } - }) - .create().show(); - } - - public void identifyMovie() { - if (mMovie.getFilepaths().size() == 1) { - getActivity().startActivityForResult(getIdentifyIntent(mMovie.getFilepaths().get(0).getFullFilepath()), 0); - } else { - MizLib.showSelectFileDialog(mContext, mMovie.getFilepaths(), new Dialog.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - startActivity(getIdentifyIntent(mMovie.getFilepaths().get(which).getFullFilepath())); - - // Dismiss the dialog - dialog.dismiss(); - } - }); - } - } - - private Intent getIdentifyIntent(String filepath) { - Intent intent = new Intent(mContext, IdentifyMovie.class); - intent.putExtra("fileName", filepath); - return intent; - } - - public void shareMovie(MenuItem item) { - Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType("text/plain"); - intent.putExtra(Intent.EXTRA_TEXT, "http://www.imdb.com/title/" + mMovie.getImdbId()); - startActivity(Intent.createChooser(intent, getString(R.string.shareWith))); - } - - public void favAction() { - mMovie.setFavourite(!mMovie.isFavourite()); // Reverse the favourite boolean - - boolean success = mDatabase.updateMovieSingleItem(mMovie.getTmdbId(), DbAdapterMovies.KEY_FAVOURITE, mMovie.getFavourite()); - - if (success) { - getActivity().invalidateOptionsMenu(); - - if (mMovie.isFavourite()) { - Toast.makeText(mContext, getString(R.string.addedToFavs), Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(mContext, getString(R.string.removedFromFavs), Toast.LENGTH_SHORT).show(); - getActivity().setResult(2); // Favorite removed - } - - notifyDatasetChanges(); - - } else Toast.makeText(mContext, getString(R.string.errorOccured), Toast.LENGTH_SHORT).show(); - - new Thread() { - @Override - public void run() { - ArrayList movie = new ArrayList(); - movie.add(mMovie); - Trakt.movieFavorite(movie, mContext); - } - }.start(); - } - - private void watched(boolean showToast) { - mMovie.setHasWatched(!mMovie.hasWatched()); // Reverse the hasWatched boolean - - boolean success = mDatabase.updateMovieSingleItem(mMovie.getTmdbId(), DbAdapterMovies.KEY_HAS_WATCHED, mMovie.getHasWatched()); - - if (success) { - getActivity().invalidateOptionsMenu(); - - if (showToast) - if (mMovie.hasWatched()) { - Toast.makeText(mContext, getString(R.string.markedAsWatched), Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(mContext, getString(R.string.markedAsUnwatched), Toast.LENGTH_SHORT).show(); - } - - notifyDatasetChanges(); - - } else Toast.makeText(mContext, getString(R.string.errorOccured), Toast.LENGTH_SHORT).show(); - - if (mRemoveMoviesFromWatchlist) - removeFromWatchlist(); - - new Thread() { - @Override - public void run() { - ArrayList watchedMovies = new ArrayList(); - watchedMovies.add(mMovie); - Trakt.markMovieAsWatched(watchedMovies, mContext); - } - }.start(); - } - - public void watchList() { - mMovie.setToWatch(!mMovie.toWatch()); // Reverse the toWatch boolean - - boolean success = mDatabase.updateMovieSingleItem(mMovie.getTmdbId(), DbAdapterMovies.KEY_TO_WATCH, mMovie.getToWatch()); - - if (success) { - getActivity().invalidateOptionsMenu(); - - if (mMovie.toWatch()) { - Toast.makeText(mContext, getString(R.string.addedToWatchList), Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(mContext, getString(R.string.removedFromWatchList), Toast.LENGTH_SHORT).show(); - } - - notifyDatasetChanges(); - - } else Toast.makeText(mContext, getString(R.string.errorOccured), Toast.LENGTH_SHORT).show(); - - new Thread() { - @Override - public void run() { - ArrayList watchlist = new ArrayList(); - watchlist.add(mMovie); - Trakt.movieWatchlist(watchlist, mContext); - } - }.start(); - } - - public void removeFromWatchlist() { - mMovie.setToWatch(false); // Remove it - - boolean success = mDatabase.updateMovieSingleItem(mMovie.getTmdbId(), DbAdapterMovies.KEY_TO_WATCH, mMovie.getToWatch()); - - if (success) { - getActivity().invalidateOptionsMenu(); - notifyDatasetChanges(); - } - - new Thread() { - @Override - public void run() { - ArrayList watchlist = new ArrayList(); - watchlist.add(mMovie); - Trakt.movieWatchlist(watchlist, mContext); - } - }.start(); - } - - public void watchOffline() { - if (mMovie.getFilepaths().size() == 1) { - watchOffline(mMovie.getFilepaths().get(0)); - } else { - MizLib.showSelectFileDialog(mContext, mMovie.getFilepaths(), new Dialog.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - watchOffline(mMovie.getFilepaths().get(which)); - - // Dismiss the dialog - dialog.dismiss(); - } - }); - } - } - - public void watchOffline(final Filepath path) { - if (mMovie.hasOfflineCopy(path)) { - AlertDialog.Builder builder = new AlertDialog.Builder(mContext); - builder.setMessage(getString(R.string.areYouSure)) - .setTitle(getString(R.string.removeOfflineCopy)) - .setCancelable(false) - .setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - boolean success = mMovie.getOfflineCopyFile(path).delete(); - if (!success) - mMovie.getOfflineCopyFile(path).delete(); - getActivity().invalidateOptionsMenu(); - return; - } - }) - .setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.cancel(); - } - }) - .create().show(); - } else { - AlertDialog.Builder builder = new AlertDialog.Builder(mContext); - builder.setMessage(getString(R.string.downloadOfflineCopy)) - .setTitle(getString(R.string.watchOffline)) - .setCancelable(false) - .setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - if (MizLib.isLocalCopyBeingDownloaded(mContext)) - Toast.makeText(mContext, R.string.addedToDownloadQueue, Toast.LENGTH_SHORT).show(); - - Intent i = new Intent(mContext, MakeAvailableOffline.class); - i.putExtra(MakeAvailableOffline.FILEPATH, path.getFilepath()); - i.putExtra(MakeAvailableOffline.TYPE, MizLib.TYPE_MOVIE); - i.putExtra("thumb", mMovie.getThumbnail().getAbsolutePath()); - i.putExtra("backdrop", mMovie.getBackdrop().getAbsolutePath()); - mContext.startService(i); - return; - } - }) - .setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.cancel(); - } - }) - .create().show(); - } - } - - public void searchCover() { - if (MizLib.isOnline(mContext)) { // Make sure that the device is connected to the web - Intent intent = new Intent(mContext, MovieCoverFanartBrowser.class); - intent.putExtra("tmdbId", mMovie.getTmdbId()); - intent.putExtra("collectionId", mMovie.getCollectionId()); - startActivity(intent); // Start the intent for result - } else { - // No movie ID / Internet connection - Toast.makeText(mContext, getString(R.string.coverSearchFailed), Toast.LENGTH_LONG).show(); - } - } - - private void notifyDatasetChanges() { - LocalBroadcastUtils.updateMovieLibrary(mContext); - } - - private void checkIn() { - new Thread() { - @Override - public void run() { - Trakt.performMovieCheckin(mMovie, getActivity()); - } - }.start(); - } - - private void playMovie() { - ArrayList paths = mMovie.getFilepaths(); - if (paths.size() == 1) { - Filepath path = paths.get(0); - if (mMovie.hasOfflineCopy(path)) { - boolean playbackStarted = VideoUtils.playVideo(getActivity(), mMovie.getOfflineCopyUri(path), FileSource.FILE, mMovie); - if (playbackStarted) { - mVideoPlaybackStarted = System.currentTimeMillis(); - checkIn(); - } - } else { - playMovie(paths.get(0).getFilepath(), paths.get(0).getType()); - } - } else { - boolean hasOfflineCopy = false; - for (Filepath path : paths) { - if (mMovie.hasOfflineCopy(path)) { - boolean playbackStarted = VideoUtils.playVideo(getActivity(), mMovie.getOfflineCopyUri(path), FileSource.FILE, mMovie); - if (playbackStarted) { - mVideoPlaybackStarted = System.currentTimeMillis(); - checkIn(); - } - - hasOfflineCopy = true; - break; - } - } - - if (!hasOfflineCopy) { - MizLib.showSelectFileDialog(mContext, mMovie.getFilepaths(), new Dialog.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Filepath path = mMovie.getFilepaths().get(which); - playMovie(path.getFilepath(), path.getType()); - } - }); - } - } - } - - private void playMovie(String filepath, int filetype) { - if (filepath.toLowerCase(Locale.getDefault()).matches(".*(cd1|part1).*")) { - new GetSplitFiles(filepath, filetype).execute(); - } else { - mVideoPlaybackStarted = System.currentTimeMillis(); - boolean playbackStarted = VideoUtils.playVideo(getActivity(), filepath, filetype, mMovie); - if (playbackStarted) - checkIn(); - } - } - - public void editMovie() { - Intent intent = new Intent(mContext, EditMovie.class); - intent.putExtra("movieId", mMovie.getTmdbId()); - getActivity().startActivityForResult(intent, 1); - } - - public void onKeyDown(int keyCode, KeyEvent event) { - switch (keyCode) { - case KeyEvent.KEYCODE_MEDIA_PLAY: - case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: - playMovie(); - } - } - - private class GetSplitFiles extends AsyncTask> { - - private ProgressDialog progress; - private String orig_filepath; - private int fileType; - - public GetSplitFiles(String filepath, int filetype) { - this.orig_filepath = filepath; - fileType = filetype; - } - - @Override - protected void onPreExecute() { - progress = new ProgressDialog(getActivity()); - progress.setIndeterminate(true); - progress.setTitle(getString(R.string.loading_movie_parts)); - progress.setMessage(getString(R.string.few_moments)); - progress.show(); - } - - @Override - protected List doInBackground(String... params) { - List parts = new ArrayList(); - List temp; - - try { - if (fileType == FileSource.SMB) - temp = MizLib.getSplitParts(orig_filepath, MizLib.getAuthFromFilepath(MizLib.TYPE_MOVIE, orig_filepath)); - else - temp = MizLib.getSplitParts(orig_filepath, null); - - for (int i = 0; i < temp.size(); i++) - parts.add(new SplitFile(temp.get(i))); - - } catch (Exception e) {} - - return parts; - } - - @Override - protected void onPostExecute(final List result) { - progress.dismiss(); - - if (result.size() > 0) - mVideoPlaybackStarted = System.currentTimeMillis(); - - if (result.size() > 1) { - AlertDialog.Builder builder = new AlertDialog.Builder(mContext); - builder.setTitle(getString(R.string.playPart)); - builder.setAdapter(new SplitAdapter(mContext, result), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - boolean playbackStarted = VideoUtils.playVideo(getActivity(), result.get(which).getFilepath(), fileType, mMovie); - if (playbackStarted) - checkIn(); - }}); - builder.show(); - } else if (result.size() == 1) { - boolean playbackStarted = VideoUtils.playVideo(getActivity(), result.get(0).getFilepath(), fileType, mMovie); - if (playbackStarted) - checkIn(); - } else { - Toast.makeText(mContext, getString(R.string.errorSomethingWentWrong), Toast.LENGTH_LONG).show(); - } - } - } - - private class SplitAdapter implements android.widget.ListAdapter { - - private List mFiles; - private Context mContext; - private LayoutInflater inflater; - - public SplitAdapter(Context context, List files) { - mContext = context; - inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - mFiles = files; - } - - @Override - public int getCount() { - return mFiles.size(); - } - - @Override - public Object getItem(int position) { - return null; - } - - @Override - public long getItemId(int position) { - return 0; - } - - @Override - public int getItemViewType(int position) { - return 0; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - - if (convertView == null) - convertView = inflater.inflate(R.layout.split_file_item, parent, false); - - // Don't care about the ViewHolder pattern here - ((TextView) convertView.findViewById(R.id.title)).setText(getString(R.string.part) + " " + mFiles.get(position).getPartNumber()); - ((TextView) convertView.findViewById(R.id.description)).setText(mFiles.get(position).getUserFilepath()); - - return convertView; - } - - @Override - public int getViewTypeCount() { - return 1; - } - - @Override - public boolean hasStableIds() { - return true; - } - - @Override - public boolean isEmpty() { - return mFiles.isEmpty(); - } - - @Override - public void registerDataSetObserver(DataSetObserver observer) {} - - @Override - public void unregisterDataSetObserver(DataSetObserver observer) {} - - @Override - public boolean areAllItemsEnabled() { - return true; - } - - @Override - public boolean isEnabled(int position) { - return true; - } - - } - - private class SplitFile { - - String filepath; - - public SplitFile(String filepath) { - this.filepath = filepath; - } - - public String getFilepath() { - return filepath; - } - - public String getUserFilepath() { - return MizLib.transformSmbPath(filepath); - } - - public int getPartNumber() { - return MizLib.getPartNumberFromFilepath(getUserFilepath()); - } - } -} \ No newline at end of file diff --git a/src/com/miz/mizuu/fragments/MovieDiscoveryViewPagerFragment.java b/src/com/miz/mizuu/fragments/MovieDiscoveryViewPagerFragment.java deleted file mode 100644 index 6a8704ee..00000000 --- a/src/com/miz/mizuu/fragments/MovieDiscoveryViewPagerFragment.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.mizuu.fragments; - -import java.util.ArrayList; - -import android.app.ActionBar; -import android.app.ActionBar.OnNavigationListener; -import android.content.Context; -import android.content.Intent; -import android.os.AsyncTask; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v4.view.ViewPager.OnPageChangeListener; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ProgressBar; -import android.widget.Toast; - -import com.miz.functions.ActionBarSpinner; -import com.miz.functions.MizLib; -import com.miz.functions.SpinnerItem; -import com.miz.mizuu.Main; -import com.miz.mizuu.R; -import com.miz.mizuu.SearchWebMovies; - -public class MovieDiscoveryViewPagerFragment extends Fragment implements OnNavigationListener { - - private ProgressBar pbar; - private String baseUrl = "", json = "", mTmdbApiKey; - private ActionBar actionBar; - private ViewPager awesomePager; - private ArrayList spinnerItems = new ArrayList(); - private ActionBarSpinner spinnerAdapter; - - public MovieDiscoveryViewPagerFragment() {} - - public static MovieDiscoveryViewPagerFragment newInstance() { - return new MovieDiscoveryViewPagerFragment(); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setHasOptionsMenu(true); - setRetainInstance(true); - - mTmdbApiKey = MizLib.getTmdbApiKey(getActivity()); - - setupSpinnerItems(); - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - // Setup ActionBar with the action list - setupActionBar(); - if (actionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST) - actionBar.setListNavigationCallbacks(spinnerAdapter, this); - } - - private void setupActionBar() { - actionBar = getActivity().getActionBar(); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - if (spinnerAdapter == null) - spinnerAdapter = new ActionBarSpinner(getActivity(), spinnerItems); - } - - private void setupSpinnerItems() { - spinnerItems.clear(); - spinnerItems.add(new SpinnerItem(getString(R.string.chooserMovies), getString(R.string.stringUpcoming))); - spinnerItems.add(new SpinnerItem(getString(R.string.chooserMovies), getString(R.string.stringNowPlaying))); - spinnerItems.add(new SpinnerItem(getString(R.string.chooserMovies), getString(R.string.stringPopular))); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.viewpager, container, false); - } - - @Override - public void onViewCreated(View v, Bundle savedInstanceState) { - super.onViewCreated(v, savedInstanceState); - - pbar = (ProgressBar) v.findViewById(R.id.progressbar); - pbar.setVisibility(View.VISIBLE); - - awesomePager = (ViewPager) v.findViewById(R.id.awesomepager); - awesomePager.setOffscreenPageLimit(3); - awesomePager.setPageMargin(MizLib.convertDpToPixels(getActivity(), 16)); - awesomePager.setOnPageChangeListener(new OnPageChangeListener() { - @Override - public void onPageScrollStateChanged(int arg0) {} - - @Override - public void onPageScrolled(int arg0, float arg1, int arg2) {} - - @Override - public void onPageSelected(int arg0) { - if (isAdded()) - actionBar.setSelectedNavigationItem(arg0); - } - }); - - if (savedInstanceState != null) { - awesomePager.setCurrentItem(savedInstanceState.getInt("selectedIndex", 0)); - } - - if (json.isEmpty()) { - new MovieLoader(getActivity()).execute(); - } else { - awesomePager.setAdapter(new WebVideosAdapter(getChildFragmentManager())); - pbar.setVisibility(View.GONE); - } - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - if (((Main) getActivity()).isDrawerOpen()) { - if (actionBar == null && getActivity() != null) - actionBar = getActivity().getActionBar(); - actionBar.setNavigationMode(ActionBar.DISPLAY_SHOW_TITLE); - ((Main) getActivity()).showDrawerOptionsMenu(menu, inflater); - } else { - setupActionBar(); - inflater.inflate(R.menu.menu_web_movies, menu); - } - super.onCreateOptionsMenu(menu, inflater); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.search_textbox: - Intent i = new Intent(getActivity().getApplicationContext(), SearchWebMovies.class); - startActivity(i); - break; - } - - return super.onOptionsItemSelected(item); - } - - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putInt("selectedIndex", awesomePager.getCurrentItem()); - } - - private class WebVideosAdapter extends FragmentPagerAdapter { - - public WebVideosAdapter(FragmentManager fm) { - super(fm); - } - - @Override - public Fragment getItem(int index) { - switch (index) { - case 0: return MovieDiscoveryFragment.newInstance("upcoming", json, baseUrl); - case 1: return MovieDiscoveryFragment.newInstance("now_playing", json, baseUrl); - default: return MovieDiscoveryFragment.newInstance("popular", json, baseUrl); - } - } - - @Override - public int getCount() { - return spinnerItems.size(); - } - } - - @Override - public boolean onNavigationItemSelected(int itemPosition, long itemId) { - awesomePager.setCurrentItem(itemPosition); - return true; - } - - private class MovieLoader extends AsyncTask { - - private Context mContext; - - public MovieLoader(Context context) { - mContext = context; - } - - @Override - protected String doInBackground(Object... params) { - try { - baseUrl = MizLib.getTmdbImageBaseUrl(mContext); - json = MizLib.getJSONObject(mContext, "https://api.themoviedb.org/3/movie?api_key=" + mTmdbApiKey + "&append_to_response=upcoming,now_playing,popular,top_rated").toString(); - - return json; - } catch (Exception e) {} // If the fragment is no longer attached to the Activity - - return null; - } - - @Override - protected void onPostExecute(String result) { - if (result != null) { - awesomePager.setAdapter(new WebVideosAdapter(getChildFragmentManager())); - - pbar.setVisibility(View.GONE); - } else { - Toast.makeText(getActivity(), R.string.errorSomethingWentWrong, Toast.LENGTH_SHORT).show(); - } - } - } -} \ No newline at end of file diff --git a/src/com/miz/mizuu/fragments/MovieLibraryFragment.java b/src/com/miz/mizuu/fragments/MovieLibraryFragment.java deleted file mode 100644 index 8b94d346..00000000 --- a/src/com/miz/mizuu/fragments/MovieLibraryFragment.java +++ /dev/null @@ -1,1319 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.mizuu.fragments; - -import static com.miz.functions.PreferenceKeys.GRID_ITEM_SIZE; -import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; -import static com.miz.functions.PreferenceKeys.SHOW_TITLES_IN_GRID; -import static com.miz.functions.PreferenceKeys.SORTING_COLLECTIONS_OVERVIEW; -import static com.miz.functions.PreferenceKeys.SORTING_MOVIES; -import static com.miz.functions.SortingKeys.ALL_MOVIES; -import static com.miz.functions.SortingKeys.AVAILABLE_FILES; -import static com.miz.functions.SortingKeys.CERTIFICATION; -import static com.miz.functions.SortingKeys.COLLECTIONS; -import static com.miz.functions.SortingKeys.DATE; -import static com.miz.functions.SortingKeys.DURATION; -import static com.miz.functions.SortingKeys.FAVORITES; -import static com.miz.functions.SortingKeys.FILE_SOURCES; -import static com.miz.functions.SortingKeys.FOLDERS; -import static com.miz.functions.SortingKeys.GENRES; -import static com.miz.functions.SortingKeys.OFFLINE_COPIES; -import static com.miz.functions.SortingKeys.RATING; -import static com.miz.functions.SortingKeys.RELEASE; -import static com.miz.functions.SortingKeys.RELEASE_YEAR; -import static com.miz.functions.SortingKeys.TITLE; -import static com.miz.functions.SortingKeys.UNWATCHED_MOVIES; -import static com.miz.functions.SortingKeys.WATCHED_MOVIES; -import static com.miz.functions.SortingKeys.WEIGHTED_RATING; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Random; -import java.util.TreeMap; -import java.util.regex.Pattern; - -import jcifs.smb.SmbFile; -import android.app.ActionBar; -import android.app.ActionBar.OnNavigationListener; -import android.app.AlertDialog; -import android.app.SearchManager; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; -import android.content.SharedPreferences.OnSharedPreferenceChangeListener; -import android.database.Cursor; -import android.graphics.Bitmap.Config; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.support.v4.app.Fragment; -import android.support.v4.app.LoaderManager.LoaderCallbacks; -import android.support.v4.content.Loader; -import android.support.v4.content.LocalBroadcastManager; -import android.support.v4.view.MenuItemCompat; -import android.support.v4.view.MenuItemCompat.OnActionExpandListener; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewTreeObserver; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.BaseAdapter; -import android.widget.GridView; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ProgressBar; -import android.widget.SearchView; -import android.widget.SearchView.OnQueryTextListener; -import android.widget.TextView; - -import com.google.common.collect.ArrayListMultimap; -import com.miz.db.DatabaseHelper; -import com.miz.db.DbAdapterMovieMappings; -import com.miz.db.DbAdapterMovies; -import com.miz.db.DbAdapterSources; -import com.miz.functions.ActionBarSpinnerViewHolder; -import com.miz.functions.AsyncTask; -import com.miz.functions.ColumnIndexCache; -import com.miz.functions.CoverItem; -import com.miz.functions.FileSource; -import com.miz.functions.Filepath; -import com.miz.functions.LibrarySectionAsyncTask; -import com.miz.functions.MediumMovie; -import com.miz.functions.MizLib; -import com.miz.functions.MovieSortHelper; -import com.miz.functions.SQLiteCursorLoader; -import com.miz.functions.SpinnerItem; -import com.miz.mizuu.Main; -import com.miz.mizuu.MizuuApplication; -import com.miz.mizuu.MovieCollection; -import com.miz.mizuu.MovieDetails; -import com.miz.mizuu.R; -import com.miz.mizuu.UnidentifiedMovies; -import com.miz.mizuu.Update; -import com.miz.utils.LocalBroadcastUtils; -import com.squareup.picasso.Picasso; - -public class MovieLibraryFragment extends Fragment implements OnNavigationListener, OnSharedPreferenceChangeListener { - - public static final int MAIN = 0, OTHER = 1; - - private SharedPreferences mSharedPreferences; - private int mImageThumbSize, mImageThumbSpacing, mType, mResizedWidth, mResizedHeight, mCurrentSort; - private LoaderAdapter mAdapter; - private ArrayList mMovies = new ArrayList(); - private ArrayList mMovieKeys = new ArrayList(); - private GridView mGridView = null; - private ProgressBar mProgressBar; - private boolean mIgnorePrefixes, mLoading, mShowTitles; - private ActionBar mActionBar; - private ArrayList mSpinnerItems = new ArrayList(); - private ActionBarSpinner mSpinnerAdapter; - private Picasso mPicasso; - private Config mConfig; - private MovieSectionLoader mMovieSectionLoader; - private SearchTask mSearch; - private View mEmptyLibraryLayout; - private TextView mEmptyLibraryTitle, mEmptyLibraryDescription; - - /** - * Empty constructor as per the Fragment documentation - */ - public MovieLibraryFragment() {} - - public static MovieLibraryFragment newInstance(int type) { - MovieLibraryFragment frag = new MovieLibraryFragment(); - Bundle b = new Bundle(); - b.putInt("type", type); - frag.setArguments(b); - return frag; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - mType = getArguments().getInt("type"); - - setRetainInstance(true); - setHasOptionsMenu(true); - - setupSpinnerItems(); - - // Set OnSharedPreferenceChange listener - PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this); - - // Initialize the PreferenceManager variable and preference variable(s) - mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); - - mIgnorePrefixes = mSharedPreferences.getBoolean(IGNORED_TITLE_PREFIXES, false); - mShowTitles = mSharedPreferences.getBoolean(SHOW_TITLES_IN_GRID, true); - - String thumbnailSize = mSharedPreferences.getString(GRID_ITEM_SIZE, getString(R.string.normal)); - if (thumbnailSize.equals(getString(R.string.large))) - mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 1.33); - else if (thumbnailSize.equals(getString(R.string.normal))) - mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 1); - else - mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 0.75); - mImageThumbSpacing = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); - - mPicasso = MizuuApplication.getPicasso(getActivity()); - mConfig = MizuuApplication.getBitmapConfig(); - - mAdapter = new LoaderAdapter(getActivity()); - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - // Setup ActionBar with the action list - setupActionBar(); - if (mActionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST) - mActionBar.setListNavigationCallbacks(mSpinnerAdapter, this); - - LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.UPDATE_MOVIE_LIBRARY)); - LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver, new IntentFilter("mizuu-movie-actor-search")); - } - - private void setupActionBar() { - mActionBar = getActivity().getActionBar(); - mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - if (mSpinnerAdapter == null) - mSpinnerAdapter = new ActionBarSpinner(); - } - - private void setupSpinnerItems() { - mSpinnerItems.clear(); - if (mType == MAIN) - mSpinnerItems.add(new SpinnerItem(getString(R.string.chooserMovies), getString(R.string.choiceAllMovies))); - else - mSpinnerItems.add(new SpinnerItem(getString(R.string.chooserWatchList), getString(R.string.choiceAllMovies))); - mSpinnerItems.add(new SpinnerItem(getString(R.string.choiceFavorites), getString(R.string.choiceFavorites))); - mSpinnerItems.add(new SpinnerItem(getString(R.string.choiceAvailableFiles), getString(R.string.choiceAvailableFiles))); - mSpinnerItems.add(new SpinnerItem(getString(R.string.choiceCollections), getString(R.string.choiceCollections))); - mSpinnerItems.add(new SpinnerItem(getString(R.string.choiceWatchedMovies), getString(R.string.choiceWatchedMovies))); - mSpinnerItems.add(new SpinnerItem(getString(R.string.choiceUnwatchedMovies), getString(R.string.choiceUnwatchedMovies))); - mSpinnerItems.add(new SpinnerItem(getString(R.string.choiceOffline), getString(R.string.choiceOffline))); - } - - private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (intent.filterEquals(new Intent("mizuu-movie-actor-search"))) { - search("actor: " + intent.getStringExtra("intent_extra_data_key")); - } else { - clearCaches(); - forceLoaderLoad(); - } - } - }; - - LoaderCallbacks loaderCallbacks = new LoaderCallbacks() { - @Override - public Loader onCreateLoader(int arg0, Bundle arg1) { - mLoading = true; - return new SQLiteCursorLoader(getActivity(), DatabaseHelper.getHelper(getActivity()).getWritableDatabase(), DbAdapterMovies.DATABASE_TABLE, - DbAdapterMovies.SELECT_ALL, "NOT(" + DbAdapterMovies.KEY_TITLE + " = '" + DbAdapterMovies.REMOVED_MOVIE_TITLE + "')", null, null, null, null); - } - - @Override - public void onLoadFinished(Loader arg0, final Cursor cursor) { - new AsyncTask() { - @Override - protected void onPreExecute() { - mMovies.clear(); - mMovieKeys.clear(); - } - - @Override - protected Void doInBackground(Void... params) { - // Normally we'd have to go through each movie and add filepaths mapped to that movie - // one by one. This is a hacky approach that gets all filepaths at once and creates a - // map of them. That way it's easy to get filepaths for a specific movie - and it's - // 2-3x faster with ~750 movies. - ArrayListMultimap filepaths = ArrayListMultimap.create(); - Cursor paths = MizuuApplication.getMovieMappingAdapter().getAllFilepaths(false); - if (paths != null) { - try { - while (paths.moveToNext()) { - filepaths.put(paths.getString(paths.getColumnIndex(DbAdapterMovieMappings.KEY_TMDB_ID)), - paths.getString(paths.getColumnIndex(DbAdapterMovieMappings.KEY_FILEPATH))); - } - } catch (Exception e) {} finally { - paths.close(); - MizuuApplication.setMovieFilepaths(filepaths); - } - } - - HashMap collectionsMap = MizuuApplication.getCollectionsAdapter().getCollectionsMap(); - ColumnIndexCache cache = new ColumnIndexCache(); - - try { - while (cursor.moveToNext()) { - if (mType == OTHER && cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TO_WATCH)).equals("0")) - continue; - - mMovies.add(new MediumMovie(getActivity(), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TITLE)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TMDB_ID)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_RATING)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_RELEASEDATE)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_GENRES)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_FAVOURITE)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_ACTORS)), - collectionsMap.get(cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_COLLECTION_ID))), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_COLLECTION_ID)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_TO_WATCH)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_HAS_WATCHED)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_DATE_ADDED)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_CERTIFICATION)), - cursor.getString(cache.getColumnIndex(cursor, DbAdapterMovies.KEY_RUNTIME)), - mIgnorePrefixes - )); - } - } catch (Exception e) {} finally { - cursor.close(); - cache.clear(); - } - - for (int i = 0; i < mMovies.size(); i++) { - if (mType == OTHER) - if (!mMovies.get(i).toWatch()) - continue; - mMovieKeys.add(i); - } - - return null; - } - - @Override - protected void onPostExecute(Void result) { - showMovieSection(mActionBar.getSelectedNavigationIndex()); - - getActivity().invalidateOptionsMenu(); - - mLoading = false; - } - }.execute(); - } - - @Override - public void onLoaderReset(Loader arg0) { - mMovies.clear(); - mMovieKeys.clear(); - notifyDataSetChanged(); - } - }; - - private void clearCaches() { - if (isAdded()) - MizuuApplication.clearLruCache(getActivity()); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.image_grid_fragment, container, false); - } - - @Override - public void onViewCreated(View v, Bundle savedInstanceState) { - super.onViewCreated(v, savedInstanceState); - - mProgressBar = (ProgressBar) v.findViewById(R.id.progress); - if (mMovieKeys.size() > 0) - mProgressBar.setVisibility(View.GONE); - - mEmptyLibraryLayout = v.findViewById(R.id.empty_library_layout); - mEmptyLibraryTitle = (TextView) v.findViewById(R.id.empty_library_title); - mEmptyLibraryTitle.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "RobotoCondensed-Regular.ttf")); - mEmptyLibraryDescription = (TextView) v.findViewById(R.id.empty_library_description); - if (mType == OTHER) - mEmptyLibraryDescription.setText(R.string.empty_watchlist_description); - mEmptyLibraryDescription.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-Light.ttf")); - - mAdapter = new LoaderAdapter(getActivity()); - - mGridView = (GridView) v.findViewById(R.id.gridView); - mGridView.setAdapter(mAdapter); - mGridView.setEmptyView(mEmptyLibraryLayout); - mGridView.setColumnWidth(mImageThumbSize); - - // Calculate the total column width to set item heights by factor 1.5 - mGridView.getViewTreeObserver().addOnGlobalLayoutListener( - new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - if (mAdapter.getNumColumns() == 0) { - final int numColumns = (int) Math.floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing)); - if (numColumns > 0) { - mAdapter.setNumColumns(numColumns); - mResizedWidth = (int) (((mGridView.getWidth() - (numColumns * mImageThumbSpacing)) - / numColumns) * 1.1); // * 1.1 is a hack to make images look slightly less blurry - mResizedHeight = (int) (mResizedWidth * 1.5); - } - - MizLib.removeViewTreeObserver(mGridView.getViewTreeObserver(), this); - } - } - }); - mGridView.setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { - showDetails(arg2); - } - }); - } - - private void showDetails(int arg2) { - Intent intent = new Intent(); - if (mActionBar.getSelectedNavigationIndex() == COLLECTIONS) { // Collection - intent.putExtra("collectionId", mMovies.get(mMovieKeys.get(arg2)).getCollectionId()); - intent.putExtra("collectionTitle", mMovies.get(mMovieKeys.get(arg2)).getCollection()); - intent.setClass(getActivity(), MovieCollection.class); - startActivity(intent); - } else { - intent.putExtra("tmdbId", mMovies.get(mMovieKeys.get(arg2)).getTmdbId()); - intent.setClass(getActivity(), MovieDetails.class); - startActivityForResult(intent, 0); - } - } - - @Override - public void onResume() { - super.onResume(); - - if (mMovies.size() == 0) - forceLoaderLoad(); - - notifyDataSetChanged(); - } - - @Override - public void onDestroy() { - // Unregister since the activity is about to be closed. - LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mMessageReceiver); - PreferenceManager.getDefaultSharedPreferences(getActivity()).unregisterOnSharedPreferenceChangeListener(this); - - super.onDestroy(); - } - - private class LoaderAdapter extends BaseAdapter { - - private LayoutInflater mInflater; - private final Context mContext; - private int mNumColumns = 0; - private boolean mCollectionsView = false; - private ArrayList mMovieKeys = new ArrayList(); - private ArrayList mMovies = new ArrayList(); - - public LoaderAdapter(Context context) { - mContext = context; - mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - } - - // This is necessary in order to avoid random ArrayOutOfBoundsException when changing the items (i.e. during a library update) - public void setItems(ArrayList movieKeys, ArrayList movies) { - mMovieKeys = new ArrayList(movieKeys); - mMovies = new ArrayList(movies); - notifyDataSetChanged(); - } - - @Override - public boolean isEmpty() { - return !mLoading && mMovieKeys.size() == 0; - } - - @Override - public int getCount() { - return mMovieKeys.size(); - } - - @Override - public Object getItem(int position) { - return position; - } - - @Override - public long getItemId(int position) { - return position; - } - - @Override - public View getView(int position, View convertView, ViewGroup container) { - final MediumMovie mMovie = mMovies.get(mMovieKeys.get(position)); - - CoverItem holder; - if (convertView == null) { - convertView = mInflater.inflate(R.layout.grid_item, container, false); - holder = new CoverItem(); - - holder.mLinearLayout = (LinearLayout) convertView.findViewById(R.id.card_layout); - holder.cover = (ImageView) convertView.findViewById(R.id.cover); - holder.text = (TextView) convertView.findViewById(R.id.text); - holder.subtext = (TextView) convertView.findViewById(R.id.gridCoverSubtitle); - holder.subtext.setSingleLine(true); - - holder.text.setTypeface(MizuuApplication.getOrCreateTypeface(mContext, "Roboto-Medium.ttf")); - - convertView.setTag(holder); - } else { - holder = (CoverItem) convertView.getTag(); - } - - if (!mShowTitles) { - holder.text.setVisibility(View.GONE); - holder.subtext.setVisibility(View.GONE); - } else { - holder.text.setVisibility(View.VISIBLE); - - holder.text.setText(mCollectionsView ? mMovie.getCollection() : mMovie.getTitle()); - if (mCollectionsView) { - holder.text.setSingleLine(false); - holder.text.setLines(2); - holder.text.setMaxLines(2); - holder.subtext.setVisibility(View.GONE); - } else { - holder.text.setSingleLine(true); - holder.text.setLines(1); - holder.text.setMaxLines(1); - holder.subtext.setVisibility(View.VISIBLE); - holder.subtext.setText(mMovie.getSubText(mCurrentSort)); - } - } - - holder.cover.setImageResource(R.color.card_background_dark); - - if (!mCollectionsView) { - // Movie poster - if (mResizedWidth > 0) - mPicasso.load(mMovie.getThumbnail()).resize(mResizedWidth, mResizedHeight).config(mConfig).into(holder); - else - mPicasso.load(mMovie.getThumbnail()).config(mConfig).into(holder); - } else { - // Collection poster - if (mResizedWidth > 0) - mPicasso.load(mMovie.getCollectionPoster()).resize(mResizedWidth, mResizedHeight).config(mConfig).into(holder); - else - mPicasso.load(mMovie.getCollectionPoster()).config(mConfig).into(holder); - } - - return convertView; - } - - @Override - public void notifyDataSetChanged() { - if (mActionBar != null) - mCollectionsView = mActionBar.getSelectedNavigationIndex() == COLLECTIONS; - - super.notifyDataSetChanged(); - } - - public void setNumColumns(int numColumns) { - mNumColumns = numColumns; - } - - public int getNumColumns() { - return mNumColumns; - } - } - - private void notifyDataSetChanged() { - if (mAdapter != null) - mAdapter.setItems(mMovieKeys, mMovies); - - if (mSpinnerAdapter != null) - mSpinnerAdapter.notifyDataSetChanged(); - } - - @Override - public boolean onNavigationItemSelected(int itemPosition, long itemId) { - if (!mLoading) - showMovieSection(itemPosition); - - return true; - } - - private class MovieSectionLoader extends LibrarySectionAsyncTask { - private int mPosition; - private ArrayList mTempKeys = new ArrayList(); - - public MovieSectionLoader(int position) { - mPosition = position; - } - - @Override - protected void onPreExecute() { - setProgressBarVisible(true); - mMovieKeys.clear(); - } - - @Override - protected Boolean doInBackground(Void... params) { - if (isCancelled()) - return false; - - switch (mPosition) { - case ALL_MOVIES: - for (int i = 0; i < mMovies.size(); i++) - if (!mMovies.get(i).isUnidentified()) - mTempKeys.add(i); - break; - - case FAVORITES: - for (int i = 0; i < mMovies.size(); i++) - if (mMovies.get(i).isFavourite()) - mTempKeys.add(i); - break; - - case AVAILABLE_FILES: - ArrayList filesources = MizLib.getFileSources(MizLib.TYPE_MOVIE, true); - - for (int i = 0; i < mMovies.size(); i++) { - if (isCancelled()) - return false; - - for (Filepath path : mMovies.get(i).getFilepaths()) { - if (path.isNetworkFile()) - if (mMovies.get(i).hasOfflineCopy(path)) { - mTempKeys.add(i); - break; // break inner loop to continue to the next movie - } else { - if (path.getType() == FileSource.SMB) { - - - if (MizLib.isWifiConnected(getActivity())) { - FileSource source = null; - - for (int j = 0; j < filesources.size(); j++) - if (path.getFilepath().contains(filesources.get(j).getFilepath())) { - source = filesources.get(j); - continue; - } - - if (source == null) - continue; - - try { - final SmbFile file = new SmbFile( - MizLib.createSmbLoginString( - source.getDomain(), - source.getUser(), - source.getPassword(), - path.getFilepath(), - false - )); - if (file.exists()) { - mTempKeys.add(i); - break; // break inner loop to continue to the next movie - } - } catch (Exception e) {} // Do nothing - the file isn't available (either MalformedURLException or SmbException) - } - } else if (path.getType() == FileSource.UPNP) { - if (MizLib.exists(path.getFilepath())) { - mTempKeys.add(i); - break; // break inner loop to continue to the next movie - } - } - } else { - if (new File(path.getFilepath()).exists()) { - mTempKeys.add(i); - break; // break inner loop to continue to the next movie - } - } - } - } - break; - - case COLLECTIONS: - HashMap map = new HashMap(); - for (int i = 0; i < mMovies.size(); i++) - if (!TextUtils.isEmpty(mMovies.get(i).getCollection()) && !mMovies.get(i).getCollection().equals("null")) - if (!map.containsKey(mMovies.get(i).getCollection())) { - map.put(mMovies.get(i).getCollection(), mMovies.get(i)); - mTempKeys.add(i); - } - map.clear(); - break; - - case WATCHED_MOVIES: - for (int i = 0; i < mMovies.size(); i++) - if (mMovies.get(i).hasWatched()) - mTempKeys.add(i); - break; - - case UNWATCHED_MOVIES: - for (int i = 0; i < mMovies.size(); i++) - if (!mMovies.get(i).hasWatched()) - mTempKeys.add(i); - break; - - case OFFLINE_COPIES: - // No point in running through all movies if the folder - // doesn't contain any files at all - so let's check that first - File offlineFolder = MizuuApplication.getAvailableOfflineFolder(getActivity()); - if (offlineFolder != null && offlineFolder.listFiles().length == 0) - return true; // Return true in order to force the notifyDataSetChanged() call - - for (int i = 0; i < mMovies.size(); i++) { - if (isCancelled()) - return false; - - for (Filepath path : mMovies.get(i).getFilepaths()) - if (mMovies.get(i).hasOfflineCopy(path)) { - mTempKeys.add(i); - break; // break inner loop to continue to the next movie - } - } - break; - } - - return true; - } - - @Override - protected void onPostExecute(Boolean success) { - // Make sure that the loading was successful, that the Fragment is still added and - // that the currently selected navigation index is the same as when we started loading - if (success && isAdded() && mActionBar.getSelectedNavigationIndex() == mPosition) { - mMovieKeys.addAll(mTempKeys); - - sortMovies(); - notifyDataSetChanged(); - setProgressBarVisible(false); - } - } - } - - private void showMovieSection(int position) { - if (mSpinnerAdapter != null) - mSpinnerAdapter.notifyDataSetChanged(); // To show "0 movies" when loading - - if (mMovieSectionLoader != null) - mMovieSectionLoader.cancel(true); - mMovieSectionLoader = new MovieSectionLoader(position); - mMovieSectionLoader.execute(); - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - if (((Main) getActivity()).isDrawerOpen()) { - if (mActionBar == null && getActivity() != null) - mActionBar = getActivity().getActionBar(); - mActionBar.setNavigationMode(ActionBar.DISPLAY_SHOW_TITLE); - ((Main) getActivity()).showDrawerOptionsMenu(menu, inflater); - } else { - setupActionBar(); - inflater.inflate(R.menu.menu, menu); - if (mType == OTHER) // Don't show the Update icon if this is the Watchlist - menu.removeItem(R.id.update); - - if (mMovies.size() == 0) - menu.findItem(R.id.random).setVisible(false); - else - menu.findItem(R.id.random).setVisible(true); - - MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.search_textbox), new OnActionExpandListener() { - @Override - public boolean onMenuItemActionExpand(MenuItem item) { - return true; - } - - @Override - public boolean onMenuItemActionCollapse(MenuItem item) { - onSearchViewCollapsed(); - return true; - } - }); - - SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); - SearchView searchView = (SearchView) menu.findItem(R.id.search_textbox).getActionView(); - searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); - searchView.setOnQueryTextListener(new OnQueryTextListener() { - @Override - public boolean onQueryTextChange(String newText) { - if (newText.length() > 0) { - search(newText); - } else { - onSearchViewCollapsed(); - } - return true; - } - @Override - public boolean onQueryTextSubmit(String query) { return false; } - }); - } - super.onCreateOptionsMenu(menu, inflater); - } - - private void onSearchViewCollapsed() { - if (isAdded() && mActionBar != null) { - if (mActionBar.getSelectedNavigationIndex() == ALL_MOVIES) - showMovieSection(ALL_MOVIES); - else - mActionBar.setSelectedNavigationItem(ALL_MOVIES); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - super.onOptionsItemSelected(item); - - switch (item.getItemId()) { - case R.id.update: - startActivityForResult(getUpdateIntent(), 0); - break; - case R.id.menuSortAdded: - sortBy(DATE); - break; - case R.id.menuSortRating: - sortBy(RATING); - break; - case R.id.menuSortWeightedRating: - sortBy(WEIGHTED_RATING); - break; - case R.id.menuSortRelease: - sortBy(RELEASE); - break; - case R.id.menuSortTitle: - sortBy(TITLE); - break; - case R.id.menuSortDuration: - sortBy(DURATION); - break; - case R.id.genres: - showGenres(); - break; - case R.id.certifications: - showCertifications(); - break; - case R.id.folders: - showFolders(); - break; - case R.id.fileSources: - showFileSources(); - break; - case R.id.release_year: - showReleaseYear(); - break; - case R.id.clear_filters: - showMovieSection(mActionBar.getSelectedNavigationIndex()); - break; - case R.id.random: - if (mMovieKeys.size() > 0) { - int random = new Random().nextInt(mMovieKeys.size()); - showDetails(random); - } - break; - case R.id.unidentifiedFiles: - startActivity(new Intent(getActivity(), UnidentifiedMovies.class)); - break; - } - - return true; - } - - private Intent getUpdateIntent() { - Intent intent = new Intent(); - intent.setClass(getActivity(), Update.class); - intent.putExtra("isMovie", true); - return intent; - } - - private void sortMovies() { - if (!isAdded()) - return; - - String SORT_TYPE = mSharedPreferences.getString((getActivity().getActionBar().getSelectedNavigationIndex() == COLLECTIONS) ? SORTING_COLLECTIONS_OVERVIEW : SORTING_MOVIES, "sortTitle"); - - if (SORT_TYPE.equals("sortRelease")) { - sortBy(RELEASE); - } else if (SORT_TYPE.equals("sortRating")) { - sortBy(RATING); - } else if (SORT_TYPE.equals("sortWeightedRating")) { - sortBy(WEIGHTED_RATING); - } else if (SORT_TYPE.equals("sortAdded")) { - sortBy(DATE); - } else if (SORT_TYPE.equals("sortDuration")) { - sortBy(DURATION); - } else { // if SORT_TYPE equals "sortTitle" - sortBy(TITLE); - } - } - - public void sortBy(int sort) { - if (!isAdded()) - return; - - mCurrentSort = sort; - - boolean isCollection = getActivity().getActionBar().getSelectedNavigationIndex() == COLLECTIONS; - - String key = isCollection ? SORTING_COLLECTIONS_OVERVIEW : SORTING_MOVIES; - Editor editor = mSharedPreferences.edit(); - switch (mCurrentSort) { - case TITLE: - editor.putString(key, "sortTitle"); - break; - case RELEASE: - editor.putString(key, "sortRelease"); - break; - case RATING: - editor.putString(key, "sortRating"); - break; - case WEIGHTED_RATING: - editor.putString(key, "sortWeightedRating"); - break; - case DATE: - editor.putString(key, "sortAdded"); - break; - case DURATION: - editor.putString(key, "sortDuration"); - break; - } - editor.apply(); - - ArrayList tempHelper = new ArrayList(); - for (int i = 0; i < mMovieKeys.size(); i++) { - tempHelper.add(new MovieSortHelper(mMovies.get(mMovieKeys.get(i)), mMovieKeys.get(i), mCurrentSort, isCollection)); - } - - Collections.sort(tempHelper); - - mMovieKeys.clear(); - for (int i = 0; i < tempHelper.size(); i++) { - mMovieKeys.add(tempHelper.get(i).getIndex()); - } - - tempHelper.clear(); - - setProgressBarVisible(false); - notifyDataSetChanged(); - } - - private void showGenres() { - final TreeMap map = new TreeMap(); - String[] splitGenres; - for (int i = 0; i < mMovieKeys.size(); i++) { - if (!mMovies.get(mMovieKeys.get(i)).getGenres().isEmpty()) { - splitGenres = mMovies.get(mMovieKeys.get(i)).getGenres().split(","); - for (int j = 0; j < splitGenres.length; j++) { - if (map.containsKey(splitGenres[j].trim())) { - map.put(splitGenres[j].trim(), map.get(splitGenres[j].trim()) + 1); - } else { - map.put(splitGenres[j].trim(), 1); - } - } - } - } - - createAndShowAlertDialog(setupItemArray(map, R.string.allGenres), R.string.selectGenre, GENRES); - } - - private void showCertifications() { - final TreeMap map = new TreeMap(); - for (int i = 0; i < mMovieKeys.size(); i++) { - String certification = mMovies.get(mMovieKeys.get(i)).getCertification(); - if (!TextUtils.isEmpty(certification)) { - if (map.containsKey(certification.trim())) { - map.put(certification.trim(), map.get(certification.trim()) + 1); - } else { - map.put(certification.trim(), 1); - } - } - } - - createAndShowAlertDialog(setupItemArray(map, R.string.allCertifications), R.string.selectCertification, CERTIFICATION); - } - - private void showFileSources() { - ArrayList sources = new ArrayList(); - - DbAdapterSources dbHelper = MizuuApplication.getSourcesAdapter(); - Cursor cursor = dbHelper.fetchAllMovieSources(); - while (cursor.moveToNext()) { - sources.add(new FileSource( - cursor.getLong(cursor.getColumnIndex(DbAdapterSources.KEY_ROWID)), - cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_FILEPATH)), - cursor.getInt(cursor.getColumnIndex(DbAdapterSources.KEY_FILESOURCE_TYPE)), - cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_USER)), - cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_PASSWORD)), - cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_DOMAIN)), - cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_TYPE)) - )); - } - cursor.close(); - - final TreeMap map = new TreeMap(); - - for (int i = 0; i < mMovieKeys.size(); i++) { - for (Filepath path : mMovies.get(mMovieKeys.get(i)).getFilepaths()) { - for (int j = 0; j < sources.size(); j++) { - String source = sources.get(j).getFilepath(); - - if (!TextUtils.isEmpty(source) && !TextUtils.isEmpty(path.getFilepath()) && path.getFilepath().contains(source)) { - if (map.containsKey(source.trim())) { - map.put(source.trim(), map.get(source.trim()) + 1); - } else { - map.put(source.trim(), 1); - } - } - } - } - } - - createAndShowAlertDialog(setupItemArray(map, R.string.allFileSources), R.string.selectFileSource, FILE_SOURCES); - } - - private void showReleaseYear() { - final TreeMap map = new TreeMap(); - for (int i = 0; i < mMovieKeys.size(); i++) { - String year = mMovies.get(mMovieKeys.get(i)).getReleaseYear().trim(); - if (!TextUtils.isEmpty(year)) { - if (map.containsKey(year)) { - map.put(year, map.get(year) + 1); - } else { - map.put(year, 1); - } - } - } - - createAndShowAlertDialog(setupItemArray(map, R.string.allReleaseYears), R.string.selectReleaseYear, RELEASE_YEAR); - } - - private void showFolders() { - final TreeMap map = new TreeMap(); - for (int i = 0; i < mMovieKeys.size(); i++) { - for (Filepath path : mMovies.get(mMovieKeys.get(i)).getFilepaths()) { - String folder = path.getFilepath(); - if (!TextUtils.isEmpty(folder)) { - if (map.containsKey(folder.trim())) { - map.put(folder.trim(), map.get(folder.trim()) + 1); - } else { - map.put(folder.trim(), 1); - } - } - } - } - - createAndShowAlertDialog(setupItemArray(map, R.string.allFolders), R.string.selectFolder, FOLDERS); - } - - private CharSequence[] setupItemArray(TreeMap map, int stringId) { - final CharSequence[] tempArray = map.keySet().toArray(new CharSequence[map.keySet().size()]); - for (int i = 0; i < tempArray.length; i++) - tempArray[i] = tempArray[i] + " (" + map.get(tempArray[i]) + ")"; - - final CharSequence[] temp = new CharSequence[tempArray.length + 1]; - temp[0] = getString(stringId); - - for (int i = 1; i < temp.length; i++) - temp[i] = tempArray[i-1]; - - return temp; - } - - private void createAndShowAlertDialog(final CharSequence[] temp, int title, final int type) { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setTitle(title) - .setItems(temp, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - handleDialogOnClick(dialog, which, type, temp); - } - }); - builder.show(); - } - - private void handleDialogOnClick(DialogInterface dialog, int which, int type, CharSequence[] temp) { - if (which > 0) { - ArrayList currentlyShown = new ArrayList(mMovieKeys); - mMovieKeys.clear(); - - String selected = temp[which].toString(); - selected = selected.substring(0, selected.lastIndexOf("(")).trim(); - - boolean condition; - for (int i = 0; i < currentlyShown.size(); i++) { - condition = false; - - switch (type) { - case GENRES: - if (mMovies.get(currentlyShown.get(i)).getGenres().contains(selected)) { - String[] genres = mMovies.get(currentlyShown.get(i)).getGenres().split(","); - for (String genre : genres) { - if (genre.trim().equals(selected)) { - condition = true; - break; - } - } - } - break; - case CERTIFICATION: - condition = mMovies.get(currentlyShown.get(i)).getCertification().trim().contains(selected); - break; - case FILE_SOURCES: - for (Filepath path : mMovies.get(currentlyShown.get(i)).getFilepaths()) { - condition = path.getFilepath().trim().contains(selected); - if (condition) - break; - } - break; - case FOLDERS: - for (Filepath path : mMovies.get(currentlyShown.get(i)).getFilepaths()) { - condition = path.getFilepath().trim().startsWith(selected); - if (condition) - break; - } - break; - case RELEASE_YEAR: - condition = mMovies.get(currentlyShown.get(i)).getReleaseYear().trim().contains(selected); - break; - } - - if (condition) - mMovieKeys.add(currentlyShown.get(i)); - } - - sortMovies(); - notifyDataSetChanged(); - } - - dialog.dismiss(); - } - - private void search(String query) { - if (mSearch != null) - mSearch.cancel(true); - mSearch = new SearchTask(query); - mSearch.execute(); - } - - private class SearchTask extends AsyncTask { - - private String mSearchQuery = ""; - private List mTempKeys; - - public SearchTask(String query) { - mSearchQuery = query.toLowerCase(Locale.ENGLISH); - } - - @Override - protected void onPreExecute() { - setProgressBarVisible(true); - mMovieKeys.clear(); - } - - @Override - protected String doInBackground(String... params) { - mTempKeys = new ArrayList(); - - if (mSearchQuery.startsWith("actor:")) { - for (int i = 0; i < mMovies.size(); i++) { - if (isCancelled()) - return null; - - if (mMovies.get(i).getCast().toLowerCase(Locale.ENGLISH).contains(mSearchQuery.replace("actor:", "").trim())) - mTempKeys.add(i); - } - } else if (mSearchQuery.equalsIgnoreCase("missing_genres")) { - for (int i = 0; i < mMovies.size(); i++) { - if (isCancelled()) - return null; - - if (TextUtils.isEmpty(mMovies.get(i).getGenres())) - mTempKeys.add(i); - } - } else if (mSearchQuery.equalsIgnoreCase("multiple_versions")) { - DbAdapterMovieMappings db = MizuuApplication.getMovieMappingAdapter(); - - for (int i = 0; i < mMovies.size(); i++) { - if (isCancelled()) - return null; - - if (db.hasMultipleFilepaths(mMovies.get(i).getTmdbId())) - mTempKeys.add(i); - } - } else { - Pattern p = Pattern.compile(MizLib.CHARACTER_REGEX); // Use a pre-compiled pattern as it's a lot faster (approx. 3x for ~700 movies) - - for (int i = 0; i < mMovies.size(); i++) { - if (isCancelled()) - return null; - - String lowerCaseTitle = mMovies.get(i).getTitle().toLowerCase(Locale.ENGLISH); - - boolean foundInTitle = false; - - if (lowerCaseTitle.indexOf(mSearchQuery) != -1 || p.matcher(lowerCaseTitle).replaceAll("").indexOf(mSearchQuery) != -1) { - mTempKeys.add(i); - foundInTitle = true; - } - - if (!foundInTitle) { - for (Filepath path : mMovies.get(i).getFilepaths()) { - String filepath = path.getFilepath().toLowerCase(Locale.ENGLISH); - if (filepath.indexOf(mSearchQuery) != -1) { - mTempKeys.add(i); - break; // Break the loop - } - } - } - } - } - - return null; - } - - @Override - protected void onPostExecute(String result) { - mMovieKeys.addAll(mTempKeys); - - sortMovies(); - notifyDataSetChanged(); - setProgressBarVisible(false); - } - } - - private void setProgressBarVisible(boolean visible) { - mProgressBar.setVisibility(visible ? View.VISIBLE : View.GONE); - mGridView.setVisibility(visible ? View.GONE : View.VISIBLE); - } - - @Override - public void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - - if (resultCode == 1) { // Update - forceLoaderLoad(); - } else if (resultCode == 2 && mActionBar.getSelectedNavigationIndex() == FAVORITES) { // Favourite removed - showMovieSection(FAVORITES); - } else if (resultCode == 3) { - notifyDataSetChanged(); - } - } - - @Override - public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - if (key.equals(IGNORED_TITLE_PREFIXES)) { - mIgnorePrefixes = mSharedPreferences.getBoolean(IGNORED_TITLE_PREFIXES, false); - forceLoaderLoad(); - } else if (key.equals(GRID_ITEM_SIZE)) { - String thumbnailSize = mSharedPreferences.getString(GRID_ITEM_SIZE, getString(R.string.normal)); - if (thumbnailSize.equals(getString(R.string.large))) - mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 1.33); - else if (thumbnailSize.equals(getString(R.string.normal))) - mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 1); - else - mImageThumbSize = (int) (getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size) * 0.75); - - mGridView.setColumnWidth(mImageThumbSize); - - final int numColumns = (int) Math.floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing)); - if (numColumns > 0) { - mAdapter.setNumColumns(numColumns); - } - - notifyDataSetChanged(); - } else if (key.equals(SHOW_TITLES_IN_GRID)) { - mShowTitles = sharedPreferences.getBoolean(SHOW_TITLES_IN_GRID, true); - notifyDataSetChanged(); - } - } - - private void forceLoaderLoad() { - if (isAdded()) - if (getLoaderManager().getLoader(0) == null) { - getLoaderManager().initLoader(0, null, loaderCallbacks); - } else { - getLoaderManager().restartLoader(0, null, loaderCallbacks); - } - } - - private class ActionBarSpinner extends BaseAdapter { - - private LayoutInflater mInflater; - - public ActionBarSpinner() { - mInflater = LayoutInflater.from(getActivity()); - } - - @Override - public int getCount() { - return mSpinnerItems.size(); - } - - @Override - public Object getItem(int position) { - return null; - } - - @Override - public long getItemId(int position) { - return 0; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - - ActionBarSpinnerViewHolder holder; - - if (convertView == null) { - convertView = mInflater.inflate(R.layout.spinner_header, parent, false); - - holder = new ActionBarSpinnerViewHolder(); - holder.title = (TextView) convertView.findViewById(R.id.title); - holder.subtitle = (TextView) convertView.findViewById(R.id.subtitle); - - convertView.setTag(holder); - } else { - holder = (ActionBarSpinnerViewHolder) convertView.getTag(); - } - - holder.title.setText(mSpinnerItems.get(position).getTitle()); - - int size = mMovieKeys.size(); - holder.subtitle.setText(size + " " + getResources().getQuantityString((mActionBar.getSelectedNavigationIndex() == COLLECTIONS) ? - R.plurals.collectionsInLibrary : R.plurals.moviesInLibrary, size, size)); - - return convertView; - } - - @Override - public View getDropDownView(int position, View convertView, ViewGroup parent) { - - if (convertView == null) { - convertView = mInflater.inflate(android.R.layout.simple_spinner_dropdown_item, parent, false); - } - - ((TextView) convertView.findViewById(android.R.id.text1)).setText(mSpinnerItems.get(position).getSubtitle()); - - return convertView; - } - } -} \ No newline at end of file diff --git a/src/com/miz/mizuu/fragments/TmdbMovieDetailsFragment.java b/src/com/miz/mizuu/fragments/TmdbMovieDetailsFragment.java deleted file mode 100644 index a9b950cc..00000000 --- a/src/com/miz/mizuu/fragments/TmdbMovieDetailsFragment.java +++ /dev/null @@ -1,474 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.mizuu.fragments; - -import android.app.ActionBar; -import android.content.Context; -import android.content.Intent; -import android.graphics.Typeface; -import android.graphics.drawable.Drawable; -import android.net.Uri; -import android.os.AsyncTask; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.text.Html; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.view.ViewGroup.LayoutParams; -import android.view.ViewTreeObserver; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.ImageView.ScaleType; -import android.widget.ScrollView; -import android.widget.TextView; -import android.widget.Toast; - -import com.miz.apis.tmdb.Movie; -import com.miz.apis.tmdb.TMDbMovieService; -import com.miz.apis.trakt.Trakt; -import com.miz.functions.MizLib; -import com.miz.functions.PaletteTransformation; -import com.miz.functions.TmdbTrailerSearch; -import com.miz.mizuu.MizuuApplication; -import com.miz.mizuu.R; -import com.miz.utils.IntentUtils; -import com.miz.utils.ViewUtils; -import com.miz.views.HorizontalCardLayout; -import com.miz.views.ObservableScrollView; -import com.miz.views.ObservableScrollView.OnScrollChangedListener; -import com.miz.views.PanningView; -import com.squareup.picasso.Callback; -import com.squareup.picasso.Picasso; - -public class TmdbMovieDetailsFragment extends Fragment { - - private Context mContext; - private String movieId; - private TextView textTitle, textPlot, textGenre, textRuntime, textReleaseDate, textRating, textTagline, textCertification; - private ImageView background, cover; - private Movie mMovie; - private View movieDetailsLayout, progressBar, mDetailsArea; - private FrameLayout container; - private boolean isRetained = false; - private Picasso mPicasso; - private Typeface mLight, mLightItalic, mMedium, mBoldItalic; - private TMDbMovieService mMovieApiService; - private HorizontalCardLayout mActorsLayout, mSimilarMoviesLayout; - private int mImageThumbSize, mImageThumbSpacing; - private Drawable mActionBarBackgroundDrawable; - private ImageView mActionBarOverlay; - private ActionBar mActionBar; - - /** - * Empty constructor as per the Fragment documentation - */ - public TmdbMovieDetailsFragment() {} - - public static TmdbMovieDetailsFragment newInstance(String movieId) { - TmdbMovieDetailsFragment pageFragment = new TmdbMovieDetailsFragment(); - Bundle bundle = new Bundle(); - bundle.putString("movieId", movieId); - pageFragment.setArguments(bundle); - return pageFragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setHasOptionsMenu(true); - setRetainInstance(true); - - mContext = getActivity(); - - mActionBar = getActivity().getActionBar(); - - mLight = MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-Light.ttf"); - mLightItalic = MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-LightItalic.ttf"); - mMedium = MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-Medium.ttf"); - mBoldItalic = MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-BoldItalic.ttf"); - - mMovieApiService = TMDbMovieService.getInstance(mContext); - - // Get the database ID of the movie in question - movieId = getArguments().getString("movieId"); - - mPicasso = MizuuApplication.getPicassoDetailsView(getActivity()); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - final View v = inflater.inflate(R.layout.movie_and_tv_show_details, container, false); - - // This needs to be re-initialized here and not in onCreate() - mImageThumbSize = getResources().getDimensionPixelSize(R.dimen.horizontal_grid_item_width); - mImageThumbSpacing = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); - - movieDetailsLayout = MizLib.isPortrait(getActivity()) ? v.findViewById(R.id.movieDetailsLayout_portrait) : v.findViewById(R.id.movieDetailsLayout); - progressBar = v.findViewById(R.id.progress_layout); - mDetailsArea = v.findViewById(R.id.details_area); - - this.container = (FrameLayout) v.findViewById(R.id.container); - background = (ImageView) v.findViewById(R.id.imageBackground); - textTitle = (TextView) v.findViewById(R.id.movieTitle); - textPlot = (TextView) v.findViewById(R.id.textView2); - textGenre = (TextView) v.findViewById(R.id.textView7); - textRuntime = (TextView) v.findViewById(R.id.textView9); - textReleaseDate = (TextView) v.findViewById(R.id.textReleaseDate); - textRating = (TextView) v.findViewById(R.id.textView12); - textTagline = (TextView) v.findViewById(R.id.textView6); - textCertification = (TextView) v.findViewById(R.id.textView11); - cover = (ImageView) v.findViewById(R.id.traktIcon); - mActorsLayout = (HorizontalCardLayout) v.findViewById(R.id.horizontal_card_layout); - mSimilarMoviesLayout = (HorizontalCardLayout) v.findViewById(R.id.horizontal_card_layout_extra); - - mActionBarOverlay = (ImageView) v.findViewById(R.id.actionbar_overlay); - mActionBarOverlay.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, - MizuuApplication.isFullscreen(mContext) ? MizLib.getActionBarHeight(mContext) : MizLib.getActionBarAndStatusBarHeight(mContext))); - - // Get rid of these... - v.findViewById(R.id.textView3).setVisibility(View.GONE); // File - - if (MizLib.isPortrait(getActivity())) { - final boolean fullscreen = MizuuApplication.isFullscreen(getActivity()); - final int height = fullscreen ? MizLib.getActionBarHeight(getActivity()) : MizLib.getActionBarAndStatusBarHeight(getActivity()); - - ObservableScrollView sv = (ObservableScrollView) v.findViewById(R.id.scrollView1); - sv.setOnScrollChangedListener(new OnScrollChangedListener() { - @Override - public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { - final int headerHeight = background.getHeight() - height; - final float ratio = (float) Math.min(Math.max(t, 0), headerHeight) / headerHeight; - final int newAlpha = (int) (ratio * 255); - - // We only want to update the ActionBar if it would actually make a change (times 1.2 to handle fast flings) - if (t <= headerHeight * 1.2) { - ViewUtils.updateActionBarDrawable(mContext, mActionBarOverlay, mActionBarBackgroundDrawable, mActionBar, mMovie.getTitle(), newAlpha, true, false); - - // Such parallax, much wow - background.setPadding(0, (int) (t / 1.5), 0, 0); - } - } - }); - } - - if (!isRetained) { // Nothing has been retained - load the data - setLoading(true); - new MovieLoader().execute(); - isRetained = true; - } else { - setupFields(); - } - - return v; - } - - private class MovieLoader extends AsyncTask { - @Override - protected Object doInBackground(String... params) { - mMovie = mMovieApiService.getCompleteMovie(movieId, "en"); - - for (int i = 0; i < mMovie.getSimilarMovies().size(); i++) { - String id = mMovie.getSimilarMovies().get(i).getId(); - mMovie.getSimilarMovies().get(i).setInLibrary(MizuuApplication.getMovieAdapter().movieExists(id)); - } - - return null; - } - - @Override - protected void onPostExecute(Object result) { - getActivity().invalidateOptionsMenu(); - - setupFields(); - } - } - - private void setupFields() { - if (isAdded() && mMovie != null) { - // Set the movie title - textTitle.setVisibility(View.VISIBLE); - textTitle.setText(mMovie.getTitle()); - textTitle.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "RobotoCondensed-Regular.ttf")); - textTitle.setLayerType(View.LAYER_TYPE_SOFTWARE, null); - - textPlot.setTypeface(mLight); - textReleaseDate.setTypeface(mLight); - - textRuntime.setTypeface(mMedium); - textCertification.setTypeface(mMedium); - textRating.setTypeface(mMedium); - - // Set the movie plot - if (!MizLib.isPortrait(getActivity())) { - textPlot.setBackgroundResource(R.drawable.selectable_background); - if (!mMovie.getTagline().isEmpty()) - textPlot.setMaxLines(getActivity().getResources().getInteger(R.integer.movie_details_max_lines)); - else - textPlot.setMaxLines(getActivity().getResources().getInteger(R.integer.show_details_max_lines)); - textPlot.setTag(true); // true = collapsed - textPlot.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (((Boolean) textPlot.getTag())) { - textPlot.setMaxLines(1000); - textPlot.setTag(false); - } else { - if (!mMovie.getTagline().isEmpty()) - textPlot.setMaxLines(getActivity().getResources().getInteger(R.integer.movie_details_max_lines)); - else - textPlot.setMaxLines(getActivity().getResources().getInteger(R.integer.show_details_max_lines)); - textPlot.setTag(true); - } - } - }); - textPlot.setEllipsize(TextUtils.TruncateAt.END); - textPlot.setFocusable(true); - } else { - if (MizLib.isTablet(getActivity())) - textPlot.setLineSpacing(0, 1.15f); - } - textPlot.setText(mMovie.getPlot()); - - // Set movie tag line - textTagline.setTypeface(mBoldItalic); - if (mMovie.getTagline().equals("NOTAGLINE") || mMovie.getTagline().isEmpty()) - textTagline.setVisibility(TextView.GONE); - else - textTagline.setText(mMovie.getTagline()); - - // Set the movie genre - textGenre.setTypeface(mLightItalic); - if (!TextUtils.isEmpty(mMovie.getGenres())) { - textGenre.setText(mMovie.getGenres()); - } else { - textGenre.setVisibility(View.GONE); - } - - // Set the movie runtime - textRuntime.setText(MizLib.getPrettyRuntime(getActivity(), Integer.parseInt(mMovie.getRuntime()))); - - // Set the movie release date - textReleaseDate.setTypeface(mMedium); - textReleaseDate.setText(MizLib.getPrettyDate(getActivity(), mMovie.getReleasedate())); - - // Set the movie rating - if (!mMovie.getRating().equals("0.0")) { - try { - int rating = (int) (Double.parseDouble(mMovie.getRating()) * 10); - textRating.setText(Html.fromHtml(rating + " %")); - } catch (NumberFormatException e) { - textRating.setText(mMovie.getRating()); - } - } else { - textRating.setText(R.string.stringNA); - } - - // Set the movie certification - if (!TextUtils.isEmpty(mMovie.getCertification())) { - textCertification.setText(mMovie.getCertification()); - } else { - textCertification.setText(R.string.stringNA); - } - - mActorsLayout.setTitle(R.string.detailsActors); - mActorsLayout.setSeeMoreVisibility(true); - mActorsLayout.getViewTreeObserver().addOnGlobalLayoutListener( - new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - if (mActorsLayout.getWidth() > 0) { - final int numColumns = (int) Math.floor(mActorsLayout.getWidth() / (mImageThumbSize + mImageThumbSpacing)); - mImageThumbSize = (mActorsLayout.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; - - mActorsLayout.loadItems(mContext, mPicasso, numColumns, mImageThumbSize, mMovie.getActors(), HorizontalCardLayout.ACTORS); - MizLib.removeViewTreeObserver(mActorsLayout.getViewTreeObserver(), this); - } - } - }); - mActorsLayout.setSeeMoreOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - startActivity(IntentUtils.getActorBrowserMovies(mContext, mMovie.getTitle(), mMovie.getId())); - } - }); - - mSimilarMoviesLayout.setVisibility(View.VISIBLE); - mSimilarMoviesLayout.setTitle(R.string.relatedMovies); - mSimilarMoviesLayout.setSeeMoreVisibility(true); - mSimilarMoviesLayout.getViewTreeObserver().addOnGlobalLayoutListener( - new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - if (mSimilarMoviesLayout.getWidth() > 0) { - final int numColumns = (int) Math.floor(mSimilarMoviesLayout.getWidth() / (mImageThumbSize + mImageThumbSpacing)); - mImageThumbSize = (mSimilarMoviesLayout.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; - - mSimilarMoviesLayout.loadItems(mContext, mPicasso, numColumns, mImageThumbSize, mMovie.getSimilarMovies(), HorizontalCardLayout.RELATED_MOVIES); - MizLib.removeViewTreeObserver(mSimilarMoviesLayout.getViewTreeObserver(), this); - } - } - }); - mSimilarMoviesLayout.setSeeMoreOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - startActivity(IntentUtils.getSimilarMovies(mContext, mMovie.getTitle(), mMovie.getId())); - } - }); - - ViewUtils.updateActionBarDrawable(mContext, mActionBarOverlay, mActionBarBackgroundDrawable, mActionBar, mMovie.getTitle(), 1, true, true); - - setLoading(false); - - loadImages(); - } - } - - private void loadImages() { - if (!mMovie.getCover().isEmpty()) - mPicasso.load(mMovie.getCover()).placeholder(R.drawable.gray).error(R.drawable.loading_image).transform(new PaletteTransformation(mMovie.getCover(), mDetailsArea, mActorsLayout.getSeeMoreView(), mSimilarMoviesLayout.getSeeMoreView())).into(cover); - else - cover.setImageResource(R.drawable.gray); - - if (!mMovie.getBackdrop().isEmpty()) - mPicasso.load(mMovie.getBackdrop()).placeholder(R.drawable.gray).error(R.drawable.bg).into(background, new Callback() { - @Override - public void onError() { - if (!isAdded()) - return; - - if (MizLib.isPortrait(getActivity())) { - ((PanningView) background).setScaleType(ScaleType.CENTER_CROP); - } - - if (!mMovie.getCover().isEmpty()) - mPicasso.load(mMovie.getCover()).placeholder(R.drawable.bg).error(R.drawable.bg).into(background); - else - background.setImageResource(R.drawable.bg); - } - - @Override - public void onSuccess() { - if (!isAdded()) - return; - - if (MizLib.isPortrait(getActivity())) { - ((PanningView) background).startPanning(); - } - } - }); - else { - if (!mMovie.getCover().isEmpty()) { - if (MizLib.isPortrait(getActivity())) { - ((PanningView) background).setScaleType(ScaleType.CENTER_CROP); - } - mPicasso.load(mMovie.getCover()).placeholder(R.drawable.bg).error(R.drawable.bg).into(background); - } else - background.setImageResource(R.drawable.bg); - } - } - - private void setLoading(boolean isLoading) { - if (isLoading) { - progressBar.setVisibility(View.VISIBLE); - movieDetailsLayout.setVisibility(View.GONE); - container.setBackgroundResource(R.drawable.bg); - } else { - progressBar.setVisibility(View.GONE); - movieDetailsLayout.setVisibility(View.VISIBLE); - container.setBackgroundResource(0); - } - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - if (mMovie != null) { - inflater.inflate(R.menu.tmdb_details, menu); - - if (MizLib.isTablet(mContext)) { - menu.findItem(R.id.share).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - menu.findItem(R.id.checkIn).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - menu.findItem(R.id.openInBrowser).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - } - - if (!Trakt.hasTraktAccount(mContext)) - menu.findItem(R.id.checkIn).setVisible(false); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - getActivity().finish(); - break; - case R.id.share: - shareMovie(); - break; - case R.id.openInBrowser: - openInBrowser(); - break; - case R.id.checkIn: - checkIn(); - break; - case R.id.trailer: - watchTrailer(); - } - - return super.onOptionsItemSelected(item); - } - - public void shareMovie() { - Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType("text/plain"); - intent.putExtra(Intent.EXTRA_TEXT, "http://www.themoviedb.org/movie/" + mMovie.getId()); - startActivity(Intent.createChooser(intent, getString(R.string.shareWith))); - } - - public void openInBrowser() { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse("http://www.themoviedb.org/movie/" + mMovie.getId())); - startActivity(Intent.createChooser(intent, getString(R.string.openWith))); - } - - public void watchTrailer() { - new TmdbTrailerSearch(getActivity(), mMovie.getId(), mMovie.getTitle()).execute(); - } - - public void checkIn() { - new AsyncTask() { - @Override - protected Boolean doInBackground(Void... params) { - return Trakt.performMovieCheckin(mMovie.getId(), mContext); - } - - @Override - protected void onPostExecute(Boolean result) { - if (result) - Toast.makeText(mContext, getString(R.string.checked_in), Toast.LENGTH_SHORT).show(); - else - Toast.makeText(mContext, getString(R.string.errorSomethingWentWrong), Toast.LENGTH_SHORT).show(); - } - }.execute(); - } -} diff --git a/src/com/miz/mizuu/fragments/TvShowDetailsFragment.java b/src/com/miz/mizuu/fragments/TvShowDetailsFragment.java deleted file mode 100644 index e2f716f2..00000000 --- a/src/com/miz/mizuu/fragments/TvShowDetailsFragment.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.mizuu.fragments; - -import java.util.List; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.database.Cursor; -import android.graphics.Typeface; -import android.os.AsyncTask; -import android.os.Bundle; -import android.preference.PreferenceManager; -import android.support.v4.app.Fragment; -import android.support.v4.content.LocalBroadcastManager; -import android.text.Html; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewTreeObserver; -import android.view.View.OnClickListener; -import android.widget.ImageView; -import android.widget.ScrollView; -import android.widget.TextView; -import android.widget.ImageView.ScaleType; - -import com.miz.apis.tmdb.TMDbTvShowService; -import com.miz.db.DbAdapterTvShows; -import com.miz.functions.Actor; -import com.miz.functions.BlurTransformation; -import com.miz.functions.MizLib; -import com.miz.functions.PaletteTransformation; -import com.miz.functions.PreferenceKeys; -import com.miz.mizuu.MizuuApplication; -import com.miz.mizuu.TvShow; -import com.miz.mizuu.R; -import com.miz.utils.IntentUtils; -import com.miz.utils.LocalBroadcastUtils; -import com.miz.views.HorizontalCardLayout; -import com.miz.views.ObservableScrollView; -import com.miz.views.PanningView; -import com.miz.views.ObservableScrollView.OnScrollChangedListener; -import com.squareup.otto.Bus; -import com.squareup.picasso.Callback; -import com.squareup.picasso.Picasso; - -import static com.miz.functions.PreferenceKeys.IGNORED_TITLE_PREFIXES; - -public class TvShowDetailsFragment extends Fragment { - - private Context mContext; - private DbAdapterTvShows dbHelper; - private TvShow thisShow; - private TextView textTitle, textPlot, textGenre, textRuntime, textReleaseDate, textRating, textCertification; - private ImageView background, cover; - private View mDetailsArea; - private boolean ignorePrefixes; - private Picasso mPicasso; - private Typeface mLight, mLightItalic, mMedium; - private Bus mBus; - private HorizontalCardLayout mActorsLayout; - private int mImageThumbSize, mImageThumbSpacing; - - /** - * Empty constructor as per the Fragment documentation - */ - public TvShowDetailsFragment() {} - - public static TvShowDetailsFragment newInstance(String showId) { - TvShowDetailsFragment pageFragment = new TvShowDetailsFragment(); - Bundle b = new Bundle(); - b.putString("showId", showId); - pageFragment.setArguments(b); - return pageFragment; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setRetainInstance(true); - - mContext = getActivity(); - - mBus = MizuuApplication.getBus(); - - mLight = MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-Light.ttf"); - mLightItalic = MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-LightItalic.ttf"); - mMedium = MizuuApplication.getOrCreateTypeface(getActivity(), "Roboto-Medium.ttf"); - - ignorePrefixes = PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean(IGNORED_TITLE_PREFIXES, false); - - // Create and open database - dbHelper = MizuuApplication.getTvDbAdapter(); - - Cursor cursor = dbHelper.getShow(getArguments().getString("showId")); - try { - if (cursor.moveToFirst()) { - thisShow = new TvShow(getActivity(), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_ID)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_TITLE)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_PLOT)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_RATING)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_GENRES)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_ACTORS)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_CERTIFICATION)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_FIRST_AIRDATE)), - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_RUNTIME)), - ignorePrefixes, - cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_FAVOURITE)), - MizuuApplication.getTvEpisodeDbAdapter().getLatestEpisodeAirdate(cursor.getString(cursor.getColumnIndex(DbAdapterTvShows.KEY_SHOW_ID))) - ); - } - } catch (Exception e) { - } finally { - cursor.close(); - } - - mPicasso = MizuuApplication.getPicassoDetailsView(getActivity()); - - LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.CLEAR_IMAGE_CACHE)); - } - - private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - loadImages(); - } - }; - - @Override - public void onResume() { - super.onResume(); - - mBus.register(getActivity()); - } - - @Override - public void onDestroy() { - super.onDestroy(); - LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mMessageReceiver); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.movie_and_tv_show_details, container, false); - } - - public void onViewCreated(final View v, Bundle savedInstanceState) { - super.onViewCreated(v, savedInstanceState); - - // This needs to be re-initialized here and not in onCreate() - mImageThumbSize = getResources().getDimensionPixelSize(R.dimen.horizontal_grid_item_width); - mImageThumbSpacing = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); - - mDetailsArea = v.findViewById(R.id.details_area); - - // TV shows don't include a tagline or filepath - v.findViewById(R.id.textView3).setVisibility(View.GONE); // Filepath - v.findViewById(R.id.textView6).setVisibility(View.GONE); // Tagline - - if (MizLib.isPortrait(getActivity())) { - final boolean fullscreen = MizuuApplication.isFullscreen(getActivity()); - final int height = fullscreen ? MizLib.getActionBarHeight(getActivity()) : MizLib.getActionBarAndStatusBarHeight(getActivity()); - - ObservableScrollView sv = (ObservableScrollView) v.findViewById(R.id.scrollView1); - sv.setOnScrollChangedListener(new OnScrollChangedListener() { - @Override - public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { - final int headerHeight = background.getHeight() - height; - final float ratio = (float) Math.min(Math.max(t, 0), headerHeight) / headerHeight; - final int newAlpha = (int) (ratio * 255); - - // We only want to update the ActionBar if it would actually make a change (times 1.2 to handle fast flings) - if (t <= headerHeight * 1.2) { - mBus.post(Integer.valueOf(newAlpha)); - - // Such parallax, much wow - background.setPadding(0, (int) (t / 1.5), 0, 0); - } - } - }); - } - - background = (ImageView) v.findViewById(R.id.imageBackground); - textTitle = (TextView) v.findViewById(R.id.movieTitle); - textPlot = (TextView) v.findViewById(R.id.textView2); - textGenre = (TextView) v.findViewById(R.id.textView7); - textRuntime = (TextView) v.findViewById(R.id.textView9); - textReleaseDate = (TextView) v.findViewById(R.id.textReleaseDate); - textRating = (TextView) v.findViewById(R.id.textView12); - textCertification = (TextView) v.findViewById(R.id.textView11); - cover = (ImageView) v.findViewById(R.id.traktIcon); - mActorsLayout = (HorizontalCardLayout) v.findViewById(R.id.horizontal_card_layout); - - // Set the show title - textTitle.setVisibility(View.VISIBLE); - textTitle.setText(thisShow.getTitle()); - textTitle.setTypeface(MizuuApplication.getOrCreateTypeface(getActivity(), "RobotoCondensed-Regular.ttf")); - textTitle.setLayerType(View.LAYER_TYPE_SOFTWARE, null); - - textPlot.setTypeface(mLight); - textRuntime.setTypeface(mLight); - textRating.setTypeface(mLight); - textCertification.setTypeface(mLight); - - textRuntime.setTypeface(mMedium); - textCertification.setTypeface(mMedium); - textRating.setTypeface(mMedium); - - // Set the show plot - if (!MizLib.isPortrait(getActivity())) { - textPlot.setBackgroundResource(R.drawable.selectable_background); - textPlot.setMaxLines(getActivity().getResources().getInteger(R.integer.show_details_max_lines)); - textPlot.setTag(true); // true = collapsed - textPlot.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (((Boolean) textPlot.getTag())) { - textPlot.setMaxLines(1000); - textPlot.setTag(false); - } else { - textPlot.setMaxLines(getActivity().getResources().getInteger(R.integer.show_details_max_lines)); - textPlot.setTag(true); - } - } - }); - textPlot.setEllipsize(TextUtils.TruncateAt.END); - textPlot.setFocusable(true); - } else { - if (MizLib.isTablet(getActivity())) - textPlot.setLineSpacing(0, 1.15f); - } - textPlot.setText(thisShow.getDescription()); - - // Set the show genres - textGenre.setTypeface(mLightItalic); - if (!TextUtils.isEmpty(thisShow.getGenres())) { - textGenre.setText(thisShow.getGenres()); - } else { - textGenre.setVisibility(View.GONE); - } - - // Set the show runtime - textRuntime.setText(MizLib.getPrettyRuntime(getActivity(), Integer.parseInt(thisShow.getRuntime()))); - - // Set the show release date - textReleaseDate.setTypeface(mMedium); - textReleaseDate.setText(MizLib.getPrettyDate(getActivity(), thisShow.getFirstAirdate())); - - // Set the show rating - if (!thisShow.getRating().equals("0.0")) { - try { - int rating = (int) (Double.parseDouble(thisShow.getRating()) * 10); - textRating.setText(Html.fromHtml(rating + " %")); - } catch (NumberFormatException e) { - textRating.setText(thisShow.getRating()); - } - } else { - textRating.setText(R.string.stringNA); - } - - // Set the show certification - if (!TextUtils.isEmpty(thisShow.getCertification())) { - textCertification.setText(thisShow.getCertification()); - } else { - textCertification.setText(R.string.stringNA); - } - - mActorsLayout.setTitle(R.string.detailsActors); - mActorsLayout.setSeeMoreVisibility(true); - mActorsLayout.getViewTreeObserver().addOnGlobalLayoutListener( - new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - if (mActorsLayout.getWidth() > 0) { - final int numColumns = (int) Math.floor(mActorsLayout.getWidth() / (mImageThumbSize + mImageThumbSpacing)); - mImageThumbSize = (mActorsLayout.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns; - - loadActors(numColumns); - MizLib.removeViewTreeObserver(mActorsLayout.getViewTreeObserver(), this); - } - } - }); - mActorsLayout.setSeeMoreOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - startActivity(IntentUtils.getActorBrowserTvShows(mContext, thisShow.getTitle(), thisShow.getId())); - } - }); - - loadImages(); - } - - private void loadImages() { - mPicasso.load(thisShow.getCoverPhoto()).skipMemoryCache().error(R.drawable.loading_image).placeholder(R.drawable.loading_image).transform(new PaletteTransformation(thisShow.getCoverPhoto().getAbsolutePath(), mDetailsArea, mActorsLayout.getSeeMoreView())).into(cover); - - if (!MizLib.isPortrait(getActivity())) { - if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(PreferenceKeys.BLUR_BACKDROPS, false)) { - mPicasso.load(thisShow.getBackdrop()).skipMemoryCache().error(R.drawable.bg).placeholder(R.drawable.bg).transform(new BlurTransformation(mContext, thisShow.getBackdrop(), 8)).into(background); - } else { - mPicasso.load(thisShow.getBackdrop()).skipMemoryCache().error(R.drawable.bg).placeholder(R.drawable.bg).into(background); - } - } else { - mPicasso.load(thisShow.getBackdrop()).skipMemoryCache().placeholder(R.drawable.bg).into(background, new Callback() { - @Override - public void onError() { - if (!isAdded()) - return; - ((PanningView) background).setScaleType(ScaleType.CENTER_CROP); - mPicasso.load(thisShow.getThumbnail()).skipMemoryCache().placeholder(R.drawable.bg).error(R.drawable.bg).into(background); - } - - @Override - public void onSuccess() { - if (!isAdded()) - return; - ((PanningView) background).startPanning(); - } - }); - } - } - - private void loadActors(final int capacity) { - // Show ProgressBar - new AsyncTask() { - private List mActors; - - @Override - protected Void doInBackground(Void... params) { - TMDbTvShowService service = TMDbTvShowService.getInstance(mContext); - mActors = service.getActors(thisShow.getId()); - - return null; - } - - @Override - protected void onPostExecute(Void result) { - mActorsLayout.loadItems(mContext, mPicasso, capacity, mImageThumbSize, mActors, HorizontalCardLayout.ACTORS); - } - }.execute(); - } -} \ No newline at end of file diff --git a/src/com/miz/mizuu/fragments/WebVideosViewPagerFragment.java b/src/com/miz/mizuu/fragments/WebVideosViewPagerFragment.java deleted file mode 100644 index a0b55d1e..00000000 --- a/src/com/miz/mizuu/fragments/WebVideosViewPagerFragment.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.mizuu.fragments; - -import java.util.ArrayList; - -import android.app.ActionBar; -import android.app.ActionBar.OnNavigationListener; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v4.view.ViewPager.OnPageChangeListener; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import com.miz.functions.ActionBarSpinner; -import com.miz.functions.SpinnerItem; -import com.miz.mizuu.R; - -public class WebVideosViewPagerFragment extends Fragment implements OnNavigationListener { - - private ActionBar actionBar; - private ViewPager awesomePager; - private ArrayList spinnerItems = new ArrayList(); - private ActionBarSpinner spinnerAdapter; - - public WebVideosViewPagerFragment() {} - - public static WebVideosViewPagerFragment newInstance() { - return new WebVideosViewPagerFragment(); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setHasOptionsMenu(true); - setRetainInstance(true); - - setupSpinnerItems(); - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - // Setup ActionBar with the action list - setupActionBar(); - if (actionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST) - actionBar.setListNavigationCallbacks(spinnerAdapter, this); - } - - private void setupActionBar() { - actionBar = getActivity().getActionBar(); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - if (spinnerAdapter == null) - spinnerAdapter = new ActionBarSpinner(getActivity(), spinnerItems); - } - - private void setupSpinnerItems() { - spinnerItems.clear(); - spinnerItems.add(new SpinnerItem(getString(R.string.chooserWebVideos), getString(R.string.choiceYouTube))); - spinnerItems.add(new SpinnerItem(getString(R.string.chooserWebVideos), getString(R.string.choiceReddit))); - spinnerItems.add(new SpinnerItem(getString(R.string.chooserWebVideos), getString(R.string.choiceTedTalks))); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.viewpager, container, false); - } - - @Override - public void onViewCreated(View v, Bundle savedInstanceState) { - super.onViewCreated(v, savedInstanceState); - - awesomePager = (ViewPager) v.findViewById(R.id.awesomepager); - awesomePager.setOffscreenPageLimit(3); - awesomePager.setAdapter(new WebVideosAdapter(getChildFragmentManager())); - awesomePager.setOnPageChangeListener(new OnPageChangeListener() { - @Override - public void onPageScrollStateChanged(int arg0) {} - - @Override - public void onPageScrolled(int arg0, float arg1, int arg2) {} - - @Override - public void onPageSelected(int arg0) { - actionBar.setSelectedNavigationItem(arg0); - } - }); - - if (savedInstanceState != null) { - awesomePager.setCurrentItem(savedInstanceState.getInt("selectedIndex", 0)); - } - } - - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putInt("selectedIndex", awesomePager.getCurrentItem()); - } - - private class WebVideosAdapter extends FragmentPagerAdapter { - - public WebVideosAdapter(FragmentManager fm) { - super(fm); - } - - @Override - public Fragment getItem(int index) { - return WebVideoFragment.newInstance(spinnerItems.get(index).getSubtitle()); - } - - @Override - public int getCount() { - return spinnerItems.size(); - } - } - - @Override - public boolean onNavigationItemSelected(int itemPosition, long itemId) { - awesomePager.setCurrentItem(itemPosition); - return true; - } -} \ No newline at end of file diff --git a/src/com/miz/utils/ViewUtils.java b/src/com/miz/utils/ViewUtils.java deleted file mode 100644 index a9e6ed90..00000000 --- a/src/com/miz/utils/ViewUtils.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.utils; - -import java.util.List; - -import android.annotation.SuppressLint; -import android.app.ActionBar; -import android.content.Context; -import android.graphics.Color; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.GradientDrawable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.ImageView; -import android.widget.TextView; - -import com.miz.functions.Actor; -import com.miz.functions.MizLib; -import com.miz.functions.WebMovie; -import com.miz.mizuu.MizuuApplication; -import com.miz.mizuu.R; -import com.squareup.picasso.Picasso; - -public class ViewUtils { - - private ViewUtils() {} // No instantiation - - /** - * Returns a actor card with name, character, image and click listener. - * @param context - * @param picasso - * @param actor - * @return - */ - @SuppressLint("InflateParams") - public static View setupActorCard(final Context context, Picasso picasso, final Actor actor) { - View v = LayoutInflater.from(context).inflate(R.layout.horizontal_grid_item_small, null); - - // Load image - picasso.load(actor.getUrl()).placeholder(R.color.card_background_dark).error(R.drawable.noactor).config(MizuuApplication.getBitmapConfig()).into(((ImageView) v.findViewById(R.id.cover))); - - // Set title - ((TextView) v.findViewById(R.id.text)).setText(actor.getName()); - ((TextView) v.findViewById(R.id.text)).setTypeface(MizuuApplication.getOrCreateTypeface(context, "Roboto-Medium.ttf")); - - // Set subtitle - ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setText(actor.getCharacter()); - ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setSingleLine(true); - - // Set click listener - v.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - context.startActivity(IntentUtils.getActorIntent(context, actor)); - } - }); - - return v; - } - - /** - * Returns a movie card with title, release date, image and click listener. - * @param context - * @param picasso - * @param movie - * @return - */ - @SuppressLint("InflateParams") - public static View setupMovieCard(final Context context, Picasso picasso, final WebMovie movie) { - View v = LayoutInflater.from(context).inflate(R.layout.horizontal_grid_item_small, null); - - // Load image - picasso.load(movie.getUrl()).placeholder(R.color.card_background_dark).error(R.drawable.loading_image).config(MizuuApplication.getBitmapConfig()).into(((ImageView) v.findViewById(R.id.cover))); - - // Set title - ((TextView) v.findViewById(R.id.text)).setText(movie.getTitle()); - ((TextView) v.findViewById(R.id.text)).setTypeface(MizuuApplication.getOrCreateTypeface(context, "Roboto-Medium.ttf")); - - // Set subtitle - ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setText(movie.getSubtitle()); - ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setSingleLine(true); - - // Set click listener - v.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - context.startActivity(IntentUtils.getTmdbMovieDetails(context, movie)); - } - }); - - return v; - } - - /** - * Returns a TV show card with title, release date, image and click listener. - * @param context - * @param picasso - * @param movie - * @return - */ - @SuppressLint("InflateParams") - public static View setupTvShowCard(final Context context, Picasso picasso, final WebMovie show) { - View v = LayoutInflater.from(context).inflate(R.layout.horizontal_grid_item_small, null); - - // Load image - picasso.load(show.getUrl()).placeholder(R.color.card_background_dark).error(R.drawable.loading_image).config(MizuuApplication.getBitmapConfig()).into(((ImageView) v.findViewById(R.id.cover))); - - // Set title - ((TextView) v.findViewById(R.id.text)).setText(show.getTitle()); - ((TextView) v.findViewById(R.id.text)).setTypeface(MizuuApplication.getOrCreateTypeface(context, "Roboto-Medium.ttf")); - - // Set subtitle - ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setText(show.getSubtitle()); - ((TextView) v.findViewById(R.id.gridCoverSubtitle)).setSingleLine(true); - - // Set click listener - v.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - context.startActivity(IntentUtils.getTmdbTvShowLink(show)); - } - }); - - return v; - } - - /** - * Returns a photo card with image and click listener. - * @param context - * @param picasso - * @param movie - * @return - */ - @SuppressLint("InflateParams") - public static View setupPhotoCard(final Context context, Picasso picasso, final String url, final List items, final int index) { - View v = LayoutInflater.from(context).inflate(R.layout.horizontal_grid_item_small_no_text, null); - - // Load image - picasso.load(url).placeholder(R.color.card_background_dark).error(R.drawable.noactor).config(MizuuApplication.getBitmapConfig()).into(((ImageView) v.findViewById(R.id.cover))); - - // Set click listener - v.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - context.startActivity(IntentUtils.getActorPhotoIntent(context, items, index)); - } - }); - - return v; - } - - /** - * Returns a photo card with image and click listener. - * @param context - * @param picasso - * @param movie - * @return - */ - @SuppressLint("InflateParams") - public static View setupTaggedPhotoCard(final Context context, Picasso picasso, final String url, final List items, final int index) { - View v = LayoutInflater.from(context).inflate(R.layout.horizontal_grid_item_small_landscape_no_text, null); - - // Load image - picasso.load(url).placeholder(R.color.card_background_dark).error(R.drawable.noactor).config(MizuuApplication.getBitmapConfig()).into(((ImageView) v.findViewById(R.id.cover))); - - // Set click listener - v.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - context.startActivity(IntentUtils.getActorTaggedPhotoIntent(context, items, index)); - } - }); - - return v; - } - - /** - * Used to update the ActionBar for movie details view as the user scrolls. - * @param context - * @param actionBarOverlay - * @param actionBarBackgroundDrawable - * @param actionBar - * @param title - * @param newAlpha - * @param setBackground - * @param showActionBar - */ - public static void updateActionBarDrawable(Context context, ImageView actionBarOverlay, Drawable actionBarBackgroundDrawable, - ActionBar actionBar, String title, int newAlpha, boolean setBackground, boolean showActionBar) { - actionBarOverlay.setVisibility(View.VISIBLE); - - if (!MizLib.isPortrait(context)) { - newAlpha = 0; - setBackground = true; - showActionBar = true; - } else { - if (!MizLib.isTablet(context) && !MizLib.usesNavigationControl(context)) { - if (newAlpha == 0) { - actionBar.hide(); - actionBarOverlay.setVisibility(View.GONE); - } else - actionBar.show(); - } - } - - actionBar.setTitle(newAlpha > 127 ? title : null); - - if (setBackground) { - actionBarBackgroundDrawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[]{Color.parseColor("#" + ((Integer.toHexString(newAlpha).length() == 1) ? ("0" + Integer.toHexString(newAlpha)) : Integer.toHexString(newAlpha)) + "000000"), (newAlpha >= 170) ? Color.parseColor("#" + Integer.toHexString(newAlpha) + "000000") : 0xaa000000}); - actionBarOverlay.setImageDrawable(actionBarBackgroundDrawable); - } - - if (showActionBar) { - actionBar.show(); - } - } -} diff --git a/src/com/miz/views/PanningView.java b/src/com/miz/views/PanningView.java deleted file mode 100644 index e11066e2..00000000 --- a/src/com/miz/views/PanningView.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.views; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.net.Uri; -import android.util.AttributeSet; -import android.widget.ImageView; - -/** - * Created by f.laurent on 25/07/13. - * Modified by Michell Bak on 18/07/14 to support centerCrop ScaleType in certain cases. - */ -public class PanningView extends ImageView { - - private final PanningViewAttacher mAttacher; - private boolean mDetached = false; - - public PanningView(Context context) { - this(context, null); - } - - public PanningView(Context context, AttributeSet attr) { - this(context, attr, 0); - } - - public PanningView(Context context, AttributeSet attr, int defStyle) { - super(context, attr, defStyle); - super.setScaleType(ScaleType.MATRIX); - mAttacher = new PanningViewAttacher(this); - } - - @Override - public void setImageDrawable(Drawable drawable) { - if (!mDetached) { - super.setImageDrawable(drawable); - stopUpdateStartIfNecessary(); - } - } - - @Override - public void setImageResource(int resId) { - if (!mDetached) { - super.setImageResource(resId); - stopUpdateStartIfNecessary(); - } - } - - @Override - public void setImageURI(Uri uri) { - if (!mDetached) { - super.setImageURI(uri); - stopUpdateStartIfNecessary(); - } - } - - private void stopUpdateStartIfNecessary() { - if (null != mAttacher) { - boolean wasPanning = mAttacher.isPanning(); - mAttacher.stopPanning(); - mAttacher.update(); - if(wasPanning) { - mAttacher.startPanning(); - } - } - } - - @Override - public void setScaleType(ScaleType scaleType) { - if (scaleType == ScaleType.CENTER_CROP) { - stopPanning(); - super.setScaleType(scaleType); - } else - throw new UnsupportedOperationException("only matrix scaleType is supported"); - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - mDetached = true; - mAttacher.cleanup(); - } - - public void startPanning() { - mAttacher.startPanning(); - } - - public void stopPanning() { - mAttacher.stopPanning(); - } -} \ No newline at end of file diff --git a/src/com/miz/views/PanningViewAttacher.java b/src/com/miz/views/PanningViewAttacher.java deleted file mode 100644 index bf70102a..00000000 --- a/src/com/miz/views/PanningViewAttacher.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Copyright (C) 2014 Michell Bak - * - * 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.miz.views; - -import java.lang.ref.WeakReference; - -import com.miz.functions.MizLib; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.ValueAnimator; -import android.graphics.Matrix; -import android.graphics.RectF; -import android.util.Log; -import android.view.ViewTreeObserver; -import android.view.animation.AccelerateDecelerateInterpolator; -import android.widget.ImageView; - -/** - * Created by f.laurent on 25/07/13. - * Modified by Michell Bak on 18/07/14 to only support LTR and RTL animations. - */ -public class PanningViewAttacher implements ViewTreeObserver.OnGlobalLayoutListener { - - private static final String TAG = "PanningViewAttacher"; - private enum Way {R2L, L2R}; - private WeakReference mImageView; - private int mIvTop, mIvRight, mIvBottom, mIvLeft; - private ViewTreeObserver mViewTreeObserver; - private Matrix mMatrix; - private RectF mDisplayRect = new RectF(); - private ValueAnimator mCurrentAnimator; - private AccelerateDecelerateInterpolator mInterpolator; - private long mCurrentPlayTime; - private long mTotalTime; - private Way mWay; - private boolean mIsPanning; - - public PanningViewAttacher(ImageView imageView) { - if(imageView == null) { - throw new IllegalArgumentException("imageView must not be null"); - } - - if(!hasDrawable(imageView)) { - throw new IllegalArgumentException("drawable must not be null"); - } - - mInterpolator = new AccelerateDecelerateInterpolator(); - mImageView = new WeakReference(imageView); - - mViewTreeObserver = imageView.getViewTreeObserver(); - mViewTreeObserver.addOnGlobalLayoutListener(this); - - setImageViewScaleTypeMatrix(imageView); - - mMatrix = imageView.getImageMatrix(); - if(mMatrix == null) { - mMatrix = new Matrix(); - } - - update(); - } - - public void update() { - mWay = null; - mTotalTime = 0; - mCurrentPlayTime = 0; - getImageView().post(new Runnable() { - @Override - public void run() { - scale(); - refreshDisplayRect(); - } - }); - } - - public boolean isPanning() { - return mIsPanning; - } - - /** - * scale and start to pan the image background - */ - public void startPanning() { - if(mIsPanning) { - return; - } - mIsPanning = true; - final Runnable panningRunnable = new Runnable() { - @Override - public void run() { - animate_(); - } - }; - getImageView().post(panningRunnable); - } - - /** - * stop current panning - */ - public void stopPanning() { - if(!mIsPanning) { - return; - } - mIsPanning = false; - Log.d(TAG, "panning animation stopped by user"); - if (mCurrentAnimator != null) { - mCurrentAnimator.removeAllListeners(); - mCurrentAnimator.cancel(); - mCurrentAnimator = null; - } - mTotalTime += mCurrentPlayTime; - Log.d(TAG, "mTotalTime : " + mTotalTime); - } - - /** - * Clean-up the resources attached to this object. This needs to be called - * when the ImageView is no longer used. A good example is from - * {@link android.view.View#onDetachedFromWindow()} or from {@link android.app.Activity#onDestroy()}. - * This is automatically called if you are using {@link com.miz.views.PanningView}. - */ - public final void cleanup() { - if (null != mImageView) { - MizLib.removeViewTreeObserver(getImageView().getViewTreeObserver(), this); - } - mViewTreeObserver = null; - - stopPanning(); - - // Finally, clear ImageView - mImageView = null; - } - - public final ImageView getImageView() { - ImageView imageView = null; - - if (null != mImageView) { - imageView = mImageView.get(); - } - - // If we don't have an ImageView, call cleanup() - if (null == imageView) { - cleanup(); - throw new IllegalStateException("ImageView no longer exists. You should not use this PanningViewAttacher any more."); - } - - return imageView; - } - - private int getDrawableIntrinsicHeight() { - if (getImageView().getDrawable() == null) - return -1; - return getImageView().getDrawable().getIntrinsicHeight(); - } - - private int getDrawableIntrinsicWidth() { - if (getImageView().getDrawable() == null) - return -1; - return getImageView().getDrawable().getIntrinsicWidth(); - } - - private int getImageViewWidth() { - if (getImageView().getDrawable() == null) - return -1; - return getImageView().getWidth(); - } - - private int getImageViewHeight() { - if (getImageView().getDrawable() == null) - return -1; - return getImageView().getHeight(); - } - - /** - * Set's the ImageView's ScaleType to Matrix. - */ - private static void setImageViewScaleTypeMatrix(ImageView imageView) { - if (null != imageView && !(imageView instanceof PanningView)) { - imageView.setScaleType(ImageView.ScaleType.MATRIX); - } - } - - /** - * @return true if the ImageView exists, and it's Drawable exists - */ - private static boolean hasDrawable(ImageView imageView) { - return null != imageView && null != imageView.getDrawable(); - } - - @Override - public void onGlobalLayout() { - ImageView imageView = getImageView(); - - if (null != imageView) { - final int top = imageView.getTop(); - final int right = imageView.getRight(); - final int bottom = imageView.getBottom(); - final int left = imageView.getLeft(); - - /** - * We need to check whether the ImageView's bounds have changed. - * This would be easier if we targeted API 11+ as we could just use - * View.OnLayoutChangeListener. Instead we have to replicate the - * work, keeping track of the ImageView's bounds and then checking - * if the values change. - */ - if (top != mIvTop || bottom != mIvBottom || left != mIvLeft || right != mIvRight) { - update(); - - // Update values as something has changed - mIvTop = top; - mIvRight = right; - mIvBottom = bottom; - mIvLeft = left; - } - } - } - - private void animate_() { - refreshDisplayRect(); - if(mWay == null) { - mWay = Way.R2L; - } - - Log.d(TAG, "mWay : " + mWay); - Log.d(TAG, "mDisplayRect : " + mDisplayRect); - - if (mWay == Way.R2L) { - animate(mDisplayRect.left, mDisplayRect.left - (mDisplayRect.right - getImageViewWidth())); - } else { - animate(mDisplayRect.left, 0.0f); - } - } - - private void changeWay() { - if (mWay == Way.R2L) { - mWay = Way.L2R; - } else if (mWay == Way.L2R) { - mWay = Way.R2L; - } - mCurrentPlayTime = 0; - mTotalTime = 0; - } - - private void animate(float start, float end) { - mCurrentAnimator = ValueAnimator.ofFloat(start, end); - mCurrentAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator animation) { - float value = (Float) animation.getAnimatedValue(); - mMatrix.reset(); - applyScaleOnMatrix(); - mMatrix.postTranslate(value, 0); - refreshDisplayRect(); - mCurrentPlayTime = animation.getCurrentPlayTime(); - setCurrentImageMatrix(); - } - }); - mCurrentAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - Log.d(TAG, "animation has finished, startPanning in the other way"); - changeWay(); - animate_(); - } - - @Override - public void onAnimationCancel(Animator animation) { - Log.d(TAG, "panning animation canceled"); - } - }); - mCurrentAnimator.setDuration(15000); - mCurrentAnimator.setInterpolator(mInterpolator); - mCurrentAnimator.start(); - } - - private void setCurrentImageMatrix() { - getImageView().setImageMatrix(mMatrix); - getImageView().invalidate(); - getImageView().requestLayout(); - } - - private void refreshDisplayRect() { - mDisplayRect.set(0, 0, getDrawableIntrinsicWidth(), getDrawableIntrinsicHeight()); - mMatrix.mapRect(mDisplayRect); - } - - private void scale() { - mMatrix.reset(); - applyScaleOnMatrix(); - setCurrentImageMatrix(); - } - - private void applyScaleOnMatrix() { - int drawableSize = getDrawableIntrinsicHeight(); - int imageViewSize = getImageViewHeight(); - float scaleFactor = (float) imageViewSize / (float) drawableSize; - - mMatrix.postScale(scaleFactor, scaleFactor); - } -} \ No newline at end of file