Live Tools Save

Live-Tools is a library project which aims to convert some Android features to LiveData

Project README

Live-Tools

Live-Tools is a library project which aims to convert some Android device features to LiveData.

Live Tool List

  • Live Orientation: Observe orientation changes
  • Live Location: Observe user location (fine and coarse location together)
  • Live Battery: Observe battery level, plug state, scale and percentage
  • Live Media Selector: Observe taken photo or selected media URI.
  • Live Video Frames: Fetch Frame List (bitmaps) of given video path.

Usage

live-orientation

Observes orientation change even if device is forced to portrait mode. It works based on sensors.

OrientationLiveData(this)
      .observe(this, Observer {
           it?.let {
               Toast.makeText(this, it.name, Toast.LENGTH_SHORT).show()
           }
      })

live-location

Observes location changes. It observers coarse and fine location internally. If user's GPS setting is disabled, live-location notifies you about this. If location permission is needed, live-location checks this internally and notifies you about this.

locationLiveData = LocationLiveData(this)
locationLiveData.observe(this,
        Observer {
            when (it?.status) {
                LocationData.Status.PERMISSION_REQUIRED -> // request permission. (it.permissionList)
                LocationData.Status.ENABLE_SETTINGS -> //enable location settings (it.resolvableApiException)
                LocationData.Status.LOCATION_SUCCESS -> // location is ready to use (it.location)
            }
        })

//Start observing
locationLiveData.start()

live-battery

Observes battery changes, state, scale, level and plug info.

BatteryLiveData(this)
                .observe(this, Observer {
                    it?.let {
                        Toast.makeText(this, "Status: " + it.status +
                                " Plug: " + it.plug +
                                " Level: " + it.level +
                                " Scale: " + it.scale +
                                " Percentage " + it.percentage, Toast.LENGTH_LONG).show()
                    }
})

live-media-selector

Observes picked camera or gallery image uri.

MediaSelectorLiveData(this)
      .observe(this, Observer {
                when (it?.status) {
                    MediaData.Status.MEDIA_SUCCESS -> { it.uri }
                    MediaData.Status.PERMISSION_REQUIRED -> { it.permissionList }
                    MediaData.Status.ERROR -> { it.exception }
                }
            })
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
      super.onActivityResult(requestCode, resultCode, data)
      mediaSelectorLiveData.onActivityResult(requestCode, resultCode, data)
}
mediaSelectorLiveData.openCamera()
mediaSelectorLiveData.openGallery()

Live Video Frames

Observes video frames as bitmap list.

val videoFramesLiveData = VideoFramesLiveData(this)
videoFramesLiveData.retrieveFrames(SAMPLE_VIDEO_PATH)
videoFramesLiveData.observe(this, Observer {
      when (it?.status) {
          VideoData.Status.PERMISSION_REQUIRED -> requestStorage(it.permissionList)
          VideoData.Status.SUCCESS -> "{Use Your VideoData (Video Duration, Video Frames as Bitmap, etc.)}")
      }
})

Live - Memory Usage

Observes memory changes info.

 MemoryInfoLiveData(this)
                .observe(this, Observer { memoryInfo ->
                    when (memoryInfo) {
                        is LiveResult.LiveValue<MemoryInfoData> -> handleMemoryInfo(memoryInfo.value)
                    }

                })

Dependency

maven { url 'https://jitpack.io' }
dependencies {
    implementation 'com.github.savepopulation:live-tools:v1.0.1'
}

Contributors:

Mert Şimşek
Efe Budak
Taylan Sabırcan
Aykut Asil
Oğulcan Uçarsu
Tolga Bolatcan

List of Apps using Live-Tools:

Phone Lab

Open Source Agenda is not affiliated with "Live Tools" Project. README Source: savepopulation/live-tools
Stars
84
Open Issues
14
Last Commit
4 years ago
License

Open Source Agenda Badge

Open Source Agenda Rating