It makes a preview from an url, grabbing all the information such as title, relevant texts and images. This a version for Android of my web link preview https://github.com/LeonardoCardoso/Link-Preview

Overview

LeoCardz Link Preview for Android

Android Arsenal

It makes a preview from an url, grabbing all the information such as title, relevant texts and images.

Visual Examples

Preview

Sample App

For a sample app, please install it from Android Link Preview on Google Play.

Requirements

  • jsoup is a smart lib to get the html code.

Installation

gradle

Simply add the repository to your build.gradle file:

repositories {
	jcenter()
	maven { url 'https://github.com/leonardocardoso/mvn-repo/raw/master/maven-deploy' }
}

And you can use the artifacts like this:

dependencies {
    compile 'org.jsoup:jsoup:1.8.3' // required
	compile 'com.leocardz:link-preview:2.0.0@aar'
	// ...
}

ProGuard

If you use ProGuard, it is advised that you keep the jsoup dependencies by adding

-keeppackagenames org.jsoup.nodes

to your ProGuard rules file.

Usage

Instantiating

import com.leocardz.link.preview.library.TextCrawler;
// ...
// Create an instance of the TextCrawler to parse your url into a preview.
TextCrawler textCrawler = new TextCrawler();

// ..

// Create the callbacks to handle pre and post exicution of the preview generation.
LinkPreviewCallback linkPreviewCallback = new LinkPreviewCallback() {
    @Override
    public void onPre() {
        // Any work that needs to be done before generating the preview. Usually inflate 
        // your custom preview layout here.
    }

    @Override
    public void onPos(SourceContent sourceContent, boolean b) {
        // Populate your preview layout with the results of sourceContent.
    }
};

Generate Preview

textCrawler.makePreview( linkPreviewCallback, url);

Cancel unfinished tasks when views are destroied.

If you are using Android Link Preview inside of an Activity, it is important to cancel unfinished Preview activites at the end of the Activity's lifecycle.

 @Override
    protected void onDestroy() {
        super.onDestroy();
        textCrawler.cancel();
    }

Apps using Android Link Preview

  1. Unshorten It

  2. ...

Information and Contact

Developed by @LeonardoCardoso.

Contact me either by Twitter @leocardz or emailing me to [email protected].

Related Projects

License

