An easy-to-use Android library that will help you to take screenshots of specif views of your app and save them to external storage (Including API 29 Q+ with Scope Storage)

Overview

🇺🇸 English | 🇧🇷 Português (pt-br)

🇺🇸 English:

An easy to use Library that will help you to take screenshots 📸 of the views in your app

Step 1. Add the JitPack repository to your build file:

Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

	dependencies {
	        implementation 'com.github.T7Droid:Easy-Screenshot-Library:v1.0.0'
	}

Step 3. Add the permissions in Manifest file:

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

Now this is ready for use!

val myImageView = findViewById<View>(R.id.myImageView

//In you Activity or Fragment, instantiate an EasyScreenshot object and pass the 
//parameters you want to it's Builder:

val screenshot: EasyScreenshot = EasyScreenshot.Builder()
    .activity(this)
    .folderName("T7Droid Images") // Defines a name for the folder that will be created in galery;
    .imageFileName("screenshots") //Set a name for the image file;
    .targetViewId(myImageView //Any View you want to take the screenshot;
    .shareAfterScreenshot(true) //Do you want to share just after take the screenshot?
    .build()

screenshot.takeScreenshot()

Methods:

activity(activity: Activity) - The Activity context, you can use "this" inside an Activity, or, if you are inside a Fragment you can use activity, requireActivity, ... in Kotlin, and getActivity( ) in Java;

folderName(folder: String ) - For the version before API 29 (Q) it will be the name of the folder that will be created to store the screenshots, for the version above (API 29 Q+) which uses the Scope Storage, it will be the name of the new folder that will be created in the Galery;

imageFileName( ) - Set a name for the image file;

targetViewId(view: View) - Here can will pass any view you want to save as an image in the JPEG format, if you want to take a screenshot of the whole screen (not including ActionBar neither StatusBar) you need only to define an id for the root view of your Activity or Fragment and pass it as a parameter in this method. If you are using View Binding just pass binding.root;

shareAfterScreenshot(share: Boolean) - Set true if you want to imediatelly share the image after taking the screenshot, if you want only to save the image and do not want to share set it as false.

🇧🇷 Português:

Uma Library fácil de usar que irá lhe permitir tirar screenshots das telas ou Views (ImageViews, TextView, etc), salvar as imagens no seu aplicativo, além de poder compartilhá-lhas!

Não se preocupe mais com ter que verificar a versão do Android, implementar Scoped Storage, solicitação de permissões em tempo de execução... 🤯 veja como usar:

Passo 1. Adicione o repositório do JitPack ao seu projeto.

Adicione a url ao seu arquivo build.gradle (Project) em repositories , ou, no seu arquivo settings.gradle:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Passo 2. adicione a dependência

	dependencies {
	        implementation 'com.github.T7Droid:Easy-Screenshot-Library:v1.0.0'
	}

Passo 3. Adicione as permissões de leitura e gravação no arquivo Manifest:

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

E pronto, é só isso! Agora você já pode usar à vontade :D

Veja alguns parâmetros que podem ser passados para o construtor neste exemplo abaixo:


val myImageView = findViewById<View>(R.id.myImageView)
//Ou binding.myImageView se estiver usando o View Binding

//Na sua aActivity ou Fragment, instancie um objeto EasyScreenshot e passe
//os parâmetros que desejar no seu construtor "EasyScreenshot.Builder()":

val screenshot: EasyScreenshot = EasyScreenshot.Builder()
    .activity(this) // 1°- Activity
    .folderName("T7Droid Images") //2° - Nome para a pasta que será criada na galeria
    .imageFileName("screenshots") //3° - Nome da imagem que será salva
    .targetViewId(myTxtView) //4° - View ou ViewGroup que desejar tirar o screenshot
    .shareAfterScreenshot(true) //5° - Deseja compartilhar após tirar o screenshot?
    .build()

//Após instanciarmos o objeto EasyScreenshot basta usá-lo chamando o método takeScreenshot() :D
screenshot.takeScreenshot()

Os métodos e parâmetros que podem ser passados são:

  • activity( activity: Activity) - Uma Activity, você pode usar "this" se estiver em uma Activity, ou, se estiver dentro de um Fragment poderá passar como parâmetro "activity, requireActivity, etc..." em Kotlin, e "getActivity( )" em Java;

  • folderName(folder: String ) - Para as versões anteriores ao Android 10 (API 29 ou Q) o nome que você passar como parâmetro aqui será o nome da nova pasta que será criada para armazenar seus screenshots. Por outro lado, nas versões Android 10 (API 29 ou Q) e acima, que fazem uso do Scoped Storage, esse será o nome da nova pasta que será criada na galeria do seu dispositivo;

Alguns exemplos de nomes: "Comprovantes", "Recibos", ou até o nome do seu próprio aplicativo :D

  • imageFileName( imageName: String) - Nome da imagem que será salva concatenado com a data em que foi tirada.

targetViewId(view: View) - Aqui você irá passar qualquer View ou ViewGroup que desejar salvar como uma imagem no formato JPEG, se você desejar tirar um screenshot de toda a tela (não incluindo nessa versão a ActionBar nem a StatusBar) você precisa apenas definir um id para a View raiz do layout da sua Activity ou Fragment e passá-lo como parâmetro nesse método;

shareAfterScreenshot(share: Boolean) - Defina como true se desejar compartilhar a imagem imediatamente após armazená-la, se você deseja apenas salvar a imagem e não deseja compartilhá-la, defina como false.

Tem alguma dúvida sobre a library? Encontrou algum problema ou tem sugestões de melhorias? Fique à vontade para me contatar.

Contato

[email protected]

You might also like...
Extremely useful library to validate EditText inputs whether by using just the validator for your custom view or using library's extremely resizable & customisable dialog
Extremely useful library to validate EditText inputs whether by using just the validator for your custom view or using library's extremely resizable & customisable dialog

Extremely useful library for validating EditText inputs whether by using just the validator (OtpinVerification) for your custom view or using library's extremely resizable & customisable dialog (OtpinDialogCreator)

😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.
😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

Material Dialogs View Releases and Changelogs Modules The core module is the fundamental module that you need in order to use this library. The others

A flutter plugin allows you to create native android floating window.
A flutter plugin allows you to create native android floating window.

A flutter plugin allows you to create native android floating window.

🗣 An overlay that gets your user’s voice permission and input as text in a customizable UI
🗣 An overlay that gets your user’s voice permission and input as text in a customizable UI

Overview Voice overlay helps you turn your user's voice into text, providing a polished UX while handling for you the necessary permission. Demo You c

LicensesDialog is an open source library to display licenses of third-party libraries in an Android app.
LicensesDialog is an open source library to display licenses of third-party libraries in an Android app.

LicensesDialog LicensesDialog is an open source library to display licenses of third-party libraries in an Android app. Download Download the latest R

Android library to show
Android library to show "Rate this app" dialog

Android-RateThisApp Android-RateThisApp is an library to show "Rate this app" dialog. The library monitors the following status How many times is the

An Android library for displaying a dialog where it presents new features in the app.
An Android library for displaying a dialog where it presents new features in the app.

WhatIsNewDialog What is new dialog for Android is used for presenting new features in the the app. It can be used in the activity starts, from menu or

Android library to show
Android library to show "Rate this app" dialog

Android-RateThisApp Android-RateThisApp is an library to show "Rate this app" dialog. The library monitors the following status How many times is the

A simple library for creating animated warnings/dialogs/alerts for Android.
A simple library for creating animated warnings/dialogs/alerts for Android.

Noty A simple library for creating animated warnings/notifications for Android. Examples Show me code Show me code Show me code Show me code Show me c

Releases(v1.0)
  • v1.0(Dec 24, 2021)

    _English:_🇺🇸

    In this release you don't need an id of the root view to take a screenshot of the whole screen, now you can just pass a constant called Type.FULLSCREEN_WITH_ACTION_BAR to the targetViewId() method:

    Example: `val screenshot = EasyViewScreenshot.Builder() .activity(this) .folderName(getString(R.string.folder_name)) .imageFileName(getString(R.string.image_name)) .targetViewId(Type.FULLSCREEN_WITH_ACTION_BAR) //Passe a constante "Type.FULLSCREEN_WITH_ACTION_BAR" para tirar um screenshot da tela inteira incluindo apenas a ActionBar. .shareAfterScreenshot(true) .build()

            screenshot.takeScreenshot()`
    

    _Português:_🇧🇷 Nesta release você não precisa mais de um id da view raiz (ou root view) para tirar um screenshot da tela inteira, agora você pode apenas passar uma constante chamada Type.FULLSCREEN_WITH_ACTION_BAR para o método targetViewId().

    Example: `val screenshot = EasyViewScreenshot.Builder() .activity(this) .folderName(getString(R.string.folder_name)) .imageFileName(getString(R.string.image_name)) .targetViewId(Type.FULLSCREEN_WITH_ACTION_BAR) //Passe a constante "Type.FULLSCREEN_WITH_ACTION_BAR" para tirar um screenshot da tela inteira incluindo apenas a ActionBar. .shareAfterScreenshot(true) .build()

            screenshot.takeScreenshot()`
    
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Dec 20, 2021)

  • v0.0.1-alpha(Dec 19, 2021)

Owner
Thyago Neves Silvestre
Android Native Programmer (Java and Kotlin)
Thyago Neves Silvestre
Backport of Material dialogs with easy-to-use API based on DialogFragment

StyledDialogs for Android Demo app: Features: Compatible with Material Design Guidelines Same look for Android 2.2+ Built on top of standard DialogFra

Avast 2.2k Nov 29, 2022
An beautiful and easy to use dialog library for Android

An beautiful and easy to use dialog library for Android

ShouHeng 22 Nov 8, 2022
Android has a built in microphone through which you can capture audio and store it , or play it in your phone. There are many ways to do that but with this dialog you can do all thats with only one dialog.

# Media Recorder Dialog ![](https://img.shields.io/badge/Platform-Android-brightgreen.svg) ![](https://img.shields.io/badge/Android-CustomView-blue.sv

Abdullah Alhazmy 73 Nov 29, 2022
An easy to use, yet very customizable search dialog

search-dialog An awesome and customizable search dialog with built-in search options. Usage First add jitpack to your projects build.gradle file allpr

Mad Mirrajabi 518 Dec 15, 2022
AlertDialog for Android, a beautiful and material alert dialog to use in your android app.

AlertDialog for Android, a beautiful and material alert dialog to use in your android app. Older verion of this library has been removed

Akshay Masram 124 Dec 28, 2022
Sleek dialogs and bottom-sheets for quick use in your app

⭐ ‎‎‎‏‏‎ ‎Offers a range of beautiful sheets (dialogs & bottom sheets) for quick use in your project. Includes many ways to customize sheets.

Maximilian Keppeler 835 Dec 25, 2022
Make your native android Dialog Fancy and Gify. A library that takes the standard Android Dialog to the next level with a variety of styling options and Gif's. Style your dialog from code.

FancyGifDialog-Android Prerequisites Add this in your root build.gradle file (not your module build.gradle file): allprojects { repositories { ...

Shashank Singhal 522 Jan 2, 2023
Alert Dialog - You can use this extension instead of creating a separate Alert Dialog for each Activity or Fragment.

We show a warning message (Alert Dialog) to the user in many parts of our applications. You can use this extension instead of creating a separate Alert Dialog for each Activity or Fragment. Thanks to this extension, you can create a Dialog and call it in the Activity or Fragment you want and customize the component you want.

Gökmen Bayram 0 Jan 9, 2022
⭐ ‎‎‎‏‏‎ ‎Offers a range of beautiful sheets (dialogs & bottom sheets) for quick use in your project. Includes many ways to customize sheets.

Sheets Sleek dialogs and bottom-sheets for quick use in your app. Choose one of the available sheets or build custom sheets on top of the existing fun

Maximilian Keppeler 838 Dec 30, 2022
[Deprecated] This project can make it easy to theme and custom Android's dialog. Also provides Holo and Material themes for old devices.

Deprecated Please use android.support.v7.app.AlertDialog of support-v7. AlertDialogPro Why AlertDialogPro? Theming Android's AlertDialog is not an eas

Feng Dai 468 Nov 10, 2022