Skip to content

Commit

Permalink
Code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruv16S committed Jun 13, 2023
1 parent 3faca97 commit 7e746e4
Show file tree
Hide file tree
Showing 32 changed files with 84 additions and 46 deletions.
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.

Binary file removed app/src/main/assets/model.tflite
Binary file not shown.
1 change: 0 additions & 1 deletion app/src/main/java/com/example/studymate/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class MainActivity : AppCompatActivity() {

if(remember){
val intent = Intent(this@MainActivity, HomePage::class.java)
val editor : SharedPreferences.Editor = preferences.edit()
startActivity(intent)
finish()
}
Expand Down
13 changes: 11 additions & 2 deletions app/src/main/java/com/example/studymate/QuestionAnsweringSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import org.tensorflow.lite.task.text.qa.BertQuestionAnswerer
import org.tensorflow.lite.task.text.qa.BertQuestionAnswerer.BertQuestionAnswererOptions
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import java.util.Locale

@OptIn(DelicateCoroutinesApi::class)
class QuestionAnsweringSystem : AppCompatActivity() {

Expand Down Expand Up @@ -79,7 +81,7 @@ class QuestionAnsweringSystem : AppCompatActivity() {
if(document.data["note-id"].toString() == intent.getStringExtra("documentId")){
questionCardExists = true
questionId = document.id
questionAndAnswerList = Json.decodeFromString<MutableList<String>?>(document.data["question-answer"]?.toJson()
questionAndAnswerList = Json.decodeFromString(document.data["question-answer"]?.toJson()
.toString())!!
for (item in questionAndAnswerList){
createQuestionCard(item.split("\n")[0], item.split("\n")[1])
Expand Down Expand Up @@ -124,7 +126,12 @@ class QuestionAnsweringSystem : AppCompatActivity() {
val highestConfidenceAnswer = answers.first()
var highestConfidenceAnswerText = highestConfidenceAnswer.text
val words = highestConfidenceAnswerText.split(" ")
val capitalizedWords = words.map { it.capitalize() }
@Suppress("NAME_SHADOWING") val capitalizedWords = words.map { it ->
it.replaceFirstChar {
if (it.isLowerCase()) it.titlecase(
Locale.getDefault()
) else it.toString()
} }
highestConfidenceAnswerText = capitalizedWords.joinToString(" ")
createQuestionCard(
question.text.toString(),
Expand All @@ -146,6 +153,8 @@ class QuestionAnsweringSystem : AppCompatActivity() {
})
}

@Suppress("DEPRECATION")
@Deprecated("Deprecated in Java")
override fun onBackPressed() {
// Check if the user went back
// Perform your desired action here
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/example/studymate/ShareActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import android.content.SharedPreferences
import io.appwrite.ID
import kotlinx.coroutines.DelicateCoroutinesApi
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale

@OptIn(DelicateCoroutinesApi::class)
class ShareActivity : AppCompatActivity() {

private lateinit var receiverEmailAddress : EditText
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_home_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
app:layout_constraintVertical_bias="0.0"
tools:ignore="VisualLintBounds" />

<FrameLayout
android:id="@+id/frame"
Expand Down
23 changes: 15 additions & 8 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@drawable/concentric_circles">
android:background="@drawable/login_signup_bg">

<TextView
android:id="@+id/textTagline"
Expand All @@ -18,7 +18,8 @@
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
app:layout_constraintTop_toBottomOf="@+id/imageView"
tools:ignore="HardcodedText" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayoutUsername"
Expand All @@ -38,7 +39,8 @@
android:inputType="textEmailAddress"
android:fontFamily="@font/open_sans"
android:textColor="@color/black"
android:textSize="14sp"/>
android:textSize="14sp"
tools:ignore="HardcodedText" />

</com.google.android.material.textfield.TextInputLayout>

Expand All @@ -61,7 +63,8 @@
android:inputType="textPassword"
android:fontFamily="@font/open_sans"
android:textColor="@color/black"
android:textSize="14sp"/>
android:textSize="14sp"
tools:ignore="HardcodedText" />

</com.google.android.material.textfield.TextInputLayout>

Expand All @@ -73,7 +76,8 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/studymate_logos_white"/>
app:srcCompat="@drawable/studymate_logos_white"
android:importantForAccessibility="no" />

<TextView
android:id="@+id/signUpHere"
Expand All @@ -87,7 +91,8 @@
app:layout_constraintBottom_toTopOf="@+id/textInputLayoutUsername"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.221"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
tools:ignore="HardcodedText" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/login"
Expand All @@ -105,7 +110,8 @@
app:layout_constraintHorizontal_bias="0.173"
android:backgroundTint="@color/mid_blue"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textInputLayoutPassword" />
app:layout_constraintTop_toBottomOf="@+id/textInputLayoutPassword"
tools:ignore="HardcodedText" />

<CheckBox
android:id="@+id/loginRemember"
Expand All @@ -120,6 +126,7 @@
app:layout_constraintHorizontal_bias="0.02"
app:layout_constraintStart_toEndOf="@+id/login"
app:layout_constraintTop_toBottomOf="@+id/textInputLayoutPassword"
android:textColor="@color/black" />
android:textColor="@color/black"
tools:ignore="HardcodedText" />

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
android:layout_marginEnd="10dp"
android:background="@drawable/button_template"
android:backgroundTint="@color/light_blue"
android:drawableStart="@drawable/baseline_question_answer"
android:drawableStart="@drawable/question_answer_icon"
android:drawablePadding="8dp"
android:fontFamily="@font/open_sans"
android:padding="10dp"
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/res/layout/activity_share.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
android:textColor="@color/black"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/shareTextLayout" />
app:layout_constraintTop_toBottomOf="@+id/shareTextLayout"
tools:ignore="HardcodedText" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/cancelShare"
Expand All @@ -108,7 +109,7 @@
android:layout_marginTop="30dp"
android:background="@drawable/button_template"
android:backgroundTint="@color/light_blue_d1"
android:drawableStart="@drawable/cancel_icon4"
android:drawableStart="@drawable/cancel_icon"
android:drawablePadding="8dp"
android:fontFamily="@font/open_sans"
android:padding="10dp"
Expand All @@ -117,6 +118,7 @@
android:textColor="@color/black"
android:textStyle="bold"
app:layout_constraintStart_toEndOf="@+id/shareNow"
app:layout_constraintTop_toBottomOf="@+id/shareTextLayout" />
app:layout_constraintTop_toBottomOf="@+id/shareTextLayout"
tools:ignore="HardcodedText" />

</androidx.constraintlayout.widget.ConstraintLayout>
31 changes: 18 additions & 13 deletions app/src/main/res/layout/activity_sign_up.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SignUp"
android:background="@drawable/concentric_circles">
android:background="@drawable/login_signup_bg">

<TextView
android:id="@+id/signUptextTagline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/open_sans"
android:text="Register now to enjoy the perks of\nAutomated Learning and\nPeer Reviews."
android:text="@string/signup_text"
android:textColor="@color/white"
android:textSize="19sp"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -34,10 +34,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="@font/open_sans"
android:hint="Email address"
android:hint="@string/email_address_hint"
android:inputType="textEmailAddress"
android:textColor="@color/black"
android:textSize="14dp" />
android:textSize="14sp" />

</com.google.android.material.textfield.TextInputLayout>

Expand All @@ -56,11 +56,11 @@
android:id="@+id/signUpeditTextPassword"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Password"
android:hint="@string/password"
android:inputType="textPassword"
android:fontFamily="@font/open_sans"
android:textColor="@color/black"
android:textSize="14dp" />
android:textSize="14sp" />
</com.google.android.material.textfield.TextInputLayout>

<!-- Confirm Password TextInputLayout -->
Expand All @@ -82,7 +82,8 @@
android:inputType="textPassword"
android:fontFamily="@font/open_sans"
android:textColor="@color/black"
android:textSize="14dp"/>
android:textSize="14sp"
tools:ignore="HardcodedText" />
</com.google.android.material.textfield.TextInputLayout>

<ImageView
Expand All @@ -93,7 +94,8 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/studymate_logos_white"/>
app:srcCompat="@drawable/studymate_logos_white"
android:importantForAccessibility="no" />


<androidx.appcompat.widget.AppCompatButton
Expand All @@ -104,7 +106,7 @@
android:layout_marginBottom="16dp"
android:background="@drawable/button_template"
android:fontFamily="@font/open_sans"
android:text="SignUp"
android:text="@string/signup"
android:textColor="@color/white"
android:textStyle="bold"
android:backgroundTint="@color/mid_blue"
Expand All @@ -125,7 +127,8 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.018"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="parent"
tools:ignore="UseCompoundDrawables">

<ImageView
android:layout_width="45dp"
Expand All @@ -134,14 +137,16 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/baseline_arrow_back" />
app:srcCompat="@drawable/back_arrow_icon"
android:importantForAccessibility="no"
tools:ignore="VisualLintBounds" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/open_sans"
android:text="Login"
android:text="@string/login"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
Expand All @@ -155,7 +160,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/open_sans"
android:text="Remember Me"
android:text="@string/remember_me"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/layout/card_design.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/share"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginEnd="10dp"
android:background="@drawable/button_template"
android:backgroundTint="@color/light_blue"
Expand All @@ -90,7 +90,8 @@
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:ignore="SpeakableTextPresentCheck" />

</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/fragment_create_notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
android:layout_marginEnd="10dp"
android:background="@drawable/button_template"
android:backgroundTint="@color/light_blue"
android:drawableStart="@drawable/save_note"
android:drawableStart="@drawable/save_note_icon"
android:drawablePadding="8dp"
android:fontFamily="@font/open_sans"
android:padding="12dp"
Expand Down Expand Up @@ -151,7 +151,7 @@
android:layout_marginTop="5dp"
android:background="@drawable/button_template"
android:backgroundTint="@color/light_blue"
android:drawableStart="@drawable/attachment"
android:drawableStart="@drawable/attachment_icon"
android:drawablePadding="8dp"
android:fontFamily="@font/open_sans"
android:padding="12dp"
Expand All @@ -171,7 +171,7 @@
android:layout_marginEnd="170dp"
android:background="@drawable/button_template"
android:backgroundTint="@color/light_blue"
android:drawableStart="@drawable/ocr"
android:drawableStart="@drawable/ocr_icon"
android:drawablePadding="8dp"
android:fontFamily="@font/open_sans"
android:padding="12dp"
Expand Down Expand Up @@ -235,7 +235,7 @@
android:layout_marginEnd="10dp"
android:background="@drawable/button_template"
android:backgroundTint="@color/light_blue"
android:drawableStart="@drawable/baseline_library_add_24"
android:drawableStart="@drawable/add_icon"
android:drawablePadding="8dp"
android:fontFamily="@font/open_sans"
android:padding="10dp"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
android:layout_height="277dp"
android:layout_marginTop="100dp"
android:contentDescription="@string/landing_page"
android:src="@drawable/learning_logo"
android:src="@drawable/home_page_image"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.893"
app:layout_constraintStart_toStartOf="parent"
Expand Down Expand Up @@ -65,7 +65,7 @@
app:layout_constraintStart_toEndOf="@+id/description"
app:layout_constraintTop_toTopOf="@+id/description"
app:layout_constraintVertical_bias="0.486"
app:srcCompat="@drawable/baseline_library_add_24"
app:srcCompat="@drawable/add_icon"
android:contentDescription="@string/make_notes" />

<TextView
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="TextContrastCheck" />
tools:ignore="HardcodedText,TextContrastCheck" />

<TextView
android:layout_width="wrap_content"
Expand Down
Loading

0 comments on commit 7e746e4

Please sign in to comment.