Copyright 2013 Leonardo Cardoso

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Cancelable AsyncTask

    Cancelable AsyncTask

    This allows for the developer to cancel a TextCrawler's task. This allows for better usage inside of a list view as well as preventing Activity lifecycle related crashes.

    opened by aleedy 6
  • Add ability for library users to specify how to extract URLs from the…

    Add ability for library users to specify how to extract URLs from the…

    … passed text

    I updated TextCrawler to allow users of the library to specify how they want to pull URLs from the passed in text. Users who choose not to do this still get the old behavior by default. I added a few tests and the Mockito library to support better tests in the future. I also added some performance enhancements in the form of eliminating unnecessary string creation/manipulation.

    opened by jdonmoyer 1
  • Add ability for library user to change how the library retrieves images

    Add ability for library user to change how the library retrieves images

    This PR consists of two commits.

    The first updates the project so that it can be built with the latest version of Android Studio and updates the JSoup version.

    The second commit adds the notion of an 'ImagePickingStrategy' this gives the library user the capability of overriding the default logic that is used in determining which images are returned by the crawling process. This commit also has some optimizations in image picking and some scoping changes to make modifying the library in the future without negatively impacting backwards compatibility. Tests were provided for the new functionality.

    opened by jdonmoyer 1
  • Handle catastrophic JSoup errors

    Handle catastrophic JSoup errors

    • Add the Internet permission at the library level since any user of the library will need it
    • Add the Google maven repository so that the Android testing libraries can be pulled down
    • Bump the minSdkVersion so that the Google testing library can be used
    • Add the Android Testing library and JUnit
    • Refactor some methods in TextCrawler to facilitate testing
    • Add a test for TextCrawler to replicate what occurs when JSoup has a catastrophic error
    opened by jdonmoyer 1
  • Updating jsoup

    Updating jsoup

    My users were seeing some NullPointerExceptions originating from the jsoup library. Looking at the issues list for jsoup, several issues have been resolved in 1.10.3 so I updated Link-Preview to use that instead.

    opened by aleedy 1
  • README update with usage details

    README update with usage details

    I recently started using your library in a project of mine. Thanks for putting it out there, it definitely does the trick. I felt like the docs were severely lacking with implementation details so I added some updates and tried to stick to the format you use on the swift version.
    Hope you find it helpful.

    opened by aleedy 1
  • Tiny Improvements on Methods - TextCrawler class

    Tiny Improvements on Methods - TextCrawler class

    a. On the for loops, we can improve them by getting the termination condition once. In the loops edited, they (termination conditions) were constantly being called every time the loop ended.

    b. On the boolean methods, we can just return the value of the statements instead of asking for their value first and then returning the value.

    opened by wching 1
  • Enhancements to image resolution capabilities

    Enhancements to image resolution capabilities

    Currently sharing an image URL that does not end in a file extension (e.g. https://cdn.shopify.com/s/files/1/1400/5075/files/website_logo2_720x_6cdc3363-fec0-4d60-a5bd-5236869352bf_720x.png?v=1533741874) results in a failed preview rather than pulling back the correct image.

    This occurs because these URLs do not match the regex used in isImage(). This results in an attempt by JSoup to process the image as an HTML document which results in an exception due to a check on the response mime type. I added code to detect this error and process the url as if it were an image if the returned mimetype is an image.

    I also updated the project to work with the newest Android Studio version and refactored DefaultImagePickingStrategy so that subclasses of BaseImagePickingStrategy can reuse the code for getting the image url from the meta tags and/or from scraping the HTML document.

    The sample app was also updated to refer to the library project rather than pull the release artifact.

    opened by jdonmoyer 0
  • ReadMe updates to include cancellation and pro guard settings

    ReadMe updates to include cancellation and pro guard settings

    Updating docs to reference the new cancel() method of the text crawler. Also adding references for necessary ProGuard settings for users that may have minify enabled in their apps.

    opened by aleedy 0
  • Bug fix for wrong URL redirection on click.

    Bug fix for wrong URL redirection on click.

    Commit: "Bug fix for wrong URL redirection on click."

    This is the fix for the bug of wrong URL opening while clicking the previews. I have checked it multiple times and its working 100%.

    opened by srujanb 0
  • Meta Tag Handling Improvements

    Meta Tag Handling Improvements

    • Add performance improvement to only convert meta tag match to lowercase once in the for loop
    • Add an updateMetaTag method that will only store the meta tag value if it is non-null and non-empty; This fixed issues where bad descriptions were being pulled in cases where multiple 'description' meta tags were found and the last one had no value. See www.fandango.com for an example case where this occurs.
    opened by jdonmoyer 0
  • Deprecate AsyncTask. Add RxJava variant of TextCrawler.makePreview()

    Deprecate AsyncTask. Add RxJava variant of TextCrawler.makePreview()

    Type of change

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • Add RxJava variant of makePreview() to TextCrawler
    • [x] Refactor
    • Move crawler network call and parsing logic to an abstraction
    • Move async task implementation to a separate class
    • [x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
    • TextCrawler.extendedTrim(String) requires reference via TextCrawler.Companion.extendedTrim(String), when called from Java.
    • [x] This change requires a documentation update

    Checklist:

    • [x] My code follows the style guidelines of this project
    • [x] I have performed a self-review of my own code
    • [x] I have commented my code, particularly in hard-to-understand areas
    • [x] I have made corresponding changes to the documentation
    • [x] My changes generate no new warnings
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [x] New and existing unit tests pass locally with my changes
    • [x] Any dependent changes have been merged and published in downstream modules
    opened by dhruvnagarajan 0
Releases(1.1)
Owner
Leonardo Cardoso
Leonardo Cardoso
A Java client for the Sixpack A/B testing framework https://github.com/seatgeek/sixpack

sixpack-java A Java client for SeatGeek's Sixpack a/b testing framework: https://github.com/seatgeek/sixpack Installing Sixpack-java is currently only

null 135 Oct 7, 2022
AudioPlayerView is an Android view that loads audio from an url and have basic playback tools.

AudioPlayerView AudioPlayerView is an Android view that loads audio from an url and have basic playback tools. It makes use of the Android MediaPlayer

Hugo Matilla 86 Nov 29, 2022
Purpose for this base architectural project is to load it with all latest components and libraries So it become reference for all kind of Android projects

The purpose of this base architectural project is to load it with all the latest components and libraries, So it becomes a reference for all kinds of Android projects

null 7 Dec 7, 2021
Makes Google play in app purchase library (BillingClient) into a flowable that can easily be used in compose world

Billy the android Our goal is to make a modern api of BillingClient so that it is easier to use in compose world. This library is still early beta and

Stefan Wärting 16 Dec 14, 2022
AboutLibraries is a library to offer some information of libraries.

AboutLibraries .. allows you to easily create an used open source libraries fragment/activity within your app. All the library information is automati

Mike Penz 3.1k Jan 3, 2023
andle is an Android tool help you sync dependencies, sdk or build tool version.

andle andle is an Android tool to help you sync dependencies, SDK or build tool version. Installation Simple install by pip: $ sudo pip install andle

Jintin 58 Sep 17, 2022
The Android Version in Kotlin of The Dialer App (in SwiftUI)

Dialer An intuitive USSD client to handle most of the common actions for you. Contains common MTN Rwanda USSD activation codes, which drastically simp

Cédric Bahirwe 1 Dec 14, 2021
A lightweight version of Zeebe from Camunda

A lightweight version of Zeebe from Camunda. It bundles Zeebe's workflow engine including some required parts to a library that can be used by other projects. Other parts of Zeebe, like clustering, are not included or are replaced with simpler implementations, for example with an In-Memory database.

Camunda Community Hub 18 Dec 22, 2022
File Picker for KMP project. Works for Android/JVM/Web.

KFilePicker File Picker for KMP project. Works for Android/JVM/Web. Setup Add Jitpack maven { url

Tlaster 7 Nov 11, 2022
Highly experimental predefined Bootstrap functions to use in Compose Web

bootstrap-compose Highly experimental predefined Bootstrap functions to use in Compose Web Install This package is uploaded to MavenCentral. repositor

Philip Wedemann 45 Jan 6, 2023
android-engineer-assignment-2021-miguelaboliveira created by GitHub Classroom

Memory Android Engineer Interview Assignment Hello and welcome to the Memory Android Engineer interview assignment! There can be no demo app that does

Memory 0 Oct 30, 2021
Using Resilience4J, this is a Demo project which uses a Library as background and manages all its requests.

Using Resilience4J, this is a Demo project which uses a Library as background and manages all its requests. This library can rent books online and the usage rate is extremely high. There is a reactive way to access, which is the one normally used, but sometimes, the system needs a bit of help from an old machine running a non-reactive MVC Spring application using JPA. Let's make this in Kotlin and find the best solution!

João Filipe Sabino Esperancinha 2 Jan 10, 2022
This repo contains examples of all the functionalities of sceneform, Face filter , Object Placement etc

ARCore-Projects This repo uses sceneform 1.17.1 to demonstrate the usage of different features of arcore such as, Augmented Faces Augmented images AR

Kashif Mehmood 21 Dec 4, 2022
A Utility to Add all of your installed steam games to the Start Launcher for Windows

Steam Start Launcher The Steam Start launcher is a small tool that will scan your computer for isntalled steam games and create a shortcut for each ga

null 1 Dec 1, 2021
SL4A brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device.

#Scripting Layer for Android (SL4A) SL4A brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreter

Damon Kohler 2.3k Dec 23, 2022
An application for runners and cyclists. Allows you to monitor your physical activity, weight and receive reminders about workouts.

An application for runners and cyclists. Allows you to monitor your physical activity, weight and receive reminders about workouts.

Just_Amalll 3 Feb 7, 2022
A curated list of standards, tests and benchmarks that can be used for testing and evaluating dev-tools

A curated list of standards, tests and benchmarks that can be used for testing and evaluating dev tools Contribution Add the description of the benchm

null 13 Dec 16, 2022
A gradle plugin for getting java lambda support in java 6, 7 and android

Gradle Retrolambda Plugin This plugin will automatically build your java or android project with retrolambda, giving you lambda goodness on java 6 or

Evan Tatarka 5.3k Jan 5, 2023
A Job Queue specifically written for Android to easily schedule jobs (tasks) that run in the background, improving UX and application stability.

Development in this repository is stopped. Future development continues on https://github.com/yigit/android-priority-jobqueue ========================

Path Mobile Inc Pte. Ltd. 2.4k Dec 9, 2022