Skip to content

Commit

Permalink
Readme features (#63)
Browse files Browse the repository at this point in the history
* Kotlin Migration - Adapter and DI (#50)

* Adapter

* DI

* Converting object to class

* Fix pair

* Migrate BasePresenter

* Migrate LceView and add copyright to BasePresenter

* Migrate LeView

* Migrate BasePresenterTest

* Add deprecated to runIfViewAttached, replace apply for run in tests, clean code

* Migration of permissionsManager

* Migration of permissionListener

* Fix redundant private set

* Refactor to clean code

* More refactor

* Kotlin migration utils (#52)

* Keyboard

* Logger

* Shared preferences

* Migration (#53)

* WolmoActivityHandler converted to kotlin (#51)

* WolmoActivityHandler converted to kotlin

* WolmoActivityHandler converted to kotlin

* WolmoActivityHandler converted to kotlin

* Kotlin migration fragments (#56)

* FRagments migrated

* Restoring GetImage.java

* Restoring java getimage test

* To spaces

* Indentation

* Reformat

* Code reformats

* fixing tests

* Reverting get image fragment

* changing imports

* Last migration (#58)

* FRagments migrated

* Restoring GetImage.java

* Restoring java getimage test

* To spaces

* Indentation

* Reformat

* Code reformats

* fixing tests

* Last migration

* Kotlin migration fixes - update versions (#59)

* Fixing overriding base presenter

* Presenter as val

* Fix tests

* Get presnter instead of require

* Fixing wolmo fragment inject

* DefaultModule as class

* Shared preferences string nullable

* Android core as api

* Reverting modules

* Updating version

* Updating versions

* Fixing tests

* Using implmentation

* API insteda of implementation revert

* Rollback handler

* Also adding some minor changes

* Another minor change

* Updating comments and using requireArgument

* Handle arguments nullable on fragment

* Fixing url

* Adding coroutine base presenter

* Coroutines and more

* updating get image fragment

* Fixing doc

* Updating get image fragment

* Rollback handler and minor changes (#61)

* Rollback handler

* Also adding some minor changes

* Another minor change

* Updating comments and using requireArgument

* Handle arguments nullable on fragment

* Fixing url

* Removing wrong comment

* Updating get image

* Moving all get image stuff to a helper

* Fixing issues

* Some fixes

* Removing wrong test

* Serializable

* Importing

* Fixing

* Reverting image provider

* Provider change

* More fixes

* Removing wrong arguments

* More navigation utils

* Updating kapt

* Removing getimagekt

* Reverting get image fragment

* Reverting get image fragment test

* Reverting spaces

* More reverts

* More reverts

* Reverting tests

* More test reverts

* Minor fixes

* More comments

* Removing log

* Single lines

* Removing imports

* Updating gradle

* More tests

* Features readme

* Reformat

* View extensions readme

* Removing wrong blank line

Co-authored-by: igsosa92 <43349271+igsosa92@users.noreply.github.com>
Co-authored-by: patofernandez <49655621+patofernandez@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 8, 2020
1 parent 947a597 commit 1b8d820
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 6 deletions.
89 changes: 89 additions & 0 deletions FEATURES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<p align="center">
<img height="140px" width="400px" src="https://cloud.githubusercontent.com/assets/4109119/25450281/cac5979e-2a94-11e7-9176-8e323df5dab8.png"/>
</p>

# WOLMO features

### BasePresenter
Base implementation of a presenter. It contains a nullable view [V] which is attached and detached given fragment’s lifecycle. It provides some callbacks to be overridden if needed:
- `onViewAttached(): Unit`: invoked when the view is attached.
- `onViewDetached(): Unit`: invoked when the view is detached.

### CoroutineBasePresenter
Coroutine implementation of a `BasePresenter`. It’s a `CoroutineScope` attached to fragment’s lifecycle (it’s cancelled on view detached). It accepts a `CoroutineContext` and uses `MainDispatcher` as default.

### GetImageHelper
Injectable helper class to open gallery and camera to get an image.
- `fun openGallery(fragment: Fragment, code: Int, onPermissionDenied: () -> Unit = {}, onGalleryNotFound: () -> Unit = {})`: Request read permissions and open the gallery for result with the given [code] app if exists.
- `fun openCamera(fragment: Fragment, code: Int, destinationFilename: String, onPermissionDenied: () -> Unit = {}, onCameraNotFound: () -> Unit = {})`: Request camera permissions and open the camera for result with the given [code] app if exists, saving the picture on the [destinationFilename].

### ImageProvider
Singleton injectable utils class to manipulate and retrieve images.
- `addPictureToDeviceGallery(picture: Uri): Unit`: adds the given [picture] to the device images gallery.
- `getImageFromGallery(fragment: Fragment, requestCode: Int): Boolean `: tries to open gallery to retrieve an image. Returns true if successful, false otherwise. Override `onActivityResult` on the given [fragment] and check the given [requestCode] for result.
- `getImageFromCamera(fragment: Fragment, requestCode: Int, file: String): Boolean`: tries to open camera to take a picture to be saved on the given [file]. Returns true if successful, false otherwise. Override `onActivityResult` on the given [fragment] and check the given [requestCode] for result.
- … and more!

### KeyboardManager
Injectable class to manage the Android's soft keyboard.
- `show(editText: EditText): Unit`: forces the soft keyboard to show for a specific [editText].
- `hide(view: View): Unit`: forces the soft keyboard to hide, meant to be called from inside a Fragment's [view].
- `hide(view: View): Unit`: forces the soft keyboard to hide, meant to be called from inside an [activity].

### Logger
Injectable wrapper of [Log] to simplify logs in the same class by reusing the tag and to simplify unit tests.

### NavigationUtils
Provides some context extensions for navigation.
- `Context.jumpTo(clazz: Class<*>, vararg intentExtras: IntentExtra): Unit`: opens a new activity [clazz] sending all the given [intentExtras].
- `Context.jumpToClearingTask(clazz: Class<*>, transition: ActivityOptionsCompat?, vararg intentExtras: IntentExtra): Unit`: opens a new activity [clazz] with a [transition] sending all the given [intentExtras].
- `Context.jumpTo(clazz: Class<*>, vararg intentExtras: IntentExtra): Unit`: opens a new activity [clazz] clearing the current task and sending all the given [intentExtras].
- `Context.openBrowser(url: String?): Unit`: opens browser with the given [url] (if it's null, open a blank page).
- `Context.makeCall(phone: String): Unit`: make a call to the given [phone]. It needs the [CALL_PHONE] permission.
- `Context.openDial(phone: String): Unit`: open the dial with the given [phone]. It doesn't need any extra permission.

### PermissionManager
Singleton injectable helper class to handler Android’s runtime permissions.
- `requestPermission(fragment: Fragment, listener: PermissionListener?, vararg permissions: String): Unit`: request one or more [permissions] from a [fragment] and invokes the [listener] on complete.
- `requestPermission(activity: Activity, listener: PermissionListener?, vararg permissions: String): Unit`: request one or more [permissions] from an [activity] and invokes the [listener] on complete.
- `onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray): Unit`: should be invoked on fragment/activity onRequestPermissionsResult. It’s already implemented on `WolmoActivity` so, since `PermissionManager` is a singleton, by using `WolmoActivity` no importance should be given to this.

### SharedPreferencesManager
Singleton injectable utility class to query and store values in [SharedPreferences].

### SimpleFragmentPagerAdapterBase
Base implementation of a `FragmentStatePagerAdapter` for a `ViewPager` that allows, simply, to add fragments:
- `addFragment(fragment: Fragment, title: String): Unit`: adds a single fragment with its titile to the adapter.
- `addFragments(fragments: List<Pair<Fragment, String>>): Unit`: adds multiple fragments with theirs titles to the adapter.

Note: The fragments given to this should be injected.

### ToastFactory
Singleton injectable utility class to simplify work with Android's [Toast] messages.

### View extensions
Provides some view extensions.
- `ViewGroup.inflate(@LayoutRes layoutRes: Int, attachToRoot: Boolean = false): View`: inflates a layout inside the [ViewGroup].
- `TextView.setTextOrGone(newText: String?): Unit`: set text and show if text is not null or empty or hide otherwise.

### WolmoActivity
Base implementation of a `DaggerActivity` that provides these extra features:
- `replaceFragment(@IdRes resId: Int, fragment: Fragment): Unit`: replace the [resId] with the given [fragment].
- `requireArgument(key: String): T`: get the argument from the intent extras by the given [key] and returns it as a non-null [T].

### WolmoFileProvider
Singleton injectable utils class for managing [File]s.
- `getNewCachePictureFilename(name: String, imageType: ImageType): String`: returns a new picture filename inside the app cache. The filename will be [name]_[System.nanoTime()].
- `getNewCacheVideoFilename(name: String): String`: returns a new video filename inside the app cache. The filename will be [name]_[System.nanoTime()].
- `getNewPictureName(name: String, imageType: ImageType): String`: returns a new picture filename inside the DCIM folder. The filename will be [name]_[System.nanoTime()].
- `getNewVideoName(name: String): String`: returns a new video filename inside the Videos folder. The filename will be [name]_[System.nanoTime()].
- … and more!

### WolmoFragment
Base implementation of a `DaggerFragment` that is MVP-ready (you can access the presenter [T] by `presenter`) and provides some extra callbacks to be overridden if needed:
- `init(): Unit`: invoked on view created and used to initialize everything necessary.
- `setListeners(): Unit`: invoked on view created and used to set listeners like `onClick`.
- `handleArguments(arguments: Bundle?): Boolean`: invoked on create and used to verify if arguments contains what fragment requires. Returning null or false will end the execution.

It also provides this extra feature:
- `requireArgument(key: String): T`: get argument by the given [key] and returns it as a non-null [T].
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ These features can be found in CORE:
* Files helpers
* Camera and image helpers

[See all the features available here.](FEATURES.md)

## <a name="topic-contributing"></a> Contributing

1. Fork it
Expand Down
4 changes: 0 additions & 4 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ dependencies {
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"

// Android KTX
api "androidx.core:core-ktx:$android_ktx_version"
api "androidx.fragment:fragment-ktx:$android_ktx_version"

// Test
testImplementation "junit:junit:$junit_version"
testImplementation "org.robolectric:robolectric:$robolectric_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ fun Context.makeCall(phone: String) {
/**
* Sends an intent to start an [Activity] for the provided [clazz] from a [context]
* with a variable number of instances of [intentExtras] that will be sent as extras.
* It accepts a [transition] that defines the animation behaviour.
*/
@SafeVarargs
fun Context.jumpTo(
Expand All @@ -110,7 +109,7 @@ fun Context.jumpTo(
}

/**
* Sends an intent to start an [Activity] for the provided [clazz] from a [context] but clearing
* Sends an intent to start an [Activity] for the provided [clazz] from a [Context] but clearing
* the current task and starting a new one with a variable number of instances of
* [intentExtras] that will be sent as extras.
*/
Expand Down

0 comments on commit 1b8d820

Please sign in to comment.