diff --git a/OGParser/build.gradle b/OGParser/build.gradle index 6edfeae..48699c4 100644 --- a/OGParser/build.gradle +++ b/OGParser/build.gradle @@ -1,8 +1,10 @@ plugins { id 'com.android.library' id 'kotlin-android' + id 'maven-publish' } + android { compileSdkVersion 30 buildToolsVersion "30.0.3" @@ -59,3 +61,29 @@ dependencies { // implementation "androidx.lifecycle:lifecycle-extensions:${lifecycle_version}" // implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${lifecycle_version}" } + +afterEvaluate { + publishing { + publications { + // Creates a Maven publication called "release". + release(MavenPublication) { + // Applies the component for the release build variant. + from components.release + + // You can then customize attributes of the publication as shown below. + groupId = 'com.github.Priyansh-Kedia' + artifactId = 'final' + version = '2.5.3' + } + // Creates a Maven publication called “debug”. + debug(MavenPublication) { + // Applies the component for the debug build variant. + from components.debug + + groupId = 'com.github.Priyansh-Kedia' + artifactId = 'final-debug' + version = '2.5.3' + } + } + } +} \ No newline at end of file diff --git a/OGParser/src/main/java/com/kedia/ogparser/JsoupNetworkCall.kt b/OGParser/src/main/java/com/kedia/ogparser/JsoupNetworkCall.kt index 3a715ca..1acb4f0 100644 --- a/OGParser/src/main/java/com/kedia/ogparser/JsoupNetworkCall.kt +++ b/OGParser/src/main/java/com/kedia/ogparser/JsoupNetworkCall.kt @@ -1,8 +1,6 @@ package com.kedia.ogparser import android.util.Log -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch import org.jsoup.Jsoup class JsoupNetworkCall { @@ -62,6 +60,14 @@ class JsoupNetworkCall { } } } + + if (openGraphResult!!.title.isNullOrEmpty()) + openGraphResult!!.title = doc.title() + if (openGraphResult!!.description.isNullOrEmpty()) + openGraphResult!!.description = if (doc.select("meta[name=description]").size != 0) doc.select("meta[name=description]") + .first().attr("content") else "" + if (openGraphResult!!.url.isNullOrEmpty()) + openGraphResult!!.url = getBaseUrl(url) } catch (e: Exception) { e.printStackTrace() return null diff --git a/OGParser/src/main/java/com/kedia/ogparser/SharedPrefs.kt b/OGParser/src/main/java/com/kedia/ogparser/SharedPrefs.kt index 1a0a600..22acb54 100644 --- a/OGParser/src/main/java/com/kedia/ogparser/SharedPrefs.kt +++ b/OGParser/src/main/java/com/kedia/ogparser/SharedPrefs.kt @@ -2,6 +2,7 @@ package com.kedia.ogparser import android.content.Context import android.content.SharedPreferences +import android.util.Log import androidx.preference.PreferenceManager class SharedPrefs(context: Context) { @@ -87,8 +88,12 @@ class SharedPrefs(context: Context) { val title = getTitle(url) val description = getDescription(url) val image = getImage(url) - - return title.isNotEmpty() && description.isNotEmpty() && image.isNotEmpty() + return title.isNotEmpty() && + title.equals("null").not() && + description.isNotEmpty() && + description.equals("null").not() && + image.isNotEmpty() && + image.equals("null").not() } } \ No newline at end of file diff --git a/OGParser/src/main/java/com/kedia/ogparser/UtilityFunctions.kt b/OGParser/src/main/java/com/kedia/ogparser/UtilityFunctions.kt index 8d665ff..d7e35b3 100644 --- a/OGParser/src/main/java/com/kedia/ogparser/UtilityFunctions.kt +++ b/OGParser/src/main/java/com/kedia/ogparser/UtilityFunctions.kt @@ -1,5 +1,8 @@ package com.kedia.ogparser +import java.net.URI +import java.net.URL + fun checkNullParserResult(openGraphResult: OpenGraphResult?): Boolean { return (openGraphResult?.title.isNullOrEmpty() || openGraphResult?.title.equals("null")) && @@ -7,4 +10,9 @@ fun checkNullParserResult(openGraphResult: OpenGraphResult?): Boolean { openGraphResult?.description.equals( "null" )) +} + +fun getBaseUrl(urlString: String): String { + val url: URL = URI.create(urlString).toURL() + return url.protocol.toString() + "://" + url.authority + "/" } \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 1725b44..b4e47c7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -44,5 +44,6 @@ dependencies { testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +// implementation 'com.github.Priyansh-Kedia:OpenGraphParser:3f0d7dfb11' } \ No newline at end of file diff --git a/app/src/main/java/com/kedia/opengraphpreview/MainActivity.kt b/app/src/main/java/com/kedia/opengraphpreview/MainActivity.kt index d93a95c..01232e6 100644 --- a/app/src/main/java/com/kedia/opengraphpreview/MainActivity.kt +++ b/app/src/main/java/com/kedia/opengraphpreview/MainActivity.kt @@ -21,7 +21,10 @@ class MainActivity : AppCompatActivity(), OpenGraphCallback { "https://chat.whatsapp.com/DdWAKRkt2VfAmd4OS47y7P", "https://www.reddit.com/r/MachineLearning/comments/s3mjqf/deep_learning_interviews_hundreds_of_fully_solved/?utm_medium=android_app&utm_source=share", "https://instagram.com/fcbarcelona?utm_medium=copy_link", - "https://www.facebook.com/groups/777946865955982/permalink/1385110621906267/" + "https://www.facebook.com/groups/777946865955982/permalink/1385110621906267/", + "https://www.youtube.com/", + "https://www.instagram.com/", + "https://klusterapp.io/kluster/message?message_id=7244&channel_id=2247&Channel_name=new-channel-with-spa&kluster_id=64" ) override fun onCreate(savedInstanceState: Bundle?) {