Skip to content

Commit

Permalink
Specialized in DuckDuckGo instant answers
Browse files Browse the repository at this point in the history
  • Loading branch information
Zagura committed Apr 4, 2022
1 parent fe839a5 commit a4a5a2c
Show file tree
Hide file tree
Showing 26 changed files with 213 additions and 855 deletions.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 52 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,57 @@
# Loader
A library to load text, rss, and ddg intant answers easily in android
# libduckduckgo
A library to load DuckDuckGo instant answers easily in android

## Installation
Add the following dependency to your ```build.gradle``` file:
```
dependencies {
implementation 'io.posidon:android.loader:0.0.1'
}
```
And also make sure that the ```jitpack.io``` repository is included
```
allprojects {
Add the dependency to your `build.gradle(.kts)` file:
<table>
<thead>
<tr>
<th>Kotlin</th>
<th>Groovy</th>
</tr>
</thead>
<tr>
<td>
<pre lang="kotlin">dependencies {
// ...
implementation("io.posidon:android.libduckduckgo:22.0")
}</pre>
</td>
<td>
<pre lang="groovy">dependencies {
// ...
implementation 'io.posidon:android.libduckduckgo:22.0'
}</pre>
</td>
</tr>
</table>

And also make sure that the `jitpack.io` repository is included
<table>
<thead>
<tr>
<th>Kotlin</th>
<th>Groovy</th>
</tr>
</thead>
<tr>
<td>
<pre lang="kotlin">allprojects {
repositories {
// ...
maven {
url = uri("https://jitpack.io")
}
}
}</pre>
</td>
<td>
<pre lang="groovy">allprojects {
repositories {
...
// ...
maven { url 'https://jitpack.io' }
}
}
```
}</pre>
</td>
</tr>
</table>
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "posidon.android.loader.demo"
applicationId "io.posidon.android.libduckduckgo.demo"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="posidon.android.loader.demo">
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="io.posidon.android.libduckduckgo.demo">

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

<application
android:allowBackup="true"
Expand All @@ -17,9 +20,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DDGTestActivity"/>
<activity android:name=".RSSTestActivity"/>
<activity android:name=".TextLoadingTestActivity"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package posidon.android.loader.demo
package io.posidon.android.libduckduckgo.demo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import posidon.android.loader.duckduckgo.DuckInstantAnswer
import io.posidon.android.libduckduckgo.DuckDuckGo
import io.posidon.android.libduckduckgo.InstantAnswer

class DDGTestActivity : AppCompatActivity() {
class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -15,14 +16,15 @@ class DDGTestActivity : AppCompatActivity() {
val infobox = Text(this)
val searchUrl = Text(this)
val data = Text(this)
val textField = TextField(this, hint = "search...", textSize = 20f)
val textField = TextField(this, hint = "Search...", textSize = 20f)
setContentView(
Scrollable(this,
Column(this,
Row(this,
textField,
Button(this, "go") {
DuckInstantAnswer.load(textField.text.toString(), "posidon.android.loader") { answer ->
val q = textField.text.toString()
DuckDuckGo.instantAnswer(q, BuildConfig.APPLICATION_ID) { answer ->
val infoboxText = answer.infoTable?.joinToString("\n") {
buildString {
appendLine(it.dataType)
Expand All @@ -37,7 +39,7 @@ class DDGTestActivity : AppCompatActivity() {
sourceUrl.text = answer.sourceUrl
description.text = answer.description
infobox.text = infoboxText
searchUrl.text = answer.searchUrl
searchUrl.text = DuckDuckGo.searchURL(q, BuildConfig.APPLICATION_ID)
data.text = answer.rawData
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package posidon.android.loader.demo
package io.posidon.android.libduckduckgo.demo

import android.content.Context
import android.view.View
Expand Down
28 changes: 0 additions & 28 deletions app/src/main/java/posidon/android/loader/demo/MainActivity.kt

This file was deleted.

80 changes: 0 additions & 80 deletions app/src/main/java/posidon/android/loader/demo/RSSTestActivity.kt

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

buildscript {
ext.kotlin_version = "1.5.31"
ext.kotlin_version = "1.6.20"
repositories {
google()
gradlePluginPortal()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
4 changes: 2 additions & 2 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ plugins {
}

android {
compileSdkVersion 31
compileSdkVersion 32

defaultConfig {
minSdkVersion 21
targetSdkVersion 31
targetSdkVersion 32

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down
6 changes: 1 addition & 5 deletions lib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="posidon.android.loader">

<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
<manifest package="io.posidon.android.libduckduckgo"/>
Loading

0 comments on commit a4a5a2c

Please sign in to comment.