diff --git a/.gitignore b/.gitignore index 39fb081a..ad8508ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,68 @@ +# Built application files +*.apk +*.ap_ + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties +keystore.properties +pixleekey.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ *.iml -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +.idea/caches + +# Keystore files +# Uncomment the following line if you do not want to check your keystore fil +\es in. +#*.jks + +# External native build folder generated in Android Studio 2.2 and later .externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md ₩ \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index e8ee3d97..af6eff41 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,7 @@ - + diff --git a/README.md b/README.md index 8386ba2c..1ed279a0 100644 --- a/README.md +++ b/README.md @@ -1,199 +1,255 @@ -# pixlee-android-sdk - -This SDK makes it easy for Pixlee customers to find and download Pixlee images and albums. There's a native wrapper to the Pixlee album API for Android, and there's also a demo app showing how easy it is to drop in and customize a UI. - -## Getting Started - -This repo includes both the Pixlee Android SDK and an example project to show you how it's used. The examples included with this SDK are meant to be used in Android Studio to create a typical Android app. These examples were created and tested in Android Studio 2.3 and can be included by following the directions below under "Including the Pixlee SDK." - -### SDK - -Before accessing the Pixlee API, you must initialize the `PXLClient`. To set the API key, call the static method initialize: - - -``` -#!java - -PXLClient.initialize(); -``` - +[![](https://jitpack.io/v/pixlee/android-sdk.svg)](https://jitpack.io/#pixlee/android-sdk) -You can then use the singleton instance to make calls against the Pixlee API: - - -``` -#!java - -PXLClient pxlClient = PXLClient.getInstance(context); -``` - - -To load the photos in an album, you'll want to use the `PXLAlbum` class. Instantiate one with your album ID and context: - - -``` -#!java -PXLAlbum pxlAlbum = new PXLAlbum(, context); -``` - -To load the photos in an Product album, you'll want to use the `PXLPdpAlbum` class. Instantiate one with your desired sku and context: - - -``` -#!java - -PXLPdpAlbum pxlPdpAlbum = new PXLPdpAlbum(, context); -``` - - -You can then set sort and filter options if desired and use `loadNextPageOfPhotos` to kick off the async request. - - -``` -#!java - -PXLAlbumFilterOptions filterOptions = new PXLAlbumFilterOptions(); -filterOptions.minTwitterFollowers = 1000; -filterOptions.minInstagramFollowers = 2000; -PXLAlbumSortOptions sortOptions = new PXLAlbumSortOptions(); -sortOptions.sortType = PXLAlbumSortType.DYNAMIC; -sortOptions.descending = true; -album.setPerPage(15); -album.setFilterOptions(filterOptions); -album.setSortOptions(sortOptions); -album.loadNextPageOfPhotos(this); -``` - - -Each successive call of `loadNextPageOfPhotos` will load the next page of photos. Be sure to set all of your request options (filters, sort, etc) before calling `loadNextPageOfPhotos`. See the source for more implementation details. +# pixlee-android-sdk +This SDK makes it easy for Pixlee customers to find and download Pixlee images and albums. There's a native wrapper to the Pixlee album API for Android, and there's also a demo app showing how easy it is to drop in and customize a UI. This repo includes both the Pixlee Android SDK and an example project to show you how it's used. + +# Table of Content +- [Get Started with Demo App](#Get-Started-with-Demo-App) + - [Add the SDK to your App](#Add-the-SDK-to-your-App) +- [Add the SDK to your App](#Add-the-SDK-to-your-App) +- [Initialize SDK](#Initialize-SDK) + - [Register Pixlee credentials](#Register-Pixlee-credentials) + - [Get PXLClient](#Get-PXLClient) +- [Album Features](#Album-Features) + - [Get Photos of an Album](#Get-Photos-of-an-Album) + - [Get Photos of a Product](#Get-Photos-of-a-Product) + - [Get more Photos](#Get-more-Photos) + - [Uploading Photos](#Uploading-Photos) +- [How to get image urls](#How-to-get-image-urls) +- [Album Analytics](#Album-Analytics) + - [Opened Widget](#Opened-Widget) + - [Load More](#Load-More) + - [Opened Lightbox](#Opened-Lightbox) + - [Action Clicked](#Action-Clicked) +- [Ecommerce Analytics](#Ecommerce-Analytics) + - [Add To Cart](#Add-To-Cart) + - [Conversion](#Conversion) + + + +# Get Started with Demo App +- The demo app included with this SDK are meant to be used in Android Studio to create a typical Android app. + +- To help you get up and running quickly, we've also built an sample application featuring a grid view, list view, and detail view. The adapters simply maintain an ArrayList of PXLBaseAlbum, which is updated via calls to `loadNextPageOfPhotos`. Since the data source contains the full PXLPhoto object, you can easily customize your own widgets to display the desired images and text. The sample also implements a scroll listener which times calls to `loadNextPageOfPhotos` to provide the endless scroll effect. +An example of the proper usage of an opened lightbox event is also included in the sample app! -Once an album has loaded photos from the server, it will instantiate `PXLPhoto` objects that can be consumed by your UI. `PXLPhoto` exposes all of the data for a photo available through the Pixlee API and offers several image url sizes depending on your needs. +1. Import this project into Android Studio +2. Open .gitignore at the root of the project folder and Add 'pixleekey.properties' to the file +3. Generate **pixleekey.properties** at the root of the project folder + - +4. Fill the file with the example below and edit it with your own credentials, albumId and SKU. +pixleeAPIKey and pixleeSecretKey are in here (https://app.pixlee.com/app#settings/pixlee_api) +AlbumId and SKU available from the Pixlee dashboard). + ``` + pixleeAPIKey=yours + pixleeSecretKey=yours + pixleeAlbumId=yours + pixleeSKU=yours + ``` + Example + ``` + pixleeAPIKey=ccWQFNExi4gQjyNYpOEf + pixleeSecretKey=b3b38f4322877060b2e4f390fd + pixleeAlbumId=5984962 + pixleeSKU=35123 + ``` + +4. Run the project on an Android device + +# Add the SDK to your App +- Option 1: (recommended) adding Gradle dependencies + - Add it in your root build.gradle at the end of repositories: + ``` + allprojects { + repositories { + ... + maven { url 'https://jitpack.io' } + } + } + ``` + - Add the dependency for Pixlee SDK library to your module (app-level) Gradle file(usually app/build.gradle) + + Version: [![](https://jitpack.io/v/pixlee/android-sdk.svg)](https://jitpack.io/#pixlee/android-sdk) + ``` + implementation 'com.github.pixlee:android-sdk:{Version}' + ``` +- Option 2: importing SDK codes + - import pixleesdk as a library project into your project + 1. Open your existing project in Android Studio + 2. Go to Import Module (File -> New -> Import Module) + 3. Enter the path of the pixlee-android-sdk directory + 4. Select the modules you would like to import and click Finish. + - [Google official doc: How to import a module](https://developer.android.com/studio/projects/add-app-module#ImportAModule) + +# Initialize SDK +### You must do this before using this SDK!! +#### Register Pixlee credentials +- Before accessing any Pixlee API, you must initialize the `PXLClient`. To set the API key, call the static method initialize: + ``` + // If you need only to use @Get APIs + #!java + + PXLClient.initialize(); + ``` + Or: + ``` + // If you need to use both @Get and @Post APIs + #!java + + PXLClient.initialize(, ); + ``` +#### Get PXLClient +- You can then use the singleton instance to make calls against the Pixlee API: + ``` + #!java + + PXLClient client = PXLClient.getInstance(context); + ``` +## Album Features +### Initiation +- #### Option 1: Album + To load the photos in an album, you'll want to use the `PXLAlbum` class. Instantiate one with your album ID and client: + + ``` + #!java + + PXLBaseAlbum album = new PXLAlbum(, client); + ``` + Or: + ``` + #!java + + PXLBaseAlbum album = new PXLAlbum(, client.getBasicRepo(), client.getAnalyticsRepo()); + ``` +- #### Option 2: Product + To load the photos in an Product album, you'll want to use the `PXLPdpAlbum` class. Instantiate one with your desired sku and client: + + ``` + #!java + + PXLBaseAlbum album = new PXLPdpAlbum(, client); + ``` + Or: + ``` + #!java + + PXLBaseAlbum album = new PXLPdpAlbum(, client.getBasicRepo(), client.getAnalyticsRepo()); + ``` +#### Get more Photos +- You can then set sort and filter options if desired and use `loadNextPageOfPhotos` to kick off the async request. + ``` + #!java + + PXLAlbumFilterOptions filterOptions = new PXLAlbumFilterOptions(); + filterOptions.minTwitterFollowers = 1000; + filterOptions.minInstagramFollowers = 2000; + PXLAlbumSortOptions sortOptions = new PXLAlbumSortOptions(); + sortOptions.sortType = PXLAlbumSortType.DYNAMIC; + sortOptions.descending = true; + album.setPerPage(15); + album.setFilterOptions(filterOptions); + album.setSortOptions(sortOptions); + album.loadNextPageOfPhotos(this); + ``` +- Each successive call of `loadNextPageOfPhotos` will load the next page of photos. Be sure to set all of your request options (filters, sort, etc) before calling `loadNextPageOfPhotos`. See the source for more implementation details. + Once an album has loaded photos from the server, it will instantiate `PXLBaseAlbum` objects that can be consumed by your UI. `PXLBaseAlbum` exposes all of the data for a photo available through the Pixlee API and offers several image url sizes depending on your needs. + #### Uploading Photos - -If you wish to build your application with photo uploading capabilities, you must initialize the `PXLClient` with an additional parameter - your Pixlee secret key. You must set the secret key along with the API key when you call the static method initialize: - +- Prerequisite: + - option 1: [Get Photos of an Album](#Get-Photos-of-an-Album) + - option 2: [Get Photos of a Product](#Get-Photos-of-a-Product) +- Call the `uploadImage` method of the PXLBaseAlbum object you are using. + ``` + #!java + + album.uploadImage("test", "test@test.com", "testuser", "https://timedotcom.files.wordpress.com/2019/05/drake-nba-finals-warning.jpg", true); + ``` +## How to get image urls +Some imageURL fields can be empty or null depending on its data's status. In order to get appropriate images, you can use this method. ``` #!java - -PXLClient.initialize(, ); +photo.getUrlForSize(PXLPhotoSize.ORIGINAL) +photo.getUrlForSize(PXLPhotoSize.BIG) +photo.getUrlForSize(PXLPhotoSize.MEDIUM) +photo.getUrlForSize(PXLPhotoSize.THUMBNAIL) ``` - -Now wen you want to upload a photo in your application, simply call the `uploadImage` method of the PXLAlbum object you are using. This would look something like this: - -``` -#!java - -album.uploadImage("test", "test@test.com", "testuser", "https://timedotcom.files.wordpress.com/2019/05/drake-nba-finals-warning.jpg", true); -``` - -### Analytics + +## Album Analytics #### Opened Widget -To fire an opened widget event, simply call the `openedWidget` method of the PXLAlbum or PXLPdpAlbum AFTER data has been returned from the first call of the `loadNextPageOfPhotos` method, and an "Opened Widget" event will be fired containing all of the necessary analytics information. -See the DataLoadedHandler function in SampleActiviy.java for an example. - -``` -#!java - -album.openedWidget(); -``` - -#### Load More -To fire a load more event, simply call the `loadMore` method of the PXLAlbum or PXLPdpAlbum AFTER data has been returned from calls via the 'loadNextPageOfPhotos' method, a "Load More" analytics event will be fired containing all of the necessary analytics information. -See the DataLoadedHandler function in SampleActiviy.java for an example. - -``` -#!java +- To fire an opened widget event, simply call the `openedWidget` method of the PXLAlbum or PXLPdpAlbum AFTER data has been returned from the first call of the `loadNextPageOfPhotos` method, and an "Opened Widget" event will be fired containing all of the necessary analytics information. +See the onComplete function in GalleryFragment.java for an example. -album.loadMore(); -``` + ``` + #!java + + album.openedWidget(); + ``` #### Load More -On calls to loadNextPageOfPhotos (except the first), a "Load More" analytics event will be fired automatically +- To fire a load more event, simply call the `loadMore` method of the PXLAlbum or PXLPdpAlbum AFTER data has been returned from calls via the 'loadNextPageOfPhotos' method, a "Load More" analytics event will be fired containing all of the necessary analytics information. +See the onComplete function in GalleryFragment.java for an example. +- On calls to loadNextPageOfPhotos (except the first), a "Load More" analytics event will be fired automatically + ``` + #!java + + album.loadMore(); + ``` #### Opened Lightbox -To fire an opened ligtbox event, simply call the `openedLightbox` method of the PXLPhoto that is being opened, and an "Opened Lightbox" event will be fired containing all of the necessary analytics information. - -``` -#!java +- To fire an opened ligtbox event, simply call the `openedLightbox` method of the PXLBaseAlbum that is being opened, and an "Opened Lightbox" event will be fired containing all of the necessary analytics information. -photo.openedLightbox(context); -``` + ``` + #!java + + photo.openedLightbox(context); + ``` #### Action Clicked -To fire an action clicked event, simply call the `actionClicked` method of the PXLPhoto that the action click is being driven from and pass in the URL of the link that the user is being redirected to. An "Action Clicked" event will be fired containing all of the necessary analytics information. - -``` -#!java - -photo.actionClicked("https://ca.puma.com/en/ca/pd/clyde-court-core-basketball-shoes/191712.html", context); -``` - -### Ecommerce Analytics - -For triggering all ecommerce analytics events within your app, you'll want to use the `PXLAnalytics` class. Instantiate one with the application context: -``` -#!Java - -Context c = this.getApplicationContext(); -PXLAnalytics pixleeAnalytics = new PXLAnalytics(c); -``` - +- To fire an action clicked event, simply call the `actionClicked` method of the PXLBaseAlbum that the action click is being driven from and pass in the URL of the link that the user is being redirected to. An "Action Clicked" event will be fired containing all of the necessary analytics information. + + ``` + #!java + + photo.actionClicked("https://ca.puma.com/en/ca/pd/clyde-court-core-basketball-shoes/191712.html", context); + ``` +## Ecommerce Analytics #### Add To Cart -To fire an Add To Cart event, simply call the `addToCart` method of the PXLAnalytics object with the necessary parameters, and an "Add To Cart" event will be fired containing all of the necessary analytics information. +- To fire an Add To Cart event, simply call the `addToCart` method of the PXLAnalytics object with the necessary parameters, and an "Add To Cart" event will be fired containing all of the necessary analytics information. The parameters for this method are: -- [Required] sku (String) -- [Required] price (String) -- [Required] quantity (Integer) -- [Optional] currency (String) - -``` -#!java + - [Required] sku (String) + - [Required] price (String) + - [Required] quantity (Integer) + - [Optional] currency (String) -pixleeAnalytics.addToCart("sku123", "123", 4); -``` + ``` + #!java + + analytics.addToCart("sku123", "123", 4); + ``` #### Conversion -To fire a Conversion event, simply call the `conversion` method of the PXLAnalytics object with the necessary parameters, and a "Conversion" event will be fired containing all of the necessary analytics information. +- To fire a Conversion event, simply call the `conversion` method of the PXLAnalytics object with the necessary parameters, and a "Conversion" event will be fired containing all of the necessary analytics information. The parameters for this method are: -- [Required] cartContents (ArrayList>) -- [Required] cartTotal (String) -- [Required] cartTotalQuantity (Integer) -- [Optional] orderId (String) -- [Optional] currency (String) - -``` -#!java - -ArrayList> cartContents = new ArrayList(); -HashMap cart1 = new HashMap(); -cart1.put("price", "123"); -cart1.put("product_sku", "test123"); -cart1.put("quantity", "4"); - -cartContents.add(cart1); -pixleeAnalytics.conversion(cartContents, "123", 4); -``` - -To help you get up and running quickly, we've also built an sample application featuring a grid view, list view, and detail view. The adapters simply maintain an ArrayList of PXLPhoto, which is updated via calls to `loadNextPageOfPhotos`. Since the data source contains the full PXLPhoto object, you can easily customize your own widgets to display the desired images and text. The sample also implements a scroll listener which times calls to `loadNextPageOfPhotos` to provide the endless scroll effect. -An example of the proper usage of an opened lightbox event is also included in the sample app! - -### Including the Pixlee Android SDK -#### Using in a preexisting project -1. Open your existing project in Android Studio -2. Go to Import Module (File -> New -> Import Module) -3. Enter the path of the pixlee-android-sdk directory -4. Select the modules you would like to import and click Finish. - -#### Loading the project as is -1. Start Android Studio and select **Import Project** -2. Select the path of the pixlee-android-sdk repo - -### Running the Sample Application -1. After loading the project as described above, navigate to the app module. -2. If you would like to display your own album, navigate to the `createAlbum` method in SampleActivity.java. Replace the album id and api key with your own values (available from the Pixlee dashboard). -3. Run the module. - -## License + - [Required] cartContents (ArrayList>) + - [Required] cartTotal (String) + - [Required] cartTotalQuantity (Integer) + - [Optional] orderId (String) + - [Optional] currency (String) + + ``` + #!java + + ArrayList> cartContents = new ArrayList(); + HashMap cart1 = new HashMap(); + cart1.put("price", "123"); + cart1.put("product_sku", "test123"); + cart1.put("quantity", "4"); + + cartContents.add(cart1); + analytics.conversion(cartContents, "123", 4); + ``` + +# License pixlee-android-sdk is available under the MIT license. \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore index 796b96d1..dbf42236 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1,67 @@ -/build +# Built application files +*.apk +*.ap_ + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties +#keystore.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +.idea/caches + +# Keystore files +# Uncomment the following line if you do not want to check your keystore fil +\es in. +#*.jks + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 71f478d7..3aadb5bb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,6 +9,10 @@ android { versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + buildConfigField "String", "PIXLEE_API_KEY", "\"" + PIXLEE_API_KEY + "\"" + buildConfigField "String", "PIXLEE_SECRET_KEY", "\"" + PIXLEE_SECRET_KEY + "\"" + buildConfigField "String", "PIXLEE_ALBUM_ID", "\"" + PIXLEE_ALBUM_ID + "\"" + buildConfigField "String", "PIXLEE_SKU", "\"" + PIXLEE_SKU + "\"" } buildTypes { release { @@ -16,6 +20,16 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + testOptions { + unitTests.returnDefaultValues = true + } + } dependencies { @@ -27,10 +41,32 @@ dependencies { implementation project(':pixleesdk') testImplementation 'junit:junit:4.12' + /** + * Testing: Network + */ + testImplementation "com.squareup.okhttp3:mockwebserver:$okhttp3" + testImplementation "com.squareup.retrofit2:retrofit:$retrofit2" + testImplementation "com.squareup.retrofit2:converter-moshi:$retrofit2" + testImplementation 'com.serjltt.moshi:moshi-lazy-adapters:2.2' + testImplementation "com.squareup.okhttp3:okhttp:$okhttp3" + + /** + * Architecture Component + */ + implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle" + implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle" + /** * Glide(Image library) */ implementation "com.github.bumptech.glide:glide:$glide" implementation "com.github.bumptech.glide:annotations:$glide" annotationProcessor "com.github.bumptech.glide:compiler:$glide" + + /** + * Butter Knife + * This is not to use View.findViewById() every time + */ + implementation 'com.jakewharton:butterknife:10.2.1' + annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bbcfd917..d512ef90 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,9 +12,10 @@ android:supportsRtl="true" android:theme="@style/AppTheme"> + android:screenOrientation="portrait" + android:theme="@style/AppTheme"> diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/BaseActivity.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/BaseActivity.java new file mode 100644 index 00000000..55b1c4e1 --- /dev/null +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/BaseActivity.java @@ -0,0 +1,124 @@ +package com.pixlee.pixleeandroidsdk; + +import android.os.Build; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; + +import androidx.annotation.ColorRes; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; + +public class BaseActivity extends AppCompatActivity { + private void changeFragmentInActivity( + int frameId, + Fragment fragment, + View sharedView, + int tranEnter, int tranExit, int tranPopEnter, int tranPopExit) { + FragmentTransaction t = getSupportFragmentManager().beginTransaction(); + + if (sharedView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + t.addSharedElement(sharedView, sharedView.getTransitionName()); + else { + t.setCustomAnimations(tranEnter, tranExit, tranPopEnter, tranPopExit); + t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); + } + + String tag = fragment.getClass().getCanonicalName() != null ? fragment.getClass().getCanonicalName() : ""; + t.addToBackStack(tag); + t.replace(frameId, fragment, tag); + t.commitAllowingStateLoss(); + } + + public void replaceFragmentInActivity( + int frameId, + Fragment fragment, + View sharedView) { + FragmentManager fm = getSupportFragmentManager(); + fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); + changeFragmentInActivity(frameId, fragment, sharedView, 0,0,0,0); + } + + /** + * The `fragment` is added to the container view with proposalIndex. The operation is + * performed by the `fragmentManager`. + */ + + public void addFragmentToActivity( + int frameId, + Fragment fragment, + View sharedView) { + + changeFragmentInActivity(frameId, fragment, sharedView, + R.anim.slide_in_right_left, + R.anim.slide_out_right_left, + R.anim.slide_in_left_right, + R.anim.slide_out_left_right); + } + + /** + * The `fragment` is added to the container view with proposalIndex. The operation is + * performed by the `fragmentManager`. + */ + public void popAndAddFragmentToActivity( + int frameId, + Fragment fragment, + View sharedView + ) { + FragmentTransaction t = getSupportFragmentManager().beginTransaction(); + + if (sharedView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + t.addSharedElement(sharedView, sharedView.getTransitionName()); + else { + t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); + } + + String tag = fragment.getClass().getCanonicalName() != null ? fragment.getClass().getCanonicalName() : ""; + t.addToBackStack(tag); + t.replace(frameId, fragment, tag); + } + + /** + * The `fragment` is restart on the container view with tag. The operation is + * performed by the `fragmentManager`. + */ + public void restartFragmentByTag(String fragmentTag) { + FragmentManager fm = getSupportFragmentManager(); + fm.popBackStack(); + Fragment f = fm.findFragmentByTag(fragmentTag); + + FragmentTransaction t = fm.beginTransaction(); + t.detach(f); + t.attach(f); + } + + public void setSystemBarLight() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + View view = findViewById(android.R.id.content); + int flags = view.getSystemUiVisibility(); + flags = flags | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; + view.setSystemUiVisibility(flags); + } + } + + public void setSystemBarColor() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + Window window = getWindow(); + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark)); + } + } + + public void setSystemBarColor(@ColorRes int colorRes) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + Window window = getWindow(); + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + window.setStatusBarColor(ContextCompat.getColor(this, colorRes)); + } + } +} diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/BaseFragment.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/BaseFragment.java new file mode 100644 index 00000000..62d4eac4 --- /dev/null +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/BaseFragment.java @@ -0,0 +1,35 @@ +package com.pixlee.pixleeandroidsdk; + +import android.widget.Toast; + +import androidx.fragment.app.Fragment; + +abstract public class BaseFragment extends Fragment { + //this is to display a title in Toolbar + public abstract int getTitleResource(); + + //this is to display a a custom title in Toolbar. This has a higher priority over getTitleResource() + String getCustomTitle(){ + return null; + } + + public void replaceFragmentInActivity(Fragment fragment) { + if (getActivity() instanceof MainActivity) { + MainActivity mainActivity = (MainActivity) getActivity(); + + mainActivity.replaceFragmentInActivity(mainActivity.frameLayoutId, fragment, null); + } else { + Toast.makeText(getContext(), "need to add replaceFragmentInActivity() to your activity", Toast.LENGTH_SHORT).show(); + } + } + + public void addFragmentToActivity(Fragment fragment) { + if (getActivity() instanceof MainActivity) { + MainActivity mainActivity = (MainActivity) getActivity(); + + mainActivity.addFragmentToActivity(mainActivity.frameLayoutId, fragment, null); + } else { + Toast.makeText(getContext(), "need to add addFragmentToActivity() to your activity", Toast.LENGTH_SHORT).show();; + } + } +} diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/GalleryClickListener.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/GalleryClickListener.java new file mode 100644 index 00000000..47275aea --- /dev/null +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/GalleryClickListener.java @@ -0,0 +1,10 @@ +package com.pixlee.pixleeandroidsdk; + +import com.pixlee.pixleesdk.PXLPhoto; + +/** + * Click Listener for Gallery + */ +public interface GalleryClickListener { + void onItemClicked(PXLPhoto photo); +} diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/MainActivity.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/MainActivity.java new file mode 100644 index 00000000..d39a9d4a --- /dev/null +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/MainActivity.java @@ -0,0 +1,99 @@ +package com.pixlee.pixleeandroidsdk; + +import android.graphics.PorterDuff; +import android.os.Bundle; +import android.util.Log; + +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.widget.Toolbar; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.FragmentManager; + +import com.pixlee.pixleeandroidsdk.gallery.GalleryFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class MainActivity extends BaseActivity { + final String TAG = "MainActivity"; + int frameLayoutId = R.id.contentFrame; + + @BindView(R.id.toolbar) + Toolbar toolbar; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + ButterKnife.bind(this); + + setSupportActionBar(toolbar); + + if (toolbar.getNavigationIcon() != null) { + toolbar.getNavigationIcon().setColorFilter( + ContextCompat.getColor(this, R.color.grey_60), + PorterDuff.Mode.SRC_ATOP + ); + } + + setSystemBarColor(R.color.grey_5); + setSystemBarLight(); + + FragmentManager fm = getSupportFragmentManager(); + fm.addOnBackStackChangedListener(onBackStackChangedListener); + + replaceFragmentInActivity(frameLayoutId, new GalleryFragment(), null); + + } + + FragmentManager.OnBackStackChangedListener onBackStackChangedListener = new FragmentManager.OnBackStackChangedListener() { + + @Override + public void onBackStackChanged() { + FragmentManager fm = getSupportFragmentManager(); + int fragmentCount = fm.getBackStackEntryCount(); + String title; + if (fragmentCount > 0) { + BaseFragment fragment = (BaseFragment) fm.getFragments().get(fm.getFragments().size() - 1); + if (fragment.getCustomTitle() != null) { + title = fragment.getCustomTitle(); + } else { + title = getString(fragment.getTitleResource()); + } + } else { + title = getString(R.string.app_name); + } + + Log.d(TAG, "fragmentCount: " + fragmentCount); + + setSupportActionBar(toolbar); + ActionBar bar = getSupportActionBar(); + bar.setTitle(title); + bar.setDisplayHomeAsUpEnabled(fragmentCount > 1); + bar.setDisplayShowHomeEnabled(fragmentCount > 1); + + invalidateOptionsMenu(); + } + }; + + @Override + public boolean onSupportNavigateUp() { + onBackPressed(); + return true; + } + + @Override + public void onBackPressed() { + try { + int fragmentStackSize = getSupportFragmentManager().getBackStackEntryCount(); + if (fragmentStackSize <= 1) { + finish(); + } + + } catch (Exception e) { + e.printStackTrace(); + } + + super.onBackPressed(); + } +} diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/SampleActivity.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/SampleActivity.java deleted file mode 100644 index 1d4be931..00000000 --- a/app/src/main/java/com/pixlee/pixleeandroidsdk/SampleActivity.java +++ /dev/null @@ -1,353 +0,0 @@ -package com.pixlee.pixleeandroidsdk; - -import android.content.Context; -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; -import android.widget.ViewSwitcher; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; -import androidx.recyclerview.widget.GridLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.bumptech.glide.Glide; -import com.pixlee.pixleesdk.PXLAlbum; -import com.pixlee.pixleesdk.PXLAlbumFilterOptions; -import com.pixlee.pixleesdk.PXLAlbumSortOptions; -import com.pixlee.pixleesdk.PXLAlbumSortType; -import com.pixlee.pixleesdk.PXLClient; -import com.pixlee.pixleesdk.PXLPhoto; -import com.pixlee.pixleesdk.PXLPhotoSize; - -import java.util.ArrayList; -import java.util.Date; - -public class SampleActivity extends AppCompatActivity implements PXLAlbum.RequestHandlers { - private ArrayList photoList; - private PXLAlbum album; - private ImageView detailImage; - private TextView detailText; - private ImageView detailSourceIcon; - private TextView detailUser; - private TextView detailLastMod; - private ViewSwitcher viewSwitcher; - private ImageView gridToggleButton; - private int lastImg; - private RecyclerView gridView; - private RecyclerView listView; - private LinearLayout actionLinksLayout; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_sample); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - photoList = new ArrayList<>(); - - viewSwitcher = (ViewSwitcher)findViewById(R.id.viewSwitcher1); - gridToggleButton = (ImageView) findViewById(R.id.gridToggle); - lastImg = R.drawable.grid_2x; - this.detailImage = (ImageView) findViewById(R.id.detailImage); - this.detailText = (TextView) findViewById(R.id.detailText); - this.detailSourceIcon = (ImageView) findViewById(R.id.detailSourceIcon); - this.detailUser = (TextView) findViewById(R.id.userName); - this.detailLastMod = (TextView) findViewById(R.id.lastModified); - gridView = (RecyclerView)findViewById(R.id.imagegallery); - listView = (RecyclerView)findViewById(R.id.imagelist); - actionLinksLayout = (LinearLayout) findViewById(R.id.actionLinksLayout); - - gridToggleButton.setImageResource(lastImg); - gridToggleButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - viewSwitcher.showNext(); - if (lastImg == R.drawable.grid_2x) { - lastImg = R.drawable.column_2x; - } else { - lastImg = R.drawable.grid_2x; - } - gridToggleButton.setImageResource(lastImg); - } - }); - - createAlbum(); - configureViews(); - samplePhotoLoad(); - } - - /*** - * Toggles between grid/list view and the detail view - * @param photo - */ - public void switchVisibilities(PXLPhoto photo) { - if (findViewById(R.id.detailview).getVisibility() == View.VISIBLE) { - findViewById(R.id.detailview).setVisibility(View.GONE); - viewSwitcher.setVisibility(View.VISIBLE); - gridToggleButton.setVisibility(View.VISIBLE); - } else { - findViewById(R.id.detailview).setVisibility(View.VISIBLE); - updateDetailView(photo); - viewSwitcher.setVisibility(View.GONE); - gridToggleButton.setVisibility(View.GONE); - } - } - - /*** - * Callback for loadNextPageOfPhotos. Update our list of photos and notify the adapters. - * @param photos - the complete list of photos (both the latest page and all previous) - */ - @Override - public void DataLoadedHandler(ArrayList photos) { - if (photos == null) { - return; - } - album.openedWidget(); - album.loadMore(); - this.photoList.clear(); - this.photoList.addAll(photos); - gridView.getAdapter().notifyDataSetChanged(); - listView.getAdapter().notifyDataSetChanged(); - } - - /*** - * Callback for a failed call to loadNextPageOfPhotos - * @param error - */ - @Override - public void DataLoadFailedHandler(String error) { - Log.e("pixlee", String.format("Failed to fetch next page of photos: %s", error)); - } - - private void configureViews() { - gridView.setHasFixedSize(true); - listView.setHasFixedSize(true); - - RecyclerView.LayoutManager gridLayoutManager = new GridLayoutManager(getApplicationContext(), 2); - RecyclerView.LayoutManager listLayoutManager = new GridLayoutManager(getApplicationContext(), 1); - gridView.setLayoutManager(gridLayoutManager); - listView.setLayoutManager(listLayoutManager); - GridAdapter gridAdapter = new GridAdapter(getApplicationContext(), photoList, this); - ListAdapter listAdapter = new ListAdapter(getApplicationContext(), photoList, this); - gridView.setAdapter(gridAdapter); - listView.setAdapter(listAdapter); - - LinearLayout detailLayout = (LinearLayout) findViewById(R.id.detailview); - detailLayout.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - switchVisibilities(null); - } - }); - - RecyclerViewEndlessScrollListener gridScrollListener = new RecyclerViewEndlessScrollListener(gridLayoutManager) { - @Override - public void onLoadMore(int page, int totalItemsCount, RecyclerView view) { - loadMorePhotos(); - } - }; - RecyclerViewEndlessScrollListener listScrollListener = new RecyclerViewEndlessScrollListener(listLayoutManager) { - @Override - public void onLoadMore(int page, int totalItemsCount, RecyclerView view) { - loadMorePhotos(); - } - }; - - gridView.addOnScrollListener(gridScrollListener); - listView.addOnScrollListener(listScrollListener); - } - - /*** - * Initializes the PXLClient and creates the PXLAlbum - */ - private void createAlbum() { - Context c = this.getApplicationContext(); - - PXLClient.initialize("196i8ZzIAhKU8dO2kDe"); - - album = new PXLAlbum("4503434", c); - PXLAlbumFilterOptions fo = new PXLAlbumFilterOptions(); - fo.minTwitterFollowers = 0; - fo.minInstagramFollowers = 0; - - /* ~~~ content source and content filter examples ~~~ - ArrayList contentSource = new ArrayList(); - contentSource.add(PXLContentSource.INSTAGRAM); - fo.contentSource = contentSource; - - ArrayList contentType = new ArrayList(); - contentType.add(PXLContentType.IMAGE); - fo.contentType = contentType; - */ - - - /* ~~~ date filter examples ~~~ - fo.submittedDateEnd = new Date(2019, 7, 16); - fo.submittedDateStart = new Date(2019, 7, 17); - */ - - - // fo.filterByRadius = "21.3069,-157.8583,20"; radius filter example - - - /* ~~~ in_categories filter example ~~~ - ArrayList incategories = new ArrayList(); - incategories.add(1234); - incategories.add(5678); - fo.inCategories = incategories; - */ - - /* ~~~ filter_by_userhandle filter example ~~~ - - HashMap userHandleFilter = new HashMap (); - userHandleFilter.put("contains", new String[] {"test1", "test2"}); - fo.filterByUserhandle = userHandleFilter; - - */ - - /* ~~~ computer_vision filter example ~~~ - - HashMap computerVisionFilter = new HashMap (); - computerVisionFilter.put("contains", new String[] {"hat"}); - fo.computerVision = computerVisionFilter; - - */ - - - // fo.hasProduct = false; - // fo.hasPermission = false; - // fo.inStockOnly = false; - - PXLAlbumSortOptions so = new PXLAlbumSortOptions(); - so.sortType = PXLAlbumSortType.RECENCY; - so.descending = true; - album.setPerPage(20); - album.setFilterOptions(fo); - album.setSortOptions(so); - PXLAlbum.RequestHandlers rh = this; - album.loadNextPageOfPhotos(rh); - - /* ~~~ content upload example ~~~ - - album.uploadImage("test", "kb@pixleeteam.com", "K.B.", "https://timedotcom.files.wordpress.com/2019/05/drake-nba-finals-warning.jpg", true); - - */ - } - - /*** - * callback for endless scroller - */ - private void loadMorePhotos() { - this.album.loadNextPageOfPhotos(this); - } - - private void updateDetailView(PXLPhoto photo) { - Context c = this.getApplicationContext(); - this.detailSourceIcon.setImageResource(photo.sourceIconImage()); - Glide.with(this) - .load(photo.getUrlForSize(PXLPhotoSize.MEDIUM).toString()) - .into(this.detailImage); - this.detailText.setText(photo.photoTitle); - this.detailUser.setText(String.format("@%s", photo.userName)); - String unit = "hour"; - Date now = new Date(); - //ms - long elapsed = now.getTime() - photo.taggedAt.getTime(); - //s - elapsed /= 1000; - //hrs - elapsed /= 60 * 60; - if (elapsed > 1) { - unit += "s"; - } - if (elapsed >= 24) { - elapsed /= 24; - unit = "day"; - if (elapsed > 1) { - unit += "s"; - } - } - this.detailLastMod.setText(String.format("%s %s ago", elapsed, unit)); - - if (photo.products.size() > 0) { - actionLinksLayout.setVisibility(View.VISIBLE); - } else { - actionLinksLayout.setVisibility(View.GONE); - } - - photo.openedLightbox(c); // Opened Lightbox Analytics Example - photo.actionClicked("https://ca.puma.com/en/ca/pd/clyde-court-core-basketball-shoes/191712.html", c); - - /* ~~~ Add to cart analytics example ~~~ - - PXLAnalytics pixleeAnalytics = new PXLAnalytics(c); - pixleeAnalytics.addToCart("sku123", "123", 4); - - */ - - - /* ~~~ Conversion analytics example ~~~ - - ArrayList> cartContents = new ArrayList(); - HashMap cart1 = new HashMap(); - cart1.put("price", "123"); - cart1.put("product_sku", "test123"); - cart1.put("quantity", "4"); - - cartContents.add(cart1); - pixleeAnalytics.conversion(cartContents, "123", 4); - */ - - - this.populateDetailActions(photo); - } - - private void populateDetailActions(PXLPhoto photo) { - actionLinksLayout.removeAllViews(); - for (int i = 0; i < photo.products.size(); i++) { - PXLProductView pxlProductView = new PXLProductView(this, null); - pxlProductView.populate(photo.products.get(i)); - actionLinksLayout.addView(pxlProductView); - } - } - - private void samplePhotoLoad() { - String identifier = "282742015"; - PXLPhoto.getPhotoWithId(getApplicationContext(), identifier, new PXLPhoto.PhotoLoadHandlers() { - @Override - public void photoLoaded(PXLPhoto photo) { - Log.d("testphoto", String.format("%s", photo.cdnSmallUrl)); - Log.d("testphoto", String.format("%s", photo.cdnMediumUrl)); - Log.d("testphoto", String.format("%s", photo.cdnLargeUrl)); - Log.d("testphoto", String.format("%s", photo.cdnOriginalUrl)); - } - - @Override - public void photoLoadFailed(String error) { - Log.e("sampleactivity", "failed to load photo: " + error); - } - }); - - //load from pxlphoto object - PXLPhoto photo = new PXLPhoto(getApplicationContext(), identifier); - photo.loadFromId(new PXLPhoto.PhotoLoadHandlers() { - @Override - public void photoLoaded(PXLPhoto photo) { - Log.d("testphoto", String.format("%s", photo.cdnSmallUrl)); - Log.d("testphoto", String.format("%s", photo.cdnMediumUrl)); - Log.d("testphoto", String.format("%s", photo.cdnLargeUrl)); - Log.d("testphoto", String.format("%s", photo.cdnOriginalUrl)); - } - - @Override - public void photoLoadFailed(String error) { - Log.e("sampleactivity", "failed to load photo: " + error); - } - }); - } -} diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/config/AppGlideModuleSetting.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/config/AppGlideModuleSetting.java new file mode 100644 index 00000000..681e63fb --- /dev/null +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/config/AppGlideModuleSetting.java @@ -0,0 +1,8 @@ +package com.pixlee.pixleeandroidsdk.config; + +import com.bumptech.glide.annotation.GlideModule; +import com.bumptech.glide.module.AppGlideModule; + +@GlideModule +public class AppGlideModuleSetting extends AppGlideModule { +} diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/GalleryFragment.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/GalleryFragment.java new file mode 100644 index 00000000..78cf7dbd --- /dev/null +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/GalleryFragment.java @@ -0,0 +1,296 @@ +package com.pixlee.pixleeandroidsdk.gallery; + +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.ViewSwitcher; + +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.pixlee.pixleeandroidsdk.BaseFragment; +import com.pixlee.pixleeandroidsdk.BuildConfig; +import com.pixlee.pixleeandroidsdk.GalleryClickListener; +import com.pixlee.pixleeandroidsdk.R; +import com.pixlee.pixleeandroidsdk.viewer.ImageViewerFragment; +import com.pixlee.pixleeandroidsdk.viewer.VideoViewerFragment; +import com.pixlee.pixleesdk.PXLAlbum; +import com.pixlee.pixleesdk.PXLAlbumFilterOptions; +import com.pixlee.pixleesdk.PXLAlbumSortOptions; +import com.pixlee.pixleesdk.PXLAlbumSortType; +import com.pixlee.pixleesdk.PXLAnalytics; +import com.pixlee.pixleesdk.PXLBaseAlbum; +import com.pixlee.pixleesdk.PXLClient; +import com.pixlee.pixleesdk.PXLPhoto; +import com.pixlee.pixleesdk.PXLPhotoSize; +import com.pixlee.pixleesdk.PXLWidgetType; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class GalleryFragment extends BaseFragment implements PXLAlbum.RequestHandlers>{ + @Override + public int getTitleResource() { + return R.string.title_gallery; + } + + private PXLAlbum album; + private ArrayList photoList; + + private int lastImg = R.drawable.grid_2x; + + @BindView(R.id.viewSwitcher1) + ViewSwitcher viewSwitcher; + + @BindView(R.id.gridToggle) + ImageView gridToggleButton; + + @BindView(R.id.imagegallery) + RecyclerView gridView; + + @BindView(R.id.imagelist) + RecyclerView listView; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + photoList = new ArrayList<>(); + } + + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_gallery, container, false); + ButterKnife.bind(this, view); + return view; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + gridToggleButton.setImageResource(lastImg); + gridToggleButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + viewSwitcher.showNext(); + if (lastImg == R.drawable.grid_2x) { + lastImg = R.drawable.column_2x; + } else { + lastImg = R.drawable.grid_2x; + } + gridToggleButton.setImageResource(lastImg); + } + }); + + loadAlbum(); + configureViews(); + } + + + + /*** + * Initializes the PXLClient and creates the PXLAlbum + */ + private void loadAlbum() { + PXLClient.initialize(BuildConfig.PIXLEE_API_KEY, BuildConfig.PIXLEE_SECRET_KEY); + PXLClient client = PXLClient.getInstance(getContext().getApplicationContext()); + + album = new PXLAlbum(BuildConfig.PIXLEE_ALBUM_ID, client.getBasicRepo(), client.getAnalyticsRepo()); + PXLAlbumFilterOptions fo = new PXLAlbumFilterOptions(); + fo.minTwitterFollowers = 0; + fo.minInstagramFollowers = 0; + + + /* ~~~ content source and content filter examples ~~~ + ArrayList contentSource = new ArrayList(); + contentSource.add(PXLContentSource.INSTAGRAM); + fo.contentSource = contentSource; + + ArrayList contentType = new ArrayList(); + contentType.add(PXLContentType.IMAGE); + fo.contentType = contentType; + */ + + + /* ~~~ date filter examples ~~~ + fo.submittedDateEnd = new Date(2019, 7, 16); + fo.submittedDateStart = new Date(2019, 7, 17); + */ + + + // fo.filterByRadius = "21.3069,-157.8583,20"; radius filter example + + + /* ~~~ in_categories filter example ~~~ + ArrayList incategories = new ArrayList(); + incategories.add(1234); + incategories.add(5678); + fo.inCategories = incategories; + */ + + /* ~~~ filter_by_userhandle filter example ~~~ + + HashMap userHandleFilter = new HashMap (); + userHandleFilter.put("contains", new String[] {"test1", "test2"}); + fo.filterByUserhandle = userHandleFilter; + + */ + + /* ~~~ computer_vision filter example ~~~ + + HashMap computerVisionFilter = new HashMap (); + computerVisionFilter.put("contains", new String[] {"hat"}); + fo.computerVision = computerVisionFilter; + + */ + + + // fo.hasProduct = false; + // fo.hasPermission = false; + // fo.inStockOnly = false; + + PXLAlbumSortOptions so = new PXLAlbumSortOptions(); + so.sortType = PXLAlbumSortType.RECENCY; + so.descending = true; + album.setPerPage(20); + album.setFilterOptions(fo); + album.setSortOptions(so); + PXLAlbum.RequestHandlers rh = this; + album.loadNextPageOfPhotos(rh); + + + PXLAnalytics analytics = new PXLAnalytics(client.getAnalyticsRepo()); + analytics.addToCart(BuildConfig.PIXLEE_SKU, "13000",2, "AUD"); + /* ~~~ content upload example ~~~ + + album.uploadImage("test", "kb@pixleeteam.com", "K.B.", "https://timedotcom.files.wordpress.com/2019/05/drake-nba-finals-warning.jpg", true); + + */ + } + + private void configureViews() { + gridView.setHasFixedSize(true); + listView.setHasFixedSize(true); + + RecyclerView.LayoutManager gridLayoutManager = new GridLayoutManager(getContext().getApplicationContext(), 2); + RecyclerView.LayoutManager listLayoutManager = new GridLayoutManager(getContext().getApplicationContext(), 1); + gridView.setLayoutManager(gridLayoutManager); + listView.setLayoutManager(listLayoutManager); + + GalleryClickListener li = new GalleryClickListener() { + @Override + public void onItemClicked(PXLPhoto photo) { + moveToViewer(photo); + } + }; + + GridAdapter gridAdapter = new GridAdapter(getContext().getApplicationContext(), photoList, li); + ListAdapter listAdapter = new ListAdapter(getContext().getApplicationContext(), photoList, li); + gridView.setAdapter(gridAdapter); + listView.setAdapter(listAdapter); + + RecyclerViewEndlessScrollListener gridScrollListener = new RecyclerViewEndlessScrollListener(gridLayoutManager) { + @Override + public void onLoadMore(int page, int totalItemsCount, RecyclerView view) { + loadMorePhotos(); + } + }; + RecyclerViewEndlessScrollListener listScrollListener = new RecyclerViewEndlessScrollListener(listLayoutManager) { + @Override + public void onLoadMore(int page, int totalItemsCount, RecyclerView view) { + loadMorePhotos(); + } + }; + + gridView.addOnScrollListener(gridScrollListener); + listView.addOnScrollListener(listScrollListener); + } + + /** + * When an item in the list is clicked, this method call Video player or Image viewer using PXLPhoto.isVideo() + * @param photo + */ + void moveToViewer(PXLPhoto photo) { + // You can choose images by using this example below. + // PXLPhotoSize Options: [ORIGINAL, BIG, MEDIUM, THUMBNAIL] + String url = photo.getUrlForSize(PXLPhotoSize.ORIGINAL).toString(); + if(photo.isVideo()){ + addFragmentToActivity(VideoViewerFragment.getInstance(url)); + }else{ + addFragmentToActivity(ImageViewerFragment.getInstance(url)); + } + } + + /*** + * callback for endless scroller + */ + private void loadMorePhotos() { + this.album.loadNextPageOfPhotos(this); + } + + private void samplePhotoLoad(PXLPhoto photo) { + // load PXLPhoto with album_photo_id + album.getPhotoWithId(photo.albumPhotoId,new PXLBaseAlbum.RequestHandlers(){ + + @Override + public void onComplete(PXLPhoto result) { + + } + + @Override + public void onError(String error) { + Log.e("sampleactivity", "failed to load photo: " + error); + } + }); + + // load PXLPhoto with pxlphoto object + album.getPhotoWithId(photo, new PXLBaseAlbum.RequestHandlers() { + @Override + public void onComplete(PXLPhoto photo) { + + } + + @Override + public void onError(String error) { + Log.e("sampleactivity", "failed to load photo: " + error); + } + }); + } + + /*** + * Callback for loadNextPageOfPhotos. Update our list of photos and notify the adapters. + * @param photos - the complete list of photos (both the latest page and all previous) + */ + @Override + public void onComplete(List photos) { + if (photos == null) { + return; + } + album.openedWidget(PXLWidgetType.horizontal); + album.openedWidget("gallery"); + album.loadMore(); + + this.photoList.clear(); + this.photoList.addAll(photos); + gridView.getAdapter().notifyDataSetChanged(); + listView.getAdapter().notifyDataSetChanged(); + + if(photos.size()>0){ + samplePhotoLoad(photos.get(0)); + } + } + + /*** + * Callback for a failed call to loadNextPageOfPhotos + * @param error + */ + @Override + public void onError(String error) { + Log.e("pixlee", String.format("Failed to fetch next page of photos: %s", error)); + } +} diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/GridAdapter.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/GridAdapter.java similarity index 62% rename from app/src/main/java/com/pixlee/pixleeandroidsdk/GridAdapter.java rename to app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/GridAdapter.java index d328ce27..7c5cc4e2 100644 --- a/app/src/main/java/com/pixlee/pixleeandroidsdk/GridAdapter.java +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/GridAdapter.java @@ -1,28 +1,29 @@ -package com.pixlee.pixleeandroidsdk; +package com.pixlee.pixleeandroidsdk.gallery; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; -import com.pixlee.pixleesdk.PXLClient; +import com.pixlee.pixleeandroidsdk.GalleryClickListener; +import com.pixlee.pixleeandroidsdk.R; import com.pixlee.pixleesdk.PXLPhoto; +import com.pixlee.pixleesdk.PXLPhotoSize; import java.util.ArrayList; public class GridAdapter extends RecyclerView.Adapter { private ArrayList galleryList; private Context context; - private SampleActivity saref; + private GalleryClickListener listener; - public GridAdapter(Context context, ArrayList galleryList, SampleActivity sa) { + public GridAdapter(Context context, ArrayList galleryList, GalleryClickListener listener) { this.galleryList = galleryList; this.context = context; - this.saref = sa; + this.listener = listener; } @Override @@ -36,18 +37,17 @@ public void onBindViewHolder(GridViewHolder viewHolder, int i) { final PXLPhoto photo = galleryList.get(i); viewHolder.title.setText(photo.photoTitle); - if (photo.thumbnailUrl != null) { - Glide.with(context) - .load(photo.thumbnailUrl.toString()) - .into(viewHolder.netImg); - viewHolder.netImg.setScaleType(ImageView.ScaleType.CENTER_CROP); - viewHolder.itemView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - saref.switchVisibilities(photo); - } - }); - } + Glide.with(context) + .load(photo.getUrlForSize(PXLPhotoSize.MEDIUM)) + .centerCrop() + .into(viewHolder.netImg); + + viewHolder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + listener.onItemClicked(photo); + } + }); } @Override diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/GridViewHolder.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/GridViewHolder.java similarity index 84% rename from app/src/main/java/com/pixlee/pixleeandroidsdk/GridViewHolder.java rename to app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/GridViewHolder.java index 37d2dcf0..d869fd7c 100644 --- a/app/src/main/java/com/pixlee/pixleeandroidsdk/GridViewHolder.java +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/GridViewHolder.java @@ -1,4 +1,4 @@ -package com.pixlee.pixleeandroidsdk; +package com.pixlee.pixleeandroidsdk.gallery; import android.view.View; import android.widget.ImageView; @@ -6,6 +6,8 @@ import androidx.recyclerview.widget.RecyclerView; +import com.pixlee.pixleeandroidsdk.R; + public class GridViewHolder extends RecyclerView.ViewHolder { public TextView title; diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/ListAdapter.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/ListAdapter.java similarity index 70% rename from app/src/main/java/com/pixlee/pixleeandroidsdk/ListAdapter.java rename to app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/ListAdapter.java index 5e778e76..a53f073e 100644 --- a/app/src/main/java/com/pixlee/pixleeandroidsdk/ListAdapter.java +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/ListAdapter.java @@ -1,28 +1,29 @@ -package com.pixlee.pixleeandroidsdk; +package com.pixlee.pixleeandroidsdk.gallery; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; -import com.pixlee.pixleesdk.PXLClient; +import com.pixlee.pixleeandroidsdk.GalleryClickListener; +import com.pixlee.pixleeandroidsdk.R; import com.pixlee.pixleesdk.PXLPhoto; +import com.pixlee.pixleesdk.PXLPhotoSize; import java.util.ArrayList; -class ListAdapter extends RecyclerView.Adapter { +public class ListAdapter extends RecyclerView.Adapter { private ArrayList galleryList; private Context context; - private SampleActivity saRef; + private GalleryClickListener listener; - public ListAdapter(Context context, ArrayList galleryList, SampleActivity sa) { + public ListAdapter(Context context, ArrayList galleryList, GalleryClickListener listener) { this.galleryList = galleryList; this.context = context; - this.saRef = sa; + this.listener = listener; } @Override @@ -35,14 +36,14 @@ public ListViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { public void onBindViewHolder(ListViewHolder viewHolder, int i) { final PXLPhoto photo = galleryList.get(i); viewHolder.title.setText(photo.photoTitle); - viewHolder.netImg.setScaleType(ImageView.ScaleType.CENTER_CROP); Glide.with(context) - .load(photo.thumbnailUrl.toString()) + .load(photo.getUrlForSize(PXLPhotoSize.MEDIUM)) + .centerCrop() .into(viewHolder.netImg); viewHolder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - saRef.switchVisibilities(photo); + listener.onItemClicked(photo); } }); } diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/ListViewHolder.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/ListViewHolder.java similarity index 84% rename from app/src/main/java/com/pixlee/pixleeandroidsdk/ListViewHolder.java rename to app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/ListViewHolder.java index 02330d09..3dbdba4e 100644 --- a/app/src/main/java/com/pixlee/pixleeandroidsdk/ListViewHolder.java +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/ListViewHolder.java @@ -1,4 +1,4 @@ -package com.pixlee.pixleeandroidsdk; +package com.pixlee.pixleeandroidsdk.gallery; import android.view.View; import android.widget.ImageView; @@ -6,6 +6,8 @@ import androidx.recyclerview.widget.RecyclerView; +import com.pixlee.pixleeandroidsdk.R; + public class ListViewHolder extends RecyclerView.ViewHolder { public TextView title; diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/PXLProductView.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/PXLProductView.java similarity index 95% rename from app/src/main/java/com/pixlee/pixleeandroidsdk/PXLProductView.java rename to app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/PXLProductView.java index 79f28120..3a060b0b 100644 --- a/app/src/main/java/com/pixlee/pixleeandroidsdk/PXLProductView.java +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/PXLProductView.java @@ -1,4 +1,4 @@ -package com.pixlee.pixleeandroidsdk; +package com.pixlee.pixleeandroidsdk.gallery; import android.content.Context; import android.content.Intent; @@ -12,6 +12,7 @@ import android.widget.TextView; import com.bumptech.glide.Glide; +import com.pixlee.pixleeandroidsdk.R; import com.pixlee.pixleesdk.PXLProduct; public class PXLProductView extends LinearLayout { diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/RecyclerViewEndlessScrollListener.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/RecyclerViewEndlessScrollListener.java similarity index 98% rename from app/src/main/java/com/pixlee/pixleeandroidsdk/RecyclerViewEndlessScrollListener.java rename to app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/RecyclerViewEndlessScrollListener.java index d953e33e..31d5ebd3 100644 --- a/app/src/main/java/com/pixlee/pixleeandroidsdk/RecyclerViewEndlessScrollListener.java +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/gallery/RecyclerViewEndlessScrollListener.java @@ -1,4 +1,4 @@ -package com.pixlee.pixleeandroidsdk; +package com.pixlee.pixleeandroidsdk.gallery; import androidx.recyclerview.widget.GridLayoutManager; diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/viewer/ImageViewerFragment.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/viewer/ImageViewerFragment.java new file mode 100644 index 00000000..5ac6cbc9 --- /dev/null +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/viewer/ImageViewerFragment.java @@ -0,0 +1,77 @@ +package com.pixlee.pixleeandroidsdk.viewer; + +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +import com.bumptech.glide.load.DataSource; +import com.bumptech.glide.load.engine.GlideException; +import com.bumptech.glide.request.RequestListener; +import com.bumptech.glide.request.target.Target; +import com.pixlee.pixleeandroidsdk.BaseFragment; +import com.pixlee.pixleeandroidsdk.R; +import com.pixlee.pixleeandroidsdk.config.GlideApp; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class ImageViewerFragment extends BaseFragment { + @Override + public int getTitleResource() { + return R.string.title_image_viewer; + } + + @BindView(R.id.iv) + ImageView iv; + + @BindView(R.id.v_loading) + View v_loading; + + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_image_viewer, container, false); + ButterKnife.bind(this, view); + return view; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + GlideApp.with(getContext()).asDrawable().clone() + .load(getImageUrl()) + .thumbnail(0.2f) + .fitCenter() + .error(R.drawable.baseline_cloud_off_black_48) + .listener(new RequestListener() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { + iv.setScaleType(ImageView.ScaleType.CENTER); + return false; + } + + @Override + public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { + v_loading.setVisibility(View.GONE); + iv.setScaleType(ImageView.ScaleType.FIT_CENTER); + return false; + } + }).into(iv); + } + + private String getImageUrl() { + return getArguments().getString("imageUrl"); + } + + public static Fragment getInstance(String imageUrl){ + Fragment f = new ImageViewerFragment(); + Bundle bundle = new Bundle(); + bundle.putString("imageUrl", imageUrl); + f.setArguments(bundle); + return f; + } +} diff --git a/app/src/main/java/com/pixlee/pixleeandroidsdk/viewer/VideoViewerFragment.java b/app/src/main/java/com/pixlee/pixleeandroidsdk/viewer/VideoViewerFragment.java new file mode 100644 index 00000000..e3f1ff3d --- /dev/null +++ b/app/src/main/java/com/pixlee/pixleeandroidsdk/viewer/VideoViewerFragment.java @@ -0,0 +1,107 @@ +package com.pixlee.pixleeandroidsdk.viewer; + +import android.media.MediaPlayer; +import android.os.Bundle; +import android.os.Handler; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import android.widget.VideoView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.lifecycle.Lifecycle; +import androidx.lifecycle.LifecycleEventObserver; +import androidx.lifecycle.LifecycleOwner; + +import com.pixlee.pixleeandroidsdk.BaseFragment; +import com.pixlee.pixleeandroidsdk.R; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class VideoViewerFragment extends BaseFragment { + @Override + public int getTitleResource() { + return R.string.title_video_viewer; + } + + @BindView(R.id.videoView) + VideoView videoView; + + @BindView(R.id.v_loading) + View v_loading; + + @BindView(R.id.tv_time) + TextView tv_time; + + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_video_viewer, container, false); + ButterKnife.bind(this, view); + return view; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { + @Override + public void onPrepared(MediaPlayer mediaPlayer) { + v_loading.setVisibility(View.GONE); + getViewLifecycleOwner().getLifecycle().addObserver(new LifecycleEventObserver() { + @Override + public void onStateChanged(@NonNull LifecycleOwner source, @NonNull Lifecycle.Event event) { + if(event==Lifecycle.Event.ON_DESTROY){ + handler.postDelayed(runnableTimer, 0); + }else{ + handler.removeCallbacks(runnableTimer); + } + } + }); + } + }); + + videoView.setVideoPath(getVideoUrl()); + videoView.start(); + } + + Handler handler = new Handler(); + Runnable runnableTimer = new Runnable(){ + + @Override + public void run() { + boolean started = videoView.isPlaying(); + if (!started || videoView.isPlaying()) { + if (!started) { + started = videoView.isPlaying(); + } + + tv_time.setText(showMMSS(videoView.getDuration(), videoView.getCurrentPosition())); + handler.postDelayed(runnableTimer, 1000); + }else{ + tv_time.setText(showMMSS(videoView.getDuration(), videoView.getDuration())); + } + } + }; + + String showMMSS(int duration, int timeInMilli) { + int gap = duration - timeInMilli; + int sec = gap / 1000; + int min = sec / 60; + int secOfMin = sec % 60; + return String.format("$min:%02d", secOfMin); + } + + private String getVideoUrl() { + return getArguments().getString("videoUrl"); + } + + public static Fragment getInstance(String imageUrl){ + Fragment f = new VideoViewerFragment(); + Bundle bundle = new Bundle(); + bundle.putString("videoUrl", imageUrl); + f.setArguments(bundle); + return f; + } +} diff --git a/app/src/main/res/anim/push_down_out.xml b/app/src/main/res/anim/push_down_out.xml new file mode 100644 index 00000000..fb18c85e --- /dev/null +++ b/app/src/main/res/anim/push_down_out.xml @@ -0,0 +1,20 @@ + + + + + + diff --git a/app/src/main/res/anim/push_up_in.xml b/app/src/main/res/anim/push_up_in.xml new file mode 100644 index 00000000..ebe8b7d2 --- /dev/null +++ b/app/src/main/res/anim/push_up_in.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/app/src/main/res/anim/slide_in_left_right.xml b/app/src/main/res/anim/slide_in_left_right.xml new file mode 100755 index 00000000..2e8af63e --- /dev/null +++ b/app/src/main/res/anim/slide_in_left_right.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/app/src/main/res/anim/slide_in_right_left.xml b/app/src/main/res/anim/slide_in_right_left.xml new file mode 100755 index 00000000..73758d36 --- /dev/null +++ b/app/src/main/res/anim/slide_in_right_left.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/app/src/main/res/anim/slide_out_left_right.xml b/app/src/main/res/anim/slide_out_left_right.xml new file mode 100755 index 00000000..1450b6c5 --- /dev/null +++ b/app/src/main/res/anim/slide_out_left_right.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/slide_out_right_left.xml b/app/src/main/res/anim/slide_out_right_left.xml new file mode 100755 index 00000000..5d21658e --- /dev/null +++ b/app/src/main/res/anim/slide_out_right_left.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/app/src/main/res/drawable-hdpi/baseline_cloud_off_black_48.png b/app/src/main/res/drawable-hdpi/baseline_cloud_off_black_48.png new file mode 100755 index 00000000..11ddb165 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/baseline_cloud_off_black_48.png differ diff --git a/app/src/main/res/drawable-mdpi/baseline_cloud_off_black_48.png b/app/src/main/res/drawable-mdpi/baseline_cloud_off_black_48.png new file mode 100755 index 00000000..d2a7ceb4 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/baseline_cloud_off_black_48.png differ diff --git a/app/src/main/res/drawable-xhdpi/baseline_cloud_off_black_48.png b/app/src/main/res/drawable-xhdpi/baseline_cloud_off_black_48.png new file mode 100755 index 00000000..9409b04b Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/baseline_cloud_off_black_48.png differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_cloud_off_black_48.png b/app/src/main/res/drawable-xxhdpi/baseline_cloud_off_black_48.png new file mode 100755 index 00000000..35004ce1 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/baseline_cloud_off_black_48.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_cloud_off_black_48.png b/app/src/main/res/drawable-xxxhdpi/baseline_cloud_off_black_48.png new file mode 100755 index 00000000..3f6c5213 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/baseline_cloud_off_black_48.png differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..1acc6ddd --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,41 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_sample.xml b/app/src/main/res/layout/activity_sample.xml deleted file mode 100644 index 6c3e30f5..00000000 --- a/app/src/main/res/layout/activity_sample.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/content_sample.xml b/app/src/main/res/layout/content_sample.xml index 897a8fff..0a7ae4b4 100644 --- a/app/src/main/res/layout/content_sample.xml +++ b/app/src/main/res/layout/content_sample.xml @@ -5,8 +5,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" - tools:context="com.pixlee.pixleeandroidsdk.SampleActivity" - tools:showIn="@layout/activity_sample"> + tools:context="com.pixlee.pixleeandroidsdk.MainActivity" + tools:showIn="@layout/activity_main"> + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_image_viewer.xml b/app/src/main/res/layout/fragment_image_viewer.xml new file mode 100644 index 00000000..438dbdd4 --- /dev/null +++ b/app/src/main/res/layout/fragment_image_viewer.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_video_viewer.xml b/app/src/main/res/layout/fragment_video_viewer.xml new file mode 100644 index 00000000..4ada49f3 --- /dev/null +++ b/app/src/main/res/layout/fragment_video_viewer.xml @@ -0,0 +1,29 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_sample.xml b/app/src/main/res/menu/menu_sample.xml index 79254b03..380a27f6 100644 --- a/app/src/main/res/menu/menu_sample.xml +++ b/app/src/main/res/menu/menu_sample.xml @@ -1,7 +1,7 @@ + tools:context="com.pixlee.pixleeandroidsdk.MainActivity"> #3F51B5 #303F9F #FF4081 + + #38a89d + #ababab + + #80c5c5c5 + #1d575757 + #29000000 + + #3a3a3a + + #f3f3f3 + #000000 + + #f2f2f2 + #666666 + + #546E7A + #42A5F5 + #8BC34A diff --git a/app/src/main/res/values/integer.xml b/app/src/main/res/values/integer.xml new file mode 100755 index 00000000..9363af94 --- /dev/null +++ b/app/src/main/res/values/integer.xml @@ -0,0 +1,4 @@ + + + 300 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 67bb77a4..b2704280 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,8 @@ Pixlee Android SDK Settings + + Gallery + Image Viewer + Video Viewer diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index fef37f9b..e6bb9f83 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,11 +1,29 @@ + + + + +