Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Augmented Reality Chemistry Laboratory
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-189
Augmented Reality Chemistry Laboratory
Commits
33bd5359
Commit
33bd5359
authored
Jun 30, 2021
by
Mahima Induvara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chat Bot Stage 1 Complete
parent
57e6b6c3
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
208 additions
and
45 deletions
+208
-45
.idea/.gitignore
.idea/.gitignore
+0
-3
.idea/vcs.xml
.idea/vcs.xml
+1
-6
app/build.gradle
app/build.gradle
+6
-0
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+5
-1
app/src/main/java/chatbot/APIService.kt
app/src/main/java/chatbot/APIService.kt
+14
-0
app/src/main/java/chatbot/AdapterChatBot.kt
app/src/main/java/chatbot/AdapterChatBot.kt
+42
-0
app/src/main/java/chatbot/ChatModel.kt
app/src/main/java/chatbot/ChatModel.kt
+4
-0
app/src/main/java/chatbot/MainActivity.kt
app/src/main/java/chatbot/MainActivity.kt
+60
-0
app/src/main/java/com/example/archemistrylab/ChatbotMain.java
...src/main/java/com/example/archemistrylab/ChatbotMain.java
+14
-0
app/src/main/java/com/example/archemistrylab/MainActivity.java
...rc/main/java/com/example/archemistrylab/MainActivity.java
+2
-2
app/src/main/res/layout/activity_chatbot_main.xml
app/src/main/res/layout/activity_chatbot_main.xml
+42
-0
app/src/main/res/layout/content_main.xml
app/src/main/res/layout/content_main.xml
+0
-33
app/src/main/res/layout/listitem_chat.xml
app/src/main/res/layout/listitem_chat.xml
+14
-0
build.gradle
build.gradle
+4
-0
No files found.
.idea/.gitignore
deleted
100644 → 0
View file @
57e6b6c3
# Default ignored files
/shelf/
/workspace.xml
.idea/vcs.xml
View file @
33bd5359
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"GitSharedSettings"
>
<option
name=
"FORCE_PUSH_PROHIBITED_PATTERNS"
>
<list
/>
</option>
</component>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"
$PROJECT_DIR$
"
vcs=
"Git"
/>
<mapping
directory=
""
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
app/build.gradle
View file @
33bd5359
plugins
{
id
'com.android.application'
id
'com.chaquo.python'
id
'kotlin-android'
id
'kotlin-android-extensions'
}
apply
plugin:
'com.android.application'
apply
plugin:
'com.chaquo.python'
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android-extensions'
android
{
compileSdkVersion
30
...
...
@@ -60,6 +65,7 @@ dependencies {
implementation
'androidx.navigation:navigation-ui:2.3.5'
implementation
'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation
'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testImplementation
'junit:junit:4.13.2'
androidTestImplementation
'androidx.test.ext:junit:1.1.2'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
...
...
app/src/main/AndroidManifest.xml
View file @
33bd5359
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.example.archemistrylab"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<application
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
...
...
@@ -9,6 +11,8 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/Theme.ARChemistryLab"
>
<activity
android:name=
".ChatbotMain"
></activity>
<activity
android:name=
"chatbot.MainActivity"
/>
<activity
android:name=
".MainActivity"
android:label=
"@string/app_name"
...
...
app/src/main/java/chatbot/APIService.kt
0 → 100644
View file @
33bd5359
package
chatbot
import
retrofit2.Call
import
retrofit2.http.Field
import
retrofit2.http.FormUrlEncoded
import
retrofit2.http.POST
interface
APIService
{
@FormUrlEncoded
@POST
(
"chat"
)
fun
chatWithTheBit
(
@Field
(
"chatInput"
)
chatText
:
String
):
Call
<
ChatResponse
>
}
data class
ChatResponse
(
val
chatBotReply
:
String
)
\ No newline at end of file
app/src/main/java/chatbot/AdapterChatBot.kt
0 → 100644
View file @
33bd5359
package
chatbot
import
android.graphics.Color
import
android.view.LayoutInflater
import
android.view.ViewGroup
import
androidx.recyclerview.widget.RecyclerView
import
com.example.archemistrylab.R
import
kotlinx.android.synthetic.main.listitem_chat.view.*
class
AdapterChatBot
:
RecyclerView
.
Adapter
<
AdapterChatBot
.
MyViewHolder
>()
{
private
val
list
=
ArrayList
<
ChatModel
>()
inner
class
MyViewHolder
(
parent
:
ViewGroup
)
:
RecyclerView
.
ViewHolder
(
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
listitem_chat
,
parent
,
false
)
)
{
fun
bind
(
chat
:
ChatModel
)
=
with
(
itemView
)
{
if
(!
chat
.
isBot
)
{
txtChat
.
setBackgroundColor
(
Color
.
WHITE
)
txtChat
.
setTextColor
(
Color
.
BLACK
)
txtChat
.
text
=
chat
.
chat
}
else
{
txtChat
.
setBackgroundColor
(
Color
.
CYAN
)
txtChat
.
setTextColor
(
Color
.
BLACK
)
txtChat
.
text
=
chat
.
chat
}
}
}
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
)
=
MyViewHolder
(
parent
)
override
fun
onBindViewHolder
(
holder
:
MyViewHolder
,
position
:
Int
)
{
holder
.
bind
(
list
[
position
])
}
override
fun
getItemCount
()
=
list
.
size
fun
addChatToList
(
chat
:
ChatModel
)
{
list
.
add
(
chat
)
notifyDataSetChanged
()
}
}
\ No newline at end of file
app/src/main/java/chatbot/ChatModel.kt
0 → 100644
View file @
33bd5359
package
chatbot
data class
ChatModel
(
val
chat
:
String
,
val
isBot
:
Boolean
=
false
)
{
}
\ No newline at end of file
app/src/main/java/chatbot/MainActivity.kt
0 → 100644
View file @
33bd5359
package
chatbot
import
android.os.Bundle
import
android.widget.Toast
import
androidx.appcompat.app.AppCompatActivity
import
androidx.recyclerview.widget.LinearLayoutManager
import
com.example.archemistrylab.R
import
kotlinx.android.synthetic.main.activity_chatbot_main.*
import
retrofit2.Call
import
retrofit2.Callback
import
retrofit2.Response
import
retrofit2.Retrofit
import
retrofit2.converter.gson.GsonConverterFactory
class
MainActivity
:
AppCompatActivity
()
{
private
val
adapterChatBot
=
AdapterChatBot
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_chatbot_main
)
val
retrofit
=
Retrofit
.
Builder
()
.
baseUrl
(
"http://192.168.1.100:5000"
)
.
addConverterFactory
(
GsonConverterFactory
.
create
())
.
build
()
val
apiService
=
retrofit
.
create
(
APIService
::
class
.
java
)
rvChatList
.
layoutManager
=
LinearLayoutManager
(
this
)
rvChatList
.
adapter
=
adapterChatBot
btnSend
.
setOnClickListener
{
if
(
etChat
.
text
.
isNullOrEmpty
()){
Toast
.
makeText
(
this
@MainActivity
,
"Please enter a text"
,
Toast
.
LENGTH_LONG
).
show
()
return
@
setOnClickListener
}
adapterChatBot
.
addChatToList
(
ChatModel
(
etChat
.
text
.
toString
()))
apiService
.
chatWithTheBit
(
etChat
.
text
.
toString
()).
enqueue
(
callBack
)
etChat
.
text
.
clear
()
}
}
private
val
callBack
=
object
:
Callback
<
ChatResponse
>{
override
fun
onResponse
(
call
:
Call
<
ChatResponse
>,
response
:
Response
<
ChatResponse
>)
{
if
(
response
.
isSuccessful
&&
response
.
body
()!=
null
){
adapterChatBot
.
addChatToList
(
ChatModel
(
response
.
body
()
!!
.
chatBotReply
,
true
))
}
else
{
Toast
.
makeText
(
this
@MainActivity
,
"NO!"
,
Toast
.
LENGTH_LONG
).
show
()
}
}
override
fun
onFailure
(
call
:
Call
<
ChatResponse
>,
t
:
Throwable
)
{
Toast
.
makeText
(
this
@MainActivity
,
"Something went wrong"
,
Toast
.
LENGTH_LONG
).
show
()
}
}
}
\ No newline at end of file
app/src/main/java/com/example/archemistrylab/ChatbotMain.java
0 → 100644
View file @
33bd5359
package
com.example.archemistrylab
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.os.Bundle
;
public
class
ChatbotMain
extends
AppCompatActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_chatbot_main
);
}
}
\ No newline at end of file
app/src/main/java/com/example/archemistrylab/MainActivity.java
View file @
33bd5359
package
com.example.archemistrylab
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.view.Menu
;
...
...
@@ -34,8 +35,7 @@ public class MainActivity extends AppCompatActivity {
fab
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
Snackbar
.
make
(
view
,
"Replace with your own action"
,
Snackbar
.
LENGTH_LONG
)
.
setAction
(
"Action"
,
null
).
show
();
startActivity
(
new
Intent
(
MainActivity
.
this
,
chatbot
.
MainActivity
.
class
));
}
});
DrawerLayout
drawer
=
findViewById
(
R
.
id
.
drawer_layout
);
...
...
app/src/main/res/layout/activity_chatbot_main.xml
0 → 100644
View file @
33bd5359
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
"chatbot.MainActivity"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rvChatList"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
app:layout_constraintBottom_toTopOf=
"@+id/etChat"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<EditText
android:id=
"@+id/etChat"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
android:layout_marginLeft=
"16dp"
android:layout_marginEnd=
"8dp"
android:layout_marginRight=
"8dp"
android:ems=
"10"
android:hint=
"Chat with bot"
android:inputType=
"textPersonName"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/btnSend"
app:layout_constraintStart_toStartOf=
"parent"
/>
<Button
android:id=
"@+id/btnSend"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:layout_marginRight=
"16dp"
android:text=
"Send"
app:layout_constraintBottom_toBottomOf=
"@+id/etChat"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"@+id/etChat"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/content_main.xml
View file @
33bd5359
...
...
@@ -30,39 +30,6 @@
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:navGraph=
"@navigation/mobile_navigation"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rvChatList"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
app:layout_constraintBottom_toTopOf=
"@+id/etChat"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<EditText
android:id=
"@+id/etChat"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
android:layout_marginLeft=
"16dp"
android:layout_marginEnd=
"8dp"
android:layout_marginRight=
"8dp"
android:ems=
"10"
android:hint=
"Chat with bot"
android:inputType=
"textPersonName"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/btnSend"
app:layout_constraintStart_toStartOf=
"parent"
/>
<Button
android:id=
"@+id/btnSend"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"16dp"
android:layout_marginRight=
"16dp"
android:text=
"Send"
app:layout_constraintBottom_toBottomOf=
"@+id/etChat"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"@+id/etChat"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/listitem_chat.xml
0 → 100644
View file @
33bd5359
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:orientation=
"vertical"
android:layout_height=
"wrap_content"
>
<TextView
android:padding=
"8dp"
android:id=
"@+id/txtChat"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:textSize=
"18sp"
android:text=
""
/>
</LinearLayout>
\ No newline at end of file
build.gradle
View file @
33bd5359
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
{
ext
{
kotlin_version
=
'1.3.72'
}
repositories
{
google
()
jcenter
()
...
...
@@ -8,6 +11,7 @@ buildscript {
dependencies
{
classpath
"com.android.tools.build:gradle:4.1.3"
classpath
"com.chaquo.python:gradle:9.1.0"
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment