Permalink
Browse files

Split the Gallery source into its own module.

Initial "just get things compiling" checkin
  • Loading branch information...
1 parent 78bbf67 commit 7ff52e3d4085bbdb942488c4bf67f38e64160ce8 @ianhanniballake ianhanniballake committed Jul 10, 2016
Showing with 1,096 additions and 199 deletions.
  1. +0 −9 android-client-common/src/main/java/com/google/android/apps/muzei/util/MathUtil.java
  2. +1 −0 main/build.gradle
  3. +0 −28 main/src/main/AndroidManifest.xml
  4. +0 −1 main/src/main/java/com/google/android/apps/muzei/render/MuzeiRendererFragment.java
  5. +0 −18 main/src/main/java/com/google/android/apps/muzei/util/IOUtil.java
  6. +0 −10 main/src/main/res/values/colors.xml
  7. +0 −10 main/src/main/res/values/dimens.xml
  8. +0 −2 main/src/main/res/values/ids.xml
  9. +0 −35 main/src/main/res/values/strings.xml
  10. +0 −22 main/src/main/res/values/styles.xml
  11. +1 −1 settings.gradle
  12. +54 −0 source-gallery/build.gradle
  13. +46 −0 source-gallery/src/main/AndroidManifest.xml
  14. 0 ...rce-gallery}/src/main/java/com/google/android/apps/muzei/event/GalleryChosenUrisChangedEvent.java
  15. +9 −14 {main → source-gallery}/src/main/java/com/google/android/apps/muzei/gallery/GalleryArtSource.java
  16. 0 {main → source-gallery}/src/main/java/com/google/android/apps/muzei/gallery/GalleryDatabase.java
  17. +0 −2 ...ce-gallery}/src/main/java/com/google/android/apps/muzei/gallery/GalleryEmptyStateGraphicView.java
  18. +40 −36 ... source-gallery}/src/main/java/com/google/android/apps/muzei/gallery/GallerySettingsActivity.java
  19. 0 ...n → source-gallery}/src/main/java/com/google/android/apps/muzei/gallery/GallerySetupActivity.java
  20. 0 {main → source-gallery}/src/main/java/com/google/android/apps/muzei/gallery/GalleryStore.java
  21. +146 −0 source-gallery/src/main/java/com/google/android/apps/muzei/util/CheatSheet.java
  22. +173 −0 source-gallery/src/main/java/com/google/android/apps/muzei/util/DrawInsetsFrameLayout.java
  23. +250 −0 source-gallery/src/main/java/com/google/android/apps/muzei/util/IOUtil.java
  24. 0 ... → source-gallery}/src/main/java/com/google/android/apps/muzei/util/MultiSelectionController.java
  25. +0 −7 {main → source-gallery}/src/main/java/com/google/android/apps/muzei/util/SelectionBuilder.java
  26. BIN ...le-nodpi/ic_source_gallery.png → source-gallery/src/main/res/drawable-nodpi/gallery_ic_source.png
  27. +23 −0 source-gallery/src/main/res/drawable-v21/grey_selectable_item_background_circle.xml
  28. +21 −0 source-gallery/src/main/res/drawable-v21/white_selectable_item_background.xml
  29. BIN {main → source-gallery}/src/main/res/drawable-xxhdpi/gallery_settings_chosen_photo_selected.png
  30. BIN {main → source-gallery}/src/main/res/drawable-xxhdpi/ic_action_play.png
  31. BIN {main → source-gallery}/src/main/res/drawable-xxhdpi/ic_action_remove.png
  32. BIN {main → source-gallery}/src/main/res/drawable-xxhdpi/ic_action_rotate_interval.png
  33. BIN {main → source-gallery}/src/main/res/drawable-xxhdpi/ic_add_photos.png
  34. BIN source-gallery/src/main/res/drawable-xxhdpi/white_item_focused.9.png
  35. BIN source-gallery/src/main/res/drawable-xxhdpi/white_item_pressed.9.png
  36. +31 −0 source-gallery/src/main/res/drawable/grey_selectable_item_background_circle.xml
  37. +24 −0 source-gallery/src/main/res/drawable/white_circle_button.xml
  38. +23 −0 source-gallery/src/main/res/drawable/white_selectable_item_background.xml
  39. +2 −4 {main → source-gallery}/src/main/res/layout/gallery_settings_activity.xml
  40. 0 {main → source-gallery}/src/main/res/layout/gallery_settings_chosen_photo_item.xml
  41. 0 {main → source-gallery}/src/main/res/menu/gallery_settings.xml
  42. 0 {main → source-gallery}/src/main/res/menu/gallery_settings_selection.xml
  43. +20 −0 source-gallery/src/main/res/values-sw600dp/dimens.xml
  44. +23 −0 source-gallery/src/main/res/values-v21/styles.xml
  45. +24 −0 source-gallery/src/main/res/values/attrs.xml
  46. +27 −0 source-gallery/src/main/res/values/colors.xml
  47. +28 −0 source-gallery/src/main/res/values/dimens.xml
  48. +19 −0 source-gallery/src/main/res/values/ids.xml
  49. +50 −0 source-gallery/src/main/res/values/strings.xml
  50. +61 −0 source-gallery/src/main/res/values/styles.xml
