Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.diffplug.gradle.spotless" version "3.19.0"
id "com.diffplug.gradle.spotless" version "3.23.0"
}

def rootConfiguration = {}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/fossasia/susi/ai/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ class MainApplication : Application() {

if (BuildConfig.DEBUG) {
Timber.plant(object : Timber.DebugTree() {
//Add the line number to the tag
// Add the line number to the tag
override fun createStackElementTag(element: StackTraceElement): String? {
return super.createStackElementTag(element) + ": " + element.lineNumber
}
})
} else {
//Release mode
// Release mode
Timber.plant(ReleaseLogTree())
}
}
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/org/fossasia/susi/ai/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ChatActivity : AppCompatActivity(), IChatView {
return super.onTouchEvent(event)
}

//Inner class for handling the gestures
// Inner class for handling the gestures
internal inner class CustomGestureListener : GestureDetector.SimpleOnGestureListener() {

override fun onFling(
Expand All @@ -128,7 +128,7 @@ class ChatActivity : AppCompatActivity(), IChatView {
velocityY: Float
): Boolean {
val X = event1.getX() - event2.getX()
//Swipe from right to left
// Swipe from right to left
if (X >= 100 && X <= 1000) {
val intent = Intent(this@ChatActivity, SkillsActivity::class.java)
startActivity(intent)
Expand Down Expand Up @@ -199,7 +199,7 @@ class ChatActivity : AppCompatActivity(), IChatView {
private fun setEditText() {
val watch = object : TextWatcher {
override fun beforeTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
//do whatever you want to do before text change in input edit text
// do whatever you want to do before text change in input edit text
}

override fun onTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
Expand All @@ -225,7 +225,7 @@ class ChatActivity : AppCompatActivity(), IChatView {
}

override fun afterTextChanged(editable: Editable) {
//do whatever you want to do after text change in input edit text
// do whatever you want to do after text change in input edit text
}
}

Expand Down Expand Up @@ -322,7 +322,7 @@ class ChatActivity : AppCompatActivity(), IChatView {
}
}

//Take user's speech as input and send the message
// Take user's speech as input and send the message
override fun promptSpeechInput() {
if (recordingThread != null) {
chatPresenter.stopHotwordDetection()
Expand All @@ -336,7 +336,7 @@ class ChatActivity : AppCompatActivity(), IChatView {
fragmentTransaction.commit()
}

//Replies user with Speech
// Replies user with Speech
override fun voiceReply(reply: String, language: String) {
searchChat.visibility = View.VISIBLE
fabsetting.visibility = View.VISIBLE
Expand Down Expand Up @@ -395,7 +395,7 @@ class ChatActivity : AppCompatActivity(), IChatView {
snackbar.show()
}

//Initiates hotword detection
// Initiates hotword detection
override fun initHotword() {
recordingThread = RecordingThread(object : Handler() {
override fun handleMessage(msg: Message) {
Expand Down Expand Up @@ -447,7 +447,7 @@ class ChatActivity : AppCompatActivity(), IChatView {
override fun checkEnterKeyPref(isChecked: Boolean) {
if (isChecked) {
askSusiMessage.imeOptions = EditorInfo.IME_ACTION_SEND
askSusiMessage.inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD //setting this programmatically works for all devices
askSusiMessage.inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD // setting this programmatically works for all devices
} else {
askSusiMessage.imeOptions = EditorInfo.IME_FLAG_NO_ENTER_ACTION
}
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/java/org/fossasia/susi/ai/chat/ChatPresenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import kotlin.collections.HashMap
* The P in MVP
* Created by chiragw15 on 9/7/17.
*/
class ChatPresenter(context: Context)
: IChatPresenter, IChatModel.OnRetrievingMessagesFinishedListener,
class ChatPresenter(context: Context) :
IChatPresenter, IChatModel.OnRetrievingMessagesFinishedListener,
IChatModel.OnLocationFromIPReceivedListener, IChatModel.OnMessageFromSusiReceivedListener,
IDatabaseRepository.OnDatabaseUpdateListener {

Expand Down Expand Up @@ -72,7 +72,7 @@ class ChatPresenter(context: Context)

override fun setUp() {

//find total number of messages and find new message index
// find total number of messages and find new message index
newMessageIndex = databaseRepository.getMessageCount() + 1
PrefManager.putLong(Constant.MESSAGE_COUNT, newMessageIndex)
micCheck = utilModel.checkMicInput()
Expand Down Expand Up @@ -100,7 +100,7 @@ class ChatPresenter(context: Context)
check = boolean
}

//initiates hotword detection
// initiates hotword detection
override fun initiateHotwordDetection() {
if (BuildConfig.FLAVOR == "fdroid")
return
Expand Down Expand Up @@ -157,7 +157,7 @@ class ChatPresenter(context: Context)
}
}

//Retrieves old Messages
// Retrieves old Messages
override fun retrieveOldMessages(firstRun: Boolean) {
if (firstRun and NetworkUtils.isNetworkConnected()) {
chatView?.showRetrieveOldMessageProgress()
Expand Down Expand Up @@ -274,7 +274,7 @@ class ChatPresenter(context: Context)
chatView?.hideRetrieveOldMessageProgress()
}

//Gets Location of user using his IP Address
// Gets Location of user using his IP Address
override fun getLocationFromIP() {
chatModel.getLocationFromIP(this)
}
Expand All @@ -297,7 +297,7 @@ class ChatPresenter(context: Context)
}
}

//Gets Location of user using gps and network
// Gets Location of user using gps and network
override fun getLocationFromLocationService() {
locationHelper = LocationHelper(MainApplication.instance.applicationContext)
getLocation()
Expand All @@ -312,7 +312,7 @@ class ChatPresenter(context: Context)
}
}

//get undelivered messages from database
// get undelivered messages from database
override fun getUndeliveredMessages() {
nonDeliveredMessages.clear()

Expand All @@ -321,7 +321,7 @@ class ChatPresenter(context: Context)
nonDelivered.mapTo(nonDeliveredMessages) { Pair(it.content, it.id) }
}

//sends message to susi
// sends message to susi
override fun sendMessage(query: String, actual: String) {
addToNonDeliveredList(query, actual)
ComputeThread().start()
Expand Down Expand Up @@ -533,7 +533,7 @@ class ChatPresenter(context: Context)
chatView?.databaseUpdated()
}

//Asks for permissions from user
// Asks for permissions from user
private fun getPermissions() {
val permissionsRequired = utilModel.permissionsToGet()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class ParseSusiResponseHelper {
Constant.ANSWER -> try {
answer = susiResponse.answers[0].actions[i].expression

//get the Urls stored in 'data' of the answer object
val text = susiResponse.answers[0].data[0].get("object") //requires api warning suppressed
// get the Urls stored in 'data' of the answer object
val text = susiResponse.answers[0].data[0].get("object") // requires api warning suppressed
if (text != null) {
val urlList = extractUrls(text)
isHavingLink = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ChatFeedRecyclerAdapter(

if (data is RealmResults) {
data.addChangeListener(RealmChangeListener {
//only scroll if new is added.
// only scroll if new is added.
if (lastMsgCount < itemCount) {
scrollToBottom()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import org.fossasia.susi.ai.rest.responses.susi.Datum
* <h1>Adapter to display horizontal list of RSS results.</h1>
*/

class SearchResultsAdapter(context: Context, private val datumList: List<Datum?>?)
: RecyclerView.Adapter<RssViewHolder>() {
class SearchResultsAdapter(context: Context, private val datumList: List<Datum?>?) :
RecyclerView.Adapter<RssViewHolder>() {
private val inflater: LayoutInflater = LayoutInflater.from(context)

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RssViewHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import org.fossasia.susi.ai.R
class SelectionDialogListAdapter(
context: Context,
private val list: List<Pair<String, Drawable>>
)
: ArrayAdapter<Pair<String, Drawable>>(context, R.layout.item_selection_dialog_list, list) {
) :
ArrayAdapter<Pair<String, Drawable>>(context, R.layout.item_selection_dialog_list, list) {

internal class ViewHolder {
var option: TextView? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import java.util.ArrayList
class TableAdapter(
private val column: List<String?>,
private val data: List<String?>
)
: RecyclerView.Adapter<TabViewHolder>() {
) :
RecyclerView.Adapter<TabViewHolder>() {
private lateinit var context: Context

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TabViewHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class VerticalRecyclerAdapter(
private val context: Context,
private val cols: List<String?>,
private val data: List<String?>
)
: RecyclerView.Adapter<VerticalCellViewHolder>() {
) :
RecyclerView.Adapter<VerticalCellViewHolder>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VerticalCellViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.table_recylcer_item, parent, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import timber.log.Timber
class WebSearchAdapter(
private val context: Context,
private val searchResults: List<WebSearchModel?>?
)
: RecyclerView.Adapter<SearchResultHolder>() {
) :
RecyclerView.Adapter<SearchResultHolder>() {

private val inflater: LayoutInflater = LayoutInflater.from(context)

Expand Down Expand Up @@ -77,9 +77,9 @@ class WebSearchAdapter(
holder.previewLayout.setOnClickListener {
if (linkurl != null) {
val webpage = Uri.parse(linkurl)
val builder = CustomTabsIntent.Builder() //custom tabs intent builder
val builder = CustomTabsIntent.Builder() // custom tabs intent builder
val customTabsIntent = builder.build()
customTabsIntent.launchUrl(context, webpage) //launching through custom tabs
customTabsIntent.launchUrl(context, webpage) // launching through custom tabs
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import timber.log.Timber
/**
* ViewHolder for drawing chat item layout.
*/
class ChatViewHolder(view: View, clickListener: MessageViewHolder.ClickListener, myMessage: Int)
: MessageViewHolder(view, clickListener) {
class ChatViewHolder(view: View, clickListener: MessageViewHolder.ClickListener, myMessage: Int) :
MessageViewHolder(view, clickListener) {

private val chatTextView: TextView by bindView(R.id.text)
private val receivedTick: ImageView? by bindOptionalView(R.id.received_tick)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import timber.log.Timber
class ImageViewHolder(
itemView: View,
clickListener: MessageViewHolder.ClickListener
)
: MessageViewHolder(itemView, clickListener) {
) :
MessageViewHolder(itemView, clickListener) {

private val imageView: ImageView by bindView(R.id.image_response)
val timeStamp: TextView by bindView(R.id.timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ import timber.log.Timber
class LinkPreviewViewHolder(
itemView: View,
listener: MessageViewHolder.ClickListener
)
: MessageViewHolder(itemView, listener) {
) :
MessageViewHolder(itemView, listener) {

val text: TextView by bindView(R.id.text)
val backgroundLayout: LinearLayout by bindView(R.id.background_layout)
Expand Down Expand Up @@ -242,9 +242,9 @@ class LinkPreviewViewHolder(

previewLayout.setOnClickListener {
val webpage = Uri.parse(url)
val builder = CustomTabsIntent.Builder() //custom tabs intent builder
val builder = CustomTabsIntent.Builder() // custom tabs intent builder
val customTabsIntent = builder.build()
customTabsIntent.launchUrl(currContext, webpage) //launching through custom tabs
customTabsIntent.launchUrl(currContext, webpage) // launching through custom tabs
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class MapViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
} else {
val builder = CustomTabsIntent.Builder()
val customTabsIntent = builder.build()
customTabsIntent.launchUrl(currContext, Uri.parse(mapHelper.webLink)) //launching through custom tabs
customTabsIntent.launchUrl(currContext, Uri.parse(mapHelper.webLink)) // launching through custom tabs
}
}
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package org.fossasia.susi.ai.chat.adapters.viewholders
import android.support.v7.widget.RecyclerView
import android.view.View

abstract class MessageViewHolder(itemView: View, private val listener: ClickListener?)
: RecyclerView.ViewHolder(itemView), View.OnClickListener, View.OnLongClickListener {
abstract class MessageViewHolder(itemView: View, private val listener: ClickListener?) :
RecyclerView.ViewHolder(itemView), View.OnClickListener, View.OnLongClickListener {

init {
itemView.setOnClickListener(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import timber.log.Timber
class PieChartViewHolder(
view: View,
listener: MessageViewHolder.ClickListener
)
: MessageViewHolder(view, listener) {
) :
MessageViewHolder(view, listener) {

val backgroundLayout: LinearLayout by bindView(R.id.background_layout)
val chatTextView: TextView by bindView(R.id.text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import java.util.ArrayList
class TableViewHolder(
itemView: View,
clickListener: MessageViewHolder.ClickListener
)
: MessageViewHolder(itemView, clickListener) {
) :
MessageViewHolder(itemView, clickListener) {

val recyclerView: RecyclerView by bindView(R.id.recyclerView)
val timeStamp: TextView by bindView(R.id.timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import timber.log.Timber
class YoutubeVideoViewHolder(
view: View,
clickListener: MessageViewHolder.ClickListener
)
: MessageViewHolder(view, clickListener) {
) :
MessageViewHolder(view, clickListener) {

private val playerView: ImageView by bindView(R.id.youtube_view)
private val playButton: ImageView by bindView(R.id.play_video)
Expand Down
Loading