Skip to content

Updated codebase #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.11'
ext.kotlin_version = '1.8.10'

repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

classpath 'com.android.tools.build:gradle:7.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
13 changes: 7 additions & 6 deletions example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-parcelize"

android {
compileSdkVersion 28

namespace "com.unsplash.pickerandroid.example"

compileSdkVersion 33
defaultConfig {
applicationId "com.unsplash.pickerandroid.example"
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -25,7 +26,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':photopicker')
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.core:core-ktx:1.1.0-alpha05'
Expand Down
26 changes: 13 additions & 13 deletions example/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.unsplash.pickerandroid.example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:name=".ExampleApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
android:name=".ExampleApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,41 @@ package com.unsplash.pickerandroid.example

import android.app.Activity
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.RadioButton
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.unsplash.pickerandroid.photopicker.data.UnsplashPhoto
import com.unsplash.pickerandroid.photopicker.presentation.UnsplashPickerActivity
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

private lateinit var mAdapter: PhotoAdapter

private val recyclerView: RecyclerView by lazy { findViewById(R.id.main_recycler_view) }
private val pickButton: Button by lazy { findViewById(R.id.main_pick_button) }
private val singleRadioButton: RadioButton by lazy { findViewById(R.id.main_single_radio_button) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// result adapter
// recycler view configuration
main_recycler_view.setHasFixedSize(true)
main_recycler_view.itemAnimator = null
main_recycler_view.layoutManager = StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL)
recyclerView.setHasFixedSize(true)
recyclerView.itemAnimator = null
recyclerView.layoutManager = StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL)
mAdapter = PhotoAdapter(this)
main_recycler_view.adapter = mAdapter
recyclerView.adapter = mAdapter
// on the pick button click, we start the library picker activity
// we are expecting a result from it so we start it for result
main_pick_button.setOnClickListener {
pickButton.setOnClickListener {
startActivityForResult(
UnsplashPickerActivity.getStartingIntent(
this,
!main_single_radio_button.isChecked
!singleRadioButton.isChecked
), REQUEST_CODE
)
}
Expand All @@ -41,7 +47,8 @@ class MainActivity : AppCompatActivity() {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE) {
// getting the photos
val photos: ArrayList<UnsplashPhoto>? = data?.getParcelableArrayListExtra(UnsplashPickerActivity.EXTRA_PHOTOS)
val photos: ArrayList<UnsplashPhoto>? =
data?.getParcelableArrayListExtra(UnsplashPickerActivity.EXTRA_PHOTOS)
// showing the preview
mAdapter.setListOfPhotos(photos)
// telling the user how many have been selected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso
import com.unsplash.pickerandroid.photopicker.data.UnsplashPhoto
import kotlinx.android.synthetic.main.item_photo.view.*

class PhotoAdapter constructor(context: Context) : RecyclerView.Adapter<PhotoAdapter.PhotoViewHolder>() {

Expand Down Expand Up @@ -46,6 +45,6 @@ class PhotoAdapter constructor(context: Context) : RecyclerView.Adapter<PhotoAda
* UnsplashPhoto view holder.
*/
class PhotoViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val imageView: ImageView = view.item_photo_iv
val imageView: ImageView = view.findViewById(R.id.item_photo_iv)
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
17 changes: 8 additions & 9 deletions photopicker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-parcelize"

android {
compileSdkVersion 28
namespace "com.unsplash.pickerandroid.photopicker"

compileSdkVersion 33
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 2
versionName "1.0.1"
targetSdkVersion 33
versionCode 3
versionName "1.0.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -17,9 +19,6 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
androidExtensions {
experimental = true
}
}

dependencies {
Expand Down Expand Up @@ -47,7 +46,7 @@ dependencies {

// lifecycle
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
kapt 'androidx.lifecycle:lifecycle-compiler:2.1.0-alpha04'
// kapt 'androidx.lifecycle:lifecycle-compiler:2.1.0-alpha04'

// test
testImplementation 'junit:junit:4.12'
Expand Down
20 changes: 9 additions & 11 deletions photopicker/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.unsplash.pickerandroid.photopicker">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />

<application>
<activity android:name=".presentation.UnsplashPickerActivity"
android:configChanges="orientation|screenSize"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity android:name=".presentation.PhotoShowActivity"
android:theme="@style/AppTheme.NoActionBar.Transparent">
</activity>
<activity
android:name=".presentation.UnsplashPickerActivity"
android:configChanges="orientation|screenSize"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".presentation.PhotoShowActivity"
android:theme="@style/AppTheme.NoActionBar.Transparent" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package com.unsplash.pickerandroid.photopicker.presentation
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import com.squareup.picasso.Picasso
import com.unsplash.pickerandroid.photopicker.R
import kotlinx.android.synthetic.main.activity_image_show.*

class PhotoShowActivity : AppCompatActivity() {

Expand All @@ -15,9 +16,9 @@ class PhotoShowActivity : AppCompatActivity() {
setContentView(R.layout.activity_image_show)
// loading the image thanks to its url
Picasso.get().load(intent.getStringExtra(EXTRA_URL))
.into(image_show_view)
.into(findViewById<ImageView>(R.id.image_show_view))
// click listener
image_show_layout.setOnClickListener { supportFinishAfterTransition() }
findViewById<ConstraintLayout>(R.id.image_show_layout).setOnClickListener { supportFinishAfterTransition() }
}

override fun onBackPressed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.recyclerview.widget.RecyclerView
import com.squareup.picasso.Picasso
import com.unsplash.pickerandroid.photopicker.R
import com.unsplash.pickerandroid.photopicker.data.UnsplashPhoto
import kotlinx.android.synthetic.main.item_unsplash_photo.view.*

/**
* The photos recycler view adapter.
Expand Down Expand Up @@ -111,9 +110,9 @@ class UnsplashPhotoAdapter constructor(context: Context, private val isMultipleS
* UnsplashPhoto view holder.
*/
class PhotoViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val imageView: AspectRatioImageView = view.item_unsplash_photo_image_view
val txtView: TextView = view.item_unsplash_photo_text_view
val checkedImageView: ImageView = view.item_unsplash_photo_checked_image_view
val overlay: View = view.item_unsplash_photo_overlay
val imageView: AspectRatioImageView = view.findViewById(R.id.item_unsplash_photo_image_view)
val txtView: TextView = view.findViewById(R.id.item_unsplash_photo_text_view)
val checkedImageView: ImageView = view.findViewById(R.id.item_unsplash_photo_checked_image_view)
val overlay: View = view.findViewById(R.id.item_unsplash_photo_overlay)
}
}
Loading