@@ -47,15 +47,6 @@ public static int intDivideRoundUp(int num, int divisor) {
return sign * (Math.abs(num) + Math.abs(divisor) - 1) / Math.abs(divisor);
}
- public static float maxDistanceToCorner(int x, int y, int left, int top, int right, int bottom) {
- float maxDistance = 0;
- maxDistance = Math.max(maxDistance, (float) Math.hypot(x - left, y - top));
- maxDistance = Math.max(maxDistance, (float) Math.hypot(x - right, y - top));
- maxDistance = Math.max(maxDistance, (float) Math.hypot(x - left, y - bottom));
- maxDistance = Math.max(maxDistance, (float) Math.hypot(x - right, y - bottom));
- return maxDistance;
- }
-
private MathUtil() {
}
}
View
@@ -127,6 +127,7 @@ dependencies {
// compile project(':api')
compile project(':android-client-common')
compile project(':source-featured-art')
+ compile project(':source-gallery')
devWearApp project(path: ':wearable', configuration: 'devRelease')
prodWearApp project(path: ':wearable', configuration: 'prodRelease')
}
@@ -25,9 +25,6 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <!-- Needed for gallery source; requested at runtime on Marshmallow -->
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
-
<!-- Don't request this starting with Marshmallow (we only write to the app's cache folder) -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="22" />
@@ -89,31 +86,6 @@
</intent-filter>
</receiver>
- <!-- Photo sources -->
- <service android:name="com.google.android.apps.muzei.gallery.GalleryArtSource"
- android:label="@string/gallery_source_title"
- android:description="@string/gallery_source_description"
- android:icon="@drawable/ic_source_gallery">
- <intent-filter>
- <action android:name="com.google.android.apps.muzei.api.MuzeiArtSource" />
- </intent-filter>
- <meta-data android:name="settingsActivity"
- android:value="com.google.android.apps.muzei.gallery.GallerySettingsActivity" />
- <meta-data android:name="setupActivity"
- android:value="com.google.android.apps.muzei.gallery.GallerySetupActivity" />
- <meta-data android:name="color" android:value="#4db6ac" />
- </service>
-
- <activity android:name="com.google.android.apps.muzei.gallery.GallerySetupActivity"
- android:label="@string/gallery_source_settings_title"
- android:theme="@style/Theme.Muzei.GallerySetup"
- android:exported="true" />
-
- <activity android:name="com.google.android.apps.muzei.gallery.GallerySettingsActivity"
- android:label="@string/gallery_source_settings_title"
- android:parentActivityName="com.google.android.apps.muzei.settings.SettingsActivity"
- android:theme="@style/Theme.Muzei.GallerySettings" />
-
<!-- Target for "Set As" intent -->
<activity android:name="com.google.android.apps.muzei.PhotoSetAsTargetActivity"
@@ -35,7 +35,6 @@
import com.google.android.apps.muzei.util.ImageBlurrer;
import com.google.android.apps.muzei.util.MathUtil;
-
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
@@ -229,22 +229,4 @@ public static File getBestAvailableCacheRoot(Context context) {
// Worst case, resort to internal storage
return context.getCacheDir();
}
-
- public static File getBestAvailableFilesRoot(Context context) {
- File[] roots = ContextCompat.getExternalFilesDirs(context, null);
- if (roots != null) {
- for (File root : roots) {
- if (root == null) {
- continue;
- }
-
- if (Environment.MEDIA_MOUNTED.equals(EnvironmentCompat.getStorageState(root))) {
- return root;
- }
- }
- }
-
- // Worst case, resort to internal storage
- return context.getFilesDir();
- }
}
@@ -19,14 +19,4 @@
<color name="theme_accent">#f2be19</color>
<color name="notification">@color/theme_primary</color>
-
- <color name="gallery_settings_theme_dark">#00796B</color>
- <color name="gallery_settings_theme">#009688</color>
- <color name="gallery_settings_theme_light">#4DB6AC</color>
- <color name="gallery_settings_empty_state_dark">@color/gallery_settings_theme_dark</color>
- <color name="gallery_settings_empty_state_light">@color/gallery_settings_theme_light</color>
-
- <color name="gallery_settings_window_background">#111</color>
- <color name="gallery_settings_inset_shade">#a111</color>
- <color name="gallery_settings_chosen_photo_placeholder">#5666</color>
</resources>
@@ -44,14 +44,4 @@
<dimen name="settings_advanced_checkbox_margin_start">0dp</dimen>
<integer name="settings_advanced_checkbox_column">0</integer>
<integer name="settings_advanced_checkbox_column_span">3</integer>
-
- <dimen name="gallery_settings_chosen_photo_grid_max_item_size">200dp</dimen>
- <dimen name="gallery_settings_chosen_photo_grid_spacing">2dp</dimen>
- <dimen name="gallery_settings_fab_space">96dp</dimen>
-
- <!-- height + top/bottom padding -->
-
- <dimen name="header_elevation">4dp</dimen>
- <dimen name="fab_elevation">8dp</dimen>
-
</resources>
@@ -25,6 +25,4 @@
<item type="id" name="source_action_8" />
<item type="id" name="source_action_9" />
<item type="id" name="source_action_10" />
-
- <item type="id" name="viewtag_position" />
</resources>
@@ -27,19 +27,6 @@
<string name="notification_new_wallpaper">New wallpaper</string>
- <string name="gallery_source_title">My photos</string>
- <string name="gallery_source_description">Random camera photos</string>
- <plurals name="gallery_source_description_choice_template">
- <item quantity="one">1 photo</item>
- <item quantity="other">%1$d photos</item>
- </plurals>
- <string name="gallery_source_settings_title">My Photos</string>
- <string name="gallery_source_settings_empty">Random camera photos</string>
- <string name="gallery_source_settings_empty_subtitle">Choose specific photos instead</string>
- <string name="gallery_source_temporary_force_image">Wallpaper set to selected image.</string>
- <string name="gallery_source_from_gallery">From your gallery</string>
- <string name="gallery_source_touch_to_view">Touch to view</string>
-
<string name="action_activate">Activate</string>
<string name="action_settings">Customize</string>
<string name="action_source_settings">Customize source</string>
@@ -61,19 +48,6 @@
<string name="done">Done</string>
<string name="retry">Retry</string>
- <string name="action_clear_photos">Remove all photos</string>
- <string name="action_add_photos">Add photos</string>
- <string name="action_rotate_interval">Change interval</string>
- <string name="action_rotate_interval_none">Don\'t change wallpaper</string>
- <string name="action_rotate_interval_1h">Every hour</string>
- <string name="action_rotate_interval_3h">Every 3 hours</string>
- <string name="action_rotate_interval_6h">Every 6 hours</string>
- <string name="action_rotate_interval_24h">Every 24 hours</string>
- <string name="action_rotate_interval_72h">Every 3 days</string>
-
- <string name="action_force_now">Set as wallpaper now</string>
- <string name="action_remove">Remove</string>
-
<string name="set_as_wallpaper_using_muzei">Wallpaper (using Muzei)</string>
<string name="tutorial_main">Open the Muzei app to see your wallpaper.</string>
@@ -101,13 +75,4 @@
]]></string>
<string name="about_version_template">v%1$s</string>
<string name="app_author">Roman Nurik</string>
-
- <!-- Marshmallow permissions -->
- <string name="gallery_source_settings_enable_random">Enable random camera photos</string>
- <string name="gallery_source_settings_permission_rationale">Allow the storage permission to show random photos as
- your background.</string>
- <string name="gallery_source_settings_edit_settings">Edit App Permissions</string>
- <string name="gallery_source_settings_denied_explanation">You must enable the <b>Storage</b> permission to use
- random photos as your background.</string>
-
</resources>
@@ -42,28 +42,6 @@
<item name="android:progressDrawable">@drawable/scrubber_progress_grey_amount</item>
</style>
- <!-- Gallery source settings -->
-
- <style name="Theme.Muzei.GallerySettings" parent="Theme.Muzei">
- <item name="android:windowBackground">@color/gallery_settings_window_background</item>
-
- <item name="colorPrimaryDark">@color/gallery_settings_theme_dark</item>
- <item name="colorPrimary">@color/gallery_settings_theme</item>
- <item name="colorAccent">@color/gallery_settings_theme</item>
- </style>
-
- <style name="ThemeOverlay.AppCompat.Dark.GallerySettingsColoredButton">
- <item name="colorAccent">@color/gallery_settings_theme</item>
- </style>
-
- <style name="Theme.Muzei.GallerySetup">
- <!-- Essentially replicate Theme.Translucent -->
- <item name="android:windowBackground">@android:color/transparent</item>
- <item name="android:colorBackgroundCacheHint">@null</item>
- <item name="android:windowIsTranslucent">true</item>
- <item name="android:windowAnimationStyle">@android:style/Animation</item> <!-- no animations -->
- </style>
-
<!-- About -->
<style name="Theme.Muzei.About" parent="Theme.Muzei.Wallpaper">
View
@@ -1 +1 @@
-include ':api', ':android-client-common', ':source-featured-art', ':main', ':wearable', ':example-source-500px','example-contract-widget', 'example-watchface'
+include ':api', ':android-client-common', ':source-featured-art', ':source-gallery', ':main', ':wearable', ':example-source-500px', 'example-contract-widget', 'example-watchface'
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * 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.
+ */
+
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath rootProject.ext.gradleClasspath
+ }
+}
+
+apply plugin: 'com.android.library'
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ compile project(':api')
+ compile 'com.squareup.okhttp3:okhttp:3.3.1'
+ compile 'com.squareup.picasso:picasso:2.5.2'
+ compile 'org.greenrobot:eventbus:3.0.0'
+ compile 'com.android.support:appcompat-v7:24.0.0'
+ compile 'com.android.support:recyclerview-v7:24.0.0'
+}
+
+android {
+ compileSdkVersion rootProject.ext.compileSdkVersion
+ buildToolsVersion rootProject.ext.buildToolsVersion
+
+ defaultConfig {
+ minSdkVersion 17
+ targetSdkVersion rootProject.ext.targetSdkVersion
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_7
+ targetCompatibility JavaVersion.VERSION_1_7
+ }
+}
@@ -0,0 +1,46 @@
+<!--
+ Copyright 2014 Google Inc.
+
+ 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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.google.android.apps.muzei.gallery" >
+
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+
+ <application>
+ <service android:name="com.google.android.apps.muzei.gallery.GalleryArtSource"
+ android:label="@string/gallery_source_title"
+ android:description="@string/gallery_source_description"
+ android:icon="@drawable/gallery_ic_source">
+ <intent-filter>
+ <action android:name="com.google.android.apps.muzei.api.MuzeiArtSource" />
+ </intent-filter>
+ <meta-data android:name="settingsActivity"
+ android:value="com.google.android.apps.muzei.gallery.GallerySettingsActivity" />
+ <meta-data android:name="setupActivity"
+ android:value="com.google.android.apps.muzei.gallery.GallerySetupActivity" />
+ <meta-data android:name="color" android:value="#4db6ac" />
+ </service>
+
+ <activity android:name="com.google.android.apps.muzei.gallery.GallerySetupActivity"
+ android:label="@string/gallery_source_settings_title"
+ android:theme="@style/Theme.Gallery.Setup"
+ android:exported="true" />
+
+ <activity android:name="com.google.android.apps.muzei.gallery.GallerySettingsActivity"
+ android:label="@string/gallery_source_settings_title"
+ android:theme="@style/Theme.Gallery.Settings" />
+ </application>
+</manifest>
Oops, something went wrong.

0 comments on commit 7ff52e3

Please sign in to comment.