Skip to content
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

Fix Open Issues #22

Open
wants to merge 5 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
7 changes: 5 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation "androidx.activity:activity-ktx:1.2.0-beta01"
implementation 'com.google.android.material:material:1.2.1'
implementation "androidx.fragment:fragment-ktx:1.3.0-beta01"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation project(':gligar')
implementation 'androidx.appcompat:appcompat:1.2.0'
}
10 changes: 8 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Main3Activity"></activity>
<activity android:name=".MainActivity">

<activity android:name=".MainScreenLauncher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".NormalActivityStarter" />
<activity android:name=".ActivityResultLauncher" />
<activity android:name=".SupportedFilesLauncher" />
<activity android:name=".ActivityStarterLauncherV2" />
<activity android:name=".CustomToolbarScreen"
android:theme="@style/CustomAppTheme"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.opensooq.supernova.gligarexample

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.opensooq.supernova.gligar.GligarPicker
import com.opensooq.supernova.gligar.ui.GligarScreenResult
import kotlinx.android.synthetic.main.activity_main.*

class ActivityResultLauncher : AppCompatActivity() {


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val startForResult = registerForActivityResult(object : GligarScreenResult() {
override fun getGligarIntentLauncher(): Intent {
return GligarPicker()
.singleSelection(true)
.disableCamera(false).cameraDirect(false).requestCode(PICKER_REQUEST_CODE)
.withActivity(this@ActivityResultLauncher).show()
}
}) {
if (!it.isNullOrEmpty()) {
imagesCount.text = "Number of selected Images: ${it.size}"
}
}

startForResult.launch(0)
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.opensooq.supernova.gligarexample

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import com.opensooq.supernova.gligar.ui.GligarResultBuilder
import kotlinx.android.synthetic.main.activity_main.*

class ActivityStarterLauncherV2 : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val starter = registerForActivityResult(object : GligarResultBuilder(this@ActivityStarterLauncherV2) {
override fun build(activity: FragmentActivity?, fragment: Fragment?, input: List<String>?): Intent {
this addLimitImages 20
this addRequestCode REQUEST_CODE
this disableCamera true
this isCustomExtSuported arrayListOf("png", "jpg", "jpeg")
this cameraDirect false
this isSingleSelection false
this isPreItemsSelected input
return getFinalIntent()
}
}) {
if (!it.isNullOrEmpty()) {
imagesCount.text = "Number of selected Images: ${it.size}"
}
}

starter.launch(arrayListOf(
"/storage/emulated/0/DCIM/Screenshots/Screenshot_20201129-101300_Facebook.jpg",
"/storage/emulated/0/DCIM/Screenshots/Screenshot_20201129-093307_Chrome.jpg",
"/storage/emulated/0/DCIM/Screenshots/Screenshot_20201129-071900_Facebook.jpg",
"/storage/emulated/0/DCIM/Screenshots/Screenshot_20201129-071500_Facebook.jpg"
))

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.opensooq.supernova.gligarexample

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.opensooq.supernova.gligar.GligarPicker
import com.opensooq.supernova.gligar.ui.GligarPickerFragment
import com.opensooq.supernova.gligar.ui.GligarPickerListener
import kotlinx.android.synthetic.main.activity_main_custom.*

class CustomToolbarScreen : AppCompatActivity(), GligarPickerListener {

@SuppressLint("RestrictedApi")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main_custom)
custom_toolbar?.let {
setSupportActionBar(it)
supportActionBar?.setDisplayShowTitleEnabled(true)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDefaultDisplayHomeAsUpEnabled(true)
}

supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, GligarPickerFragment.getInstance(getGligarPicker()))
.commitNowAllowingStateLoss()
}

private fun getGligarPicker(): GligarPicker {
return GligarPicker()
.cameraDirect(false)
.disableCamera(true)
.limit(20)
.setCustomBackgroundColor("#FFA07A")
.supportExtensions(arrayListOf("png", "jpg", "jpeg"))
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
onBackPressed()
return super.onOptionsItemSelected(item)
}

override fun onImagesSelected(items: Array<String>) {
Toast.makeText(this, "Selected Images : ${items.size}", Toast.LENGTH_SHORT).show()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.opensooq.supernova.gligarexample

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main_launcher.*

class MainScreenLauncher : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main_launcher)

normal_launcher_button?.setOnClickListener {
startActivity(Intent(this@MainScreenLauncher, NormalActivityStarter::class.java))
}

start_launcher_button?.setOnClickListener {
startActivity(Intent(this@MainScreenLauncher, ActivityResultLauncher::class.java))
}

supported_files_button?.setOnClickListener {
startActivity(Intent(this@MainScreenLauncher, SupportedFilesLauncher::class.java))
}

pre_selected_files_button?.setOnClickListener {
startActivity(Intent(this@MainScreenLauncher, ActivityStarterLauncherV2::class.java))
}

custom_screen?.setOnClickListener {
startActivity(Intent(this@MainScreenLauncher, CustomToolbarScreen::class.java))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.appcompat.app.AppCompatActivity
import com.opensooq.supernova.gligar.GligarPicker
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
class NormalActivityStarter : AppCompatActivity() {

val PICKER_REQUEST_CODE = 30

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.opensooq.supernova.gligarexample

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.opensooq.supernova.gligar.GligarPicker
import com.opensooq.supernova.gligar.ui.GligarScreenResult
import kotlinx.android.synthetic.main.activity_main.*

class SupportedFilesLauncher : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val startForResult = registerForActivityResult(object : GligarScreenResult() {
override fun getGligarIntentLauncher(): Intent {
return GligarPicker()
.supportExtensions(arrayListOf("png"))
.singleSelection(true)
.disableCamera(false).cameraDirect(false).requestCode(PICKER_REQUEST_CODE)
.withActivity(this@SupportedFilesLauncher).show()
}
}) {
if (!it.isNullOrEmpty()) {
imagesCount.text = "Number of selected Images: ${it.size}"
}
}

startForResult.launch(0)
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
tools:context=".ActivityResultLauncher">

<TextView
android:layout_width="wrap_content"
Expand Down
28 changes: 28 additions & 0 deletions app/src/main/res/layout/activity_main_custom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.appcompat.widget.Toolbar
android:id="@+id/custom_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="Custom Toolbar"
app:titleTextColor="#fff"
android:background="#FFA07A"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/fragment_container"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/custom_toolbar" />

</androidx.constraintlayout.widget.ConstraintLayout>
58 changes: 58 additions & 0 deletions app/src/main/res/layout/activity_main_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">

<Button
android:layout_width="match_parent"
android:textAlignment="center"
android:id="@+id/start_launcher_button"
android:textAllCaps="false"
android:layout_marginTop="10dp"
android:text="Start Activity Launcher Result"
android:layout_height="wrap_content"/>

<Button
android:layout_width="match_parent"
android:textAlignment="center"
android:textAllCaps="false"
android:layout_marginTop="10dp"
android:id="@+id/normal_launcher_button"
android:text="Normal Activity Result"
android:layout_height="wrap_content"/>

<Button
android:layout_width="match_parent"
android:textAlignment="center"
android:textAllCaps="false"
android:layout_marginTop="10dp"
android:id="@+id/supported_files_button"
android:text="StartScreen With Supported Files"
android:layout_height="wrap_content"/>

<Button
android:layout_width="match_parent"
android:textAlignment="center"
android:textAllCaps="false"
android:layout_marginTop="10dp"
android:id="@+id/pre_selected_files_button"
android:text="StartScreen PreSelected Images"
android:layout_height="wrap_content"/>

<Button
android:layout_width="match_parent"
android:textAlignment="center"
android:textAllCaps="false"
android:layout_marginTop="10dp"
android:id="@+id/custom_screen"
android:text="Custom Screen With Fragment"
android:layout_height="wrap_content"/>

</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
5 changes: 5 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="CustomAppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

</resources>
10 changes: 6 additions & 4 deletions gligar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "androidx.activity:activity-ktx:1.2.0-beta01"
implementation "androidx.fragment:fragment-ktx:1.3.0-beta01"
implementation 'androidx.core:core-ktx:1.3.2'

implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0-alpha04'
implementation "androidx.lifecycle:lifecycle-runtime:2.1.0-alpha04"
Expand All @@ -73,8 +75,8 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0'
implementation "android.arch.paging:runtime:1.0.1"

implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.google.android.material:material:1.2.0-alpha02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

Expand Down
Loading